bug#78882: stty.c compilation error

Collin Funk <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Message-ID <[email protected]>
Hi Bruno,

Bruno Haible via GNU coreutils Bug Reports <[email protected]>
writes:

> It looks like the 'speedgen' script, added in commit
> 357fda90d15fd3f7dba61e1ab322b183a48d0081, produces this invalid C code.
>
> With GNU sed:
>
> $ echo 100 | sed -e 's/^.*$/#  ifdef B&\n      case B&: return &;\n#  endif/'
> #  ifdef B100
>       case B100: return 100;
> #  endif
>
> With OpenBSD sed and Solaris sed:
>
> $ echo 100 | sed -e 's/^.*$/#  ifdef B&\n      case B&: return &;\n#  endif/'
> #  ifdef B100n      case B100: return 100;n#  endif
>
> The attached patch fixes it.

Good catch, I fixed something similar in git a few weeks ago [1]. From
the commit message:


    The OpenBSD 'sed' command does not support '\n' to represent newlines in
    sed expressions. This leads to the follow compiler error:
    
        In file included from builtin/help.c:15:
        ./config-list.h:282:18: error: use of undeclared identifier 'n'
                "gitcvs.dbUser",n       "gitcvs.dbPass",
                                ^
        1 error generated.
        gmake: *** [Makefile:2821: builtin/help.o] Error 1


Perhaps it is worth documenting somewhere? I think Autoconf's manual has
a section of shell portability gotchas.

Collin

[1] https://github.com/git/git/commit/db170e18262ed10e5e9b7f3cbca6a0ac43267b20
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.