diff options
Diffstat (limited to '')
-rw-r--r-- | coreutils/test.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/coreutils/test.c b/coreutils/test.c index ecd154907..2b624e308 100644 --- a/coreutils/test.c +++ b/coreutils/test.c | |||
@@ -178,7 +178,6 @@ static arith_t getn(const char *s); | |||
178 | static int newerf(const char *f1, const char *f2); | 178 | static int newerf(const char *f1, const char *f2); |
179 | static int olderf(const char *f1, const char *f2); | 179 | static int olderf(const char *f1, const char *f2); |
180 | static int equalf(const char *f1, const char *f2); | 180 | static int equalf(const char *f1, const char *f2); |
181 | static void syntax(const char *op, const char *msg); | ||
182 | static int test_eaccess(char *path, int mode); | 181 | static int test_eaccess(char *path, int mode); |
183 | static int is_a_group_member(gid_t gid); | 182 | static int is_a_group_member(gid_t gid); |
184 | static void initialize_group_array(void); | 183 | static void initialize_group_array(void); |
@@ -230,20 +229,11 @@ int test_main(int argc, char **argv) | |||
230 | res = !oexpr(t_lex(*t_wp)); | 229 | res = !oexpr(t_lex(*t_wp)); |
231 | 230 | ||
232 | if (*t_wp != NULL && *++t_wp != NULL) | 231 | if (*t_wp != NULL && *++t_wp != NULL) |
233 | syntax(*t_wp, "unknown operand"); | 232 | bb_error_msg_and_die("%s: unknown operand", *t_wp); |
234 | 233 | ||
235 | return (res); | 234 | return (res); |
236 | } | 235 | } |
237 | 236 | ||
238 | static void syntax(const char *op, const char *msg) | ||
239 | { | ||
240 | if (op && *op) { | ||
241 | bb_error_msg_and_die("%s: %s", op, msg); | ||
242 | } else { | ||
243 | bb_error_msg_and_die("%s", msg); | ||
244 | } | ||
245 | } | ||
246 | |||
247 | static arith_t oexpr(enum token n) | 237 | static arith_t oexpr(enum token n) |
248 | { | 238 | { |
249 | arith_t res; | 239 | arith_t res; |
@@ -279,18 +269,18 @@ static arith_t primary(enum token n) | |||
279 | arith_t res; | 269 | arith_t res; |
280 | 270 | ||
281 | if (n == EOI) { | 271 | if (n == EOI) { |
282 | syntax(NULL, "argument expected"); | 272 | bb_error_msg_and_die("argument expected"); |
283 | } | 273 | } |
284 | if (n == LPAREN) { | 274 | if (n == LPAREN) { |
285 | res = oexpr(t_lex(*++t_wp)); | 275 | res = oexpr(t_lex(*++t_wp)); |
286 | if (t_lex(*++t_wp) != RPAREN) | 276 | if (t_lex(*++t_wp) != RPAREN) |
287 | syntax(NULL, "closing paren expected"); | 277 | bb_error_msg_and_die("closing paren expected"); |
288 | return res; | 278 | return res; |
289 | } | 279 | } |
290 | if (t_wp_op && t_wp_op->op_type == UNOP) { | 280 | if (t_wp_op && t_wp_op->op_type == UNOP) { |
291 | /* unary expression */ | 281 | /* unary expression */ |
292 | if (*++t_wp == NULL) | 282 | if (*++t_wp == NULL) |
293 | syntax(t_wp_op->op_text, "argument expected"); | 283 | bb_error_msg_and_die(bb_msg_requires_arg, t_wp_op->op_text); |
294 | switch (n) { | 284 | switch (n) { |
295 | case STREZ: | 285 | case STREZ: |
296 | return strlen(*t_wp) == 0; | 286 | return strlen(*t_wp) == 0; |
@@ -320,7 +310,7 @@ static int binop(void) | |||
320 | op = t_wp_op; | 310 | op = t_wp_op; |
321 | 311 | ||
322 | if ((opnd2 = *++t_wp) == (char *) 0) | 312 | if ((opnd2 = *++t_wp) == (char *) 0) |
323 | syntax(op->op_text, "argument expected"); | 313 | bb_error_msg_and_die(bb_msg_requires_arg, op->op_text); |
324 | 314 | ||
325 | switch (op->op_num) { | 315 | switch (op->op_num) { |
326 | case STREQ: | 316 | case STREQ: |