csi-trace does not show help?

Submitted by suzuki toshiya on March 31, 2018, 12:28 p.m.

Details

Message ID 5ABF7EFE.8020405@hiroshima-u.ac.jp
State New
Headers show
Series "csi-trace does not show help?" ( rev: 1 ) in Cairo

Not browsing as part of any series.

Commit Message

suzuki toshiya March 31, 2018, 12:28 p.m.
Hi,

I'm afraid that csi-trace does not show help string correctly,
because there could be a bug in its command line argument parse.

Regards,
mpsuzuki

Patch hide | download patch | download mbox

diff --git a/util/cairo-script/csi-trace.c b/util/cairo-script/csi-trace.c
index 52eeade..d64a644 100644
--- a/util/cairo-script/csi-trace.c
+++ b/util/cairo-script/csi-trace.c
@@ -64,10 +64,10 @@  main (int argc, char **argv)
     csi = cairo_script_interpreter_create ();

     for (i = 1; i < argc; i++) {
-        if (strcmp (argv[i], "--version")) {
+        if (!strcmp (argv[i], "--version")) {
             printf ("%s: version %s\n", argv[0], __DATE__);
 	    exit (0);
-        } else if (strcmp (argv[i], "--help")) {
+        } else if (!strcmp (argv[i], "--help")) {
 	    printf ("usage: %s < in > out\n", argv[0]);
 	    exit (0);
         }

Comments

Thanks, that's a good find.  I confirmed the misbehavior without this
fix.

I modified the patch a little, to say "strcmp(..) == 0" instead of
"!strcmp()", since the former style seems to be the more common in
cairo/util.

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>

Pushed:
To ssh://git.freedesktop.org/git/cairo
   50a6ad5..33a348d  master -> master


On Sat, Mar 31, 2018 at 09:28:46PM +0900, suzuki toshiya wrote:
> Hi,
> 
> I'm afraid that csi-trace does not show help string correctly,
> because there could be a bug in its command line argument parse.
> 
> Regards,
> mpsuzuki
> 
> diff --git a/util/cairo-script/csi-trace.c b/util/cairo-script/csi-trace.c
> index 52eeade..d64a644 100644
> --- a/util/cairo-script/csi-trace.c
> +++ b/util/cairo-script/csi-trace.c
> @@ -64,10 +64,10 @@ main (int argc, char **argv)
>      csi = cairo_script_interpreter_create ();
> 
>      for (i = 1; i < argc; i++) {
> -        if (strcmp (argv[i], "--version")) {
> +        if (!strcmp (argv[i], "--version")) {
>              printf ("%s: version %s\n", argv[0], __DATE__);
>  	    exit (0);
> -        } else if (strcmp (argv[i], "--help")) {
> +        } else if (!strcmp (argv[i], "--help")) {
>  	    printf ("usage: %s < in > out\n", argv[0]);
>  	    exit (0);
>          }
> 
> -- 
> cairo mailing list
> cairo@cairographics.org
> https://lists.cairographics.org/mailman/listinfo/cairo
Thanks!

Bryce Harrington wrote:
> Thanks, that's a good find.  I confirmed the misbehavior without this
> fix.
> 
> I modified the patch a little, to say "strcmp(..) == 0" instead of
> "!strcmp()", since the former style seems to be the more common in
> cairo/util.
> 
> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
> 
> Pushed:
> To ssh://git.freedesktop.org/git/cairo
>    50a6ad5..33a348d  master -> master
> 
> 
> On Sat, Mar 31, 2018 at 09:28:46PM +0900, suzuki toshiya wrote:
>> Hi,
>>
>> I'm afraid that csi-trace does not show help string correctly,
>> because there could be a bug in its command line argument parse.
>>
>> Regards,
>> mpsuzuki
>>
>> diff --git a/util/cairo-script/csi-trace.c b/util/cairo-script/csi-trace.c
>> index 52eeade..d64a644 100644
>> --- a/util/cairo-script/csi-trace.c
>> +++ b/util/cairo-script/csi-trace.c
>> @@ -64,10 +64,10 @@ main (int argc, char **argv)
>>      csi = cairo_script_interpreter_create ();
>>
>>      for (i = 1; i < argc; i++) {
>> -        if (strcmp (argv[i], "--version")) {
>> +        if (!strcmp (argv[i], "--version")) {
>>              printf ("%s: version %s\n", argv[0], __DATE__);
>>  	    exit (0);
>> -        } else if (strcmp (argv[i], "--help")) {
>> +        } else if (!strcmp (argv[i], "--help")) {
>>  	    printf ("usage: %s < in > out\n", argv[0]);
>>  	    exit (0);
>>          }
>>
>> -- 
>> cairo mailing list
>> cairo@cairographics.org
>> https://lists.cairographics.org/mailman/listinfo/cairo
>