Changed bb_regcomp to xregcomp and #if 0'ed out destroy_cmd_strs in sed.c
(maybe I'll remove it later).
diff --git a/editors/sed.c b/editors/sed.c
index 9e4a002..21f8681 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -97,6 +97,7 @@
#endif
;
+#if 0
static void destroy_cmd_strs()
{
if (sed_cmds == NULL)
@@ -125,6 +126,7 @@
free(sed_cmds);
sed_cmds = NULL;
}
+#endif
/*
* trim_str - trims leading and trailing space from a string
@@ -199,10 +201,7 @@
fatalError("unterminated match expression\n");
my_str[idx] = '\0';
*regex = (regex_t *)xmalloc(sizeof(regex_t));
- if (bb_regcomp(*regex, my_str+1, REG_NEWLINE) != 0) {
- free(my_str);
- exit(1);
- }
+ xregcomp(*regex, my_str+1, REG_NEWLINE);
}
else {
fprintf(stderr, "sed.c:get_address: no address found in string\n");
@@ -291,10 +290,7 @@
/* compile the regex */
sed_cmd->sub_match = (regex_t *)xmalloc(sizeof(regex_t));
- if (bb_regcomp(sed_cmd->sub_match, match, cflags) != 0) {
- free(match);
- exit(1);
- }
+ xregcomp(sed_cmd->sub_match, match, cflags);
free(match);
}
}
@@ -460,11 +456,13 @@
if (argv[1] && (strcmp(argv[1], "--help") == 0))
usage(sed_usage);
+#if 0
/* destroy command strings on exit */
if (atexit(destroy_cmd_strs) == -1) {
perror("sed");
exit(1);
}
+#endif
/* do normal option parsing */
while ((opt = getopt(argc, argv, "Vhne:f:")) > 0) {
diff --git a/findutils/grep.c b/findutils/grep.c
index dec365f..77b5100 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -146,8 +146,7 @@
reflags = REG_NOSUB | REG_NEWLINE;
if (ignore_case)
reflags |= REG_ICASE;
- if (bb_regcomp(®ex, argv[optind], reflags) != 0)
- exit(1);
+ xregcomp(®ex, argv[optind], reflags);
/* argv[(optind+1)..(argc-1)] should be names of file to grep through. If
* there is more than one file to grep, we will print the filenames */
diff --git a/grep.c b/grep.c
index dec365f..77b5100 100644
--- a/grep.c
+++ b/grep.c
@@ -146,8 +146,7 @@
reflags = REG_NOSUB | REG_NEWLINE;
if (ignore_case)
reflags |= REG_ICASE;
- if (bb_regcomp(®ex, argv[optind], reflags) != 0)
- exit(1);
+ xregcomp(®ex, argv[optind], reflags);
/* argv[(optind+1)..(argc-1)] should be names of file to grep through. If
* there is more than one file to grep, we will print the filenames */
diff --git a/internal.h b/internal.h
index 44c2e81..e636e18 100644
--- a/internal.h
+++ b/internal.h
@@ -265,7 +265,7 @@
extern char *get_line_from_file(FILE *file);
extern char process_escape_sequence(char **ptr);
extern char *get_last_path_component(char *path);
-extern int bb_regcomp(regex_t *preg, const char *regex, int cflags);
+extern void xregcomp(regex_t *preg, const char *regex, int cflags);
extern void *xmalloc (size_t size);
extern char *xstrdup (const char *s);
diff --git a/sed.c b/sed.c
index 9e4a002..21f8681 100644
--- a/sed.c
+++ b/sed.c
@@ -97,6 +97,7 @@
#endif
;
+#if 0
static void destroy_cmd_strs()
{
if (sed_cmds == NULL)
@@ -125,6 +126,7 @@
free(sed_cmds);
sed_cmds = NULL;
}
+#endif
/*
* trim_str - trims leading and trailing space from a string
@@ -199,10 +201,7 @@
fatalError("unterminated match expression\n");
my_str[idx] = '\0';
*regex = (regex_t *)xmalloc(sizeof(regex_t));
- if (bb_regcomp(*regex, my_str+1, REG_NEWLINE) != 0) {
- free(my_str);
- exit(1);
- }
+ xregcomp(*regex, my_str+1, REG_NEWLINE);
}
else {
fprintf(stderr, "sed.c:get_address: no address found in string\n");
@@ -291,10 +290,7 @@
/* compile the regex */
sed_cmd->sub_match = (regex_t *)xmalloc(sizeof(regex_t));
- if (bb_regcomp(sed_cmd->sub_match, match, cflags) != 0) {
- free(match);
- exit(1);
- }
+ xregcomp(sed_cmd->sub_match, match, cflags);
free(match);
}
}
@@ -460,11 +456,13 @@
if (argv[1] && (strcmp(argv[1], "--help") == 0))
usage(sed_usage);
+#if 0
/* destroy command strings on exit */
if (atexit(destroy_cmd_strs) == -1) {
perror("sed");
exit(1);
}
+#endif
/* do normal option parsing */
while ((opt = getopt(argc, argv, "Vhne:f:")) > 0) {
diff --git a/utility.c b/utility.c
index 6d1e1d4..61f6761 100644
--- a/utility.c
+++ b/utility.c
@@ -1722,18 +1722,15 @@
#endif
#if defined BB_GREP || defined BB_SED
-int bb_regcomp(regex_t *preg, const char *regex, int cflags)
+void xregcomp(regex_t *preg, const char *regex, int cflags)
{
int ret;
if ((ret = regcomp(preg, regex, cflags)) != 0) {
int errmsgsz = regerror(ret, preg, NULL, 0);
char *errmsg = xmalloc(errmsgsz);
regerror(ret, preg, errmsg, errmsgsz);
- errorMsg("bb_regcomp: %s\n", errmsg);
- free(errmsg);
- regfree(preg);
+ fatalError("bb_regcomp: %s\n", errmsg);
}
- return ret;
}
#endif