Mercurial > hg > toybox
comparison toys/posix/uname.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 | fa858a67e231 |
children | b89ab13436fa |
comparison
equal
deleted
inserted
replaced
693:4a5a250e0633 | 694:786841fdb1e0 |
---|---|
1 /* vi: set sw=4 ts=4: | 1 /* uname.c - return system name |
2 * | |
3 * uname.c - return system name | |
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/uname.html | 5 * See http://opengroup.org/onlinepubs/9699919799/utilities/uname.html |
8 | 6 |
9 USE_UNAME(NEWTOY(uname, "amvrns", TOYFLAG_BIN)) | 7 USE_UNAME(NEWTOY(uname, "amvrns", TOYFLAG_BIN)) |
10 | 8 |
11 config UNAME | 9 config UNAME |
12 bool "uname" | 10 bool "uname" |
13 default y | 11 default y |
14 help | 12 help |
15 usage: uname [-asnrvmpio] | 13 usage: uname [-asnrvmpio] |
16 | 14 |
17 Print system information. | 15 Print system information. |
18 | 16 |
19 -s System name | 17 -s System name |
20 -n Network (domain) name | 18 -n Network (domain) name |
21 -r Release number | 19 -r Release number |
22 -v Version (build date) | 20 -v Version (build date) |
23 -m Machine (hardware) name | 21 -m Machine (hardware) name |
24 -a All of the above | 22 -a All of the above |
25 */ | 23 */ |
26 | 24 |
27 #define FOR_uname | 25 #define FOR_uname |
28 #include "toys.h" | 26 #include "toys.h" |
29 | 27 |
40 #define GROSS "i386" | 38 #define GROSS "i386" |
41 #endif | 39 #endif |
42 | 40 |
43 void uname_main(void) | 41 void uname_main(void) |
44 { | 42 { |
45 int i, flags = toys.optflags, needspace=0; | 43 int i, flags = toys.optflags, needspace=0; |
46 | 44 |
47 uname((void *)toybuf); | 45 uname((void *)toybuf); |
48 | 46 |
49 if (!flags) flags = FLAG_s; | 47 if (!flags) flags = FLAG_s; |
50 for (i=0; i<5; i++) { | 48 for (i=0; i<5; i++) { |
51 char *c = toybuf+(65*i); | 49 char *c = toybuf+(65*i); |
52 | 50 |
53 if (flags & ((1<<i)|FLAG_a)) { | 51 if (flags & ((1<<i)|FLAG_a)) { |
54 int len = strlen(c); | 52 int len = strlen(c); |
55 | 53 |
56 // This problem originates in autoconf, so of course the solution | 54 // This problem originates in autoconf, so of course the solution |
57 // is horribly ugly. | 55 // is horribly ugly. |
58 #ifdef GROSS | 56 #ifdef GROSS |
59 if (i==4 && !strcmp(c,"x86_64")) { | 57 if (i==4 && !strcmp(c,"x86_64")) { |
60 printf(GROSS); | 58 printf(GROSS); |
61 continue; | 59 continue; |
62 } | 60 } |
63 #endif | 61 #endif |
64 | 62 |
65 if (needspace++) { | 63 if (needspace++) { |
66 // We can't decrement on the first entry, because | 64 // We can't decrement on the first entry, because |
67 // needspace would be 0 | 65 // needspace would be 0 |
68 *(--c)=' '; | 66 *(--c)=' '; |
69 len++; | 67 len++; |
70 } | 68 } |
71 xwrite(1, c, len); | 69 xwrite(1, c, len); |
72 } | 70 } |
73 } | 71 } |
74 putchar('\n'); | 72 putchar('\n'); |
75 } | 73 } |