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

Sean Bruno sean_bruno at yahoo.com
Mon Oct 21 23:43:55 UTC 2013


On Sun, 2013-10-20 at 23:50 -0400, Sean Bruno wrote:
> 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')
>               ~~~~~~~~~~~~^~~~~~~~~~~~~~ ~~
> 
> 

Heh, Matthew suggested the obvious in private mail, it seems that this
would be better "spelled" as "isalpha" :-)

Index: contrib/gperf/src/options.cc
===================================================================
--- contrib/gperf/src/options.cc	(revision 256865)
+++ contrib/gperf/src/options.cc	(working copy)
@@ -281,7 +281,7 @@
         {
           putchar (*arg);
           arg++;
-          if (*arg >= 'A' && *arg <= 'Z' || *arg >= 'a' && *arg <= 'z')
+          if (isalpha(*arg))
             {
               putchar (*arg);
               arg++;
@@ -293,7 +293,7 @@
                   putchar (*arg);
                   arg++;
                 }
-              while (*arg >= 'A' && *arg <= 'Z' || *arg >= 'a' && *arg
<= 'z' || *arg == '-');
+              while (isalpha(*arg) || *arg == '-');
               if (*arg == '=')
                 {
                   putchar (*arg);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freebsd.org/pipermail/freebsd-current/attachments/20131021/a4c17bbb/attachment.sig>


More information about the freebsd-current mailing list