From: Eric Blake Date: Thu, 2 Oct 2008 15:02:37 +0000 (-0600) Subject: Document more binary file portability traps. X-Git-Tag: v2.63b~289 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2bde72f548d74e76a7dced0a3aeb58fe91de5b8;p=thirdparty%2Fautoconf.git Document more binary file portability traps. * doc/autoconf.texi (Limitations of Usual Tools) : Remind reader that NUL and sed don't always mix. : Mention Solaris /usr/ucb/tr bug with \0. Signed-off-by: Eric Blake --- diff --git a/ChangeLog b/ChangeLog index 6b3f95b5..dbba2f88 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-10-02 Eric Blake + + Document more binary file portability traps. + * doc/autoconf.texi (Limitations of Usual Tools) : Remind + reader that NUL and sed don't always mix. + : Mention Solaris /usr/ucb/tr bug with \0. + 2008-10-02 Ralf Wildenhues Implement parallel Autotest test execution: testsuite --jobs. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index e515a870..939eaea7 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -15849,7 +15849,9 @@ sed: 1: "s/x/x/;;s/x/x/": invalid command code ; @end example Input should not have unreasonably long lines, since some @command{sed} -implementations have an input buffer limited to 4000 bytes. +implementations have an input buffer limited to 4000 bytes. Likewise, +not all @command{sed} implementations can handle embedded @code{NUL} or +a missing trailing newline. Portable @command{sed} regular expressions should use @samp{\} only to escape characters in the string @samp{$()*.0123456789[\^n@{@}}. For example, @@ -16101,6 +16103,19 @@ $ @kbd{@{ echo moon; echo light; @} | /usr/ucb/tr -d '\012' ; echo} moonlight @end example +Posix requires @command{tr} to operate on binary files. But at least +Solaris @command{/usr/ucb/tr} still fails to handle @samp{\0} as the +octal escape for @code{NUL}. On Solaris, when using @command{tr} to +neutralize a binary file by converting @code{NUL} to a different +character, it is necessary to use @command{/usr/xpg4/bin/tr} instead. + +@example +$ @kbd{printf 'a\0b\n' | /usr/ucb/tr '\0' '~' | wc -c} +3 +$ @kbd{printf 'a\0b\n' | /usr/xpg4/bin/tr '\0' '~' | wc -c} +4 +@end example + @end table