1
0
mirror of https://github.com/sheumann/hush.git synced 2025-01-15 03:33:06 +00:00

Patch from Matt Kraai to fix 'dirname /'

This commit is contained in:
Eric Andersen 2000-12-12 23:27:48 +00:00
parent 4d4b3b1d88
commit 483262f633
2 changed files with 12 additions and 10 deletions

@ -32,13 +32,14 @@ extern int dirname_main(int argc, char **argv)
argv++; argv++;
s=*argv+strlen(*argv)-1; s=*argv+strlen(*argv)-1;
while (s && *s == '/') { while (s != *argv && *s == '/') {
*s = '\0'; *s-- = '\0';
s=*argv+strlen(*argv)-1;
} }
s = strrchr(*argv, '/'); s = strrchr(*argv, '/');
if (s && *s) if (s != NULL && s == *argv)
s[1] = '\0';
else if (s != NULL)
*s = '\0'; *s = '\0';
printf("%s\n", (s)? *argv : "."); puts(s ? *argv : ".");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

@ -32,13 +32,14 @@ extern int dirname_main(int argc, char **argv)
argv++; argv++;
s=*argv+strlen(*argv)-1; s=*argv+strlen(*argv)-1;
while (s && *s == '/') { while (s != *argv && *s == '/') {
*s = '\0'; *s-- = '\0';
s=*argv+strlen(*argv)-1;
} }
s = strrchr(*argv, '/'); s = strrchr(*argv, '/');
if (s && *s) if (s != NULL && s == *argv)
s[1] = '\0';
else if (s != NULL)
*s = '\0'; *s = '\0';
printf("%s\n", (s)? *argv : "."); puts(s ? *argv : ".");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }