From 44019e149cf40caa0b6d0eb57115eea555fdfee6 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 29 May 2011 23:15:36 +0200 Subject: [PATCH] trim: remove three superfluous assignments * lib/trim.c (trim2): Remove three superfluous assignments and correct brace positioning. --- ChangeLog | 6 ++++++ lib/trim.c | 33 +++++++++++++++------------------ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9c8b3a9e38..8bcf08756f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-05-29 Jim Meyering + + trim: remove three superfluous assignments + * lib/trim.c (trim2): Remove three superfluous assignments + and correct brace positioning. + 2011-05-29 Bruno Haible wctype-h: Avoid namespace pollution on Solaris 2.6. diff --git a/lib/trim.c b/lib/trim.c index 6515cfaff2..155063eed3 100644 --- a/lib/trim.c +++ b/lib/trim.c @@ -73,10 +73,7 @@ trim2 (const char *s, int how) 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 @@ trim2 (const char *s, int how) } if (state == 1 && !mb_isspace (mbi_cur (i))) - { - state = 1; - continue; - } + continue; if (state == 1 && mb_isspace (mbi_cur (i))) { @@ -97,7 +91,7 @@ trim2 (const char *s, int how) } else if (state == 2 && mb_isspace (mbi_cur (i))) { - state = 2; + /* empty */ } else { @@ -114,18 +108,21 @@ trim2 (const char *s, int how) 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; -- 2.30.2