fix fixincludes

Bruce Korb bkorb@gnu.org
Thu Sep 3 20:32:00 GMT 2009


On Thu, Sep 3, 2009 at 12:23 PM, Ralf Wildenhues<Ralf.Wildenhues@gmx.de> wrote:
> Hi Bruce,
>
> the patch below fixes some typos and so on in fixincludes files, and
> then addresses sed portability issues in inclhack.def:
>
> - in a sed BRE, backslash-n has to be used to match a newline.  However,
>  in the replacement string of an 's' command (that's the second
>  argument to 's'), a newline has to be encoded as backslash-newline
>  (i.e., literal newline!).  Using a backslash-n here works with GNU sed
>  but is not POSIX conforming (and doesn't work with BSD sed).
>  So, for example:
>
> $ (echo a; echo b) | sed 'N; s/\n/x\
> y/'
>
> prints:
> ax
> yb
>
>  Note the difference in encoding the newline in the two arguments.
>
> - the \+ operator is neither POSIX nor portable sed, but \{1,\} is;
>  also, there was one instance where literal + was certainly intended
>  ('extern "C\+\+"' in sco_math), but we may want to run this by
>  somebody with system access to ensure that that is what should happen,
>
> - the alternation operator \| is neither POSIX, not fully portable
>  (Solaris sed does not support it), I've replaced them with repeated
>  sed scripts for each instance.
>
> - more issues, quoting autoconf.info:
>
>     If a sed script is specified on the command line and ends in an
>     `a', `c', or `i' command, the last line of inserted text should be
>     followed by a newline.  Otherwise some `sed' implementations
>     (e.g., OpenBSD 3.9) do not append a newline to the inserted text.
>
>     Many `sed' implementations (e.g., MacOS X 10.4, OpenBSD 3.9,
>     Solaris 10 `/usr/ucb/sed') strip leading white space from the text
>     of `a', `c', and `i' commands.  Prepend a backslash to work around
>     this incompatibility with Posix
>
>
> I have tested the patch on GNU/Linux, with sed 4.2.1, 4.1.5, 3.02,
> HP-UX 11.11 sed, FreeBSD 6.4 sed, and Solaris 10 sed.  They now all
> pass all fixincludes tests.
>
> OK to apply (after the freeze)?

Hi Ralf,

My 30 second review says it looks good, but I'd like to examine it carefully.
Someone once told me that sed is a write-only language.  I've never
disagreed.  :)  I'm very happy you worked your way through the mess.
I'll respond fully before Tuesday, after our long weekend.  Thanks - Bruce



More information about the Gcc-patches mailing list