summaryrefslogtreecommitdiff
path: root/findutils
diff options
context:
space:
mode:
authorManuel Novoa III2003-03-19 09:13:01 +0000
committerManuel Novoa III2003-03-19 09:13:01 +0000
commitcad5364599eb5062d59e0c397ed638ddd61a8d5d (patch)
treea318d0f03aa076c74b576ea45dc543a5669e8e91 /findutils
parente01f9662a5bd5d91be4f6b3941b57fff73cd5af1 (diff)
downloadbusybox-cad5364599eb5062d59e0c397ed638ddd61a8d5d.zip
busybox-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.gz
Major coreutils update.
Diffstat (limited to 'findutils')
-rw-r--r--findutils/find.c28
-rw-r--r--findutils/grep.c24
-rw-r--r--findutils/xargs.c12
3 files changed, 30 insertions, 34 deletions
diff --git a/findutils/find.c b/findutils/find.c
index 048aac5..58bc8bf 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -167,7 +167,7 @@ static int find_type(char *type)
}
if (mask == 0 || type[1] != '\0')
- error_msg_and_die(msg_invalid_arg, type, "-type");
+ bb_error_msg_and_die(msg_invalid_arg, type, "-type");
return mask;
}
@@ -192,22 +192,22 @@ int find_main(int argc, char **argv)
}
else if (strcmp(argv[i], "-name") == 0) {
if (++i == argc)
- error_msg_and_die(msg_req_arg, "-name");
+ bb_error_msg_and_die(msg_req_arg, "-name");
pattern = argv[i];
#ifdef CONFIG_FEATURE_FIND_TYPE
} else if (strcmp(argv[i], "-type") == 0) {
if (++i == argc)
- error_msg_and_die(msg_req_arg, "-type");
+ bb_error_msg_and_die(msg_req_arg, "-type");
type_mask = find_type(argv[i]);
#endif
#ifdef CONFIG_FEATURE_FIND_PERM
} else if (strcmp(argv[i], "-perm") == 0) {
char *end;
if (++i == argc)
- error_msg_and_die(msg_req_arg, "-perm");
+ bb_error_msg_and_die(msg_req_arg, "-perm");
perm_mask = strtol(argv[i], &end, 8);
if ((end[0] != '\0') || (perm_mask > 07777))
- error_msg_and_die(msg_invalid_arg, argv[i], "-perm");
+ bb_error_msg_and_die(msg_invalid_arg, argv[i], "-perm");
if ((perm_char = argv[i][0]) == '-')
perm_mask = -perm_mask;
#endif
@@ -215,10 +215,10 @@ int find_main(int argc, char **argv)
} else if (strcmp(argv[i], "-mtime") == 0) {
char *end;
if (++i == argc)
- error_msg_and_die(msg_req_arg, "-mtime");
+ bb_error_msg_and_die(msg_req_arg, "-mtime");
mtime_days = strtol(argv[i], &end, 10);
if (end[0] != '\0')
- error_msg_and_die(msg_invalid_arg, argv[i], "-mtime");
+ bb_error_msg_and_die(msg_invalid_arg, argv[i], "-mtime");
if ((mtime_char = argv[i][0]) == '-')
mtime_days = -mtime_days;
#endif
@@ -231,14 +231,14 @@ int find_main(int argc, char **argv)
if ( firstopt == 1 ) {
if ( stat ( ".", &stbuf ) < 0 )
- error_msg_and_die("could not stat '.'" );
+ bb_error_msg_and_die("could not stat '.'" );
xdev_dev [0] = stbuf. st_dev;
}
else {
for (i = 1; i < firstopt; i++) {
if ( stat ( argv [i], &stbuf ) < 0 )
- error_msg_and_die("could not stat '%s'", argv [i] );
+ bb_error_msg_and_die("could not stat '%s'", argv [i] );
xdev_dev [i-1] = stbuf. st_dev;
}
}
@@ -247,22 +247,22 @@ int find_main(int argc, char **argv)
} else if (strcmp(argv[i], "-newer") == 0) {
struct stat stat_newer;
if (++i == argc)
- error_msg_and_die(msg_req_arg, "-newer");
+ bb_error_msg_and_die(msg_req_arg, "-newer");
if (stat (argv[i], &stat_newer) != 0)
- error_msg_and_die("file %s not found", argv[i]);
+ bb_error_msg_and_die("file %s not found", argv[i]);
newer_mtime = stat_newer.st_mtime;
#endif
#ifdef CONFIG_FEATURE_FIND_INUM
} else if (strcmp(argv[i], "-inum") == 0) {
char *end;
if (++i == argc)
- error_msg_and_die(msg_req_arg, "-inum");
+ bb_error_msg_and_die(msg_req_arg, "-inum");
inode_num = strtol(argv[i], &end, 10);
if (end[0] != '\0')
- error_msg_and_die(msg_invalid_arg, argv[i], "-inum");
+ bb_error_msg_and_die(msg_invalid_arg, argv[i], "-inum");
#endif
} else
- show_usage();
+ bb_show_usage();
}
if (firstopt == 1) {
diff --git a/findutils/grep.c b/findutils/grep.c
index cc2b697..b4a2592 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -88,8 +88,7 @@ static void grep_file(FILE *file)
int idx = 0; /* used for iteration through the circular buffer */
#endif /* CONFIG_FEATURE_GREP_CONTEXT */
- while ((line = get_line_from_file(file)) != NULL) {
- chomp(line);
+ while ((line = bb_get_chomped_line_from_file(file)) != NULL) {
linenum++;
for (i = 0; i < nregexes; i++) {
@@ -154,7 +153,7 @@ static void grep_file(FILE *file)
/* Add the line to the circular 'before' buffer */
if(lines_before) {
free(before_buf[curpos]);
- before_buf[curpos] = xstrdup(line);
+ before_buf[curpos] = bb_xstrdup(line);
curpos = (curpos + 1) % lines_before;
}
}
@@ -205,9 +204,8 @@ static void add_regex(const char *restr)
static void load_regexes_from_file(const char *filename)
{
char *line;
- FILE *f = xfopen(filename, "r");
- while ((line = get_line_from_file(f)) != NULL) {
- chomp(line);
+ FILE *f = bb_xfopen(filename, "r");
+ while ((line = bb_get_chomped_line_from_file(f)) != NULL) {
add_regex(line);
free(line);
}
@@ -242,7 +240,7 @@ extern int grep_main(int argc, char **argv)
#endif
#ifdef CONFIG_FEATURE_GREP_EGREP_ALIAS
- if (strcmp(get_last_path_component(argv[0]), "egrep") == 0)
+ if (strcmp(bb_get_last_path_component(argv[0]), "egrep") == 0)
reflags |= REG_EXTENDED;
#endif
@@ -298,23 +296,23 @@ extern int grep_main(int argc, char **argv)
case 'A':
lines_after = strtoul(optarg, &junk, 10);
if(*junk != '\0')
- error_msg_and_die("invalid context length argument");
+ bb_error_msg_and_die("invalid context length argument");
break;
case 'B':
lines_before = strtoul(optarg, &junk, 10);
if(*junk != '\0')
- error_msg_and_die("invalid context length argument");
+ bb_error_msg_and_die("invalid context length argument");
before_buf = (char **)xcalloc(lines_before, sizeof(char *));
break;
case 'C':
lines_after = lines_before = strtoul(optarg, &junk, 10);
if(*junk != '\0')
- error_msg_and_die("invalid context length argument");
+ bb_error_msg_and_die("invalid context length argument");
before_buf = (char **)xcalloc(lines_before, sizeof(char *));
break;
#endif /* CONFIG_FEATURE_GREP_CONTEXT */
default:
- show_usage();
+ bb_show_usage();
}
}
@@ -322,7 +320,7 @@ extern int grep_main(int argc, char **argv)
* argv[optind] should be the pattern. no pattern, no worky */
if (nregexes == 0) {
if (argv[optind] == NULL)
- show_usage();
+ bb_show_usage();
else {
add_regex(argv[optind]);
optind++;
@@ -356,7 +354,7 @@ extern int grep_main(int argc, char **argv)
file = fopen(cur_file, "r");
if (file == NULL) {
if (!suppress_err_msgs)
- perror_msg("%s", cur_file);
+ bb_perror_msg("%s", cur_file);
}
else {
grep_file(file);
diff --git a/findutils/xargs.c b/findutils/xargs.c
index 677618d..d4bed57 100644
--- a/findutils/xargs.c
+++ b/findutils/xargs.c
@@ -53,11 +53,11 @@ static void xargs_exec(char * const * args)
wait(NULL);
if(common[0]) {
errno = common[0];
- perror_msg_and_die("%s", args[0]);
+ bb_perror_msg_and_die("%s", args[0]);
}
}
} else {
- perror_msg_and_die("vfork");
+ bb_perror_msg_and_die("vfork");
}
}
@@ -81,7 +81,7 @@ int xargs_main(int argc, char **argv)
flg_no_empty = 1;
break;
default:
- show_usage();
+ bb_show_usage();
}
}
@@ -101,9 +101,7 @@ int xargs_main(int argc, char **argv)
/* Now, read in one line at a time from stdin, and store this
* line to be used later as an argument to the command */
- while ((file_to_act_on = get_line_from_file(stdin)) != NULL) {
- /* eat the newline off the filename. */
- chomp(file_to_act_on);
+ while ((file_to_act_on = bb_get_chomped_line_from_file(stdin)) != NULL) {
if(file_to_act_on[0] != 0 || flg_no_empty == 0) {
args[a] = file_to_act_on[0] ? file_to_act_on : NULL;
if(flg_vi) {
@@ -114,7 +112,7 @@ int xargs_main(int argc, char **argv)
}
fprintf(stderr, "%s", ((flg_vi & 2) ? " ?..." : "\n"));
}
- if((flg_vi & 2) == 0 || ask_confirmation() != 0 ) {
+ if((flg_vi & 2) == 0 || bb_ask_confirmation() != 0 ) {
xargs_exec(args);
}
}