comparison toys/posix/rmdir.c @ 694:786841fdb1e0

Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style. The actual code should be the same afterward, this is just cosmetic refactoring.
author Rob Landley <rob@landley.net>
date Tue, 13 Nov 2012 17:14:08 -0600
parents 2986aa63a021
children 3d7526f6115b
comparison
equal deleted inserted replaced
693:4a5a250e0633 694:786841fdb1e0
1 /* vi: set sw=4 ts=4: 1 /* rmdir.c - remove directory/path
2 *
3 * rmdir.c - remove directory/path
4 * 2 *
5 * Copyright 2008 Rob Landley <rob@landley.net> 3 * Copyright 2008 Rob Landley <rob@landley.net>
6 * 4 *
7 * See http://opengroup.org/onlinepubs/9699919799/utilities/rmdir.html 5 * See http://opengroup.org/onlinepubs/9699919799/utilities/rmdir.html
8 6
9 USE_RMDIR(NEWTOY(rmdir, "<1p", TOYFLAG_BIN)) 7 USE_RMDIR(NEWTOY(rmdir, "<1p", TOYFLAG_BIN))
10 8
11 config RMDIR 9 config RMDIR
12 bool "rmdir" 10 bool "rmdir"
13 default y 11 default y
14 help 12 help
15 usage: rmdir [-p] [dirname...] 13 usage: rmdir [-p] [dirname...]
16 Remove one or more directories. 14 Remove one or more directories.
17 15
18 -p Remove path. 16 -p Remove path.
19 */ 17 */
20 18
21 #include "toys.h" 19 #include "toys.h"
22 20
23 static void do_rmdir(char *name) 21 static void do_rmdir(char *name)
24 { 22 {
25 for (;;) { 23 for (;;) {
26 char *temp; 24 char *temp;
27 25
28 if (rmdir(name)) { 26 if (rmdir(name)) {
29 perror_msg("%s",name); 27 perror_msg("%s",name);
30 return; 28 return;
31 } 29 }
32 if (!toys.optflags) return; 30 if (!toys.optflags) return;
33 if (!(temp=strrchr(name,'/'))) return; 31 if (!(temp=strrchr(name,'/'))) return;
34 *temp=0; 32 *temp=0;
35 } 33 }
36 } 34 }
37 35
38 void rmdir_main(void) 36 void rmdir_main(void)
39 { 37 {
40 char **s; 38 char **s;
41 39
42 for (s=toys.optargs; *s; s++) do_rmdir(*s); 40 for (s=toys.optargs; *s; s++) do_rmdir(*s);
43 } 41 }