diff options
author | Ron Yorston <rmy@pobox.com> | 2020-02-15 13:25:04 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2020-02-15 13:25:04 +0000 |
commit | 0abe89bc214c9d1f16f32c4339792066b875b7c6 (patch) | |
tree | 3748f654565bd08513093ebfbb68487f612b5e3f /findutils/xargs.c | |
parent | 6885083a7e4f94938ca0a98e2c6c69a84eb08a1f (diff) | |
parent | a6e48dead331c3c19e070992d2d571e74a1d9a8d (diff) | |
download | busybox-w32-0abe89bc214c9d1f16f32c4339792066b875b7c6.tar.gz busybox-w32-0abe89bc214c9d1f16f32c4339792066b875b7c6.tar.bz2 busybox-w32-0abe89bc214c9d1f16f32c4339792066b875b7c6.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'findutils/xargs.c')
-rw-r--r-- | findutils/xargs.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/findutils/xargs.c b/findutils/xargs.c index e0dbcbc7a..8d3a0027c 100644 --- a/findutils/xargs.c +++ b/findutils/xargs.c | |||
@@ -120,18 +120,29 @@ struct globals { | |||
120 | #endif | 120 | #endif |
121 | #endif | 121 | #endif |
122 | smalluint xargs_exitcode; | 122 | smalluint xargs_exitcode; |
123 | #if ENABLE_FEATURE_XARGS_SUPPORT_QUOTES | ||
124 | #define NORM 0 | ||
125 | #define QUOTE 1 | ||
126 | #define BACKSLASH 2 | ||
127 | #define SPACE 4 | ||
128 | smalluint process_stdin__state; | ||
129 | char process_stdin__q; | ||
130 | #endif | ||
123 | } FIX_ALIASING; | 131 | } FIX_ALIASING; |
124 | #define G (*(struct globals*)bb_common_bufsiz1) | 132 | #define G (*(struct globals*)bb_common_bufsiz1) |
125 | #define INIT_G() do { \ | 133 | #define INIT_G() do { \ |
126 | setup_common_bufsiz(); \ | 134 | setup_common_bufsiz(); \ |
127 | G.eof_str = NULL; /* need to clear by hand because we are NOEXEC applet */ \ | 135 | IF_FEATURE_XARGS_SUPPORT_REPL_STR(G.repl_str = "{}";) \ |
136 | IF_FEATURE_XARGS_SUPPORT_REPL_STR(G.eol_ch = '\n';) \ | ||
137 | /* Even zero values are set because we are NOEXEC applet */ \ | ||
138 | G.eof_str = NULL; \ | ||
128 | G.idx = 0; \ | 139 | G.idx = 0; \ |
129 | IF_FEATURE_XARGS_SUPPORT_PARALLEL(G.running_procs = 0;) \ | 140 | IF_FEATURE_XARGS_SUPPORT_PARALLEL(G.running_procs = 0;) \ |
130 | IF_FEATURE_XARGS_SUPPORT_PARALLEL(G.max_procs = 1;) \ | 141 | IF_FEATURE_XARGS_SUPPORT_PARALLEL(G.max_procs = 1;) \ |
131 | IF_FEATURE_XARGS_SUPPORT_PARALLEL(IF_PLATFORM_MINGW32(G.procs = NULL;)) \ | 142 | IF_FEATURE_XARGS_SUPPORT_PARALLEL(IF_PLATFORM_MINGW32(G.procs = NULL;)) \ |
132 | G.xargs_exitcode = 0; \ | 143 | G.xargs_exitcode = 0; \ |
133 | IF_FEATURE_XARGS_SUPPORT_REPL_STR(G.repl_str = "{}";) \ | 144 | IF_FEATURE_XARGS_SUPPORT_QUOTES(G.process_stdin__state = NORM;) \ |
134 | IF_FEATURE_XARGS_SUPPORT_REPL_STR(G.eol_ch = '\n';) \ | 145 | IF_FEATURE_XARGS_SUPPORT_QUOTES(G.process_stdin__q = '\0';) \ |
135 | } while (0) | 146 | } while (0) |
136 | 147 | ||
137 | 148 | ||
@@ -330,12 +341,8 @@ static void store_param(char *s) | |||
330 | #if ENABLE_FEATURE_XARGS_SUPPORT_QUOTES | 341 | #if ENABLE_FEATURE_XARGS_SUPPORT_QUOTES |
331 | static char* FAST_FUNC process_stdin(int n_max_chars, int n_max_arg, char *buf) | 342 | static char* FAST_FUNC process_stdin(int n_max_chars, int n_max_arg, char *buf) |
332 | { | 343 | { |
333 | #define NORM 0 | 344 | #define q G.process_stdin__q |
334 | #define QUOTE 1 | 345 | #define state G.process_stdin__state |
335 | #define BACKSLASH 2 | ||
336 | #define SPACE 4 | ||
337 | char q = '\0'; /* quote char */ | ||
338 | char state = NORM; | ||
339 | char *s = buf; /* start of the word */ | 346 | char *s = buf; /* start of the word */ |
340 | char *p = s + strlen(buf); /* end of the word */ | 347 | char *p = s + strlen(buf); /* end of the word */ |
341 | 348 | ||
@@ -412,6 +419,8 @@ static char* FAST_FUNC process_stdin(int n_max_chars, int n_max_arg, char *buf) | |||
412 | /* store_param(NULL) - caller will do it */ | 419 | /* store_param(NULL) - caller will do it */ |
413 | dbg_msg("return:'%s'", s); | 420 | dbg_msg("return:'%s'", s); |
414 | return s; | 421 | return s; |
422 | #undef q | ||
423 | #undef state | ||
415 | } | 424 | } |
416 | #else | 425 | #else |
417 | /* The variant does not support single quotes, double quotes or backslash */ | 426 | /* The variant does not support single quotes, double quotes or backslash */ |