diff options
author | Eric Andersen <andersen@codepoet.org> | 2003-10-31 08:19:44 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2003-10-31 08:19:44 +0000 |
commit | 252183e3f53b58984397bf6e8bd727b2ebe85b2e (patch) | |
tree | 00afdb55cc6701a11112cda2b8d3666226e277d1 /findutils | |
parent | e64bf409dd07d818d16b48bcee4a285b1dc81f4f (diff) | |
download | busybox-w32-252183e3f53b58984397bf6e8bd727b2ebe85b2e.tar.gz busybox-w32-252183e3f53b58984397bf6e8bd727b2ebe85b2e.tar.bz2 busybox-w32-252183e3f53b58984397bf6e8bd727b2ebe85b2e.zip |
Try to make indent formatting less horrible
Diffstat (limited to 'findutils')
-rw-r--r-- | findutils/xargs.c | 76 |
1 files changed, 37 insertions, 39 deletions
diff --git a/findutils/xargs.c b/findutils/xargs.c index 3f3c9449c..8d7e813b5 100644 --- a/findutils/xargs.c +++ b/findutils/xargs.c | |||
@@ -92,18 +92,17 @@ static int xargs_exec(char *const *args) | |||
92 | return exec_errno == ENOENT ? 127 : 126; | 92 | return exec_errno == ENOENT ? 127 : 126; |
93 | } else { | 93 | } else { |
94 | if (WEXITSTATUS(status) == 255) { | 94 | if (WEXITSTATUS(status) == 255) { |
95 | bb_error_msg("%s: exited with status 255; aborting", | 95 | bb_error_msg("%s: exited with status 255; aborting", args[0]); |
96 | args[0]); | ||
97 | return 124; | 96 | return 124; |
98 | } | 97 | } |
99 | if (WIFSTOPPED(status)) { | 98 | if (WIFSTOPPED(status)) { |
100 | bb_error_msg("%s: stopped by signal %d", args[0], | 99 | bb_error_msg("%s: stopped by signal %d", |
101 | WSTOPSIG(status)); | 100 | args[0], WSTOPSIG(status)); |
102 | return 125; | 101 | return 125; |
103 | } | 102 | } |
104 | if (WIFSIGNALED(status)) { | 103 | if (WIFSIGNALED(status)) { |
105 | bb_error_msg("%s: terminated by signal %d", args[0], | 104 | bb_error_msg("%s: terminated by signal %d", |
106 | WTERMSIG(status)); | 105 | args[0], WTERMSIG(status)); |
107 | return 125; | 106 | return 125; |
108 | } | 107 | } |
109 | if (WEXITSTATUS(status) != 0) | 108 | if (WEXITSTATUS(status) != 0) |
@@ -130,8 +129,8 @@ static int eof_stdin_detected; | |||
130 | || (c) == '\f' || (c) == '\v') | 129 | || (c) == '\f' || (c) == '\v') |
131 | 130 | ||
132 | #ifdef CONFIG_FEATURE_XARGS_SUPPORT_QUOTES | 131 | #ifdef CONFIG_FEATURE_XARGS_SUPPORT_QUOTES |
133 | static xlist_t *process_stdin(xlist_t * list_arg, const char *eof_str, | 132 | static xlist_t *process_stdin(xlist_t * list_arg, |
134 | size_t mc, char *buf) | 133 | const char *eof_str, size_t mc, char *buf) |
135 | { | 134 | { |
136 | #define NORM 0 | 135 | #define NORM 0 |
137 | #define QUOTE 1 | 136 | #define QUOTE 1 |
@@ -140,11 +139,11 @@ static xlist_t *process_stdin(xlist_t * list_arg, const char *eof_str, | |||
140 | 139 | ||
141 | char *s = NULL; /* start word */ | 140 | char *s = NULL; /* start word */ |
142 | char *p = NULL; /* pointer to end word */ | 141 | char *p = NULL; /* pointer to end word */ |
143 | char q = 0; /* quote char */ | 142 | char q = 0; /* quote char */ |
144 | char state = NORM; | 143 | char state = NORM; |
145 | char eof_str_detected = 0; | 144 | char eof_str_detected = 0; |
146 | size_t line_l = 0; /* size loaded args line */ | 145 | size_t line_l = 0; /* size loaded args line */ |
147 | int c; /* current char */ | 146 | int c; /* current char */ |
148 | xlist_t *cur; | 147 | xlist_t *cur; |
149 | xlist_t *prev; | 148 | xlist_t *prev; |
150 | 149 | ||
@@ -174,11 +173,11 @@ static xlist_t *process_stdin(xlist_t * list_arg, const char *eof_str, | |||
174 | } else { | 173 | } else { |
175 | goto set; | 174 | goto set; |
176 | } | 175 | } |
177 | } else { /* if(state == NORM) */ | 176 | } else { /* if(state == NORM) */ |
178 | 177 | ||
179 | if (ISSPACE(c)) { | 178 | if (ISSPACE(c)) { |
180 | if (s) { | 179 | if (s) { |
181 | unexpected_eof: | 180 | unexpected_eof: |
182 | state = SPACE; | 181 | state = SPACE; |
183 | c = 0; | 182 | c = 0; |
184 | goto set; | 183 | goto set; |
@@ -192,7 +191,7 @@ static xlist_t *process_stdin(xlist_t * list_arg, const char *eof_str, | |||
192 | q = c; | 191 | q = c; |
193 | state = QUOTE; | 192 | state = QUOTE; |
194 | } else { | 193 | } else { |
195 | set: | 194 | set: |
196 | if ((p - buf) >= mc) | 195 | if ((p - buf) >= mc) |
197 | bb_error_msg_and_die("argument line too long"); | 196 | bb_error_msg_and_die("argument line too long"); |
198 | *p++ = c; | 197 | *p++ = c; |
@@ -200,9 +199,10 @@ static xlist_t *process_stdin(xlist_t * list_arg, const char *eof_str, | |||
200 | } | 199 | } |
201 | } | 200 | } |
202 | if (state == SPACE) { /* word's delimiter or EOF detected */ | 201 | if (state == SPACE) { /* word's delimiter or EOF detected */ |
203 | if (q) | 202 | if (q) { |
204 | bb_error_msg_and_die("unmatched %s quote", | 203 | bb_error_msg_and_die("unmatched %s quote", |
205 | q == '\'' ? "single" : "double"); | 204 | q == '\'' ? "single" : "double"); |
205 | } | ||
206 | /* word loaded */ | 206 | /* word loaded */ |
207 | if (eof_str) { | 207 | if (eof_str) { |
208 | eof_str_detected = strcmp(s, eof_str) == 0; | 208 | eof_str_detected = strcmp(s, eof_str) == 0; |
@@ -233,12 +233,12 @@ static xlist_t *process_stdin(xlist_t * list_arg, const char *eof_str, | |||
233 | return list_arg; | 233 | return list_arg; |
234 | } | 234 | } |
235 | #else | 235 | #else |
236 | /* The variant is unsupport single, double quotes and backslash */ | 236 | /* The variant does not support single quotes, double quotes or backslash */ |
237 | static xlist_t *process_stdin(xlist_t * list_arg, const char *eof_str, | 237 | static xlist_t *process_stdin(xlist_t * list_arg, |
238 | size_t mc, char *buf) | 238 | const char *eof_str, size_t mc, char *buf) |
239 | { | 239 | { |
240 | 240 | ||
241 | int c; /* current char */ | 241 | int c; /* current char */ |
242 | int eof_str_detected = 0; | 242 | int eof_str_detected = 0; |
243 | char *s = NULL; /* start word */ | 243 | char *s = NULL; /* start word */ |
244 | char *p = NULL; /* pointer to end word */ | 244 | char *p = NULL; /* pointer to end word */ |
@@ -298,7 +298,7 @@ static xlist_t *process_stdin(xlist_t * list_arg, const char *eof_str, | |||
298 | } | 298 | } |
299 | return list_arg; | 299 | return list_arg; |
300 | } | 300 | } |
301 | #endif /* CONFIG_FEATURE_XARGS_SUPPORT_QUOTES */ | 301 | #endif /* CONFIG_FEATURE_XARGS_SUPPORT_QUOTES */ |
302 | 302 | ||
303 | 303 | ||
304 | #ifdef CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION | 304 | #ifdef CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION |
@@ -331,7 +331,7 @@ static int xargs_ask_confirmation(void) | |||
331 | #else | 331 | #else |
332 | # define OPT_INC_P 0 | 332 | # define OPT_INC_P 0 |
333 | # define xargs_ask_confirmation() 1 | 333 | # define xargs_ask_confirmation() 1 |
334 | #endif /* CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION */ | 334 | #endif /* CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION */ |
335 | 335 | ||
336 | #ifdef CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT | 336 | #ifdef CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT |
337 | # define OPT_INC_X 1 | 337 | # define OPT_INC_X 1 |
@@ -343,7 +343,7 @@ static int xargs_ask_confirmation(void) | |||
343 | static xlist_t *process0_stdin(xlist_t * list_arg, const char *eof_str, | 343 | static xlist_t *process0_stdin(xlist_t * list_arg, const char *eof_str, |
344 | size_t mc, char *buf) | 344 | size_t mc, char *buf) |
345 | { | 345 | { |
346 | int c; /* current char */ | 346 | int c; /* current char */ |
347 | char *s = NULL; /* start word */ | 347 | char *s = NULL; /* start word */ |
348 | char *p = NULL; /* pointer to end word */ | 348 | char *p = NULL; /* pointer to end word */ |
349 | size_t line_l = 0; /* size loaded args line */ | 349 | size_t line_l = 0; /* size loaded args line */ |
@@ -399,7 +399,7 @@ static xlist_t *process0_stdin(xlist_t * list_arg, const char *eof_str, | |||
399 | #else | 399 | #else |
400 | # define OPT_INC_0 0 /* future use */ | 400 | # define OPT_INC_0 0 /* future use */ |
401 | # define READ_ARGS(l, e, nmc, mc) process_stdin(l, e, nmc, mc) | 401 | # define READ_ARGS(l, e, nmc, mc) process_stdin(l, e, nmc, mc) |
402 | #endif /* CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM */ | 402 | #endif /* CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM */ |
403 | 403 | ||
404 | 404 | ||
405 | #define OPT_VERBOSE (1<<0) | 405 | #define OPT_VERBOSE (1<<0) |
@@ -434,8 +434,7 @@ int xargs_main(int argc, char **argv) | |||
434 | size_t n_max_chars; | 434 | size_t n_max_chars; |
435 | 435 | ||
436 | #ifdef CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM | 436 | #ifdef CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM |
437 | xlist_t *(*read_args) (xlist_t *, const char *, size_t, char *) = | 437 | xlist_t *(*read_args) (xlist_t *, const char *, size_t, char *) = process_stdin; |
438 | process_stdin; | ||
439 | #endif | 438 | #endif |
440 | 439 | ||
441 | #ifdef CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION | 440 | #ifdef CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION |
@@ -444,15 +443,15 @@ int xargs_main(int argc, char **argv) | |||
444 | 443 | ||
445 | opt = bb_getopt_ulflags(argc, argv, "+trn:s:e::" | 444 | opt = bb_getopt_ulflags(argc, argv, "+trn:s:e::" |
446 | #ifdef CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION | 445 | #ifdef CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION |
447 | "p" | 446 | "p" |
448 | #endif | 447 | #endif |
449 | #ifdef CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT | 448 | #ifdef CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT |
450 | "x" | 449 | "x" |
451 | #endif | 450 | #endif |
452 | #ifdef CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM | 451 | #ifdef CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM |
453 | "0" | 452 | "0" |
454 | #endif | 453 | #endif |
455 | , &max_args, &max_chars, &eof_str); | 454 | ,&max_args, &max_chars, &eof_str); |
456 | 455 | ||
457 | a = argc - optind; | 456 | a = argc - optind; |
458 | argv += optind; | 457 | argv += optind; |
@@ -472,8 +471,7 @@ int xargs_main(int argc, char **argv) | |||
472 | n_chars += strlen(*argv) + 1; | 471 | n_chars += strlen(*argv) + 1; |
473 | } | 472 | } |
474 | if (n_max_chars < n_chars) { | 473 | if (n_max_chars < n_chars) { |
475 | bb_error_msg_and_die | 474 | bb_error_msg_and_die("can not fit single argument within argument list size limit"); |
476 | ("can not fit single argument within argument list size limit"); | ||
477 | } | 475 | } |
478 | n_max_chars -= n_chars; | 476 | n_max_chars -= n_chars; |
479 | } else { | 477 | } else { |
@@ -498,8 +496,9 @@ int xargs_main(int argc, char **argv) | |||
498 | read_args = process0_stdin; | 496 | read_args = process0_stdin; |
499 | #endif | 497 | #endif |
500 | 498 | ||
501 | while ((list = READ_ARGS(list, eof_str, n_max_chars, max_chars)) != NULL | 499 | while ((list = READ_ARGS(list, eof_str, n_max_chars, max_chars)) != NULL || |
502 | || (opt & OPT_NO_EMPTY) == 0) { | 500 | (opt & OPT_NO_EMPTY) == 0) |
501 | { | ||
503 | opt |= OPT_NO_EMPTY; | 502 | opt |= OPT_NO_EMPTY; |
504 | n = 0; | 503 | n = 0; |
505 | n_chars = 0; | 504 | n_chars = 0; |
@@ -522,7 +521,7 @@ int xargs_main(int argc, char **argv) | |||
522 | break; | 521 | break; |
523 | } | 522 | } |
524 | } | 523 | } |
525 | #endif /* CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT */ | 524 | #endif /* CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT */ |
526 | 525 | ||
527 | /* allocating pointers for execvp: | 526 | /* allocating pointers for execvp: |
528 | a*arg, n*arg from stdin, NULL */ | 527 | a*arg, n*arg from stdin, NULL */ |
@@ -575,9 +574,8 @@ const char *bb_applet_name = "debug stuff usage"; | |||
575 | 574 | ||
576 | void bb_show_usage(void) | 575 | void bb_show_usage(void) |
577 | { | 576 | { |
578 | fprintf(stderr, | 577 | fprintf(stderr, "Usage: %s [-p] [-r] [-t] -[x] [-n max_arg] [-s max_chars]\n", |
579 | "Usage: %s [-p] [-r] [-t] -[x] [-n max_arg] [-s max_chars]\n", | 578 | bb_applet_name); |
580 | bb_applet_name); | ||
581 | exit(1); | 579 | exit(1); |
582 | } | 580 | } |
583 | 581 | ||
@@ -585,4 +583,4 @@ int main(int argc, char **argv) | |||
585 | { | 583 | { |
586 | return xargs_main(argc, argv); | 584 | return xargs_main(argc, argv); |
587 | } | 585 | } |
588 | #endif /* TEST */ | 586 | #endif /* TEST */ |