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: Warren Turkal
Subject: Re: GNU sed fails to insert tab at beginning of line in a certain way
Date: Wed, 3 Nov 2010 16:13:06 -0700

Should I assume this patch will be included in the next version of sed?

Thanks,
wt

On Wed, Nov 3, 2010 at 10:46, Paolo Bonzini <address@hidden> wrote:

> 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]