Re: sed on binary files

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

 



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

According to Ralf Wildenhues on 10/1/2008 11:32 PM:

Hi Ralf, Gary,

>> Is there any portable way to process files that contain NUL bytes?
> 
> tr?  If you only need to compare for equality, then use cmp.

Equality is insufficient the way the test is currently written; I'm
checking that m4's errprint can directly output NUL, while warning
messages quote filenames, so I must normalize VPATH output such as:
  src/m4:../examples/null.m4:98: Warning: indir: undefined macro `\0-\0'
to match the expected error
  m4:examples/null.m4:98: Warning: indir: undefined macro `\0-\0'

I suppose I could split the test into two - with m4, any output line that
needs normalization should not be using raw NUL (error messages), while
anything that allows outputs raw NUL to stderr shouldn't need
normalization (errprint, dumpdef, trace output).  But that is not
necessarily trivial to do either (it means the m4 testsuite would have to
conditionally run sed, instead of its current attitude of always running
the sed normalization).

> 
>> 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.
> 
> That's what I'd try first, too.

I verified that Solaris /usr/xpg4/bin/tr can do the trick, but not
/usr/bin/tr.

> 
>> Any suggestions?  Is this worth documenting in the autoconf manual?
> 
> I guess the bit that Solaris /usr/bin/tr is deficient, is (what about
> other vendors' tr?).  I wouldn't recommend a way to treat binary files
> in the manual, until there is actual experience with it, and then only
> if that deviates substantially from what Posix says.

I'll add a blurb to the autoconf manual on sed mentioning that it cannot
be used on binary files (although Posix already says that), as well as on
tr mentioning the Solaris /usr/bin/tr bug.

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

Eric Blake             ebb9@xxxxxxx
-----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

iEYEARECAAYFAkjkwq4ACgkQ84KuGfSFAYClSQCePmkHN8TG9NuuvwT7F3+j80BE
pb4AnR7SKAiAuelsx4yxyGZWgxPu5pkN
=QXG6
-----END PGP SIGNATURE-----


_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux