summaryrefslogtreecommitdiff
path: root/src/rmdir.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1995-11-10 03:14:41 +0000
committerJim Meyering <jim@meyering.net>1995-11-10 03:14:41 +0000
commitc2e9e7a31bdcb9b4927b365c3122cf2b2b1cadf2 (patch)
treeb250ab9a2f97a356db52ec6ebbe678992cd14cdb /src/rmdir.c
parent49f397e6e76958257fcea444f4feed807f8c241a (diff)
downloadcoreutils-c2e9e7a31bdcb9b4927b365c3122cf2b2b1cadf2.tar.xz
(main): Move to the end.
Remove fwd dcls.
Diffstat (limited to 'src/rmdir.c')
-rw-r--r--src/rmdir.c85
1 files changed, 41 insertions, 44 deletions
diff --git a/src/rmdir.c b/src/rmdir.c
index da4331365..8c2f75b7e 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);
-}