diff options
author | Mark Whitley <markw@lineo.com> | 2000-07-12 23:35:21 +0000 |
---|---|---|
committer | Mark Whitley <markw@lineo.com> | 2000-07-12 23:35:21 +0000 |
commit | c41e8c840fd6faf802628036c7e5b2683d623c5d (patch) | |
tree | c4a47f2e1f1af68d3019f598bada0268f872c1b9 | |
parent | 6f96e674b9176cafcc25de2a1d79d6f6d7f0e908 (diff) | |
download | busybox-w32-c41e8c840fd6faf802628036c7e5b2683d623c5d.tar.gz busybox-w32-c41e8c840fd6faf802628036c7e5b2683d623c5d.tar.bz2 busybox-w32-c41e8c840fd6faf802628036c7e5b2683d623c5d.zip |
Changed bb_regcomp to xregcomp and #if 0'ed out destroy_cmd_strs in sed.c
(maybe I'll remove it later).
-rw-r--r-- | editors/sed.c | 14 | ||||
-rw-r--r-- | findutils/grep.c | 3 | ||||
-rw-r--r-- | grep.c | 3 | ||||
-rw-r--r-- | internal.h | 2 | ||||
-rw-r--r-- | sed.c | 14 | ||||
-rw-r--r-- | utility.c | 7 |
6 files changed, 17 insertions, 26 deletions
diff --git a/editors/sed.c b/editors/sed.c index 9e4a002d8..21f868167 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -97,6 +97,7 @@ static const char sed_usage[] = | |||
97 | #endif | 97 | #endif |
98 | ; | 98 | ; |
99 | 99 | ||
100 | #if 0 | ||
100 | static void destroy_cmd_strs() | 101 | static void destroy_cmd_strs() |
101 | { | 102 | { |
102 | if (sed_cmds == NULL) | 103 | if (sed_cmds == NULL) |
@@ -125,6 +126,7 @@ static void destroy_cmd_strs() | |||
125 | free(sed_cmds); | 126 | free(sed_cmds); |
126 | sed_cmds = NULL; | 127 | sed_cmds = NULL; |
127 | } | 128 | } |
129 | #endif | ||
128 | 130 | ||
129 | /* | 131 | /* |
130 | * trim_str - trims leading and trailing space from a string | 132 | * trim_str - trims leading and trailing space from a string |
@@ -199,10 +201,7 @@ static int get_address(const char *str, int *line, regex_t **regex) | |||
199 | fatalError("unterminated match expression\n"); | 201 | fatalError("unterminated match expression\n"); |
200 | my_str[idx] = '\0'; | 202 | my_str[idx] = '\0'; |
201 | *regex = (regex_t *)xmalloc(sizeof(regex_t)); | 203 | *regex = (regex_t *)xmalloc(sizeof(regex_t)); |
202 | if (bb_regcomp(*regex, my_str+1, REG_NEWLINE) != 0) { | 204 | xregcomp(*regex, my_str+1, REG_NEWLINE); |
203 | free(my_str); | ||
204 | exit(1); | ||
205 | } | ||
206 | } | 205 | } |
207 | else { | 206 | else { |
208 | fprintf(stderr, "sed.c:get_address: no address found in string\n"); | 207 | fprintf(stderr, "sed.c:get_address: no address found in string\n"); |
@@ -291,10 +290,7 @@ static void parse_cmd_str(struct sed_cmd *sed_cmd, const char *cmdstr) | |||
291 | 290 | ||
292 | /* compile the regex */ | 291 | /* compile the regex */ |
293 | sed_cmd->sub_match = (regex_t *)xmalloc(sizeof(regex_t)); | 292 | sed_cmd->sub_match = (regex_t *)xmalloc(sizeof(regex_t)); |
294 | if (bb_regcomp(sed_cmd->sub_match, match, cflags) != 0) { | 293 | xregcomp(sed_cmd->sub_match, match, cflags); |
295 | free(match); | ||
296 | exit(1); | ||
297 | } | ||
298 | free(match); | 294 | free(match); |
299 | } | 295 | } |
300 | } | 296 | } |
@@ -460,11 +456,13 @@ extern int sed_main(int argc, char **argv) | |||
460 | if (argv[1] && (strcmp(argv[1], "--help") == 0)) | 456 | if (argv[1] && (strcmp(argv[1], "--help") == 0)) |
461 | usage(sed_usage); | 457 | usage(sed_usage); |
462 | 458 | ||
459 | #if 0 | ||
463 | /* destroy command strings on exit */ | 460 | /* destroy command strings on exit */ |
464 | if (atexit(destroy_cmd_strs) == -1) { | 461 | if (atexit(destroy_cmd_strs) == -1) { |
465 | perror("sed"); | 462 | perror("sed"); |
466 | exit(1); | 463 | exit(1); |
467 | } | 464 | } |
465 | #endif | ||
468 | 466 | ||
469 | /* do normal option parsing */ | 467 | /* do normal option parsing */ |
470 | while ((opt = getopt(argc, argv, "Vhne:f:")) > 0) { | 468 | while ((opt = getopt(argc, argv, "Vhne:f:")) > 0) { |
diff --git a/findutils/grep.c b/findutils/grep.c index dec365f05..77b510002 100644 --- a/findutils/grep.c +++ b/findutils/grep.c | |||
@@ -146,8 +146,7 @@ extern int grep_main(int argc, char **argv) | |||
146 | reflags = REG_NOSUB | REG_NEWLINE; | 146 | reflags = REG_NOSUB | REG_NEWLINE; |
147 | if (ignore_case) | 147 | if (ignore_case) |
148 | reflags |= REG_ICASE; | 148 | reflags |= REG_ICASE; |
149 | if (bb_regcomp(®ex, argv[optind], reflags) != 0) | 149 | xregcomp(®ex, argv[optind], reflags); |
150 | exit(1); | ||
151 | 150 | ||
152 | /* argv[(optind+1)..(argc-1)] should be names of file to grep through. If | 151 | /* argv[(optind+1)..(argc-1)] should be names of file to grep through. If |
153 | * there is more than one file to grep, we will print the filenames */ | 152 | * there is more than one file to grep, we will print the filenames */ |
@@ -146,8 +146,7 @@ extern int grep_main(int argc, char **argv) | |||
146 | reflags = REG_NOSUB | REG_NEWLINE; | 146 | reflags = REG_NOSUB | REG_NEWLINE; |
147 | if (ignore_case) | 147 | if (ignore_case) |
148 | reflags |= REG_ICASE; | 148 | reflags |= REG_ICASE; |
149 | if (bb_regcomp(®ex, argv[optind], reflags) != 0) | 149 | xregcomp(®ex, argv[optind], reflags); |
150 | exit(1); | ||
151 | 150 | ||
152 | /* argv[(optind+1)..(argc-1)] should be names of file to grep through. If | 151 | /* argv[(optind+1)..(argc-1)] should be names of file to grep through. If |
153 | * there is more than one file to grep, we will print the filenames */ | 152 | * there is more than one file to grep, we will print the filenames */ |
diff --git a/internal.h b/internal.h index 44c2e81ac..e636e18ce 100644 --- a/internal.h +++ b/internal.h | |||
@@ -265,7 +265,7 @@ extern int find_real_root_device_name(char* name); | |||
265 | extern char *get_line_from_file(FILE *file); | 265 | extern char *get_line_from_file(FILE *file); |
266 | extern char process_escape_sequence(char **ptr); | 266 | extern char process_escape_sequence(char **ptr); |
267 | extern char *get_last_path_component(char *path); | 267 | extern char *get_last_path_component(char *path); |
268 | extern int bb_regcomp(regex_t *preg, const char *regex, int cflags); | 268 | extern void xregcomp(regex_t *preg, const char *regex, int cflags); |
269 | 269 | ||
270 | extern void *xmalloc (size_t size); | 270 | extern void *xmalloc (size_t size); |
271 | extern char *xstrdup (const char *s); | 271 | extern char *xstrdup (const char *s); |
@@ -97,6 +97,7 @@ static const char sed_usage[] = | |||
97 | #endif | 97 | #endif |
98 | ; | 98 | ; |
99 | 99 | ||
100 | #if 0 | ||
100 | static void destroy_cmd_strs() | 101 | static void destroy_cmd_strs() |
101 | { | 102 | { |
102 | if (sed_cmds == NULL) | 103 | if (sed_cmds == NULL) |
@@ -125,6 +126,7 @@ static void destroy_cmd_strs() | |||
125 | free(sed_cmds); | 126 | free(sed_cmds); |
126 | sed_cmds = NULL; | 127 | sed_cmds = NULL; |
127 | } | 128 | } |
129 | #endif | ||
128 | 130 | ||
129 | /* | 131 | /* |
130 | * trim_str - trims leading and trailing space from a string | 132 | * trim_str - trims leading and trailing space from a string |
@@ -199,10 +201,7 @@ static int get_address(const char *str, int *line, regex_t **regex) | |||
199 | fatalError("unterminated match expression\n"); | 201 | fatalError("unterminated match expression\n"); |
200 | my_str[idx] = '\0'; | 202 | my_str[idx] = '\0'; |
201 | *regex = (regex_t *)xmalloc(sizeof(regex_t)); | 203 | *regex = (regex_t *)xmalloc(sizeof(regex_t)); |
202 | if (bb_regcomp(*regex, my_str+1, REG_NEWLINE) != 0) { | 204 | xregcomp(*regex, my_str+1, REG_NEWLINE); |
203 | free(my_str); | ||
204 | exit(1); | ||
205 | } | ||
206 | } | 205 | } |
207 | else { | 206 | else { |
208 | fprintf(stderr, "sed.c:get_address: no address found in string\n"); | 207 | fprintf(stderr, "sed.c:get_address: no address found in string\n"); |
@@ -291,10 +290,7 @@ static void parse_cmd_str(struct sed_cmd *sed_cmd, const char *cmdstr) | |||
291 | 290 | ||
292 | /* compile the regex */ | 291 | /* compile the regex */ |
293 | sed_cmd->sub_match = (regex_t *)xmalloc(sizeof(regex_t)); | 292 | sed_cmd->sub_match = (regex_t *)xmalloc(sizeof(regex_t)); |
294 | if (bb_regcomp(sed_cmd->sub_match, match, cflags) != 0) { | 293 | xregcomp(sed_cmd->sub_match, match, cflags); |
295 | free(match); | ||
296 | exit(1); | ||
297 | } | ||
298 | free(match); | 294 | free(match); |
299 | } | 295 | } |
300 | } | 296 | } |
@@ -460,11 +456,13 @@ extern int sed_main(int argc, char **argv) | |||
460 | if (argv[1] && (strcmp(argv[1], "--help") == 0)) | 456 | if (argv[1] && (strcmp(argv[1], "--help") == 0)) |
461 | usage(sed_usage); | 457 | usage(sed_usage); |
462 | 458 | ||
459 | #if 0 | ||
463 | /* destroy command strings on exit */ | 460 | /* destroy command strings on exit */ |
464 | if (atexit(destroy_cmd_strs) == -1) { | 461 | if (atexit(destroy_cmd_strs) == -1) { |
465 | perror("sed"); | 462 | perror("sed"); |
466 | exit(1); | 463 | exit(1); |
467 | } | 464 | } |
465 | #endif | ||
468 | 466 | ||
469 | /* do normal option parsing */ | 467 | /* do normal option parsing */ |
470 | while ((opt = getopt(argc, argv, "Vhne:f:")) > 0) { | 468 | while ((opt = getopt(argc, argv, "Vhne:f:")) > 0) { |
@@ -1722,18 +1722,15 @@ char *get_last_path_component(char *path) | |||
1722 | #endif | 1722 | #endif |
1723 | 1723 | ||
1724 | #if defined BB_GREP || defined BB_SED | 1724 | #if defined BB_GREP || defined BB_SED |
1725 | int bb_regcomp(regex_t *preg, const char *regex, int cflags) | 1725 | void xregcomp(regex_t *preg, const char *regex, int cflags) |
1726 | { | 1726 | { |
1727 | int ret; | 1727 | int ret; |
1728 | if ((ret = regcomp(preg, regex, cflags)) != 0) { | 1728 | if ((ret = regcomp(preg, regex, cflags)) != 0) { |
1729 | int errmsgsz = regerror(ret, preg, NULL, 0); | 1729 | int errmsgsz = regerror(ret, preg, NULL, 0); |
1730 | char *errmsg = xmalloc(errmsgsz); | 1730 | char *errmsg = xmalloc(errmsgsz); |
1731 | regerror(ret, preg, errmsg, errmsgsz); | 1731 | regerror(ret, preg, errmsg, errmsgsz); |
1732 | errorMsg("bb_regcomp: %s\n", errmsg); | 1732 | fatalError("bb_regcomp: %s\n", errmsg); |
1733 | free(errmsg); | ||
1734 | regfree(preg); | ||
1735 | } | 1733 | } |
1736 | return ret; | ||
1737 | } | 1734 | } |
1738 | #endif | 1735 | #endif |
1739 | 1736 | ||