summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-05-12 16:03:19 +0000
committerJim Meyering <jim@meyering.net>2001-05-12 16:03:19 +0000
commit992b068bd2c377d38a25b92e30e0717603f061d3 (patch)
treea39959359dafc5f9765817afaf11f55d79fbc866 /src
parentd8535172f6af72f528b16d78c6fc2a17a33f0920 (diff)
downloadcoreutils-992b068bd2c377d38a25b92e30e0717603f061d3.tar.xz
(strip_trailing_slashes): Remove decl; now in dirname.h.
(main): Use dir_len rather than dir_name_r.
Diffstat (limited to 'src')
-rw-r--r--src/dirname.c20
1 files changed, 13 insertions, 7 deletions
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 = &dot;
+ len = 1;
+ }
+
+ fwrite (result, 1, len, stdout);
+ putchar ('\n');
exit (0);
}