diff options
author | Robert Griebl <griebl@gmx.de> | 2002-08-06 23:13:31 +0000 |
---|---|---|
committer | Robert Griebl <griebl@gmx.de> | 2002-08-06 23:13:31 +0000 |
commit | 00f5ecb141caaa0b77bb8f3090ff95ac52458699 (patch) | |
tree | f1422f5f5968287fafddb83db1fa08890a511a9b | |
parent | 7940147e2516b7042cff956acb98aca39007fdb8 (diff) | |
download | busybox-00f5ecb141caaa0b77bb8f3090ff95ac52458699.tar.gz |
Somehow I applied an old patch for the last commit - this one works now:
- Added \CregexC support to sed (sed testsuite reported no errors, btw)
-rw-r--r-- | editors/sed.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/editors/sed.c b/editors/sed.c index 5fc3a14a5..23e9d545b 100644 --- a/editors/sed.c +++ b/editors/sed.c @@ -178,7 +178,7 @@ static int index_of_next_unescaped_regexp_delim(const struct sed_cmd * const sed static int get_address(struct sed_cmd *sed_cmd, const char *str, int *linenum, regex_t **regex) { char *my_str = xstrdup(str); - int idx = 0; + int idx = 0, idx_start = 1; char olddelimiter; olddelimiter = sed_cmd->delimiter; sed_cmd->delimiter = '/'; @@ -196,7 +196,7 @@ static int get_address(struct sed_cmd *sed_cmd, const char *str, int *linenum, r } else if (my_str[idx] == '/' || my_str[idx] == '\\') { if (my_str[idx] == '\\') { - my_str[idx] = 0; + idx_start++; sed_cmd-> delimiter = my_str[++idx]; } idx = index_of_next_unescaped_regexp_delim(sed_cmd, my_str, ++idx); @@ -204,7 +204,7 @@ static int get_address(struct sed_cmd *sed_cmd, const char *str, int *linenum, r error_msg_and_die("unterminated match expression"); my_str[idx] = '\0'; *regex = (regex_t *)xmalloc(sizeof(regex_t)); - xregcomp(*regex, my_str+1, REG_NEWLINE); + xregcomp(*regex, my_str+idx_start, REG_NEWLINE); idx++; /* so it points to the next character after the last '/' */ } else { @@ -401,7 +401,7 @@ static char *parse_cmd_str(struct sed_cmd * const sed_cmd, const char *const cmd */ /* first part (if present) is an address: either a number or a /regex/ */ - if (isdigit(cmdstr[idx]) || cmdstr[idx] == '/') + if (isdigit(cmdstr[idx]) || cmdstr[idx] == '/' || ( cmdstr[idx] == '\\' && cmdstr[idx+1] != '\\')) idx = get_address(sed_cmd, cmdstr, &sed_cmd->beg_line, &sed_cmd->beg_match); /* second part (if present) will begin with a comma */ |