From: Bruno Haible Date: Mon, 3 Dec 2001 14:14:35 +0000 (+0000) Subject: Make it possible to match static method names. X-Git-Tag: v0.11~236 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1de33cc8d1469b84aa62801ebec5be228cb01f46;p=thirdparty%2Fgettext.git Make it possible to match static method names. --- diff --git a/src/ChangeLog b/src/ChangeLog index a6e708089..e659be43b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2001-12-03 Tommy Johansson + + * x-java.l (tailcmp): New function. + (do_compare): Use it instead of strcmp. + (extract_java): After seeing an invocation, don't set the state to + STATE_NONE. + 2001-11-30 Bruno Haible * message.c (message_merge): Determine whether postprocessing is diff --git a/src/x-java.l b/src/x-java.l index 237b4f099..883f71a4d 100644 --- a/src/x-java.l +++ b/src/x-java.l @@ -102,6 +102,7 @@ static char *append_strings PARAMS ((char *a, char *b)); static inline bool isplus PARAMS ((char *s)); static inline bool isdot PARAMS ((char *s)); static char *translate_esc PARAMS ((char *s)); +static bool tailcmp PARAMS ((const char *s1, const char *s2)); static bool do_compare PARAMS ((const char *s1, const char *s2)); static java_keyword *is_keyword PARAMS ((const char *s)); static void free_global PARAMS ((void)); @@ -430,6 +431,22 @@ extract_msgid_plural_arg (key) } +/** + * Backwards substring match. + */ +static bool +tailcmp (s1, s2) + const char *s1; + const char *s2; +{ + int len1 = strlen (s1); + int len2 = strlen (s2); + int start = len1 - len2; + if (start < 0) + return false; + return strcmp (s1 + start, s2) == 0; +} + /** * Try to match a string against the keyword. If substring_match is * true substring match is used. @@ -442,7 +459,7 @@ do_compare (s1, s2) if (substring_match) return strstr (s1, s2) != NULL; else - return strcmp (s1, s2) == 0; + return tailcmp (s1, s2); } /** @@ -547,8 +564,10 @@ extract_java (f, real_filename, logical_filename, mdlp) if (java_keywords == NULL) { /* ops, no standard keywords */ - x_java_keyword ("gettext"); /* GettextResource.gettext */ - x_java_keyword ("ngettext:1,2"); /* GettextResource.ngettext */ + x_java_keyword ("GettextResource.gettext:2"); /* static method */ + x_java_keyword ("GettextResource.ngettext:2,3"); /* static method */ + x_java_keyword ("gettext"); + x_java_keyword ("ngettext:1,2"); x_java_keyword ("getString"); /* ResourceBundle.getString */ } @@ -575,7 +594,6 @@ extract_java (f, real_filename, logical_filename, mdlp) k2 = append_strings (key, "."); free (key); key = append_strings (k2, parser_global->word); - state = STATE_NONE; } else {