bug-sed
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#22460: 'y' command doesn't allow a comment after it one the same lin


From: Thorsten Heymann
Subject: bug#22460: 'y' command doesn't allow a comment after it one the same line
Date: Mon, 25 Jan 2016 02:28:22 +0100
User-agent: Mutt/1.5.24 (2015-08-30)

Unlike other commands, the current implementation of the 'y' command does not 
allow a comment on the same line if the command is not "terminated" by a ';'

For example (the comments are part of the program):

    s/1/a/g    # Substitute 1's by a's
    x          # Swapping hold and pattern buffer
    1d         # Deleting the first line
    ...

works, but

    y/1/a/     # Substitute 1's by a's

produces:

    sed: -e expression #1, char 8: extra characters after command

This patch fixes this.

Greets,
Thorsten
---
 sed/compile.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sed/compile.c b/sed/compile.c
index 270caaf..442aeb5 100644
--- a/sed/compile.c
+++ b/sed/compile.c
@@ -1329,7 +1329,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);
-- 
2.4.10






reply via email to

[Prev in Thread] Current Thread [Next in Thread]