From cfac154888e6915b2ccc0a3156ac8e6820eb0406 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Thu, 17 Apr 2014 11:32:53 +0900 Subject: [PATCH] msgfmt: Simplify LINGUAS parsing --- gettext-tools/src/msgfmt.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/gettext-tools/src/msgfmt.c b/gettext-tools/src/msgfmt.c index 46369204e..57986b9a6 100644 --- a/gettext-tools/src/msgfmt.c +++ b/gettext-tools/src/msgfmt.c @@ -1345,25 +1345,21 @@ get_languages (const char *directory) continue; /* Split the line by whitespace and build the languages list. */ - start = line_buf; - while (*start != '\0') + for (start = line_buf; start - line_buf < len; ) { - char *end = start; - int c; + char *p; - while (*end != '\0' && *end != ' ' && *end != '\t') - end++; - - c = *end; - *end = '\0'; - string_list_append_unique (languages, start); - - if (c == '\0') - break; - - start = end + 1; + /* Skip whitespace before the string. */ while (*start == ' ' || *start == '\t') start++; + + p = start; + while (*p != ' ' && *p != '\t') + p++; + + *p = '\0'; + string_list_append_unique (languages, start); + start = p + 1; } } -- 2.47.2