diff lib/misc.c @ 307:76c912483d1d

2003-11-5 Brian Masney <masneyb@gftp.org> * TODO - updated * configure.in - updated version to 2.0.16. * configure.in docs/Makefile.am - Added check for the db2html command (from gtk+ configure) * docs/gftp-faq.sgml - updated with more informationA * docs/website/index.html.in - updated list of translations * lib/misc.c (expand_path) - expand paths with double slashes properly to support Novell directory listings. (gftp_build_path) - better checking of paths that end in /. (gftp_info) - show if _REENTRANT was defined when it was compiled. * README - removed, this is automatically generated now.
author masneyb
date Thu, 06 Nov 2003 03:19:04 +0000
parents 3b9d5797050f
children cc2eeb30b793
line wrap: on
line diff
--- a/lib/misc.c	Tue Nov 04 02:56:11 2003 +0000
+++ b/lib/misc.c	Thu Nov 06 03:19:04 2003 +0000
@@ -151,7 +151,8 @@
 char *
 expand_path (const char *src)
 {
-  char *str, *pos, *endpos, *prevpos, *newstr, *tempstr, tempchar;
+  char *str, *pos, *endpos, *prevpos, *newstr, *tempstr, *ntoken,
+       tempchar;
   struct passwd *pw;
 
   pw = NULL;
@@ -178,22 +179,28 @@
   while ((pos = strchr (endpos, '/')) != NULL)
     {
       pos++;
-      while (*pos == '/')
-        pos++;
 
-      if ((endpos = strchr (pos, '/')) == NULL)
+      for (ntoken = pos; *ntoken == '/'; ntoken++);
+
+      if ((endpos = strchr (ntoken, '/')) == NULL)
 	endpos = pos + strlen (pos);
 
       tempchar = *endpos;
       *endpos = '\0';
 
-      if (strcmp (pos, "..") == 0)
+      if (strcmp (ntoken, "..") == 0)
 	{
-	  *(pos - 1) = '\0';
 	  if (newstr != NULL && (prevpos = strrchr (newstr, '/')) != NULL)
-	    *prevpos = '\0';
+            {
+	      *prevpos = '\0';
+              if (*newstr == '\0')
+                {
+                  g_free (newstr);
+                  newstr = NULL;
+                }
+            }
 	}
-      else if (strcmp (pos, ".") != 0)
+      else if (strcmp (ntoken, ".") != 0)
 	{
 	  if (newstr == NULL)
 	    newstr = g_strdup (pos - 1);
@@ -215,7 +222,7 @@
   if (endpos != NULL && *endpos != '\0' && newstr == NULL)
     {
       if (strcmp (endpos, "..") == 0)
-        newstr = g_malloc0 (1);
+        newstr = g_strdup ("/");
       else
         newstr = g_strdup (endpos);
     }
@@ -360,6 +367,10 @@
 
   printf ("%s\n", gftp_version);
 
+#ifdef _REENTRANT
+  printf ("#define _REENTRANT\n");
+#endif
+
 #ifdef _GNU_SOURCE
   printf ("#define _GNU_SOURCE\n");
 #endif
@@ -1229,7 +1240,7 @@
     {
       len = strlen (element);
 
-      if (len > 0 && element[len - 1] == '/')
+      if (retlen > 0 && ret[retlen - 1] == '/')
         add_separator = 0;
       else
         {