From 992b068bd2c377d38a25b92e30e0717603f061d3 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 12 May 2001 16:03:19 +0000 Subject: (strip_trailing_slashes): Remove decl; now in dirname.h. (main): Use dir_len rather than dir_name_r. --- src/dirname.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/dirname.c b/src/dirname.c index acfa5a300..a59548b38 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); } -- cgit v1.2.3-70-g09d2