aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2006-06-07 20:17:41 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2006-06-07 20:17:41 +0000
commit19008b83735341c91fa8a09a072ffe9816c9e423 (patch)
tree6e35288c247102998a775cbc16f9ec014e00e7fd /coreutils
parent4c5ad2fc90389bf1239f17d84967d07b82f31dd7 (diff)
downloadbusybox-19008b83735341c91fa8a09a072ffe9816c9e423.tar.gz
- reuse strings and messages. Saves about 600B
Diffstat (limited to 'coreutils')
-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)
noerror = TRUE;
ibuf += 7;
} else {
- bb_error_msg_and_die("invalid conversion `%s'", argv[i]+5);
+ bb_error_msg_and_die(bb_msg_invalid_arg, argv[i]+5, "conv");
}
if (ibuf[0] == '\0') break;
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)
while (*dirlist2 != NULL && strcmp(*dirlist2, start) < 0)
dirlist2++;
if ((*dirlist1 == NULL) || (*dirlist2 == NULL))
- bb_error_msg("Invalid argument to -S");
+ bb_error_msg(bb_msg_invalid_arg, "NULL", "-S");
}
/* Now that both dirlist1 and dirlist2 contain sorted directory
@@ -1194,7 +1194,6 @@ static void diffdir(char *p1, char *p2)
int diff_main(int argc, char **argv)
{
- char *ep;
int gotstdin = 0;
char *U_opt;
@@ -1229,11 +1228,7 @@ int diff_main(int argc, char **argv)
context = 3; /* This is the default number of lines of context. */
if (cmd_flags & FLAG_U) {
- context = strtol(U_opt, &ep, 10);
- if (context == 0) {
- bb_error_msg("Invalid context length");
- bb_show_usage();
- }
+ context = bb_xgetlarg(U_opt, 10, 1, INT_MAX);
}
argc -= optind;
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 @@
//#define TEST
+#include "busybox.h"
#include <stddef.h>
#include <termios.h>
#include <sys/ioctl.h>
@@ -45,7 +46,6 @@
#include <errno.h>
#include <limits.h>
#include <fcntl.h>
-#include "busybox.h"
#define STREQ(a, b) (strcmp ((a), (b)) == 0)
@@ -608,7 +608,7 @@ int main(int argc, char **argv)
for (i = 0; i < NUM_control_info; ++i)
if (STREQ(argv[k], control_info[i].name)) {
if (k == argc - 1)
- bb_error_msg_and_die("missing argument to `%s'", argv[k]);
+ bb_error_msg_and_die(bb_msg_requires_arg, argv[k]);
match_found = 1;
++k;
set_control_char(&control_info[i], argv[k], &mode);
@@ -619,14 +619,14 @@ int main(int argc, char **argv)
if (match_found == 0) {
if (STREQ(argv[k], "ispeed")) {
if (k == argc - 1)
- bb_error_msg_and_die("missing argument to `%s'", argv[k]);
+ bb_error_msg_and_die(bb_msg_requires_arg, argv[k]);
++k;
set_speed(input_speed, argv[k], &mode);
speed_was_set = 1;
require_set_attr = 1;
} else if (STREQ(argv[k], "ospeed")) {
if (k == argc - 1)
- bb_error_msg_and_die("missing argument to `%s'", argv[k]);
+ bb_error_msg_and_die(bb_msg_requires_arg, argv[k]);
++k;
set_speed(output_speed, argv[k], &mode);
speed_was_set = 1;
@@ -635,13 +635,13 @@ int main(int argc, char **argv)
#ifdef TIOCGWINSZ
else if (STREQ(argv[k], "rows")) {
if (k == argc - 1)
- bb_error_msg_and_die("missing argument to `%s'", argv[k]);
+ bb_error_msg_and_die(bb_msg_requires_arg, argv[k]);
++k;
set_window_size((int) bb_xparse_number(argv[k], stty_suffixes),
-1);
} else if (STREQ(argv[k], "cols") || STREQ(argv[k], "columns")) {
if (k == argc - 1)
- bb_error_msg_and_die("missing argument to `%s'", argv[k]);
+ bb_error_msg_and_die(bb_msg_requires_arg, argv[k]);
++k;
set_window_size(-1,
(int) bb_xparse_number(argv[k], stty_suffixes));
@@ -654,7 +654,7 @@ int main(int argc, char **argv)
#ifdef HAVE_C_LINE
else if (STREQ(argv[k], "line")) {
if (k == argc - 1)
- bb_error_msg_and_die("missing argument to `%s'", argv[k]);
+ bb_error_msg_and_die(bb_msg_requires_arg, argv[k]);
++k;
mode.c_line = bb_xparse_number(argv[k], stty_suffixes);
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);
static int newerf(const char *f1, const char *f2);
static int olderf(const char *f1, const char *f2);
static int equalf(const char *f1, const char *f2);
-static void syntax(const char *op, const char *msg);
static int test_eaccess(char *path, int mode);
static int is_a_group_member(gid_t gid);
static void initialize_group_array(void);
@@ -230,20 +229,11 @@ int test_main(int argc, char **argv)
res = !oexpr(t_lex(*t_wp));
if (*t_wp != NULL && *++t_wp != NULL)
- syntax(*t_wp, "unknown operand");
+ bb_error_msg_and_die("%s: unknown operand", *t_wp);
return (res);
}
-static void syntax(const char *op, const char *msg)
-{
- if (op && *op) {
- bb_error_msg_and_die("%s: %s", op, msg);
- } else {
- bb_error_msg_and_die("%s", msg);
- }
-}
-
static arith_t oexpr(enum token n)
{
arith_t res;
@@ -279,18 +269,18 @@ static arith_t primary(enum token n)
arith_t res;
if (n == EOI) {
- syntax(NULL, "argument expected");
+ bb_error_msg_and_die("argument expected");
}
if (n == LPAREN) {
res = oexpr(t_lex(*++t_wp));
if (t_lex(*++t_wp) != RPAREN)
- syntax(NULL, "closing paren expected");
+ bb_error_msg_and_die("closing paren expected");
return res;
}
if (t_wp_op && t_wp_op->op_type == UNOP) {
/* unary expression */
if (*++t_wp == NULL)
- syntax(t_wp_op->op_text, "argument expected");
+ bb_error_msg_and_die(bb_msg_requires_arg, t_wp_op->op_text);
switch (n) {
case STREZ:
return strlen(*t_wp) == 0;
@@ -320,7 +310,7 @@ static int binop(void)
op = t_wp_op;
if ((opnd2 = *++t_wp) == (char *) 0)
- syntax(op->op_text, "argument expected");
+ bb_error_msg_and_die(bb_msg_requires_arg, op->op_text);
switch (op->op_num) {
case STREQ: