Skip to content

Commit

Permalink
sed: allow comments, braces after y///
Browse files Browse the repository at this point in the history
sed-4.4 and earlier rejected the following:
  $ sed 'y/1/a/ #f'
  sed: -e expression #1, char 8: extra characters after command

See https://bugs.gnu.org/22460 .

* sed/compile.c (compile_program): Handle comments, braces after 'y' command.
* NEWS: Mention it.
  • Loading branch information
Thorsten Heymann authored and agordon committed Mar 22, 2017
1 parent b092d4a commit cf8eb6c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ GNU sed NEWS -*- outline -*-

* Noteworthy changes in release ?.? (????-??-??) [?]

** Bug fixes

sed no longer rejects comments and closing braces after y/// commands.
[Bug existed at least since sed-3.02]


* Noteworthy changes in release 4.4 (2017-02-03) [stable]

Expand Down
5 changes: 4 additions & 1 deletion sed/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,10 @@ compile_program(struct vector *vector)
cur_cmd->x.translate = translate;
}

if ((ch = in_nonblank()) != EOF && ch != '\n' && ch != ';')
ch = in_nonblank();
if (ch == CLOSE_BRACE || ch == '#')
savchar(ch);
else if (ch != EOF && ch != '\n' && ch != ';')
bad_prog(_(EXCESS_JUNK));

free_buffer(b);
Expand Down

0 comments on commit cf8eb6c

Please sign in to comment.