diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-09-23 16:01:09 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-09-23 16:01:09 +0000 |
commit | 21e2f957472d29731c5b970bd91bdab3ce15f835 (patch) | |
tree | 0961ae48901bd3defbcc6bbd5cd57bd90a3f849e | |
parent | 44940cc81c7e6daad4636ed0f7d4ac4f1bb173de (diff) | |
download | busybox-w32-21e2f957472d29731c5b970bd91bdab3ce15f835.tar.gz busybox-w32-21e2f957472d29731c5b970bd91bdab3ce15f835.tar.bz2 busybox-w32-21e2f957472d29731c5b970bd91bdab3ce15f835.zip |
remove unneeded #includes, fix indentation
git-svn-id: svn://busybox.net/trunk/busybox@16206 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | coreutils/printf.c | 38 | ||||
-rw-r--r-- | libbb/xgetcwd.c | 39 | ||||
-rw-r--r-- | miscutils/runlevel.c | 31 |
3 files changed, 47 insertions, 61 deletions
diff --git a/coreutils/printf.c b/coreutils/printf.c index 93b142765..4a208040f 100644 --- a/coreutils/printf.c +++ b/coreutils/printf.c | |||
@@ -38,37 +38,30 @@ | |||
38 | 38 | ||
39 | // 19990508 Busy Boxed! Dave Cinege | 39 | // 19990508 Busy Boxed! Dave Cinege |
40 | 40 | ||
41 | #include <unistd.h> | ||
42 | #include <stdio.h> | ||
43 | #include <sys/types.h> | ||
44 | #include <string.h> | ||
45 | #include <errno.h> | ||
46 | #include <stdlib.h> | ||
47 | #include <fcntl.h> | ||
48 | #include <ctype.h> | ||
49 | #include <assert.h> | ||
50 | #include "busybox.h" | 41 | #include "busybox.h" |
51 | 42 | ||
52 | static int print_formatted (char *format, int argc, char **argv); | 43 | static int print_formatted(char *format, int argc, char **argv); |
53 | static void print_direc (char *start, size_t length, | 44 | static void print_direc(char *start, size_t length, |
54 | int field_width, int precision, char *argument); | 45 | int field_width, int precision, char *argument); |
55 | 46 | ||
56 | typedef int (*converter)(char *arg, void *result); | 47 | typedef int (*converter)(char *arg, void *result); |
48 | |||
57 | static void multiconvert(char *arg, void *result, converter convert) | 49 | static void multiconvert(char *arg, void *result, converter convert) |
58 | { | 50 | { |
59 | char s[16]; | 51 | char s[16]; |
60 | if (*arg == '"' || *arg == '\'') { | 52 | if (*arg == '"' || *arg == '\'') { |
61 | sprintf(s,"%d",(unsigned)*(++arg)); | 53 | sprintf(s, "%d", (unsigned)arg[1]); |
62 | arg=s; | 54 | arg = s; |
63 | } | 55 | } |
64 | if(convert(arg,result)) fprintf(stderr, "%s", arg); | 56 | if (convert(arg, result)) |
57 | fputs(arg, stderr); | ||
65 | } | 58 | } |
66 | 59 | ||
67 | static unsigned long xstrtoul(char *arg) | 60 | static unsigned long xstrtoul(char *arg) |
68 | { | 61 | { |
69 | unsigned long result; | 62 | unsigned long result; |
70 | 63 | ||
71 | multiconvert(arg,&result, (converter)safe_strtoul); | 64 | multiconvert(arg, &result, (converter)safe_strtoul); |
72 | return result; | 65 | return result; |
73 | } | 66 | } |
74 | 67 | ||
@@ -104,7 +97,7 @@ int printf_main(int argc, char **argv) | |||
104 | char *format; | 97 | char *format; |
105 | int args_used; | 98 | int args_used; |
106 | 99 | ||
107 | if (argc <= 1 || **(argv + 1) == '-') { | 100 | if (argc <= 1 || argv[1][0] == '-') { |
108 | bb_show_usage(); | 101 | bb_show_usage(); |
109 | } | 102 | } |
110 | 103 | ||
@@ -119,9 +112,8 @@ int printf_main(int argc, char **argv) | |||
119 | } | 112 | } |
120 | while (args_used > 0 && argc > 0); | 113 | while (args_used > 0 && argc > 0); |
121 | 114 | ||
122 | /* | 115 | /* if (argc > 0) |
123 | if (argc > 0) | 116 | fprintf(stderr, "excess args ignored"); |
124 | fprintf(stderr, "excess args ignored"); | ||
125 | */ | 117 | */ |
126 | 118 | ||
127 | return EXIT_SUCCESS; | 119 | return EXIT_SUCCESS; |
@@ -199,9 +191,9 @@ static int print_formatted(char *format, int argc, char **argv) | |||
199 | ++direc_length; | 191 | ++direc_length; |
200 | } | 192 | } |
201 | /* | 193 | /* |
202 | if (!strchr ("diouxXfeEgGcs", *f)) | 194 | if (!strchr ("diouxXfeEgGcs", *f)) |
203 | fprintf(stderr, "%%%c: invalid directive", *f); | 195 | fprintf(stderr, "%%%c: invalid directive", *f); |
204 | */ | 196 | */ |
205 | ++direc_length; | 197 | ++direc_length; |
206 | if (argc > 0) { | 198 | if (argc > 0) { |
207 | print_direc(direc_start, direc_length, field_width, | 199 | print_direc(direc_start, direc_length, field_width, |
@@ -232,7 +224,7 @@ static void | |||
232 | print_direc(char *start, size_t length, int field_width, int precision, | 224 | print_direc(char *start, size_t length, int field_width, int precision, |
233 | char *argument) | 225 | char *argument) |
234 | { | 226 | { |
235 | char *p; /* Null-terminated copy of % directive. */ | 227 | char *p; /* Null-terminated copy of % directive. */ |
236 | 228 | ||
237 | p = xmalloc((unsigned) (length + 1)); | 229 | p = xmalloc((unsigned) (length + 1)); |
238 | strncpy(p, start, length); | 230 | strncpy(p, start, length); |
diff --git a/libbb/xgetcwd.c b/libbb/xgetcwd.c index f6cfb34a7..0ac450d3b 100644 --- a/libbb/xgetcwd.c +++ b/libbb/xgetcwd.c | |||
@@ -7,11 +7,6 @@ | |||
7 | * Special function for busybox written by Vladimir Oleynik <dzo@simtreas.ru> | 7 | * Special function for busybox written by Vladimir Oleynik <dzo@simtreas.ru> |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <stdlib.h> | ||
11 | #include <errno.h> | ||
12 | #include <unistd.h> | ||
13 | #include <limits.h> | ||
14 | #include <sys/param.h> | ||
15 | #include "libbb.h" | 10 | #include "libbb.h" |
16 | 11 | ||
17 | /* Amount to increase buffer size by in each try. */ | 12 | /* Amount to increase buffer size by in each try. */ |
@@ -23,27 +18,27 @@ | |||
23 | */ | 18 | */ |
24 | 19 | ||
25 | char * | 20 | char * |
26 | xgetcwd (char *cwd) | 21 | xgetcwd(char *cwd) |
27 | { | 22 | { |
28 | char *ret; | 23 | char *ret; |
29 | unsigned path_max; | 24 | unsigned path_max; |
30 | 25 | ||
31 | path_max = (unsigned) PATH_MAX; | 26 | path_max = (unsigned) PATH_MAX; |
32 | path_max += 2; /* The getcwd docs say to do this. */ | 27 | path_max += 2; /* The getcwd docs say to do this. */ |
33 | 28 | ||
34 | if(cwd==0) | 29 | if (cwd==0) |
35 | cwd = xmalloc (path_max); | 30 | cwd = xmalloc(path_max); |
36 | 31 | ||
37 | while ((ret = getcwd (cwd, path_max)) == NULL && errno == ERANGE) { | 32 | while ((ret = getcwd(cwd, path_max)) == NULL && errno == ERANGE) { |
38 | path_max += PATH_INCR; | 33 | path_max += PATH_INCR; |
39 | cwd = xrealloc (cwd, path_max); | 34 | cwd = xrealloc(cwd, path_max); |
40 | } | 35 | } |
41 | 36 | ||
42 | if (ret == NULL) { | 37 | if (ret == NULL) { |
43 | free (cwd); | 38 | free(cwd); |
44 | bb_perror_msg("getcwd()"); | 39 | bb_perror_msg("getcwd"); |
45 | return NULL; | 40 | return NULL; |
46 | } | 41 | } |
47 | 42 | ||
48 | return cwd; | 43 | return cwd; |
49 | } | 44 | } |
diff --git a/miscutils/runlevel.c b/miscutils/runlevel.c index a042a7012..91d49fa55 100644 --- a/miscutils/runlevel.c +++ b/miscutils/runlevel.c | |||
@@ -20,24 +20,23 @@ | |||
20 | 20 | ||
21 | int runlevel_main(int argc, char *argv[]) | 21 | int runlevel_main(int argc, char *argv[]) |
22 | { | 22 | { |
23 | struct utmp *ut; | 23 | struct utmp *ut; |
24 | char prev; | 24 | char prev; |
25 | 25 | ||
26 | if (argc > 1) utmpname(argv[1]); | 26 | if (argc > 1) utmpname(argv[1]); |
27 | 27 | ||
28 | setutent(); | 28 | setutent(); |
29 | while ((ut = getutent()) != NULL) { | 29 | while ((ut = getutent()) != NULL) { |
30 | if (ut->ut_type == RUN_LVL) { | 30 | if (ut->ut_type == RUN_LVL) { |
31 | prev = ut->ut_pid / 256; | 31 | prev = ut->ut_pid / 256; |
32 | if (prev == 0) prev = 'N'; | 32 | if (prev == 0) prev = 'N'; |
33 | printf("%c %c\n", prev, ut->ut_pid % 256); | 33 | printf("%c %c\n", prev, ut->ut_pid % 256); |
34 | endutent(); | 34 | endutent(); |
35 | return (0); | 35 | return 0; |
36 | } | ||
36 | } | 37 | } |
37 | } | ||
38 | 38 | ||
39 | printf("unknown\n"); | 39 | puts("unknown"); |
40 | endutent(); | 40 | endutent(); |
41 | return (1); | 41 | return 1; |
42 | } | 42 | } |
43 | |||