]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(strip_trailing_slashes): Remove decl; now in dirname.h.
authorJim Meyering <jim@meyering.net>
Sat, 12 May 2001 16:03:19 +0000 (16:03 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 12 May 2001 16:03:19 +0000 (16:03 +0000)
(main): Use dir_len rather than dir_name_r.

src/dirname.c

index acfa5a3009114637dd2ff8a8fca99caa2a728b34..a59548b3806afd43ec3bef3bac62b90cb3a3a186 100644 (file)
@@ -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);
 }