From: Bruno Haible Date: Wed, 27 Mar 2019 20:36:14 +0000 (+0100) Subject: its: Simplify code. X-Git-Tag: v0.20~109 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=439a07921d7197ecb88cd31833c8e16715a57bea;p=thirdparty%2Fgettext.git its: Simplify code. Suggested by Daiki Ueno. * gettext-tools/src/its.c (normalize_whitespace): Remove local variable. --- diff --git a/gettext-tools/src/its.c b/gettext-tools/src/its.c index 8b72e1e19..d9306cd23 100644 --- a/gettext-tools/src/its.c +++ b/gettext-tools/src/its.c @@ -480,28 +480,25 @@ normalize_whitespace (const char *text, enum its_whitespace_type_ty whitespace) return result; } default: - /* Normalize whitespaces within the text, but not at the beginning - nor the end of the text. */ + /* Normalize whitespaces within the text, but do not eliminate whitespace + at the beginning nor the end of the text. */ { - char *result, *p, *out; - bool last_ws = false; + char *result = xstrdup (text); + char *out; + const char *p; - result = xstrdup (text); - for (p = out = result; *p != '\0'; p++) + out = result; + for (p = result; *p != '\0';) { if (*p == ' ' || *p == '\t' || *p == '\n') { - if (!last_ws) - { - *out++ = ' '; - last_ws = true; - } + do + p++; + while (*p == ' ' || *p == '\t' || *p == '\n'); + *out++ = ' '; } else - { - *out++ = *p; - last_ws = false; - } + *out++ = *p++; } *out = '\0'; return result;