]> granicus.if.org Git - shadow/commitdiff
* lib/fputsx.c: Add brackets.
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Mon, 26 May 2008 00:59:42 +0000 (00:59 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Mon, 26 May 2008 00:59:42 +0000 (00:59 +0000)
* lib/fputsx.c: Avoid assignments in comparisons.
* lib/fputsx.c: Avoid implicit conversion of pointers / integers / chars to booleans.

ChangeLog
lib/fputsx.c

index f52d048be1a2c41f4e9c34a8833b85e56718a4ca..a09292a358009b512708ac9640bccf06d7860bf5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-05-26  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * lib/fputsx.c: Add brackets.
+       * lib/fputsx.c: Avoid assignments in comparisons.
+       * lib/fputsx.c: Avoid implicit conversion of pointers / integers /
+       chars to booleans.
+
 2008-05-26  Nicolas François  <nicolas.francois@centraliens.net>
 
        * lib/commonio.h: commonio_entry.changed, commonio_db.changed,
index 1573207286b724ef51f4fee00370a48a131e7a82..18eb76ce7a962b9572a194cb6796524b88bde2d0 100644 (file)
@@ -46,16 +46,22 @@ char *fgetsx (char *buf, int cnt, FILE * f)
 
        while (cnt > 0) {
                if (fgets (cp, cnt, f) == 0) {
-                       if (cp == buf)
+                       if (cp == buf) {
                                return 0;
-                       else
+                       } else {
                                break;
+                       }
                }
-               if ((ep = strrchr (cp, '\\')) && *(ep + 1) == '\n') {
-                       if ((cnt -= ep - cp) > 0)
-                               *(cp = ep) = '\0';
-               } else
+               ep = strrchr (cp, '\\');
+               if ((NULL != ep) && (*(ep + 1) == '\n')) {
+                       cnt -= ep - cp;
+                       if (cnt > 0) {
+                               cp = ep;
+                               *cp = '\0';
+                       }
+               } else {
                        break;
+               }
        }
        return buf;
 }
@@ -64,9 +70,10 @@ int fputsx (const char *s, FILE * stream)
 {
        int i;
 
-       for (i = 0; *s; i++, s++) {
-               if (putc (*s, stream) == EOF)
+       for (i = 0; '\0' != *s; i++, s++) {
+               if (putc (*s, stream) == EOF) {
                        return EOF;
+               }
 
 #if 0                          /* The standard getgr*() can't handle that.  --marekm */
                if (i > (BUFSIZ / 2)) {
@@ -80,3 +87,4 @@ int fputsx (const char *s, FILE * stream)
        }
        return 0;
 }
+