getstyle: Fix output to stdout
commit5ef03b2a3a43b69a3652e2066d05f5e62e0f3f72
authorCarlos R. Mafra <crmafra@gmail.com>
Sun, 15 Jan 2012 01:20:19 +0000 (15 01:20 +0000)
committerCarlos R. Mafra <crmafra@gmail.com>
Sun, 15 Jan 2012 02:45:00 +0000 (15 02:45 +0000)
tree0b07f9ec2e474bfbff52aeab7aa9e5b8865d8792
parent385dbdb3d61d55bf4cbdf1e2926456da9e7b6e7f
getstyle: Fix output to stdout

There is a problem with getstyle invoked with no arguments:

[mafra@Pilar:util]$ ./getstyle
Usage: getstyle [-t] [-p] [-h] [-v] [file]

or with -t:

[mafra@Pilar:util]$ ./getstyle -t
Usage: getstyle [-t] [-p] [-h] [-v] [file]

In both cases it is supposed to write to the standard output:

[mafra@Pilar:wmaker.git]$ getstyle -h
Usage: getstyle [-t] [-p] [-h] [-v] [file]
Retrieves style/theme configuration and output to FILE or to stdout

This regression was caused by commit 6bf79945201265dccf62 ("style Stuff up").
When that commit did

       argc -= optind;

       if (argc != 1)
               print_help(0,1);

it excluded the output to stdout as valid, because in this case
argc - optind is zero (see the manpage of getopt(3)).

The correct handling is to set the style_file only when there is
one non-option ARGV-element (argc - optind == 1) and print the
help message when there are more than one non-option element.
util/getstyle.c