diff options
Diffstat (limited to 'gettext-runtime/src')
-rw-r--r-- | gettext-runtime/src/ChangeLog | 4 | ||||
-rw-r--r-- | gettext-runtime/src/envsubst.c | 338 | ||||
-rw-r--r-- | gettext-runtime/src/gettext.c | 246 | ||||
-rw-r--r-- | gettext-runtime/src/ngettext.c | 134 |
4 files changed, 363 insertions, 359 deletions
diff --git a/gettext-runtime/src/ChangeLog b/gettext-runtime/src/ChangeLog index 9d685bd..da8169c 100644 --- a/gettext-runtime/src/ChangeLog +++ b/gettext-runtime/src/ChangeLog @@ -1,3 +1,7 @@ +2009-12-12 Bruno Haible <bruno@clisp.org> + + * *.c: Untabify. + 2009-01-17 Bruno Haible <bruno@clisp.org> Update after gnulib changed. diff --git a/gettext-runtime/src/envsubst.c b/gettext-runtime/src/envsubst.c index 59c05ed..511c1d9 100644 --- a/gettext-runtime/src/envsubst.c +++ b/gettext-runtime/src/envsubst.c @@ -89,7 +89,7 @@ main (int argc, char *argv[]) while ((opt = getopt_long (argc, argv, "hvV", long_options, NULL)) != EOF) switch (opt) { - case '\0': /* Long option. */ + case '\0': /* Long option. */ break; case 'h': do_help = true; @@ -114,7 +114,7 @@ License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\ This is free software: you are free to change and redistribute it.\n\ There is NO WARRANTY, to the extent permitted by law.\n\ "), - "2003-2007"); + "2003-2007"); printf (_("Written by %s.\n"), proper_name ("Bruno Haible")); exit (EXIT_SUCCESS); } @@ -131,31 +131,31 @@ There is NO WARRANTY, to the extent permitted by law.\n\ { /* Output only the variables. */ switch (argc - optind) - { - case 1: - break; - case 0: - error (EXIT_FAILURE, 0, _("missing arguments")); - default: - abort (); - } + { + case 1: + break; + case 0: + error (EXIT_FAILURE, 0, _("missing arguments")); + default: + abort (); + } print_variables (argv[optind++]); } else { /* Actually perform the substitutions. */ switch (argc - optind) - { - case 1: - all_variables = false; - note_variables (argv[optind++]); - break; - case 0: - all_variables = true; - break; - default: - abort (); - } + { + case 1: + all_variables = false; + note_variables (argv[optind++]); + break; + case 0: + all_variables = true; + break; + default: + abort (); + } subst_from_stdin (); } @@ -169,7 +169,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { /* xgettext: no-wrap */ @@ -234,45 +234,45 @@ of the environment variables that are referenced in SHELL-FORMAT, one per line.\ encodings. */ static void find_variables (const char *string, - void (*callback) (const char *var_ptr, size_t var_len)) + void (*callback) (const char *var_ptr, size_t var_len)) { for (; *string != '\0';) if (*string++ == '$') { - const char *variable_start; - const char *variable_end; - bool valid; - char c; - - if (*string == '{') - string++; - - variable_start = string; - c = *string; - if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '_') - { - do - c = *++string; - while ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') - || (c >= '0' && c <= '9') || c == '_'); - variable_end = string; - - if (variable_start[-1] == '{') - { - if (*string == '}') - { - string++; - valid = true; - } - else - valid = false; - } - else - valid = true; - - if (valid) - callback (variable_start, variable_end - variable_start); - } + const char *variable_start; + const char *variable_end; + bool valid; + char c; + + if (*string == '{') + string++; + + variable_start = string; + c = *string; + if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '_') + { + do + c = *++string; + while ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') + || (c >= '0' && c <= '9') || c == '_'); + variable_end = string; + + if (variable_start[-1] == '{') + { + if (*string == '}') + { + string++; + valid = true; + } + else + valid = false; + } + else + valid = true; + + if (valid) + callback (variable_start, variable_end - variable_start); + } } } @@ -373,22 +373,22 @@ sorted_string_list_member (const string_list_ty *slp, const char *s) { /* Binary search. */ while (j2 - j1 > 1) - { - /* Here we know that if s is in the list, it is at an index j - with j1 <= j < j2. */ - size_t j = (j1 + j2) >> 1; - int result = strcmp (slp->item[j], s); - - if (result > 0) - j2 = j; - else if (result == 0) - return 1; - else - j1 = j + 1; - } + { + /* Here we know that if s is in the list, it is at an index j + with j1 <= j < j2. */ + size_t j = (j1 + j2) >> 1; + int result = strcmp (slp->item[j], s); + + if (result > 0) + j2 = j; + else if (result == 0) + return 1; + else + j1 = j + 1; + } if (j2 > j1) - if (strcmp (slp->item[j1], s) == 0) - return 1; + if (strcmp (slp->item[j1], s) == 0) + return 1; } return 0; } @@ -439,7 +439,7 @@ do_getc () if (c == EOF) { if (ferror (stdin)) - error (EXIT_FAILURE, errno, _("\ + error (EXIT_FAILURE, errno, _("\ error while reading \"%s\""), _("standard input")); } @@ -466,104 +466,104 @@ subst_from_stdin () { c = do_getc (); if (c == EOF) - break; + break; /* Look for $VARIABLE or ${VARIABLE}. */ if (c == '$') - { - bool opening_brace = false; - bool closing_brace = false; - - c = do_getc (); - if (c == '{') - { - opening_brace = true; - c = do_getc (); - } - if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '_') - { - bool valid; - - /* Accumulate the VARIABLE in buffer. */ - buflen = 0; - do - { - if (buflen >= bufmax) - { - bufmax = 2 * bufmax + 10; - buffer = xrealloc (buffer, bufmax); - } - buffer[buflen++] = c; - - c = do_getc (); - } - while ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') - || (c >= '0' && c <= '9') || c == '_'); - - if (opening_brace) - { - if (c == '}') - { - closing_brace = true; - valid = true; - } - else - { - valid = false; - do_ungetc (c); - } - } - else - { - valid = true; - do_ungetc (c); - } - - if (valid) - { - /* Terminate the variable in the buffer. */ - if (buflen >= bufmax) - { - bufmax = 2 * bufmax + 10; - buffer = xrealloc (buffer, bufmax); - } - buffer[buflen] = '\0'; - - /* Test whether the variable shall be substituted. */ - if (!all_variables - && !sorted_string_list_member (&variables_set, buffer)) - valid = false; - } - - if (valid) - { - /* Substitute the variable's value from the environment. */ - const char *env_value = getenv (buffer); - - if (env_value != NULL) - fputs (env_value, stdout); - } - else - { - /* Perform no substitution at all. Since the buffered input - contains no other '$' than at the start, we can just - output all the buffered contents. */ - putchar ('$'); - if (opening_brace) - putchar ('{'); - fwrite (buffer, buflen, 1, stdout); - if (closing_brace) - putchar ('}'); - } - } - else - { - do_ungetc (c); - putchar ('$'); - if (opening_brace) - putchar ('{'); - } - } + { + bool opening_brace = false; + bool closing_brace = false; + + c = do_getc (); + if (c == '{') + { + opening_brace = true; + c = do_getc (); + } + if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '_') + { + bool valid; + + /* Accumulate the VARIABLE in buffer. */ + buflen = 0; + do + { + if (buflen >= bufmax) + { + bufmax = 2 * bufmax + 10; + buffer = xrealloc (buffer, bufmax); + } + buffer[buflen++] = c; + + c = do_getc (); + } + while ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') + || (c >= '0' && c <= '9') || c == '_'); + + if (opening_brace) + { + if (c == '}') + { + closing_brace = true; + valid = true; + } + else + { + valid = false; + do_ungetc (c); + } + } + else + { + valid = true; + do_ungetc (c); + } + + if (valid) + { + /* Terminate the variable in the buffer. */ + if (buflen >= bufmax) + { + bufmax = 2 * bufmax + 10; + buffer = xrealloc (buffer, bufmax); + } + buffer[buflen] = '\0'; + + /* Test whether the variable shall be substituted. */ + if (!all_variables + && !sorted_string_list_member (&variables_set, buffer)) + valid = false; + } + + if (valid) + { + /* Substitute the variable's value from the environment. */ + const char *env_value = getenv (buffer); + + if (env_value != NULL) + fputs (env_value, stdout); + } + else + { + /* Perform no substitution at all. Since the buffered input + contains no other '$' than at the start, we can just + output all the buffered contents. */ + putchar ('$'); + if (opening_brace) + putchar ('{'); + fwrite (buffer, buflen, 1, stdout); + if (closing_brace) + putchar ('}'); + } + } + else + { + do_ungetc (c); + putchar ('$'); + if (opening_brace) + putchar ('{'); + } + } else - putchar (c); + putchar (c); } } diff --git a/gettext-runtime/src/gettext.c b/gettext-runtime/src/gettext.c index c051bf8..1453479 100644 --- a/gettext-runtime/src/gettext.c +++ b/gettext-runtime/src/gettext.c @@ -95,10 +95,10 @@ main (int argc, char *argv[]) /* Parse command line options. */ while ((optchar = getopt_long (argc, argv, "+d:eEhnsV", long_options, NULL)) - != EOF) + != EOF) switch (optchar) { - case '\0': /* Long option. */ + case '\0': /* Long option. */ break; case 'd': domain = optarg; @@ -135,7 +135,7 @@ License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\ This is free software: you are free to change and redistribute it.\n\ There is NO WARRANTY, to the extent permitted by law.\n\ "), - "1995-1997, 2000-2007"); + "1995-1997, 2000-2007"); printf (_("Written by %s.\n"), proper_name ("Ulrich Drepper")); exit (EXIT_SUCCESS); } @@ -152,78 +152,78 @@ There is NO WARRANTY, to the extent permitted by law.\n\ /* Get arguments. */ switch (argc - optind) - { - default: - error (EXIT_FAILURE, 0, _("too many arguments")); + { + default: + error (EXIT_FAILURE, 0, _("too many arguments")); - case 2: - domain = argv[optind++]; - /* FALLTHROUGH */ + case 2: + domain = argv[optind++]; + /* FALLTHROUGH */ - case 1: - break; + case 1: + break; - case 0: - error (EXIT_FAILURE, 0, _("missing arguments")); - } + case 0: + error (EXIT_FAILURE, 0, _("missing arguments")); + } msgid = argv[optind++]; /* Expand escape sequences if enabled. */ if (do_expand) - msgid = expand_escape (msgid); + msgid = expand_escape (msgid); /* If no domain name is given we don't translate. */ if (domain == NULL || domain[0] == '\0') - { - fputs (msgid, stdout); - } + { + fputs (msgid, stdout); + } else - { - /* Bind domain to appropriate directory. */ - if (domaindir != NULL && domaindir[0] != '\0') - bindtextdomain (domain, domaindir); - - /* Write out the result. */ - fputs (dgettext (domain, msgid), stdout); - } + { + /* Bind domain to appropriate directory. */ + if (domaindir != NULL && domaindir[0] != '\0') + bindtextdomain (domain, domaindir); + + /* Write out the result. */ + fputs (dgettext (domain, msgid), stdout); + } } else { if (optind < argc) - { - /* If no domain name is given we print the original string. - We mark this assigning NULL to domain. */ - if (domain == NULL || domain[0] == '\0') - domain = NULL; - else - /* Bind domain to appropriate directory. */ - if (domaindir != NULL && domaindir[0] != '\0') - bindtextdomain (domain, domaindir); - - /* We have to simulate `echo'. All arguments are strings. */ - do - { - msgid = argv[optind++]; - - /* Expand escape sequences if enabled. */ - if (do_expand) - msgid = expand_escape (msgid); - - /* Write out the result. */ - fputs (domain == NULL ? msgid : dgettext (domain, msgid), - stdout); - - /* We separate the arguments by a single ' '. */ - if (optind < argc) - fputc (' ', stdout); - } - while (optind < argc); - } + { + /* If no domain name is given we print the original string. + We mark this assigning NULL to domain. */ + if (domain == NULL || domain[0] == '\0') + domain = NULL; + else + /* Bind domain to appropriate directory. */ + if (domaindir != NULL && domaindir[0] != '\0') + bindtextdomain (domain, domaindir); + + /* We have to simulate `echo'. All arguments are strings. */ + do + { + msgid = argv[optind++]; + + /* Expand escape sequences if enabled. */ + if (do_expand) + msgid = expand_escape (msgid); + + /* Write out the result. */ + fputs (domain == NULL ? msgid : dgettext (domain, msgid), + stdout); + + /* We separate the arguments by a single ' '. */ + if (optind < argc) + fputc (' ', stdout); + } + while (optind < argc); + } /* If not otherwise told: add trailing newline. */ if (add_newline) - fputc ('\n', stdout); + fputc ('\n', stdout); } exit (EXIT_SUCCESS); @@ -236,7 +236,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { /* xgettext: no-wrap */ @@ -270,7 +270,7 @@ When used with the -s option the program behaves like the `echo' command.\n\ But it does not simply copy its arguments to stdout. Instead those messages\n\ found in the selected catalog are translated.\n\ Standard search directory: %s\n"), - getenv ("IN_HELP2MAN") == NULL ? LOCALEDIR : "@localedir@"); + getenv ("IN_HELP2MAN") == NULL ? LOCALEDIR : "@localedir@"); printf ("\n"); /* TRANSLATORS: The placeholder indicates the bug-reporting address for this package. Please add _another line_ saying @@ -293,14 +293,14 @@ expand_escape (const char *str) for (;;) { while (cp[0] != '\0' && cp[0] != '\\') - ++cp; + ++cp; if (cp[0] == '\0') - return str; + return str; /* Found a backslash. */ if (cp[1] == '\0') - return str; + return str; if (strchr ("abcfnrtv\\01234567", cp[1]) != NULL) - break; + break; ++cp; } @@ -313,69 +313,69 @@ expand_escape (const char *str) { /* Here cp[0] == '\\'. */ switch (*++cp) - { - case 'a': /* alert */ - *rp++ = '\a'; - ++cp; - break; - case 'b': /* backspace */ - *rp++ = '\b'; - ++cp; - break; - case 'c': /* suppress trailing newline */ - add_newline = false; - ++cp; - break; - case 'f': /* form feed */ - *rp++ = '\f'; - ++cp; - break; - case 'n': /* new line */ - *rp++ = '\n'; - ++cp; - break; - case 'r': /* carriage return */ - *rp++ = '\r'; - ++cp; - break; - case 't': /* horizontal tab */ - *rp++ = '\t'; - ++cp; - break; - case 'v': /* vertical tab */ - *rp++ = '\v'; - ++cp; - break; - case '\\': - *rp = '\\'; - ++cp; - break; - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - { - int ch = *cp++ - '0'; - - if (*cp >= '0' && *cp <= '7') - { - ch *= 8; - ch += *cp++ - '0'; - - if (*cp >= '0' && *cp <= '7') - { - ch *= 8; - ch += *cp++ - '0'; - } - } - *rp = ch; - } - break; - default: - *rp = '\\'; - break; - } + { + case 'a': /* alert */ + *rp++ = '\a'; + ++cp; + break; + case 'b': /* backspace */ + *rp++ = '\b'; + ++cp; + break; + case 'c': /* suppress trailing newline */ + add_newline = false; + ++cp; + break; + case 'f': /* form feed */ + *rp++ = '\f'; + ++cp; + break; + case 'n': /* new line */ + *rp++ = '\n'; + ++cp; + break; + case 'r': /* carriage return */ + *rp++ = '\r'; + ++cp; + break; + case 't': /* horizontal tab */ + *rp++ = '\t'; + ++cp; + break; + case 'v': /* vertical tab */ + *rp++ = '\v'; + ++cp; + break; + case '\\': + *rp = '\\'; + ++cp; + break; + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + { + int ch = *cp++ - '0'; + + if (*cp >= '0' && *cp <= '7') + { + ch *= 8; + ch += *cp++ - '0'; + + if (*cp >= '0' && *cp <= '7') + { + ch *= 8; + ch += *cp++ - '0'; + } + } + *rp = ch; + } + break; + default: + *rp = '\\'; + break; + } while (cp[0] != '\0' && cp[0] != '\\') - *rp++ = *cp++; + *rp++ = *cp++; } while (cp[0] != '\0'); diff --git a/gettext-runtime/src/ngettext.c b/gettext-runtime/src/ngettext.c index be39463..8a8ecb5 100644 --- a/gettext-runtime/src/ngettext.c +++ b/gettext-runtime/src/ngettext.c @@ -91,10 +91,10 @@ main (int argc, char *argv[]) /* Parse command line options. */ while ((optchar = getopt_long (argc, argv, "+d:eEhV", long_options, NULL)) - != EOF) + != EOF) switch (optchar) { - case '\0': /* Long option. */ + case '\0': /* Long option. */ break; case 'd': domain = optarg; @@ -125,7 +125,7 @@ License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\ This is free software: you are free to change and redistribute it.\n\ There is NO WARRANTY, to the extent permitted by law.\n\ "), - "1995-1997, 2000-2007"); + "1995-1997, 2000-2007"); printf (_("Written by %s.\n"), proper_name ("Ulrich Drepper")); exit (EXIT_SUCCESS); } @@ -189,7 +189,7 @@ There is NO WARRANTY, to the extent permitted by law.\n\ { /* Bind domain to appropriate directory. */ if (domaindir != NULL && domaindir[0] != '\0') - bindtextdomain (domain, domaindir); + bindtextdomain (domain, domaindir); /* Write out the result. */ fputs (dngettext (domain, msgid, msgid_plural, n), stdout); @@ -205,7 +205,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { /* xgettext: no-wrap */ @@ -236,7 +236,7 @@ environment variable TEXTDOMAIN. If the message catalog is not found in the\n\ regular directory, another location can be specified with the environment\n\ variable TEXTDOMAINDIR.\n\ Standard search directory: %s\n"), - getenv ("IN_HELP2MAN") == NULL ? LOCALEDIR : "@localedir@"); + getenv ("IN_HELP2MAN") == NULL ? LOCALEDIR : "@localedir@"); printf ("\n"); /* TRANSLATORS: The placeholder indicates the bug-reporting address for this package. Please add _another line_ saying @@ -259,14 +259,14 @@ expand_escape (const char *str) for (;;) { while (cp[0] != '\0' && cp[0] != '\\') - ++cp; + ++cp; if (cp[0] == '\0') - return str; + return str; /* Found a backslash. */ if (cp[1] == '\0') - return str; + return str; if (strchr ("abcfnrtv\\01234567", cp[1]) != NULL) - break; + break; ++cp; } @@ -279,65 +279,65 @@ expand_escape (const char *str) { /* Here cp[0] == '\\'. */ switch (*++cp) - { - case 'a': /* alert */ - *rp++ = '\a'; - ++cp; - break; - case 'b': /* backspace */ - *rp++ = '\b'; - ++cp; - break; - case 'f': /* form feed */ - *rp++ = '\f'; - ++cp; - break; - case 'n': /* new line */ - *rp++ = '\n'; - ++cp; - break; - case 'r': /* carriage return */ - *rp++ = '\r'; - ++cp; - break; - case 't': /* horizontal tab */ - *rp++ = '\t'; - ++cp; - break; - case 'v': /* vertical tab */ - *rp++ = '\v'; - ++cp; - break; - case '\\': - *rp = '\\'; - ++cp; - break; - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - { - int ch = *cp++ - '0'; - - if (*cp >= '0' && *cp <= '7') - { - ch *= 8; - ch += *cp++ - '0'; - - if (*cp >= '0' && *cp <= '7') - { - ch *= 8; - ch += *cp++ - '0'; - } - } - *rp = ch; - } - break; - default: - *rp = '\\'; - break; - } + { + case 'a': /* alert */ + *rp++ = '\a'; + ++cp; + break; + case 'b': /* backspace */ + *rp++ = '\b'; + ++cp; + break; + case 'f': /* form feed */ + *rp++ = '\f'; + ++cp; + break; + case 'n': /* new line */ + *rp++ = '\n'; + ++cp; + break; + case 'r': /* carriage return */ + *rp++ = '\r'; + ++cp; + break; + case 't': /* horizontal tab */ + *rp++ = '\t'; + ++cp; + break; + case 'v': /* vertical tab */ + *rp++ = '\v'; + ++cp; + break; + case '\\': + *rp = '\\'; + ++cp; + break; + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + { + int ch = *cp++ - '0'; + + if (*cp >= '0' && *cp <= '7') + { + ch *= 8; + ch += *cp++ - '0'; + + if (*cp >= '0' && *cp <= '7') + { + ch *= 8; + ch += *cp++ - '0'; + } + } + *rp = ch; + } + break; + default: + *rp = '\\'; + break; + } while (cp[0] != '\0' && cp[0] != '\\') - *rp++ = *cp++; + *rp++ = *cp++; } while (cp[0] != '\0'); |