summaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorMatt Kraai2001-08-24 14:45:50 +0000
committerMatt Kraai2001-08-24 14:45:50 +0000
commita0065d5955133f0b20864e966dfc692fe41aed2b (patch)
tree8baad7a565ba34772da3f8a7d7c88cf7aa9daaf6 /editors
parent31b35a16e060960dd035010190059a3ec4ff50f7 (diff)
downloadbusybox-a0065d5955133f0b20864e966dfc692fe41aed2b.zip
busybox-a0065d5955133f0b20864e966dfc692fe41aed2b.tar.gz
Fix s/[/]// handling (noted by Dumas Patrice).
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 4fe882d..989df7c 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -144,8 +144,21 @@ static void destroy_cmd_strs()
*/
static int index_of_next_unescaped_regexp_delim(struct sed_cmd *sed_cmd, const char *str, int idx)
{
+ int bracket = -1;
+ int escaped = 0;
+
for ( ; str[idx]; idx++) {
- if (str[idx] == sed_cmd->delimiter && str[idx-1] != '\\')
+ if (bracket != -1) {
+ if (str[idx] == ']' && !(bracket == idx - 1 ||
+ (bracket == idx - 2 && str[idx-1] == '^')))
+ bracket = -1;
+ } else if (escaped)
+ escaped = 0;
+ else if (str[idx] == '\\')
+ escaped = 1;
+ else if (str[idx] == '[')
+ bracket = idx;
+ else if (str[idx] == sed_cmd->delimiter)
return idx;
}