diff options
author | Ralf Wildenhues <Ralf.Wildenhues@gmx.de> | 2008-12-31 10:02:47 +0100 |
---|---|---|
committer | Paolo Bonzini <bonzini@gnu.org> | 2008-12-31 10:05:03 +0100 |
commit | ed1c249d94bfc34f58f5f3e40fdbd857edb90531 (patch) | |
tree | ac38f428d550b9f3203de23f7334f849a8fb0083 /sed | |
parent | 559a106598e83e18ddb9fcd00600cb66507a533f (diff) | |
download | sed-ed1c249d94bfc34f58f5f3e40fdbd857edb90531.tar.gz |
Let --posix turn off more GNU extensions.
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.
Diffstat (limited to 'sed')
-rw-r--r-- | sed/compile.c | 23 |
1 files changed, 18 insertions, 5 deletions
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(); |