diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-23 16:01:09 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-23 16:01:09 +0000 |
commit | c290563319b61c8230deca52ab625d8dc335e2d3 (patch) | |
tree | 0961ae48901bd3defbcc6bbd5cd57bd90a3f849e /coreutils/printf.c | |
parent | c1876d7364a260e06cd23a3255b9058240527b02 (diff) | |
download | busybox-w32-c290563319b61c8230deca52ab625d8dc335e2d3.tar.gz busybox-w32-c290563319b61c8230deca52ab625d8dc335e2d3.tar.bz2 busybox-w32-c290563319b61c8230deca52ab625d8dc335e2d3.zip |
remove unneeded #includes, fix indentation
Diffstat (limited to 'coreutils/printf.c')
-rw-r--r-- | coreutils/printf.c | 38 |
1 files changed, 15 insertions, 23 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); |