diff options
author | Matt Kraai <kraai@debian.org> | 2001-08-24 14:45:50 +0000 |
---|---|---|
committer | Matt Kraai <kraai@debian.org> | 2001-08-24 14:45:50 +0000 |
commit | a0065d5955133f0b20864e966dfc692fe41aed2b (patch) | |
tree | 8baad7a565ba34772da3f8a7d7c88cf7aa9daaf6 | |
parent | 31b35a16e060960dd035010190059a3ec4ff50f7 (diff) | |
download | busybox-w32-a0065d5955133f0b20864e966dfc692fe41aed2b.tar.gz busybox-w32-a0065d5955133f0b20864e966dfc692fe41aed2b.tar.bz2 busybox-w32-a0065d5955133f0b20864e966dfc692fe41aed2b.zip |
Fix s/[/]// handling (noted by Dumas Patrice).
-rw-r--r-- | Changelog | 2 | ||||
-rw-r--r-- | editors/sed.c | 15 | ||||
-rw-r--r-- | sed.c | 15 |
3 files changed, 30 insertions, 2 deletions
@@ -15,6 +15,8 @@ | |||
15 | -- a whole bunch of ash size optimizations | 15 | -- a whole bunch of ash size optimizations |
16 | * Rodney Brown <RDBrown@mira.net> | 16 | * Rodney Brown <RDBrown@mira.net> |
17 | -- Optimized gzip.c, shrinking it be ~1.5k | 17 | -- Optimized gzip.c, shrinking it be ~1.5k |
18 | * Matt Kraai | ||
19 | -- Fix sed s/[/]// handling (closes: #1208). | ||
18 | 20 | ||
19 | 21 | ||
20 | -Erik Andersen, --not yet released-- | 22 | -Erik Andersen, --not yet released-- |
diff --git a/editors/sed.c b/editors/sed.c index 4fe882d20..989df7cb4 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -144,8 +144,21 @@ static void destroy_cmd_strs() | |||
144 | */ | 144 | */ |
145 | static int index_of_next_unescaped_regexp_delim(struct sed_cmd *sed_cmd, const char *str, int idx) | 145 | static int index_of_next_unescaped_regexp_delim(struct sed_cmd *sed_cmd, const char *str, int idx) |
146 | { | 146 | { |
147 | int bracket = -1; | ||
148 | int escaped = 0; | ||
149 | |||
147 | for ( ; str[idx]; idx++) { | 150 | for ( ; str[idx]; idx++) { |
148 | if (str[idx] == sed_cmd->delimiter && str[idx-1] != '\\') | 151 | if (bracket != -1) { |
152 | if (str[idx] == ']' && !(bracket == idx - 1 || | ||
153 | (bracket == idx - 2 && str[idx-1] == '^'))) | ||
154 | bracket = -1; | ||
155 | } else if (escaped) | ||
156 | escaped = 0; | ||
157 | else if (str[idx] == '\\') | ||
158 | escaped = 1; | ||
159 | else if (str[idx] == '[') | ||
160 | bracket = idx; | ||
161 | else if (str[idx] == sed_cmd->delimiter) | ||
149 | return idx; | 162 | return idx; |
150 | } | 163 | } |
151 | 164 | ||
@@ -144,8 +144,21 @@ static void destroy_cmd_strs() | |||
144 | */ | 144 | */ |
145 | static int index_of_next_unescaped_regexp_delim(struct sed_cmd *sed_cmd, const char *str, int idx) | 145 | static int index_of_next_unescaped_regexp_delim(struct sed_cmd *sed_cmd, const char *str, int idx) |
146 | { | 146 | { |
147 | int bracket = -1; | ||
148 | int escaped = 0; | ||
149 | |||
147 | for ( ; str[idx]; idx++) { | 150 | for ( ; str[idx]; idx++) { |
148 | if (str[idx] == sed_cmd->delimiter && str[idx-1] != '\\') | 151 | if (bracket != -1) { |
152 | if (str[idx] == ']' && !(bracket == idx - 1 || | ||
153 | (bracket == idx - 2 && str[idx-1] == '^'))) | ||
154 | bracket = -1; | ||
155 | } else if (escaped) | ||
156 | escaped = 0; | ||
157 | else if (str[idx] == '\\') | ||
158 | escaped = 1; | ||
159 | else if (str[idx] == '[') | ||
160 | bracket = idx; | ||
161 | else if (str[idx] == sed_cmd->delimiter) | ||
149 | return idx; | 162 | return idx; |
150 | } | 163 | } |
151 | 164 | ||