From: Bruno Haible Date: Thu, 9 Oct 2003 10:04:26 +0000 (+0000) Subject: Remove extraneous optimization of extract_all. X-Git-Tag: v0.13~218 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7474a39c0d7791db008a1939a68a31e100d64762;p=thirdparty%2Fgettext.git Remove extraneous optimization of extract_all. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index c7bf9a60e..2217514ec 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,16 @@ +2003-09-23 Bruno Haible + + * x-awk.c (extract_parenthesized): Remove optimization of the + extract_all case. + * x-c.c (extract_parenthesized): Likewise. + * x-elisp.c (read_object): Likewise. + * x-librep.c (read_object): Likewise. + * x-lisp.c (read_object): Likewise. + * x-perl.c (x_perl_prelex, extract_balanced): Likewise. + * x-php.c (extract_parenthesized): Likewise. + * x-python.c (extract_parenthesized): Likewise. + * x-sh.c (read_command): Likewise. + 2003-10-08 Bruno Haible * msgmerge.c (main): Make option -N work. diff --git a/gettext-tools/src/x-awk.c b/gettext-tools/src/x-awk.c index 40d1194ea..5d5dfefa4 100644 --- a/gettext-tools/src/x-awk.c +++ b/gettext-tools/src/x-awk.c @@ -689,32 +689,27 @@ extract_parenthesized (message_list_ty *mlp, switch (token.type) { case token_type_symbol: - /* No need to bother if we extract all strings anyway. */ - if (!extract_all) - { - void *keyword_value; + { + void *keyword_value; - if (find_entry (&keywords, token.string, strlen (token.string), - &keyword_value) - == 0) - { - int argnum1 = (int) (long) keyword_value & ((1 << 10) - 1); - int argnum2 = (int) (long) keyword_value >> 10; + if (find_entry (&keywords, token.string, strlen (token.string), + &keyword_value) + == 0) + { + int argnum1 = (int) (long) keyword_value & ((1 << 10) - 1); + int argnum2 = (int) (long) keyword_value >> 10; - next_commas_to_skip = argnum1 - 1; - next_plural_commas = (argnum2 > argnum1 ? argnum2 - argnum1 : 0); - state = 1; - } - else - state = 0; - } + next_commas_to_skip = argnum1 - 1; + next_plural_commas = (argnum2 > argnum1 ? argnum2 - argnum1 : 0); + state = 1; + } + else + state = 0; + } free (token.string); continue; case token_type_lparen: - /* No need to recurse if we extract all strings anyway. */ - if (extract_all) - continue; if (state ? extract_parenthesized (mlp, next_commas_to_skip, next_plural_commas) @@ -724,15 +719,9 @@ extract_parenthesized (message_list_ty *mlp, continue; case token_type_rparen: - /* No need to return if we extract all strings anyway. */ - if (extract_all) - continue; return false; case token_type_comma: - /* No need to bother if we extract all strings anyway. */ - if (extract_all) - continue; if (commas_to_skip >= 0) { if (commas_to_skip > 0) @@ -779,10 +768,10 @@ extract_parenthesized (message_list_ty *mlp, } else free (token.string); - state = 0; } - continue; } + state = 0; + continue; case token_type_i18nstring: { diff --git a/gettext-tools/src/x-c.c b/gettext-tools/src/x-c.c index 05797fb51..cb0d548d9 100644 --- a/gettext-tools/src/x-c.c +++ b/gettext-tools/src/x-c.c @@ -1373,9 +1373,6 @@ extract_parenthesized (message_list_ty *mlp, switch (token.type) { case xgettext_token_type_keyword: - /* No need to bother if we extract all strings anyway. */ - if (extract_all) - continue; next_commas_to_skip = token.argnum1 - 1; next_plural_commas = (token.argnum2 > token.argnum1 ? token.argnum2 - token.argnum1 : 0); @@ -1383,9 +1380,6 @@ extract_parenthesized (message_list_ty *mlp, continue; case xgettext_token_type_lparen: - /* No need to recurse if we extract all strings anyway. */ - if (extract_all) - continue; if (state ? extract_parenthesized (mlp, next_commas_to_skip, next_plural_commas) @@ -1395,15 +1389,9 @@ extract_parenthesized (message_list_ty *mlp, continue; case xgettext_token_type_rparen: - /* No need to return if we extract all strings anyway. */ - if (extract_all) - continue; return false; case xgettext_token_type_comma: - /* No need to bother if we extract all strings anyway. */ - if (extract_all) - continue; if (commas_to_skip >= 0) { if (commas_to_skip > 0) @@ -1445,8 +1433,8 @@ extract_parenthesized (message_list_ty *mlp, } else free (token.string); - state = 0; } + state = 0; continue; case xgettext_token_type_symbol: diff --git a/gettext-tools/src/x-elisp.c b/gettext-tools/src/x-elisp.c index 9c0fb9403..7bd7b3e10 100644 --- a/gettext-tools/src/x-elisp.c +++ b/gettext-tools/src/x-elisp.c @@ -660,58 +660,54 @@ read_object (struct object *op, bool first_in_list, bool new_backquote_flag) if (inner.type == t_eof) break; - /* No need to bother if we extract all strings anyway. */ - if (!extract_all) + if (arg == 0) { - if (arg == 0) + /* This is the function position. */ + if (inner.type == t_symbol) { - /* This is the function position. */ - if (inner.type == t_symbol) + char *symbol_name = string_of_object (&inner); + void *keyword_value; + + if (find_entry (&keywords, + symbol_name, strlen (symbol_name), + &keyword_value) + == 0) { - char *symbol_name = string_of_object (&inner); - void *keyword_value; - - if (find_entry (&keywords, - symbol_name, strlen (symbol_name), - &keyword_value) - == 0) - { - argnum1 = (int) (long) keyword_value & ((1 << 10) - 1); - argnum2 = (int) (long) keyword_value >> 10; - } - - free (symbol_name); + argnum1 = (int) (long) keyword_value & ((1 << 10) - 1); + argnum2 = (int) (long) keyword_value >> 10; } + + free (symbol_name); } - else + } + else + { + /* These are the argument positions. + Extract a string if we have reached the right + argument position. */ + if (arg == argnum1) { - /* These are the argument positions. - Extract a string if we have reached the right - argument position. */ - if (arg == argnum1) + if (inner.type == t_string) { - if (inner.type == t_string) - { - lex_pos_ty pos; - message_ty *mp; - - pos.file_name = logical_file_name; - pos.line_number = inner.line_number_at_start; - mp = remember_a_message (mlp, string_of_object (&inner), &pos); - if (argnum2 > 0) - plural_mp = mp; - } + lex_pos_ty pos; + message_ty *mp; + + pos.file_name = logical_file_name; + pos.line_number = inner.line_number_at_start; + mp = remember_a_message (mlp, string_of_object (&inner), &pos); + if (argnum2 > 0) + plural_mp = mp; } - else if (arg == argnum2) + } + else if (arg == argnum2) + { + if (inner.type == t_string && plural_mp != NULL) { - if (inner.type == t_string && plural_mp != NULL) - { - lex_pos_ty pos; - - pos.file_name = logical_file_name; - pos.line_number = inner.line_number_at_start; - remember_a_message_plural (plural_mp, string_of_object (&inner), &pos); - } + lex_pos_ty pos; + + pos.file_name = logical_file_name; + pos.line_number = inner.line_number_at_start; + remember_a_message_plural (plural_mp, string_of_object (&inner), &pos); } } } diff --git a/gettext-tools/src/x-librep.c b/gettext-tools/src/x-librep.c index 82d5bf28e..036c3686f 100644 --- a/gettext-tools/src/x-librep.c +++ b/gettext-tools/src/x-librep.c @@ -636,58 +636,54 @@ read_object (struct object *op) if (inner.type == t_eof) break; - /* No need to bother if we extract all strings anyway. */ - if (!extract_all) + if (arg == 0) { - if (arg == 0) + /* This is the function position. */ + if (inner.type == t_symbol) { - /* This is the function position. */ - if (inner.type == t_symbol) - { - char *symbol_name = string_of_object (&inner); - void *keyword_value; - - if (find_entry (&keywords, - symbol_name, strlen (symbol_name), - &keyword_value) - == 0) - { - argnum1 = (int) (long) keyword_value & ((1 << 10) - 1); - argnum2 = (int) (long) keyword_value >> 10; - } + char *symbol_name = string_of_object (&inner); + void *keyword_value; - free (symbol_name); + if (find_entry (&keywords, + symbol_name, strlen (symbol_name), + &keyword_value) + == 0) + { + argnum1 = (int) (long) keyword_value & ((1 << 10) - 1); + argnum2 = (int) (long) keyword_value >> 10; } + + free (symbol_name); } - else + } + else + { + /* These are the argument positions. + Extract a string if we have reached the right + argument position. */ + if (arg == argnum1) { - /* These are the argument positions. - Extract a string if we have reached the right - argument position. */ - if (arg == argnum1) + if (inner.type == t_string) { - if (inner.type == t_string) - { - lex_pos_ty pos; - message_ty *mp; - - pos.file_name = logical_file_name; - pos.line_number = inner.line_number_at_start; - mp = remember_a_message (mlp, string_of_object (&inner), &pos); - if (argnum2 > 0) - plural_mp = mp; - } + lex_pos_ty pos; + message_ty *mp; + + pos.file_name = logical_file_name; + pos.line_number = inner.line_number_at_start; + mp = remember_a_message (mlp, string_of_object (&inner), &pos); + if (argnum2 > 0) + plural_mp = mp; } - else if (arg == argnum2) + } + else if (arg == argnum2) + { + if (inner.type == t_string && plural_mp != NULL) { - if (inner.type == t_string && plural_mp != NULL) - { - lex_pos_ty pos; + lex_pos_ty pos; - pos.file_name = logical_file_name; - pos.line_number = inner.line_number_at_start; - remember_a_message_plural (plural_mp, string_of_object (&inner), &pos); - } + pos.file_name = logical_file_name; + pos.line_number = inner.line_number_at_start; + remember_a_message_plural (plural_mp, string_of_object (&inner), &pos); } } } diff --git a/gettext-tools/src/x-lisp.c b/gettext-tools/src/x-lisp.c index 4828b8ef0..14cf7db46 100644 --- a/gettext-tools/src/x-lisp.c +++ b/gettext-tools/src/x-lisp.c @@ -1025,68 +1025,64 @@ read_object (struct object *op) if (inner.type == t_eof) break; - /* No need to bother if we extract all strings anyway. */ - if (!extract_all) + if (arg == 0) { - if (arg == 0) + /* This is the function position. */ + if (inner.type == t_symbol) { - /* This is the function position. */ - if (inner.type == t_symbol) + char *symbol_name = string_of_object (&inner); + int i; + int prefix_len; + void *keyword_value; + + /* Omit any package name. */ + i = inner.token->charcount; + while (i > 0 + && inner.token->chars[i-1].attribute != a_pack_m) + i--; + prefix_len = i; + + if (find_entry (&keywords, + symbol_name + prefix_len, + strlen (symbol_name + prefix_len), + &keyword_value) + == 0) { - char *symbol_name = string_of_object (&inner); - int i; - int prefix_len; - void *keyword_value; - - /* Omit any package name. */ - i = inner.token->charcount; - while (i > 0 - && inner.token->chars[i-1].attribute != a_pack_m) - i--; - prefix_len = i; - - if (find_entry (&keywords, - symbol_name + prefix_len, - strlen (symbol_name + prefix_len), - &keyword_value) - == 0) - { - argnum1 = (int) (long) keyword_value & ((1 << 10) - 1); - argnum2 = (int) (long) keyword_value >> 10; - } - - free (symbol_name); + argnum1 = (int) (long) keyword_value & ((1 << 10) - 1); + argnum2 = (int) (long) keyword_value >> 10; } + + free (symbol_name); } - else + } + else + { + /* These are the argument positions. + Extract a string if we have reached the right + argument position. */ + if (arg == argnum1) { - /* These are the argument positions. - Extract a string if we have reached the right - argument position. */ - if (arg == argnum1) + if (inner.type == t_string) { - if (inner.type == t_string) - { - lex_pos_ty pos; - message_ty *mp; - - pos.file_name = logical_file_name; - pos.line_number = inner.line_number_at_start; - mp = remember_a_message (mlp, string_of_object (&inner), &pos); - if (argnum2 > 0) - plural_mp = mp; - } + lex_pos_ty pos; + message_ty *mp; + + pos.file_name = logical_file_name; + pos.line_number = inner.line_number_at_start; + mp = remember_a_message (mlp, string_of_object (&inner), &pos); + if (argnum2 > 0) + plural_mp = mp; } - else if (arg == argnum2) + } + else if (arg == argnum2) + { + if (inner.type == t_string && plural_mp != NULL) { - if (inner.type == t_string && plural_mp != NULL) - { - lex_pos_ty pos; - - pos.file_name = logical_file_name; - pos.line_number = inner.line_number_at_start; - remember_a_message_plural (plural_mp, string_of_object (&inner), &pos); - } + lex_pos_ty pos; + + pos.file_name = logical_file_name; + pos.line_number = inner.line_number_at_start; + remember_a_message_plural (plural_mp, string_of_object (&inner), &pos); } } } diff --git a/gettext-tools/src/x-perl.c b/gettext-tools/src/x-perl.c index 4af37e5d4..03a8b1cfe 100644 --- a/gettext-tools/src/x-perl.c +++ b/gettext-tools/src/x-perl.c @@ -2024,8 +2024,7 @@ x_perl_prelex (message_list_ty *mlp, token_ty *tp) return; } extract_triple_quotelike (mlp, tp, delim, - buffer[0] == 's' && !extract_all - && delim != '\''); + buffer[0] == 's' && delim != '\''); /* Eat the following modifiers. */ do @@ -2059,7 +2058,7 @@ x_perl_prelex (message_list_ty *mlp, token_ty *tp) return; } extract_quotelike (tp, delim); - if (!extract_all && delim != '\'') + if (delim != '\'') interpolate_keywords (mlp, tp->string, line_number); free (tp->string); tp->type = token_type_regex_op; @@ -2116,8 +2115,7 @@ x_perl_prelex (message_list_ty *mlp, token_ty *tp) case 'x': tp->type = token_type_string; tp->sub_type = string_type_qq; - if (!extract_all) - interpolate_keywords (mlp, tp->string, line_number); + interpolate_keywords (mlp, tp->string, line_number); break; case 'r': tp->type = token_type_regex_op; @@ -2151,16 +2149,14 @@ x_perl_prelex (message_list_ty *mlp, token_ty *tp) prefer_division_over_regexp = true; extract_quotelike (tp, c); tp->sub_type = string_type_qq; - if (!extract_all) - interpolate_keywords (mlp, tp->string, line_number); + interpolate_keywords (mlp, tp->string, line_number); return; case '`': prefer_division_over_regexp = true; extract_quotelike (tp, c); tp->sub_type = string_type_qq; - if (!extract_all) - interpolate_keywords (mlp, tp->string, line_number); + interpolate_keywords (mlp, tp->string, line_number); return; case '\'': @@ -2274,8 +2270,7 @@ x_perl_prelex (message_list_ty *mlp, token_ty *tp) tp->type = token_type_string; tp->sub_type = string_type_qq; tp->line_number = line_number + 1; - if (!extract_all) - interpolate_keywords (mlp, tp->string, line_number + 1); + interpolate_keywords (mlp, tp->string, line_number + 1); return; } else if ((c >= 'A' && c <= 'Z') @@ -2316,8 +2311,7 @@ x_perl_prelex (message_list_ty *mlp, token_ty *tp) tp->type = token_type_string; tp->sub_type = string_type_qq; tp->line_number = line_number + 1; - if (!extract_all) - interpolate_keywords (mlp, tp->string, line_number + 1); + interpolate_keywords (mlp, tp->string, line_number + 1); return; } } @@ -2352,8 +2346,7 @@ x_perl_prelex (message_list_ty *mlp, token_ty *tp) if (!prefer_division_over_regexp) { extract_quotelike (tp, c); - if (!extract_all) - interpolate_keywords (mlp, tp->string, line_number); + interpolate_keywords (mlp, tp->string, line_number); free (tp->string); tp->type = token_type_other; prefer_division_over_regexp = true; @@ -2731,23 +2724,21 @@ extract_balanced (message_list_ty *mlp, int arg_sg, int arg_pl, int state, tp->string); #endif - /* No need to bother if we extract all strings anyway. */ - if (!extract_all) - { - void *keyword_value; + { + void *keyword_value; - if (find_entry (&keywords, tp->string, strlen (tp->string), - &keyword_value) == 0) - { - last_token = token_type_keyword_symbol; + if (find_entry (&keywords, tp->string, strlen (tp->string), + &keyword_value) == 0) + { + last_token = token_type_keyword_symbol; - arg_sg = (int) (long) keyword_value & ((1 << 10) - 1); - arg_pl = (int) (long) keyword_value >> 10; - arg_count = 1; + arg_sg = (int) (long) keyword_value & ((1 << 10) - 1); + arg_pl = (int) (long) keyword_value >> 10; + arg_count = 1; - state = 2; - } - } + state = 2; + } + } break; case token_type_variable: @@ -2765,21 +2756,15 @@ extract_balanced (message_list_ty *mlp, int arg_sg, int arg_pl, int state, #endif ++paren_seen; - /* No need to recurse if we extract all strings anyway. */ - if (extract_all) - ; - else + if (extract_balanced (mlp, arg_sg - arg_count + 1, + arg_pl - arg_count + 1, state, + token_type_rparen)) { - if (extract_balanced (mlp, arg_sg - arg_count + 1, - arg_pl - arg_count + 1, state, - token_type_rparen)) - { - free_token (tp); - return true; - } - if (my_last_token == token_type_keyword_symbol) - arg_sg = arg_pl = -1; + free_token (tp); + return true; } + if (my_last_token == token_type_keyword_symbol) + arg_sg = arg_pl = -1; break; case token_type_rparen: @@ -2788,11 +2773,6 @@ extract_balanced (message_list_ty *mlp, int arg_sg, int arg_pl, int state, logical_file_name, tp->line_number, nesting_level); #endif --paren_seen; - - /* No need to return if we extract all strings anyway. */ - if (extract_all) - ; - break; case token_type_comma: @@ -2801,25 +2781,18 @@ extract_balanced (message_list_ty *mlp, int arg_sg, int arg_pl, int state, fprintf (stderr, "%s:%d: type comma (%d)\n", logical_file_name, tp->line_number, nesting_level); #endif - /* No need to bother if we extract all strings anyway. */ - if (extract_all) - ; - else + ++arg_count; + if (arg_count > arg_sg && arg_count > arg_pl) { - ++arg_count; - - if (arg_count > arg_sg && arg_count > arg_pl) - { - /* We have missed the argument. */ - arg_sg = arg_pl = -1; - arg_count = 0; - } + /* We have missed the argument. */ + arg_sg = arg_pl = -1; + arg_count = 0; + } #if DEBUG_PERL - fprintf (stderr, "%s:%d: arg_count: %d, arg_sg: %d, arg_pl: %d\n", - real_file_name, tp->line_number, - arg_count, arg_sg, arg_pl); + fprintf (stderr, "%s:%d: arg_count: %d, arg_sg: %d, arg_pl: %d\n", + real_file_name, tp->line_number, + arg_count, arg_sg, arg_pl); #endif - } break; case token_type_string: @@ -2895,16 +2868,10 @@ extract_balanced (message_list_ty *mlp, int arg_sg, int arg_pl, int state, fprintf (stderr, "%s:%d: type lbrace (%d)\n", logical_file_name, tp->line_number, nesting_level); #endif - /* No need to recurse if we extract all strings anyway. */ - if (extract_all) - ; - else + if (extract_balanced (mlp, -1, -1, 0, token_type_rbrace)) { - if (extract_balanced (mlp, -1, -1, 0, token_type_rbrace)) - { - free_token (tp); - return true; - } + free_token (tp); + return true; } break; @@ -2921,16 +2888,10 @@ extract_balanced (message_list_ty *mlp, int arg_sg, int arg_pl, int state, fprintf (stderr, "%s:%d: type lbracket (%d)\n", logical_file_name, tp->line_number, nesting_level); #endif - /* No need to recurse if we extract all strings anyway. */ - if (extract_all) - ; - else + if (extract_balanced (mlp, -1, -1, 0, token_type_rbracket)) { - if (extract_balanced (mlp, -1, -1, 0, token_type_rbracket)) - { - free_token (tp); - return true; - } + free_token (tp); + return true; } break; diff --git a/gettext-tools/src/x-php.c b/gettext-tools/src/x-php.c index fc7bd2456..027b74e1c 100644 --- a/gettext-tools/src/x-php.c +++ b/gettext-tools/src/x-php.c @@ -1211,32 +1211,27 @@ extract_parenthesized (message_list_ty *mlp, switch (token.type) { case token_type_symbol: - /* No need to bother if we extract all strings anyway. */ - if (!extract_all) - { - void *keyword_value; + { + void *keyword_value; - if (find_entry (&keywords, token.string, strlen (token.string), - &keyword_value) - == 0) - { - int argnum1 = (int) (long) keyword_value & ((1 << 10) - 1); - int argnum2 = (int) (long) keyword_value >> 10; + if (find_entry (&keywords, token.string, strlen (token.string), + &keyword_value) + == 0) + { + int argnum1 = (int) (long) keyword_value & ((1 << 10) - 1); + int argnum2 = (int) (long) keyword_value >> 10; - next_commas_to_skip = argnum1 - 1; - next_plural_commas = (argnum2 > argnum1 ? argnum2 - argnum1 : 0); - state = 1; - } - else - state = 0; - } + next_commas_to_skip = argnum1 - 1; + next_plural_commas = (argnum2 > argnum1 ? argnum2 - argnum1 : 0); + state = 1; + } + else + state = 0; + } free (token.string); continue; case token_type_lparen: - /* No need to recurse if we extract all strings anyway. */ - if (extract_all) - continue; if (state ? extract_parenthesized (mlp, next_commas_to_skip, next_plural_commas) @@ -1246,15 +1241,9 @@ extract_parenthesized (message_list_ty *mlp, continue; case token_type_rparen: - /* No need to return if we extract all strings anyway. */ - if (extract_all) - continue; return false; case token_type_comma: - /* No need to bother if we extract all strings anyway. */ - if (extract_all) - continue; if (commas_to_skip >= 0) { if (commas_to_skip > 0) @@ -1301,10 +1290,10 @@ extract_parenthesized (message_list_ty *mlp, } else free (token.string); - state = 0; } - continue; } + state = 0; + continue; case token_type_other: state = 0; diff --git a/gettext-tools/src/x-python.c b/gettext-tools/src/x-python.c index 6f1a8d53f..e59ee750c 100644 --- a/gettext-tools/src/x-python.c +++ b/gettext-tools/src/x-python.c @@ -1014,32 +1014,27 @@ extract_parenthesized (message_list_ty *mlp, switch (token.type) { case token_type_symbol: - /* No need to bother if we extract all strings anyway. */ - if (!extract_all) - { - void *keyword_value; + { + void *keyword_value; - if (find_entry (&keywords, token.string, strlen (token.string), - &keyword_value) - == 0) - { - int argnum1 = (int) (long) keyword_value & ((1 << 10) - 1); - int argnum2 = (int) (long) keyword_value >> 10; + if (find_entry (&keywords, token.string, strlen (token.string), + &keyword_value) + == 0) + { + int argnum1 = (int) (long) keyword_value & ((1 << 10) - 1); + int argnum2 = (int) (long) keyword_value >> 10; - next_commas_to_skip = argnum1 - 1; - next_plural_commas = (argnum2 > argnum1 ? argnum2 - argnum1 : 0); - state = 1; - } - else - state = 0; - } + next_commas_to_skip = argnum1 - 1; + next_plural_commas = (argnum2 > argnum1 ? argnum2 - argnum1 : 0); + state = 1; + } + else + state = 0; + } free (token.string); continue; case token_type_lparen: - /* No need to recurse if we extract all strings anyway. */ - if (extract_all) - continue; if (state ? extract_parenthesized (mlp, next_commas_to_skip, next_plural_commas) @@ -1049,15 +1044,9 @@ extract_parenthesized (message_list_ty *mlp, continue; case token_type_rparen: - /* No need to return if we extract all strings anyway. */ - if (extract_all) - continue; return false; case token_type_comma: - /* No need to bother if we extract all strings anyway. */ - if (extract_all) - continue; if (commas_to_skip >= 0) { if (commas_to_skip > 0) @@ -1104,10 +1093,10 @@ extract_parenthesized (message_list_ty *mlp, } else free (token.string); - state = 0; } - continue; } + state = 0; + continue; case token_type_eof: return true; diff --git a/gettext-tools/src/x-sh.c b/gettext-tools/src/x-sh.c index 16d26ab7d..3cef49f95 100644 --- a/gettext-tools/src/x-sh.c +++ b/gettext-tools/src/x-sh.c @@ -1114,83 +1114,81 @@ read_command (int looking_for) remember_a_message (mlp, string_of_word (&inner), &pos); } } + + if (arg_of_redirect) + { + /* Ignore arguments of redirection operators. */ + arg_of_redirect = false; + } + else if (inner.type == t_redirect) + { + /* Ignore this word and the following one. */ + arg_of_redirect = true; + } else { - if (arg_of_redirect) - { - /* Ignore arguments of redirection operators. */ - arg_of_redirect = false; - } - else if (inner.type == t_redirect) + if (argnum1 < 0 && argnum2 < 0) { - /* Ignore this word and the following one. */ - arg_of_redirect = true; + /* This is the function position. */ + arg = 0; + if (inner.type == t_string) + { + char *function_name = string_of_word (&inner); + void *keyword_value; + + if (find_entry (&keywords, + function_name, strlen (function_name), + &keyword_value) + == 0) + { + argnum1 = (int) (long) keyword_value & ((1 << 10) - 1); + argnum2 = (int) (long) keyword_value >> 10; + } + + free (function_name); + } } else { - if (argnum1 < 0 && argnum2 < 0) + /* These are the argument positions. + Extract a string if we have reached the right + argument position. */ + if (arg == argnum1) { - /* This is the function position. */ - arg = 0; if (inner.type == t_string) { - char *function_name = string_of_word (&inner); - void *keyword_value; - - if (find_entry (&keywords, - function_name, strlen (function_name), - &keyword_value) - == 0) - { - argnum1 = (int) (long) keyword_value & ((1 << 10) - 1); - argnum2 = (int) (long) keyword_value >> 10; - } - - free (function_name); + lex_pos_ty pos; + message_ty *mp; + + pos.file_name = logical_file_name; + pos.line_number = inner.line_number_at_start; + mp = remember_a_message (mlp, string_of_word (&inner), &pos); + if (argnum2 > 0) + plural_mp = mp; } } - else + else if (arg == argnum2) { - /* These are the argument positions. - Extract a string if we have reached the right - argument position. */ - if (arg == argnum1) - { - if (inner.type == t_string) - { - lex_pos_ty pos; - message_ty *mp; - - pos.file_name = logical_file_name; - pos.line_number = inner.line_number_at_start; - mp = remember_a_message (mlp, string_of_word (&inner), &pos); - if (argnum2 > 0) - plural_mp = mp; - } - } - else if (arg == argnum2) + if (inner.type == t_string && plural_mp != NULL) { - if (inner.type == t_string && plural_mp != NULL) - { - lex_pos_ty pos; + lex_pos_ty pos; - pos.file_name = logical_file_name; - pos.line_number = inner.line_number_at_start; - remember_a_message_plural (plural_mp, string_of_word (&inner), &pos); - } - } - - if (arg >= argnum1 && arg >= argnum2) - { - /* Stop looking for arguments of the last function_name. */ - argnum1 = -1; - argnum2 = -1; - plural_mp = NULL; + pos.file_name = logical_file_name; + pos.line_number = inner.line_number_at_start; + remember_a_message_plural (plural_mp, string_of_word (&inner), &pos); } } - arg++; + if (arg >= argnum1 && arg >= argnum2) + { + /* Stop looking for arguments of the last function_name. */ + argnum1 = -1; + argnum2 = -1; + plural_mp = NULL; + } } + + arg++; } free_word (&inner);