comparison toys/other/help.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 6df4ccc0acbe
children 34ac05521d94
comparison
equal deleted inserted replaced
693:4a5a250e0633 694:786841fdb1e0
1 /* vi: set sw=4 ts=4: 1 /* help.c - Show help for toybox commands
2 *
3 * help.c - Show help for toybox commands
4 * 2 *
5 * Copyright 2007 Rob Landley <rob@landley.net> 3 * Copyright 2007 Rob Landley <rob@landley.net>
6 * 4 *
7 * Often a shell builtin. 5 * Often a shell builtin.
8 6
9 USE_HELP(NEWTOY(help, "<1", TOYFLAG_BIN)) 7 USE_HELP(NEWTOY(help, "<1", TOYFLAG_BIN))
10 8
11 config HELP 9 config HELP
12 bool "help" 10 bool "help"
13 default y 11 default y
14 help 12 help
15 usage: help [command] 13 usage: help [command]
16 14
17 Show usage information for toybox commands. 15 Show usage information for toybox commands.
18 Run "toybox" with no arguments for a list of available commands. 16 Run "toybox" with no arguments for a list of available commands.
19 */ 17 */
20 18
21 19
22 #include "toys.h" 20 #include "toys.h"
23 #include "generated/help.h" 21 #include "generated/help.h"
24 22
25 #undef NEWTOY 23 #undef NEWTOY
30 #include "generated/newtoys.h" 28 #include "generated/newtoys.h"
31 ; 29 ;
32 30
33 void help_main(void) 31 void help_main(void)
34 { 32 {
35 struct toy_list *t = toy_find(*toys.optargs); 33 struct toy_list *t = toy_find(*toys.optargs);
36 int i = t-toy_list; 34 int i = t-toy_list;
37 char *s = help_data; 35 char *s = help_data;
38 36
39 if (!t) error_exit("Unknown command '%s'", *toys.optargs); 37 if (!t) error_exit("Unknown command '%s'", *toys.optargs);
40 for (;;) { 38 for (;;) {
41 while (i--) s += strlen(s) + 1; 39 while (i--) s += strlen(s) + 1;
42 if (*s != 255) break; 40 if (*s != 255) break;
43 i = toy_find(++s)-toy_list; 41 i = toy_find(++s)-toy_list;
44 s = help_data; 42 s = help_data;
45 } 43 }
46 44
47 fprintf(toys.exithelp ? stderr : stdout, "%s", s); 45 fprintf(toys.exithelp ? stderr : stdout, "%s", s);
48 } 46 }