gperf/src/options.cc -- quiesce clang warnings -Wlogical-op-parentheses

From: Sean Bruno <sean_bruno_at_yahoo.com>
Date: Sun, 20 Oct 2013 23:50:52 -0400
gperf has some clang warnings that seem to be harmless, but annoying
regarding some of the logical operations around detecting ascii chars:

c++ -O2 -pipe -I/usr/obj/usr/src/tmp/legacy/usr/include -Wno-c
++11-extensions -I/usr/src/gnu/usr.bin/gperf/../../../contrib/gperf/lib
-I/usr/src/gnu/usr.bin/g
perf -c /usr/src/gnu/usr.bin/gperf/../../../contrib/gperf/src/options.cc
/usr/src/gnu/usr.bin/gperf/../../../contrib/gperf/src/options.cc:284:27:
warning: '&&' within '||' [-Wlogical-op-parentheses]
          if (*arg >= 'A' && *arg <= 'Z' || *arg >= 'a' && *arg <= 'z')
              ~~~~~~~~~~~~^~~~~~~~~~~~~~ ~~


I propose the following change:

Index: options.cc
===================================================================
--- options.cc  (revision 256712)
+++ options.cc  (working copy)
_at__at_ -281,7 +281,7 _at__at_
         {
           putchar (*arg);
           arg++;
-          if (*arg >= 'A' && *arg <= 'Z' || *arg >= 'a' && *arg <= 'z')
+          if ( (*arg >= 'A' && *arg <= 'Z') || (*arg >= 'a' && *arg <=
'z') )
             {
               putchar (*arg);
               arg++;
_at__at_ -293,7 +293,9 _at__at_
                   putchar (*arg);
                   arg++;
                 }
-              while (*arg >= 'A' && *arg <= 'Z' || *arg >= 'a' && *arg
<= 'z' || *arg == '-');
+              while ( (*arg >= 'A' && *arg <= 'Z') ||
+                     (*arg >= 'a' && *arg <= 'z') ||
+                     (*arg == '-') );
               if (*arg == '=')
                 {
                   putchar (*arg);


Received on Mon Oct 21 2013 - 01:53:59 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:43 UTC