autoconf
[Top][All Lists]
Advanced

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

sed on binary files


From: Eric Blake
Subject: sed on binary files
Date: Wed, 01 Oct 2008 20:51:58 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080914 Thunderbird/2.0.0.17 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Is there any portable way to process files that contain NUL bytes?  I'm
working on making m4 1.6 transparently handle NUL, and want to
post-process the output to normalize error messages while still verifying
that NUL bytes appeared where expected on stderr.  But on Solaris, the
native sed strips NUL bytes before processing the line (NUL bytes cannot
appear in text files, and POSIX does not define behavior on non-text
files, so this is not a bug, just a difference from GNU diff).  As a
result, the m4 testsuite either fails (if I only postprocess the captured
stderr and not the expected error) or can have false positives (if both
stderr and expected error are normalized, then regressions involving added
or missing NUL are not detected).  I don't want to require perl for just
this one test; m4 seems fundamental enough to keep the testsuite
restricted to the GNU coding standards set of tools.  The Solaris man
pages mention that /usr/xpg4/bin/tr can handle NUL bytes, but not
/usr/bin/tr; maybe I could search for an adequate tr, and change all NUL
to some other byte that does not otherwise appear in my expected output
(with the added benefit that diff might not give up early with the
complaint that the files are binary), but I don't know if that is portable
either.  Any suggestions?  Is this worth documenting in the autoconf manual?

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkjkN04ACgkQ84KuGfSFAYDOlACghSRq8rKgoGeRMav1zNqhGV7+
mSoAoKeL615d5MOBCBcQ4wkrgX0M4pzs
=niYA
-----END PGP SIGNATURE-----




reply via email to

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