diff options
| author | sandman <sandman@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2002-08-06 23:13:31 +0000 |
|---|---|---|
| committer | sandman <sandman@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2002-08-06 23:13:31 +0000 |
| commit | 1f297fa60cf7b50aaa6ab132ff795118ffdfd784 (patch) | |
| tree | f1422f5f5968287fafddb83db1fa08890a511a9b | |
| parent | 711367ec2e29a06ccc45d166ff6688f09f439dc8 (diff) | |
| download | busybox-w32-1f297fa60cf7b50aaa6ab132ff795118ffdfd784.tar.gz busybox-w32-1f297fa60cf7b50aaa6ab132ff795118ffdfd784.tar.bz2 busybox-w32-1f297fa60cf7b50aaa6ab132ff795118ffdfd784.zip | |
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)
git-svn-id: svn://busybox.net/trunk/busybox@5165 69ca8d6d-28ef-0310-b511-8ec308f3f277
| -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 | |||
| 178 | static int get_address(struct sed_cmd *sed_cmd, const char *str, int *linenum, regex_t **regex) | 178 | static int get_address(struct sed_cmd *sed_cmd, const char *str, int *linenum, regex_t **regex) |
| 179 | { | 179 | { |
| 180 | char *my_str = xstrdup(str); | 180 | char *my_str = xstrdup(str); |
| 181 | int idx = 0; | 181 | int idx = 0, idx_start = 1; |
| 182 | char olddelimiter; | 182 | char olddelimiter; |
| 183 | olddelimiter = sed_cmd->delimiter; | 183 | olddelimiter = sed_cmd->delimiter; |
| 184 | sed_cmd->delimiter = '/'; | 184 | sed_cmd->delimiter = '/'; |
| @@ -196,7 +196,7 @@ static int get_address(struct sed_cmd *sed_cmd, const char *str, int *linenum, r | |||
| 196 | } | 196 | } |
| 197 | else if (my_str[idx] == '/' || my_str[idx] == '\\') { | 197 | else if (my_str[idx] == '/' || my_str[idx] == '\\') { |
| 198 | if (my_str[idx] == '\\') { | 198 | if (my_str[idx] == '\\') { |
| 199 | my_str[idx] = 0; | 199 | idx_start++; |
| 200 | sed_cmd-> delimiter = my_str[++idx]; | 200 | sed_cmd-> delimiter = my_str[++idx]; |
| 201 | } | 201 | } |
| 202 | idx = index_of_next_unescaped_regexp_delim(sed_cmd, my_str, ++idx); | 202 | 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 | |||
| 204 | error_msg_and_die("unterminated match expression"); | 204 | error_msg_and_die("unterminated match expression"); |
| 205 | my_str[idx] = '\0'; | 205 | my_str[idx] = '\0'; |
| 206 | *regex = (regex_t *)xmalloc(sizeof(regex_t)); | 206 | *regex = (regex_t *)xmalloc(sizeof(regex_t)); |
| 207 | xregcomp(*regex, my_str+1, REG_NEWLINE); | 207 | xregcomp(*regex, my_str+idx_start, REG_NEWLINE); |
| 208 | idx++; /* so it points to the next character after the last '/' */ | 208 | idx++; /* so it points to the next character after the last '/' */ |
| 209 | } | 209 | } |
| 210 | else { | 210 | else { |
| @@ -401,7 +401,7 @@ static char *parse_cmd_str(struct sed_cmd * const sed_cmd, const char *const cmd | |||
| 401 | */ | 401 | */ |
| 402 | 402 | ||
| 403 | /* first part (if present) is an address: either a number or a /regex/ */ | 403 | /* first part (if present) is an address: either a number or a /regex/ */ |
| 404 | if (isdigit(cmdstr[idx]) || cmdstr[idx] == '/') | 404 | if (isdigit(cmdstr[idx]) || cmdstr[idx] == '/' || ( cmdstr[idx] == '\\' && cmdstr[idx+1] != '\\')) |
| 405 | idx = get_address(sed_cmd, cmdstr, &sed_cmd->beg_line, &sed_cmd->beg_match); | 405 | idx = get_address(sed_cmd, cmdstr, &sed_cmd->beg_line, &sed_cmd->beg_match); |
| 406 | 406 | ||
| 407 | /* second part (if present) will begin with a comma */ | 407 | /* second part (if present) will begin with a comma */ |
