From 887e7ab6c5a13398e5986c7054235a135e6429f9 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 16 Dec 2000 07:54:18 +0000 Subject: Update. 2000-12-13 Jakub Jelinek * misc/efgcvt.c (FCVT_MAXDIG): Define. (FCVT_BUFPTR): New variable. (fcvt): If fcvt_r returns -1 on the static short buffer, try to malloc a sufficiently large one and retry. (free_mem): New function. * misc/qefgcvt.c (FCVT_MAXDIG): Define. * misc/tst-efgcvt.c (fcvt_tests): Add new test. 2000-12-15 Ulrich Drepper * misc/dirname.c (dirname): Fix search for second to last slash. 2000-12-13 Andreas Jaeger * misc/tst-dirname.c (main): Fix typo in test to really use the examples from Unix98. Reported by Michael Kerrisk . --- misc/dirname.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'misc/dirname.c') diff --git a/misc/dirname.c b/misc/dirname.c index 26c5a8b1ee..8be25e51b8 100644 --- a/misc/dirname.c +++ b/misc/dirname.c @@ -1,5 +1,5 @@ /* dirname - return directory part of PATH. - Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1996, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -31,17 +31,20 @@ dirname (char *path) /* Find last '/'. */ last_slash = path != NULL ? strrchr (path, '/') : NULL; - if (last_slash == path) - /* The last slash is the first character in the string. We have to - return "/". */ - ++last_slash; - else if (last_slash != NULL && last_slash[1] == '\0') + if (last_slash != NULL && last_slash != path && last_slash[1] == '\0') /* The '/' is the last character, we have to look further. */ - last_slash = memchr (path, last_slash - path, '/'); + last_slash = __memrchr (path, '/', last_slash - path); if (last_slash != NULL) - /* Terminate the path. */ - last_slash[0] = '\0'; + { + /* Terminate the path. */ + if (last_slash == path) + /* The last slash is the first character in the string. We have to + return "/". */ + ++last_slash; + + last_slash[0] = '\0'; + } else /* This assignment is ill-designed but the XPG specs require to return a string containing "." in any case no directory part is -- cgit v1.2.3