From: Jim Meyering Date: Sat, 12 May 2001 16:03:19 +0000 (+0000) Subject: (strip_trailing_slashes): Remove decl; now in dirname.h. X-Git-Tag: CPPI-1_9~141 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=992b068bd2c377d38a25b92e30e0717603f061d3;p=thirdparty%2Fcoreutils.git (strip_trailing_slashes): Remove decl; now in dirname.h. (main): Use dir_len rather than dir_name_r. --- diff --git a/src/dirname.c b/src/dirname.c index acfa5a3009..a59548b380 100644 --- a/src/dirname.c +++ b/src/dirname.c @@ -33,8 +33,6 @@ #define AUTHORS "David MacKenzie and Jim Meyering" -void strip_trailing_slashes (); - /* The name this program was run with. */ char *program_name; @@ -66,7 +64,9 @@ output `.' (meaning the current directory).\n\ int main (int argc, char **argv) { + static char const dot = '.'; char *result; + size_t len; program_name = argv[0]; setlocale (LC_ALL, ""); @@ -92,11 +92,17 @@ main (int argc, char **argv) usage (1); } - result = dir_name (argv[1]); - if (result == NULL) - xalloc_die (); - puts (result); - free (result); + result = argv[1]; + len = dir_len (result); + + if (! len) + { + result = ˙ + len = 1; + } + + fwrite (result, 1, len, stdout); + putchar ('\n'); exit (0); }