changeset 34536:3705a4d4a831

trim: remove three superfluous assignments * lib/trim.c (trim2): Remove three superfluous assignments and correct brace positioning.
author Jim Meyering <meyering@redhat.com>
date Sun, 29 May 2011 23:15:36 +0200
parents 58cf3d25e85a
children 8cc838add561
files ChangeLog lib/trim.c
diffstat 2 files changed, 21 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat May 28 20:58:14 2011 +0200
+++ b/ChangeLog	Sun May 29 23:15:36 2011 +0200
@@ -1,3 +1,9 @@
+2011-05-29  Jim Meyering  <meyering@redhat.com>
+
+	trim: remove three superfluous assignments
+	* lib/trim.c (trim2): Remove three superfluous assignments
+	and correct brace positioning.
+
 2011-05-29  Bruno Haible  <bruno@clisp.org>
 
 	wctype-h: Avoid namespace pollution on Solaris 2.6.
--- a/lib/trim.c	Sat May 28 20:58:14 2011 +0200
+++ b/lib/trim.c	Sun May 29 23:15:36 2011 +0200
@@ -73,10 +73,7 @@
           for (; mbi_avail (i); mbi_advance (i))
             {
               if (state == 0 && mb_isspace (mbi_cur (i)))
-                {
-                  state = 0;
-                  continue;
-                }
+                continue;
 
               if (state == 0 && !mb_isspace (mbi_cur (i)))
                 {
@@ -85,10 +82,7 @@
                 }
 
               if (state == 1 && !mb_isspace (mbi_cur (i)))
-                {
-                  state = 1;
-                  continue;
-                }
+                continue;
 
               if (state == 1 && mb_isspace (mbi_cur (i)))
                 {
@@ -97,7 +91,7 @@
                 }
               else if (state == 2 && mb_isspace (mbi_cur (i)))
                 {
-                  state = 2;
+                  /* empty */
                 }
               else
                 {
@@ -114,18 +108,21 @@
       char *p;
 
       /* Trim leading whitespaces. */
-      if (how != TRIM_TRAILING) {
-        for (p = d; *p && isspace ((unsigned char) *p); p++)
-          ;
+      if (how != TRIM_TRAILING)
+        {
+          for (p = d; *p && isspace ((unsigned char) *p); p++)
+            ;
 
-        memmove (d, p, strlen (p) + 1);
-      }
+          memmove (d, p, strlen (p) + 1);
+        }
 
       /* Trim trailing whitespaces. */
-      if (how != TRIM_LEADING) {
-        for (p = d + strlen (d) - 1; p >= d && isspace ((unsigned char) *p); p--)
-          *p = '\0';
-      }
+      if (how != TRIM_LEADING)
+        {
+          for (p = d + strlen (d) - 1;
+               p >= d && isspace ((unsigned char) *p); p--)
+            *p = '\0';
+        }
     }
 
   return d;