diff options
author | Daiki Ueno <ueno@gnu.org> | 2014-05-14 11:42:34 +0900 |
---|---|---|
committer | Daiki Ueno <ueno@gnu.org> | 2014-05-14 16:48:02 +0900 |
commit | 5223d52de8af36b81ebb71087384f21a175b8fc8 (patch) | |
tree | 4f089009c5aee758fc0ae2e8e7646eac16a6476f | |
parent | 2a644d7a28191082c631d095d7b73a6fd34455b3 (diff) | |
download | external_gettext-5223d52de8af36b81ebb71087384f21a175b8fc8.zip external_gettext-5223d52de8af36b81ebb71087384f21a175b8fc8.tar.gz external_gettext-5223d52de8af36b81ebb71087384f21a175b8fc8.tar.bz2 |
filter-quote: Minor refactoring of string copy
-rw-r--r-- | gettext-tools/src/filter-quote.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/gettext-tools/src/filter-quote.c b/gettext-tools/src/filter-quote.c index 4cddf09..5ca233a 100644 --- a/gettext-tools/src/filter-quote.c +++ b/gettext-tools/src/filter-quote.c @@ -69,6 +69,16 @@ convert_ascii_quote_to_unicode (const char *input, size_t input_len, + (bold ? 7 : 3) * quote_count + 1, char); +#undef COPY_SEEN +#define COPY_SEEN \ + do \ + { \ + memcpy (r, start, p - start); \ + r += p - start; \ + start = p; \ + } \ + while (0) + for (p = start; p <= end; p++) { switch (*p) @@ -111,10 +121,7 @@ convert_ascii_quote_to_unicode (const char *input, size_t input_len, } else { - /* Copy the preceding string to R. */ - memcpy (r, start, p - start); - r += p - start; - start = p; + COPY_SEEN; state = true; } break; @@ -123,18 +130,11 @@ convert_ascii_quote_to_unicode (const char *input, size_t input_len, if (state) { if (*start == '`') - { - memcpy (r, start, p - start); - r += p - start; - start = p; - } + COPY_SEEN; } else { - /* Copy the preceding string to R. */ - memcpy (r, start, p - start); - r += p - start; - start = p; + COPY_SEEN; state = true; } break; @@ -179,26 +179,20 @@ convert_ascii_quote_to_unicode (const char *input, size_t input_len, start = p + 1; } else - { - /* Copy the preceding string to R. */ - memcpy (r, start, p - start); - r += p - start; - start = p; - } + COPY_SEEN; state = false; } else if (p == input || *(p - 1) == '\n' || *(p - 1) == ' ') { - /* Copy the preceding string to R. */ - memcpy (r, start, p - start); - r += p - start; - start = p; + COPY_SEEN; state = true; } break; } } +#undef COPY_SEEN + /* Copy the rest to R. */ if (p > start) { |