aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--coreutils/dd.c2
-rw-r--r--coreutils/diff.c9
-rw-r--r--coreutils/stty.c14
-rw-r--r--coreutils/test.c20
4 files changed, 15 insertions, 30 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 53aa085ed..33e789311 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -96,7 +96,7 @@ int dd_main(int argc, char **argv)
96 noerror = TRUE; 96 noerror = TRUE;
97 ibuf += 7; 97 ibuf += 7;
98 } else { 98 } else {
99 bb_error_msg_and_die("invalid conversion `%s'", argv[i]+5); 99 bb_error_msg_and_die(bb_msg_invalid_arg, argv[i]+5, "conv");
100 } 100 }
101 if (ibuf[0] == '\0') break; 101 if (ibuf[0] == '\0') break;
102 if (ibuf[0] == ',') ibuf++; 102 if (ibuf[0] == ',') ibuf++;
diff --git a/coreutils/diff.c b/coreutils/diff.c
index 57b32eb78..786e2a8ab 100644
--- a/coreutils/diff.c
+++ b/coreutils/diff.c
@@ -1158,7 +1158,7 @@ static void diffdir(char *p1, char *p2)
1158 while (*dirlist2 != NULL && strcmp(*dirlist2, start) < 0) 1158 while (*dirlist2 != NULL && strcmp(*dirlist2, start) < 0)
1159 dirlist2++; 1159 dirlist2++;
1160 if ((*dirlist1 == NULL) || (*dirlist2 == NULL)) 1160 if ((*dirlist1 == NULL) || (*dirlist2 == NULL))
1161 bb_error_msg("Invalid argument to -S"); 1161 bb_error_msg(bb_msg_invalid_arg, "NULL", "-S");
1162 } 1162 }
1163 1163
1164 /* Now that both dirlist1 and dirlist2 contain sorted directory 1164 /* Now that both dirlist1 and dirlist2 contain sorted directory
@@ -1194,7 +1194,6 @@ static void diffdir(char *p1, char *p2)
1194 1194
1195int diff_main(int argc, char **argv) 1195int diff_main(int argc, char **argv)
1196{ 1196{
1197 char *ep;
1198 int gotstdin = 0; 1197 int gotstdin = 0;
1199 1198
1200 char *U_opt; 1199 char *U_opt;
@@ -1229,11 +1228,7 @@ int diff_main(int argc, char **argv)
1229 1228
1230 context = 3; /* This is the default number of lines of context. */ 1229 context = 3; /* This is the default number of lines of context. */
1231 if (cmd_flags & FLAG_U) { 1230 if (cmd_flags & FLAG_U) {
1232 context = strtol(U_opt, &ep, 10); 1231 context = bb_xgetlarg(U_opt, 10, 1, INT_MAX);
1233 if (context == 0) {
1234 bb_error_msg("Invalid context length");
1235 bb_show_usage();
1236 }
1237 } 1232 }
1238 argc -= optind; 1233 argc -= optind;
1239 argv += optind; 1234 argv += optind;
diff --git a/coreutils/stty.c b/coreutils/stty.c
index 8b70af65e..cfb7f7f39 100644
--- a/coreutils/stty.c
+++ b/coreutils/stty.c
@@ -23,6 +23,7 @@
23 23
24//#define TEST 24//#define TEST
25 25
26#include "busybox.h"
26#include <stddef.h> 27#include <stddef.h>
27#include <termios.h> 28#include <termios.h>
28#include <sys/ioctl.h> 29#include <sys/ioctl.h>
@@ -45,7 +46,6 @@
45#include <errno.h> 46#include <errno.h>
46#include <limits.h> 47#include <limits.h>
47#include <fcntl.h> 48#include <fcntl.h>
48#include "busybox.h"
49 49
50#define STREQ(a, b) (strcmp ((a), (b)) == 0) 50#define STREQ(a, b) (strcmp ((a), (b)) == 0)
51 51
@@ -608,7 +608,7 @@ int main(int argc, char **argv)
608 for (i = 0; i < NUM_control_info; ++i) 608 for (i = 0; i < NUM_control_info; ++i)
609 if (STREQ(argv[k], control_info[i].name)) { 609 if (STREQ(argv[k], control_info[i].name)) {
610 if (k == argc - 1) 610 if (k == argc - 1)
611 bb_error_msg_and_die("missing argument to `%s'", argv[k]); 611 bb_error_msg_and_die(bb_msg_requires_arg, argv[k]);
612 match_found = 1; 612 match_found = 1;
613 ++k; 613 ++k;
614 set_control_char(&control_info[i], argv[k], &mode); 614 set_control_char(&control_info[i], argv[k], &mode);
@@ -619,14 +619,14 @@ int main(int argc, char **argv)
619 if (match_found == 0) { 619 if (match_found == 0) {
620 if (STREQ(argv[k], "ispeed")) { 620 if (STREQ(argv[k], "ispeed")) {
621 if (k == argc - 1) 621 if (k == argc - 1)
622 bb_error_msg_and_die("missing argument to `%s'", argv[k]); 622 bb_error_msg_and_die(bb_msg_requires_arg, argv[k]);
623 ++k; 623 ++k;
624 set_speed(input_speed, argv[k], &mode); 624 set_speed(input_speed, argv[k], &mode);
625 speed_was_set = 1; 625 speed_was_set = 1;
626 require_set_attr = 1; 626 require_set_attr = 1;
627 } else if (STREQ(argv[k], "ospeed")) { 627 } else if (STREQ(argv[k], "ospeed")) {
628 if (k == argc - 1) 628 if (k == argc - 1)
629 bb_error_msg_and_die("missing argument to `%s'", argv[k]); 629 bb_error_msg_and_die(bb_msg_requires_arg, argv[k]);
630 ++k; 630 ++k;
631 set_speed(output_speed, argv[k], &mode); 631 set_speed(output_speed, argv[k], &mode);
632 speed_was_set = 1; 632 speed_was_set = 1;
@@ -635,13 +635,13 @@ int main(int argc, char **argv)
635#ifdef TIOCGWINSZ 635#ifdef TIOCGWINSZ
636 else if (STREQ(argv[k], "rows")) { 636 else if (STREQ(argv[k], "rows")) {
637 if (k == argc - 1) 637 if (k == argc - 1)
638 bb_error_msg_and_die("missing argument to `%s'", argv[k]); 638 bb_error_msg_and_die(bb_msg_requires_arg, argv[k]);
639 ++k; 639 ++k;
640 set_window_size((int) bb_xparse_number(argv[k], stty_suffixes), 640 set_window_size((int) bb_xparse_number(argv[k], stty_suffixes),
641 -1); 641 -1);
642 } else if (STREQ(argv[k], "cols") || STREQ(argv[k], "columns")) { 642 } else if (STREQ(argv[k], "cols") || STREQ(argv[k], "columns")) {
643 if (k == argc - 1) 643 if (k == argc - 1)
644 bb_error_msg_and_die("missing argument to `%s'", argv[k]); 644 bb_error_msg_and_die(bb_msg_requires_arg, argv[k]);
645 ++k; 645 ++k;
646 set_window_size(-1, 646 set_window_size(-1,
647 (int) bb_xparse_number(argv[k], stty_suffixes)); 647 (int) bb_xparse_number(argv[k], stty_suffixes));
@@ -654,7 +654,7 @@ int main(int argc, char **argv)
654#ifdef HAVE_C_LINE 654#ifdef HAVE_C_LINE
655 else if (STREQ(argv[k], "line")) { 655 else if (STREQ(argv[k], "line")) {
656 if (k == argc - 1) 656 if (k == argc - 1)
657 bb_error_msg_and_die("missing argument to `%s'", argv[k]); 657 bb_error_msg_and_die(bb_msg_requires_arg, argv[k]);
658 ++k; 658 ++k;
659 mode.c_line = bb_xparse_number(argv[k], stty_suffixes); 659 mode.c_line = bb_xparse_number(argv[k], stty_suffixes);
660 require_set_attr = 1; 660 require_set_attr = 1;
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);
178static int newerf(const char *f1, const char *f2); 178static int newerf(const char *f1, const char *f2);
179static int olderf(const char *f1, const char *f2); 179static int olderf(const char *f1, const char *f2);
180static int equalf(const char *f1, const char *f2); 180static int equalf(const char *f1, const char *f2);
181static void syntax(const char *op, const char *msg);
182static int test_eaccess(char *path, int mode); 181static int test_eaccess(char *path, int mode);
183static int is_a_group_member(gid_t gid); 182static int is_a_group_member(gid_t gid);
184static void initialize_group_array(void); 183static 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
238static 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
247static arith_t oexpr(enum token n) 237static 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: