Mercurial > hg > octave-lojdl > gnulib-hg
changeset 14845:7f850a75bbdb
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 | d6cca2f0c240 |
children | a8d8fc44bcc4 |
files | ChangeLog lib/trim.c |
diffstat | 2 files changed, 21 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -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 +++ b/lib/trim.c @@ -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;