Index: glib/gutils.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gutils.c,v
retrieving revision 1.115.2.1
diff -u -2 -r1.115.2.1 gutils.c
--- glib/gutils.c	18 Jun 2003 23:13:45 -0000	1.115.2.1
+++ glib/gutils.c	15 Aug 2003 05:19:33 -0000
@@ -84,4 +84,10 @@
 #endif
 
+#ifdef G_OS_WIN32
+#define G_IS_DIR_SEPARATOR(c) (c == G_DIR_SEPARATOR || c == '/')
+#else
+#define G_IS_DIR_SEPARATOR(c) (c == G_DIR_SEPARATOR)
+#endif
+
 const guint glib_major_version = GLIB_MAJOR_VERSION;
 const guint glib_minor_version = GLIB_MINOR_VERSION;
@@ -251,5 +257,9 @@
    */
   if (g_path_is_absolute (program)
-      || strchr (program, G_DIR_SEPARATOR) != NULL)
+      || strchr (program, G_DIR_SEPARATOR) != NULL
+#ifdef G_OS_WIN32
+      || strchr (program, '/') != NULL
+#endif
+      )
     {
       if (g_file_test (program, G_FILE_TEST_IS_EXECUTABLE))
@@ -403,4 +413,13 @@
   
   base = strrchr (file_name, G_DIR_SEPARATOR);
+
+#ifdef G_OS_WIN32
+  {
+    gchar *q = strrchr (file_name, '/');
+    if (base == NULL || (q != NULL && q > base))
+	base = q;
+  }
+#endif
+
   if (base)
     return base + 1;
@@ -443,5 +462,5 @@
   last_nonslash = strlen (file_name) - 1;
 
-  while (last_nonslash >= 0 && file_name [last_nonslash] == G_DIR_SEPARATOR)
+  while (last_nonslash >= 0 && G_IS_DIR_SEPARATOR (file_name [last_nonslash]))
     last_nonslash--;
 
@@ -458,5 +477,5 @@
   base = last_nonslash;
 
-  while (base >=0 && file_name [base] != G_DIR_SEPARATOR)
+  while (base >=0 && !G_IS_DIR_SEPARATOR (file_name [base]))
     base--;
 
@@ -478,14 +497,10 @@
   g_return_val_if_fail (file_name != NULL, FALSE);
   
-  if (file_name[0] == G_DIR_SEPARATOR
-#ifdef G_OS_WIN32
-      || file_name[0] == '/'
-#endif
-				     )
+  if (G_IS_DIR_SEPARATOR (file_name[0]))
     return TRUE;
 
 #ifdef G_OS_WIN32
   /* Recognize drive letter on native Windows */
-  if (g_ascii_isalpha (file_name[0]) && file_name[1] == ':' && (file_name[2] == G_DIR_SEPARATOR || file_name[2] == '/'))
+  if (g_ascii_isalpha (file_name[0]) && file_name[1] == ':' && G_IS_DIR_SEPARATOR (file_name[2]))
     return TRUE;
 #endif /* G_OS_WIN32 */
@@ -501,20 +516,29 @@
 #ifdef G_PLATFORM_WIN32
   /* Skip \\server\share (Win32) or //server/share (Cygwin) */
-  if (file_name[0] == G_DIR_SEPARATOR &&
-      file_name[1] == G_DIR_SEPARATOR &&
+  if (G_IS_DIR_SEPARATOR (file_name[0]) &&
+      G_IS_DIR_SEPARATOR (file_name[1]) &&
       file_name[2])
     {
       gchar *p;
 
-      if ((p = strchr (file_name + 2, G_DIR_SEPARATOR)) > file_name + 2 &&
+      p = strchr (file_name + 2, G_DIR_SEPARATOR);
+#ifdef G_OS_WIN32
+      {
+	gchar *q = strchr (file_name + 2, '/');
+	if (p == NULL || (q != NULL && q < p))
+	  p = q;
+      }
+#endif
+      if (p &&
+	  p > file_name + 2 &&
 	  p[1])
 	{
 	  file_name = p + 1;
 
-	  while (file_name[0] && file_name[0] != G_DIR_SEPARATOR)
+	  while (file_name[0] && !G_IS_DIR_SEPARATOR (file_name[0]))
 	    file_name++;
 
 	  /* Possibly skip a backslash after the share name */
-	  if (file_name[0] == G_DIR_SEPARATOR)
+	  if (G_IS_DIR_SEPARATOR (file_name[0]))
 	    file_name++;
 
@@ -525,7 +549,7 @@
   
   /* Skip initial slashes */
-  if (file_name[0] == G_DIR_SEPARATOR)
+  if (G_IS_DIR_SEPARATOR (file_name[0]))
     {
-      while (file_name[0] == G_DIR_SEPARATOR)
+      while (G_IS_DIR_SEPARATOR (file_name[0]))
 	file_name++;
       return (gchar *)file_name;
@@ -534,5 +558,5 @@
 #ifdef G_OS_WIN32
   /* Skip X:\ */
-  if (g_ascii_isalpha (file_name[0]) && file_name[1] == ':' && file_name[2] == G_DIR_SEPARATOR)
+  if (g_ascii_isalpha (file_name[0]) && file_name[1] == ':' && G_IS_DIR_SEPARATOR (file_name[2]))
     return (gchar *)file_name + 3;
 #endif
@@ -550,7 +574,14 @@
   
   base = strrchr (file_name, G_DIR_SEPARATOR);
+#ifdef G_OS_WIN32
+  {
+    gchar *q = strrchr (file_name, '/');
+    if (base == NULL || (q != NULL && q > base))
+	base = q;
+  }
+#endif
   if (!base)
     return g_strdup (".");
-  while (base > file_name && *base == G_DIR_SEPARATOR)
+  while (base > file_name && G_IS_DIR_SEPARATOR (*base))
     base--;
   len = (guint) 1 + base - file_name;
@@ -712,5 +743,5 @@
 	  g_tmp_dir = g_strdup (P_tmpdir);
 	  k = strlen (g_tmp_dir);
-	  if (k > 1 && g_tmp_dir[k - 1] == G_DIR_SEPARATOR)
+	  if (k > 1 && G_IS_DIR_SEPARATOR (g_tmp_dir[k - 1]))
 	    g_tmp_dir[k - 1] = '\0';
 	}
