Mercurial > gftp.yaz
diff lib/misc.c @ 204:9b2de8d3fafe
2003-6-25 Brian Masney <masneyb@gftp.org>
* lib/misc.c (expand_path) - small improvements
* lib/rfc2068.c src/text/gftp-gtk.c - fixes for path handling, namely
when changing directories to the parent (..)
author | masneyb |
---|---|
date | Thu, 26 Jun 2003 02:14:24 +0000 |
parents | 95e669973a84 |
children | cf4098008615 |
line wrap: on
line diff
--- a/lib/misc.c Thu Jun 26 01:40:24 2003 +0000 +++ b/lib/misc.c Thu Jun 26 02:14:24 2003 +0000 @@ -149,10 +149,13 @@ pos++; while (*pos == '/') pos++; + if ((endpos = strchr (pos, '/')) == NULL) endpos = pos + strlen (pos); + tempchar = *endpos; *endpos = '\0'; + if (strcmp (pos, "..") == 0) { *(pos - 1) = '\0'; @@ -170,18 +173,28 @@ newstr = tempstr; } } + *endpos = tempchar; if (*endpos == '\0') break; + endpos = pos + 1; } + if (endpos != NULL && *endpos != '\0' && newstr == NULL) + { + if (strcmp (endpos, "..") == 0) + newstr = g_malloc0 (1); + else + newstr = g_strdup (endpos); + } + if (newstr == NULL || *newstr == '\0') { if (newstr != NULL) g_free (newstr); - newstr = g_malloc0 (2); - *newstr = '/'; + + newstr = g_malloc0 (1); } g_free (str);