summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--NEWS5
-rw-r--r--sed/compile.c23
3 files changed, 34 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 1f8834d..99ec744 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2008-12-31 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
+ Let --posix turn off more GNU extensions.
+ * sed/compile.c (mark_subst_opts): Turn off subst options i, I,
+ s, S, x, X, m, and M in --posix mode.
+ (compile_address): Disallow address modifiers, `FIRST~STEP',
+ `ADDR1,+N', and `ADDR1,~N' in --posix mode.
+ (compile_program): In --posix mode, do not accept e or z commands;
+ do not accept text between an a, c, or i command and the following
+ backslash; do not accept an argument to the l command.
+
2008-12-22 Paolo Bonzini <bonzini@gnu.org>
* autoboot.conf: Request modules emulating mb functions.
diff --git a/NEWS b/NEWS
index 89f93ff..6c51674 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,11 @@ GNU sed with NLS support
* multibyte processing fixed
+* the following GNU extensions are turned off by --posix: options [iImMsSxX]
+in the `s' command, address kinds `FIRST~STEP' and `ADDR1,+N' and `ADDR1,~N',
+`e' or `z' commands, text between an `a' or `c' or `i' command and the
+following backslash, arguments to the `l' command.
+
----------------------------------------------------------------------------
Sed 4.1e
diff --git a/sed/compile.c b/sed/compile.c
index 2b471ee..bc0416d 100644
--- a/sed/compile.c
+++ b/sed/compile.c
@@ -605,18 +605,24 @@ mark_subst_opts(cmd)
{
case 'i': /* GNU extension */
case 'I': /* GNU extension */
+ if (posixicity == POSIXLY_BASIC)
+ bad_prog(_(UNKNOWN_S_OPT));
flags |= REG_ICASE;
break;
#ifdef REG_PERL
case 's': /* GNU extension */
case 'S': /* GNU extension */
+ if (posixicity == POSIXLY_BASIC)
+ bad_prog(_(UNKNOWN_S_OPT));
if (extended_regexp_flags & REG_PERL)
flags |= REG_DOTALL;
break;
case 'x': /* GNU extension */
case 'X': /* GNU extension */
+ if (posixicity == POSIXLY_BASIC)
+ bad_prog(_(UNKNOWN_S_OPT));
if (extended_regexp_flags & REG_PERL)
flags |= REG_EXTENDED;
break;
@@ -624,6 +630,8 @@ mark_subst_opts(cmd)
case 'm': /* GNU extension */
case 'M': /* GNU extension */
+ if (posixicity == POSIXLY_BASIC)
+ bad_prog(_(UNKNOWN_S_OPT));
flags |= REG_NEWLINE;
break;
@@ -950,6 +958,8 @@ compile_address(addr, ch)
for(;;)
{
ch = in_nonblank();
+ if (posixicity == POSIXLY_BASIC)
+ goto posix_address_modifier;
switch(ch)
{
case 'I': /* GNU extension */
@@ -973,6 +983,7 @@ compile_address(addr, ch)
break;
default:
+ posix_address_modifier:
savchar (ch);
addr->addr_regex = compile_regex (b, flags, 0);
free_buffer(b);
@@ -985,7 +996,7 @@ compile_address(addr, ch)
addr->addr_number = in_integer(ch);
addr->addr_type = ADDR_IS_NUM;
ch = in_nonblank();
- if (ch != '~')
+ if (ch != '~' || posixicity == POSIXLY_BASIC)
{
savchar(ch);
}
@@ -999,7 +1010,7 @@ compile_address(addr, ch)
}
}
}
- else if (ch == '+' || ch == '~')
+ else if ((ch == '+' || ch == '~') && posixicity != POSIXLY_BASIC)
{
addr->addr_step = in_integer(in_nonblank());
if (addr->addr_step==0)
@@ -1088,8 +1099,8 @@ compile_program(vector)
if (posixicity == POSIXLY_BASIC)
switch (ch)
{
- case 'v': case 'L': case 'Q': case 'T':
- case 'R': case 'W':
+ case 'e': case 'v': case 'z': case 'L':
+ case 'Q': case 'T': case 'R': case 'W':
bad_command(ch);
case 'a': case 'i': case 'l':
@@ -1173,6 +1184,8 @@ compile_program(vector)
ch = inchar();
else
{
+ if (posixicity == POSIXLY_BASIC)
+ bad_prog(_(EXPECTED_SLASH));
savchar(ch);
ch = '\n';
}
@@ -1201,7 +1214,7 @@ compile_program(vector)
case 'L':
case 'l':
ch = in_nonblank();
- if (ISDIGIT(ch))
+ if (ISDIGIT(ch) && posixicity != POSIXLY_BASIC)
{
cur_cmd->x.int_arg = in_integer(ch);
ch = in_nonblank();