Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/rmdir Fix rmdir -p x/y/z//



details:   https://anonhg.NetBSD.org/src/rev/93e5c96f8f62
branches:  trunk
changeset: 552664:93e5c96f8f62
user:      dsl <dsl%NetBSD.org@localhost>
date:      Mon Sep 29 21:11:15 2003 +0000

description:
Fix rmdir -p x/y/z//
Remove redundant code.

diffstat:

 bin/rmdir/rmdir.c |  29 +++++++----------------------
 1 files changed, 7 insertions(+), 22 deletions(-)

diffs (65 lines):

diff -r b85d16b1a6e7 -r 93e5c96f8f62 bin/rmdir/rmdir.c
--- a/bin/rmdir/rmdir.c Mon Sep 29 21:04:53 2003 +0000
+++ b/bin/rmdir/rmdir.c Mon Sep 29 21:11:15 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rmdir.c,v 1.22 2003/09/14 19:20:25 jschauma Exp $ */
+/* $NetBSD: rmdir.c,v 1.23 2003/09/29 21:11:15 dsl Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)rmdir.c    8.3 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: rmdir.c,v 1.22 2003/09/14 19:20:25 jschauma Exp $");
+__RCSID("$NetBSD: rmdir.c,v 1.23 2003/09/29 21:11:15 dsl Exp $");
 #endif
 #endif /* not lint */
 
@@ -52,9 +52,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <vis.h>
-
-int    stdout_ok;                      /* stdout connected to a terminal */
 
 int    rm_path(char *);
 void   usage(void);
@@ -84,20 +81,8 @@
        if (argc == 0)
                usage();
 
-       stdout_ok = isatty(STDIN_FILENO);
-
        for (errors = 0; *argv; argv++) {
-#ifdef notdef
-               char *p;
-
-               /* Kernel takes care of this */
-               /* Delete trailing slashes, per POSIX. */
-               p = *argv + strlen(*argv);
-               while (--p > *argv && *p == '/')
-                       ;
-               *++p = '\0';
-#endif
-
+               /* We rely on the kernel to ignore trailing '/' characters. */
                if (rmdir(*argv) < 0) {
                        warn("%s", *argv);
                        errors = 1;
@@ -115,10 +100,10 @@
        char *p;
 
        while ((p = strrchr(path, '/')) != NULL) {
-               /* Delete trailing slashes. */
-               while (--p > path && *p == '/')
-                       ;
-               *++p = '\0';
+               *p = 0;
+               if (p[1] == 0)
+                       /* Ignore trailing '/' on deleted name */
+                       continue;
 
                if (rmdir(path) < 0) {
                        warn("%s", path);



Home | Main Index | Thread Index | Old Index