From c2e9e7a31bdcb9b4927b365c3122cf2b2b1cadf2 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 10 Nov 1995 03:14:41 +0000 Subject: [PATCH] (main): Move to the end. Remove fwd dcls. --- src/rmdir.c | 85 ++++++++++++++++++++++++++--------------------------- 1 file changed, 41 insertions(+), 44 deletions(-) diff --git a/src/rmdir.c b/src/rmdir.c index da43313658..8c2f75b7ec 100644 --- a/src/rmdir.c +++ b/src/rmdir.c @@ -33,9 +33,6 @@ void strip_trailing_slashes (); -static void remove_parents (char *path); -static void usage (int status); - /* The name this program was run with. */ char *program_name; @@ -57,6 +54,47 @@ static struct option const longopts[] = {NULL, 0, NULL, 0} }; +/* Remove any empty parent directories of `path'. + Replaces '/' characters in `path' with NULs. */ + +static void +remove_parents (char *path) +{ + char *slash; + + do + { + slash = strrchr (path, '/'); + if (slash == NULL) + break; + /* Remove any characters after the slash, skipping any extra + slashes in a row. */ + while (slash > path && *slash == '/') + --slash; + slash[1] = 0; + } + while (rmdir (path) == 0); +} + +static void +usage (int status) +{ + if (status != 0) + fprintf (stderr, "Try `%s --help' for more information.\n", + program_name); + else + { + printf ("Usage: %s [OPTION]... DIRECTORY...\n", program_name); + printf ("\ +Remove the DIRECTORY(ies), if they are empty.\n\ +\n\ + -p, --parents remove explicit parent directories if being emptied\n\ + --help display this help and exit\n\ + --version output version information and exit\n"); + } + exit (status); +} + void main (int argc, char **argv) { @@ -111,44 +149,3 @@ main (int argc, char **argv) exit (errors); } - -/* Remove any empty parent directories of `path'. - Replaces '/' characters in `path' with NULs. */ - -static void -remove_parents (char *path) -{ - char *slash; - - do - { - slash = strrchr (path, '/'); - if (slash == NULL) - break; - /* Remove any characters after the slash, skipping any extra - slashes in a row. */ - while (slash > path && *slash == '/') - --slash; - slash[1] = 0; - } - while (rmdir (path) == 0); -} - -static void -usage (int status) -{ - if (status != 0) - fprintf (stderr, "Try `%s --help' for more information.\n", - program_name); - else - { - printf ("Usage: %s [OPTION]... DIRECTORY...\n", program_name); - printf ("\ -Remove the DIRECTORY(ies), if they are empty.\n\ -\n\ - -p, --parents remove explicit parent directories if being emptied\n\ - --help display this help and exit\n\ - --version output version information and exit\n"); - } - exit (status); -} -- 2.47.2