diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-08 12:49:22 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-08 12:49:22 +0000 |
commit | 1385899416a4396385ad421ae1f532be7103738a (patch) | |
tree | fc4d14a910593d1235318bb36abe5e9f72d2039e /coreutils/printf.c | |
parent | 5625415085e68ac5e150f54e685417c866620d76 (diff) | |
download | busybox-w32-1385899416a4396385ad421ae1f532be7103738a.tar.gz busybox-w32-1385899416a4396385ad421ae1f532be7103738a.tar.bz2 busybox-w32-1385899416a4396385ad421ae1f532be7103738a.zip |
attempt to regularize atoi mess.
Diffstat (limited to 'coreutils/printf.c')
-rw-r--r-- | coreutils/printf.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/coreutils/printf.c b/coreutils/printf.c index 4a208040f..1511034a1 100644 --- a/coreutils/printf.c +++ b/coreutils/printf.c | |||
@@ -30,7 +30,7 @@ | |||
30 | 30 | ||
31 | %b = print an argument string, interpreting backslash escapes | 31 | %b = print an argument string, interpreting backslash escapes |
32 | 32 | ||
33 | The `format' argument is re-used as many times as necessary | 33 | The 'format' argument is re-used as many times as necessary |
34 | to convert all of the given arguments. | 34 | to convert all of the given arguments. |
35 | 35 | ||
36 | David MacKenzie <djm@gnu.ai.mit.edu> */ | 36 | David MacKenzie <djm@gnu.ai.mit.edu> */ |
@@ -57,7 +57,7 @@ static void multiconvert(char *arg, void *result, converter convert) | |||
57 | fputs(arg, stderr); | 57 | fputs(arg, stderr); |
58 | } | 58 | } |
59 | 59 | ||
60 | static unsigned long xstrtoul(char *arg) | 60 | static unsigned long my_xstrtoul(char *arg) |
61 | { | 61 | { |
62 | unsigned long result; | 62 | unsigned long result; |
63 | 63 | ||
@@ -65,14 +65,14 @@ static unsigned long xstrtoul(char *arg) | |||
65 | return result; | 65 | return result; |
66 | } | 66 | } |
67 | 67 | ||
68 | static long xstrtol(char *arg) | 68 | static long my_xstrtol(char *arg) |
69 | { | 69 | { |
70 | long result; | 70 | long result; |
71 | multiconvert(arg, &result, (converter)safe_strtol); | 71 | multiconvert(arg, &result, (converter)safe_strtol); |
72 | return result; | 72 | return result; |
73 | } | 73 | } |
74 | 74 | ||
75 | static double xstrtod(char *arg) | 75 | static double my_xstrtod(char *arg) |
76 | { | 76 | { |
77 | double result; | 77 | double result; |
78 | multiconvert(arg, &result, (converter)safe_strtod); | 78 | multiconvert(arg, &result, (converter)safe_strtod); |
@@ -120,13 +120,13 @@ int printf_main(int argc, char **argv) | |||
120 | } | 120 | } |
121 | 121 | ||
122 | /* Print the text in FORMAT, using ARGV (with ARGC elements) for | 122 | /* Print the text in FORMAT, using ARGV (with ARGC elements) for |
123 | arguments to any `%' directives. | 123 | arguments to any '%' directives. |
124 | Return the number of elements of ARGV used. */ | 124 | Return the number of elements of ARGV used. */ |
125 | 125 | ||
126 | static int print_formatted(char *format, int argc, char **argv) | 126 | static int print_formatted(char *format, int argc, char **argv) |
127 | { | 127 | { |
128 | int save_argc = argc; /* Preserve original value. */ | 128 | int save_argc = argc; /* Preserve original value. */ |
129 | char *f; /* Pointer into `format'. */ | 129 | char *f; /* Pointer into 'format'. */ |
130 | char *direc_start; /* Start of % directive. */ | 130 | char *direc_start; /* Start of % directive. */ |
131 | size_t direc_length; /* Length of % directive. */ | 131 | size_t direc_length; /* Length of % directive. */ |
132 | int field_width; /* Arg to first '*', or -1 if none. */ | 132 | int field_width; /* Arg to first '*', or -1 if none. */ |
@@ -158,7 +158,7 @@ static int print_formatted(char *format, int argc, char **argv) | |||
158 | ++f; | 158 | ++f; |
159 | ++direc_length; | 159 | ++direc_length; |
160 | if (argc > 0) { | 160 | if (argc > 0) { |
161 | field_width = xstrtoul(*argv); | 161 | field_width = my_xstrtoul(*argv); |
162 | ++argv; | 162 | ++argv; |
163 | --argc; | 163 | --argc; |
164 | } else | 164 | } else |
@@ -175,7 +175,7 @@ static int print_formatted(char *format, int argc, char **argv) | |||
175 | ++f; | 175 | ++f; |
176 | ++direc_length; | 176 | ++direc_length; |
177 | if (argc > 0) { | 177 | if (argc > 0) { |
178 | precision = xstrtoul(*argv); | 178 | precision = my_xstrtoul(*argv); |
179 | ++argv; | 179 | ++argv; |
180 | --argc; | 180 | --argc; |
181 | } else | 181 | } else |
@@ -235,14 +235,14 @@ print_direc(char *start, size_t length, int field_width, int precision, | |||
235 | case 'i': | 235 | case 'i': |
236 | if (field_width < 0) { | 236 | if (field_width < 0) { |
237 | if (precision < 0) | 237 | if (precision < 0) |
238 | printf(p, xstrtol(argument)); | 238 | printf(p, my_xstrtol(argument)); |
239 | else | 239 | else |
240 | printf(p, precision, xstrtol(argument)); | 240 | printf(p, precision, my_xstrtol(argument)); |
241 | } else { | 241 | } else { |
242 | if (precision < 0) | 242 | if (precision < 0) |
243 | printf(p, field_width, xstrtol(argument)); | 243 | printf(p, field_width, my_xstrtol(argument)); |
244 | else | 244 | else |
245 | printf(p, field_width, precision, xstrtol(argument)); | 245 | printf(p, field_width, precision, my_xstrtol(argument)); |
246 | } | 246 | } |
247 | break; | 247 | break; |
248 | 248 | ||
@@ -252,14 +252,14 @@ print_direc(char *start, size_t length, int field_width, int precision, | |||
252 | case 'X': | 252 | case 'X': |
253 | if (field_width < 0) { | 253 | if (field_width < 0) { |
254 | if (precision < 0) | 254 | if (precision < 0) |
255 | printf(p, xstrtoul(argument)); | 255 | printf(p, my_xstrtoul(argument)); |
256 | else | 256 | else |
257 | printf(p, precision, xstrtoul(argument)); | 257 | printf(p, precision, my_xstrtoul(argument)); |
258 | } else { | 258 | } else { |
259 | if (precision < 0) | 259 | if (precision < 0) |
260 | printf(p, field_width, xstrtoul(argument)); | 260 | printf(p, field_width, my_xstrtoul(argument)); |
261 | else | 261 | else |
262 | printf(p, field_width, precision, xstrtoul(argument)); | 262 | printf(p, field_width, precision, my_xstrtoul(argument)); |
263 | } | 263 | } |
264 | break; | 264 | break; |
265 | 265 | ||
@@ -270,14 +270,14 @@ print_direc(char *start, size_t length, int field_width, int precision, | |||
270 | case 'G': | 270 | case 'G': |
271 | if (field_width < 0) { | 271 | if (field_width < 0) { |
272 | if (precision < 0) | 272 | if (precision < 0) |
273 | printf(p, xstrtod(argument)); | 273 | printf(p, my_xstrtod(argument)); |
274 | else | 274 | else |
275 | printf(p, precision, xstrtod(argument)); | 275 | printf(p, precision, my_xstrtod(argument)); |
276 | } else { | 276 | } else { |
277 | if (precision < 0) | 277 | if (precision < 0) |
278 | printf(p, field_width, xstrtod(argument)); | 278 | printf(p, field_width, my_xstrtod(argument)); |
279 | else | 279 | else |
280 | printf(p, field_width, precision, xstrtod(argument)); | 280 | printf(p, field_width, precision, my_xstrtod(argument)); |
281 | } | 281 | } |
282 | break; | 282 | break; |
283 | 283 | ||