bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: GNU sed fails to insert tab at beginning of line in a certain way


From: Paolo Bonzini
Subject: Re: GNU sed fails to insert tab at beginning of line in a certain way
Date: Wed, 03 Nov 2010 18:46:50 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101027 Fedora/3.1.6-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.6

On 11/03/2010 06:21 PM, Warren Turkal wrote:

I don't really understand why the \t doesn't work when it comes first in
the append command. Is that expected behavior?

It looks like you have to double the backslash to have the desired effect--but only at the beginning of the line. So, this is certainly a bug and this patch fixes it.

diff --git a/sed/compile.c b/sed/compile.c
index b2fb825..33bf74c 100644
--- a/sed/compile.c
+++ b/sed/compile.c
@@ -897,10 +897,7 @@ read_text(buf, leadin_ch)
   if (leadin_ch == EOF)
     return;

-  if (leadin_ch != '\n')
-    add1_buffer(pending_text, leadin_ch);
-
-  ch = inchar();
+  ch = (leadin_ch == '\n') ? inchar() : leadin_ch;
   while (ch != EOF && ch != '\n')
     {
       if (ch == '\\')
@@ -1181,7 +1178,16 @@ compile_program(vector)
            bad_prog(_(EXPECTED_SLASH));
        
          if (ch == '\\')
-           ch = inchar();
+            {
+              ch = inchar();
+              if (ch != '\n')
+                {
+                  if (posixicity == POSIXLY_BASIC && ch != '\n')
+                    bad_prog(_(EXPECTED_SLASH));
+                  savchar(ch);
+                  ch = '\\';
+                }
+            }
          else
            {
              if (posixicity == POSIXLY_BASIC)


Paolo



reply via email to

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