svn commit: r281758 - head/bin/ed

Eitan Adler eadler at freebsd.org
Mon Apr 20 18:53:39 UTC 2015


On 19 April 2015 at 21:23, Bruce Evans <brde at optusnet.com.au> wrote:
> On Mon, 20 Apr 2015, Eitan Adler wrote:
>
>> Log:
>>  ed(1): Fix [-Werror=logical-not-parentheses]
>>         /usr/src/bin/ed/glbl.c:64:36: error: logical not is only applied
>> to
>>         theleft hand side of comparison [-Werror=logical-not-parentheses]
>>
>>  Obtained from: Dragonfly (1fff89cbaeaa43af720a1f23d9c466b756dd8a58)
>>  MFC After:     1 month
>>
>> Modified:
>>  head/bin/ed/glbl.c
>>
>> Modified: head/bin/ed/glbl.c
>>
>> ==============================================================================
>> --- head/bin/ed/glbl.c  Mon Apr 20 00:24:32 2015        (r281757)
>> +++ head/bin/ed/glbl.c  Mon Apr 20 02:07:57 2015        (r281758)
>> @@ -60,7 +60,7 @@ build_active_list(int isgcmd)
>>                         return ERR;
>>                 if (isbinary)
>>                         NUL_TO_NEWLINE(s, lp->len);
>> -               if (!regexec(pat, s, 0, NULL, 0) == isgcmd &&
>> +               if (!(regexec(pat, s, 0, NULL, 0) == isgcmd) &&
>>                     set_active_node(lp) < 0)
>>                         return ERR;
>>         }
>
>
> How can this be right?  !(a == b) is an obfuscated way of writing a != b.
bah!

How does something like the following look?

Index: ed.h
===================================================================
--- ed.h    (revision 281759)
+++ ed.h    (working copy)
@@ -33,6 +33,7 @@
 #include <limits.h>
 #include <regex.h>
 #include <signal.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -191,7 +192,7 @@ int put_des_char(int, FILE *);
 void add_line_node(line_t *);
 int append_lines(long);
 int apply_subst_template(const char *, regmatch_t *, int, int);
-int build_active_list(int);
+int build_active_list(bool);
 int cbc_decode(unsigned char *, FILE *);
 int cbc_encode(unsigned char *, int, FILE *);
 int check_addr_range(long, long);
Index: glbl.c
===================================================================
--- glbl.c    (revision 281759)
+++ glbl.c    (working copy)
@@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$");

 /* build_active_list:  add line matching a pattern to the global-active list */
 int
-build_active_list(int isgcmd)
+build_active_list(bool isgcmd)
 {
     pattern_t *pat;
     line_t *lp;
@@ -60,7 +60,7 @@ int
             return ERR;
         if (isbinary)
             NUL_TO_NEWLINE(s, lp->len);
-        if (!(regexec(pat, s, 0, NULL, 0) == isgcmd) &&
+        if ((!regexec(pat, s, 0, NULL, 0)) == isgcmd &&
             set_active_node(lp) < 0)
             return ERR;
     }


-- 
Eitan Adler
Source, Ports, Doc committer
Bugmeister, Ports Security teams


More information about the svn-src-all mailing list