aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorkraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-08-24 14:45:50 +0000
committerkraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-08-24 14:45:50 +0000
commit22d7185e000390c498da0818e9388fbe8cc994f6 (patch)
tree8baad7a565ba34772da3f8a7d7c88cf7aa9daaf6 /editors
parentb1113c516df8fbc61cb2b3ebe185000c6abbb5ce (diff)
downloadbusybox-w32-22d7185e000390c498da0818e9388fbe8cc994f6.tar.gz
busybox-w32-22d7185e000390c498da0818e9388fbe8cc994f6.tar.bz2
busybox-w32-22d7185e000390c498da0818e9388fbe8cc994f6.zip
Fix s/[/]// handling (noted by Dumas Patrice).
git-svn-id: svn://busybox.net/trunk/busybox@3348 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'editors')
-rw-r--r--editors/sed.c15
1 files changed, 14 insertions, 1 deletions
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 */
145static int index_of_next_unescaped_regexp_delim(struct sed_cmd *sed_cmd, const char *str, int idx) 145static 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