bug-coreutils
[Top][All Lists]
Advanced

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

Re: Options --enable{,-no}-install-program


From: Eric Blake
Subject: Re: Options --enable{,-no}-install-program
Date: Sat, 26 Jan 2008 16:31:23 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666

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

According to Jim Meyering on 1/26/2008 3:55 PM:

| +  "groups -- foo" no longer generates a spurious error about the
| +  nonexistent group "--".

Huh?  That's been fixed for some time now (Sept 2006):
http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=b7c315c

| - while I know too well how bad stdio is, I'm tempted to remove the
|     new tests of each printf return value.  I noticed that you check
|     those while not checking putchar.

That's where the combination of xprintf and close-stdout will help -
xprintf catches any errors that don't set the ferror bit, and all
remaining errors (all putchar errors, and most printf errors) touch the
ferror bit and are then caught by close-stdout.  In other words,

| +int
| +main (int argc, char **argv)
| +{
...
| +
| +  atexit (close_stdout);
| +

because of this call...

| +
| +          if (printf ("%s : ", argv[optind]) < 0)
| +            {
| +              write_error ();
| +              ok = false;
| +            }

You can use xprintf, and the above becomes one line instead of five...

| +          if (EOF == putchar ('\n'))
| +            {
| +              write_error ();
| +              ok = false;
| +            }

And the above need only be 'putchar ('\n');' instead of five lines, and
you don't need the helper function write_error().

| +        }
| +    }
| +
| +  exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);

And if you get here, you can use simply 'exit EXIT_SUCCESS;' - the atexit
handler will take care of correcting the exit status if there was any
write error in the meantime.

| -    print_user (use_real ? ruid : euid);
| +    {
| +      print_user (use_real ? ruid : euid);
| +    }

Why are you making these cosmetic changes, with no other change in the
code?  GNU Coding Standards recommend eliding the braces for single-line
statements (yes, it is a style that not everyone likes, because you then
have to remember to add braces if you add a statement, but consistency
looks nicer).

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

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

iD8DBQFHm8LL84KuGfSFAYARAhqLAKCIGzZxagwv6uKrQZNd0Vfo1hq7XACfX2kU
yz4KQydFFZcObH58+8zVOFc=
=yJqQ
-----END PGP SIGNATURE-----




reply via email to

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