mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-08-12 12:00:21 +02:00
(main): Move to the end.
Remove fwd dcls.
This commit is contained in:
+41
-44
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user