]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Regenerated.
authorBruno Haible <bruno@clisp.org>
Wed, 8 Jan 2003 14:10:55 +0000 (14:10 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:08:54 +0000 (12:08 +0200)
src/po-hash-gen.c
src/x-java.c

index c338e02ad712d154f981b3d71094af8b3a9ae523..3d894f76ccc1daa4f04b930d6e83c313a2f78991 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <string.h>
 
 #include "xmalloc.h"
 #define yycheck  po_hash_yycheck
 
 
-#line 101 "po-hash-gen.y"
+#line 102 "po-hash-gen.y"
 typedef union
 {
   char *string;
   size_t number;
 } YYSTYPE;
-#line 110 "po-hash-gen.y"
+#line 111 "po-hash-gen.y"
 
 
-static const char *cur;
-
-
-void yyerror PARAMS ((char *));
-int yylex PARAMS ((void));
-
-
-int
-po_hash (s)
-     const char *s;
-{
-  extern int yyparse PARAMS ((void));
-
-  cur = s;
-  return yyparse ();
-}
+/* Forward declarations, to avoid gcc warnings.  */
+void yyerror (char *);
+int yylex (void);
 
 
 void
-yyerror (s)
-     char *s;
+yyerror (char *s)
 {
   /* Do nothing, the grammar is used as a recogniser.  */
 }
@@ -179,7 +166,7 @@ static const short yyrhs[] = {    -1,
 
 #if YYDEBUG != 0
 static const short yyrline[] = { 0,
-   141,   142,   146,   152,   158,   164,   170
+   128,   129,   133,   139,   145,   151,   157
 };
 #endif
 
@@ -775,7 +762,7 @@ yyreduce:
   switch (yyn) {
 
 case 3:
-#line 147 "po-hash-gen.y"
+#line 134 "po-hash-gen.y"
 {
                  /* GNU style */
                  po_callback_comment_filepos (yyvsp[-2].string, yyvsp[0].number);
@@ -783,7 +770,7 @@ case 3:
                ;
     break;}
 case 4:
-#line 153 "po-hash-gen.y"
+#line 140 "po-hash-gen.y"
 {
                  /* GNU style, without line number (e.g. from Pascal .rst) */
                  po_callback_comment_filepos (yyvsp[0].string, (size_t)(-1));
@@ -791,7 +778,7 @@ case 4:
                ;
     break;}
 case 5:
-#line 159 "po-hash-gen.y"
+#line 146 "po-hash-gen.y"
 {
                  /* SunOS style */
                  po_callback_comment_filepos (yyvsp[-4].string, yyvsp[0].number);
@@ -799,7 +786,7 @@ case 5:
                ;
     break;}
 case 6:
-#line 165 "po-hash-gen.y"
+#line 152 "po-hash-gen.y"
 {
                  /* Solaris style */
                  po_callback_comment_filepos (yyvsp[-5].string, yyvsp[0].number);
@@ -807,7 +794,7 @@ case 6:
                ;
     break;}
 case 7:
-#line 171 "po-hash-gen.y"
+#line 158 "po-hash-gen.y"
 {
                  /* GNU style, but STRING is `file'.  Esoteric, but it
                     happened.  */
@@ -1036,22 +1023,30 @@ yyerrhandle:
     }
   return 1;
 }
-#line 178 "po-hash-gen.y"
+#line 165 "po-hash-gen.y"
 
 
 
+/* Current position in the pseudo-comment line.  */
+static const char *cur;
+
+/* The NUMBER token must only be recognized after colon.  So we have to
+   remember whether the last token was a colon.  */
+static bool last_was_colon;
+
+/* Returns the next token from the current pseudo-comment line.  */
 int
 yylex ()
 {
   static char *buf;
   static size_t bufmax;
-  size_t bufpos;
-  size_t n;
-  int c;
+
+  bool look_for_number = last_was_colon;
+  last_was_colon = false;
 
   for (;;)
     {
-      c = *cur++;
+      int c = *cur++;
       switch (c)
        {
        case 0:
@@ -1064,6 +1059,7 @@ yylex ()
          break;
 
        case ':':
+         last_was_colon = true;
          return COLON;
 
        case ',':
@@ -1079,79 +1075,99 @@ yylex ()
        case '7':
        case '8':
        case '9':
-         /* Accumulate a number.  */
-         n = 0;
-         for (;;)
+         if (look_for_number)
            {
-             n = n * 10 + c - '0';
-             c = *cur++;
-             switch (c)
+             /* Accumulate a number.  */
+             size_t n = 0;
+
+             for (;;)
                {
-               default:
+                 n = n * 10 + c - '0';
+                 c = *cur++;
+                 switch (c)
+                   {
+                   default:
+                     break;
+
+                   case '0':
+                   case '1':
+                   case '2':
+                   case '3':
+                   case '4':
+                   case '5':
+                   case '6':
+                   case '7':
+                   case '8':
+                   case '9':
+                     continue;
+                   }
                  break;
-
-               case '0':
-               case '1':
-               case '2':
-               case '3':
-               case '4':
-               case '5':
-               case '6':
-               case '7':
-               case '8':
-               case '9':
-                 continue;
                }
-             break;
+             --cur;
+             yylval.number = n;
+             return NUMBER;
            }
-         --cur;
-         yylval.number = n;
-         return NUMBER;
+         /* FALLTHROUGH */
 
        default:
          /* Accumulate a string.  */
-         bufpos = 0;
-         for (;;)
-           {
-             if (bufpos >= bufmax)
-               {
-                 bufmax += 100;
-                 buf = xrealloc (buf, bufmax);
-               }
-             buf[bufpos++] = c;
-
-             c = *cur++;
-             switch (c)
-               {
-               default:
-                 continue;
-
-               case 0:
-               case ':':
-               case ',':
-               case ' ':
-               case '\t':
-                 --cur;
-                 break;
-               }
-             break;
-           }
-
-         if (bufpos >= bufmax)
-           {
-             bufmax += 100;
-             buf = xrealloc (buf, bufmax);
-           }
-         buf[bufpos] = 0;
-
-         if (strcmp (buf, "file") == 0 || strcmp (buf, "File") == 0)
-           return FILE_KEYWORD;
-         if (strcmp (buf, "line") == 0)
-           return LINE_KEYWORD;
-         if (strcmp (buf, "number") == 0)
-           return NUMBER_KEYWORD;
-         yylval.string = xstrdup (buf);
-         return STRING;
+         {
+           size_t bufpos;
+
+           bufpos = 0;
+           for (;;)
+             {
+               if (bufpos >= bufmax)
+                 {
+                   bufmax += 100;
+                   buf = xrealloc (buf, bufmax);
+                 }
+               buf[bufpos++] = c;
+
+               c = *cur++;
+               switch (c)
+                 {
+                 default:
+                   continue;
+
+                 case 0:
+                 case ':':
+                 case ',':
+                 case ' ':
+                 case '\t':
+                   --cur;
+                   break;
+                 }
+               break;
+             }
+
+           if (bufpos >= bufmax)
+             {
+               bufmax += 100;
+               buf = xrealloc (buf, bufmax);
+             }
+           buf[bufpos] = 0;
+
+           if (strcmp (buf, "file") == 0 || strcmp (buf, "File") == 0)
+             return FILE_KEYWORD;
+           if (strcmp (buf, "line") == 0)
+             return LINE_KEYWORD;
+           if (strcmp (buf, "number") == 0)
+             return NUMBER_KEYWORD;
+           yylval.string = xstrdup (buf);
+           return STRING;
+         }
        }
     }
 }
+
+
+/* Analyze whether the string (a pseudo-comment line) contains file names
+   and line numbers.  */
+int
+po_hash (const char *s)
+{
+  cur = s;
+  last_was_colon = false;
+  return yyparse ();
+}
index 493dad6b176461dfc8b1e07346407006c89bfaa1..60c3d83b2fe944d8f95a227742890f9ffc68c7a5 100644 (file)
@@ -501,31 +501,6 @@ typedef struct _java_keyword
 } java_keyword;
 
 
-/* Prototypes for local functions.  Needed to ensure compiler checking of
-   function argument counts despite of K&R C function definition syntax.  */
-static char_buf *create_char_buf PARAMS ((void));
-static void append_char_buf PARAMS ((char_buf *b, int c));
-static char *get_string PARAMS ((char_buf *b));
-static void destroy_charbuf PARAMS ((char_buf *b));
-static void update_line_no PARAMS ((int c));
-static void strip_ending_spaces PARAMS ((char *str));
-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 object_list * object_list_alloc PARAMS ((void));
-static void object_list_destroy PARAMS ((object_list *list));
-static int get_num_objects PARAMS ((const object_list *list));
-static void * get_object PARAMS ((const object_list *list, int i));
-static void add_object PARAMS ((object_list *list, void *object));
-static java_keyword * alloc_keyword PARAMS ((const char *keyword,
-                                            int arg1, int arg2));
-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));
-
-
 #define INITIAL_CHARBUF_SIZE 500
 #define CHARBUF_GROWTH 100
 static char_buf *
@@ -540,9 +515,7 @@ create_char_buf ()
 }
 
 static void
-append_char_buf (b, c)
-     char_buf *b;
-     int c;
+append_char_buf (char_buf *b, int c)
 {
   if (b->len >= b->maxlen - 1)
     {
@@ -554,31 +527,27 @@ append_char_buf (b, c)
 }
 
 static char *
-get_string (b)
-     char_buf *b;
+get_string (char_buf *b)
 {
   return xstrdup (b->data);
 }
 
 static void
-destroy_charbuf (b)
-     char_buf *b;
+destroy_charbuf (char_buf *b)
 {
   free (b->data);
   free (b);
 }
 
 static void
-update_line_no (c)
-     int c;
+update_line_no (int c)
 {
   if (c == '\n')
     parser_global->line_no++;
 }
 
 static void
-strip_ending_spaces (str)
-     char *str;
+strip_ending_spaces (char *str)
 {
   int len = strlen (str);
 
@@ -586,7 +555,7 @@ strip_ending_spaces (str)
     len--;
   str[len] = '\0';
 }
-#line 590 "x-java.c-tmp"
+#line 559 "x-java.c-tmp"
 
 /* Macros after this point can all be overridden by user definitions in
  * section 1.
@@ -737,10 +706,10 @@ YY_DECL
        register char *yy_cp, *yy_bp;
        register int yy_act;
 
-#line 186 "./x-java.l"
+#line 155 "./x-java.l"
 
 
-#line 744 "x-java.c-tmp"
+#line 713 "x-java.c-tmp"
 
        if ( yy_init )
                {
@@ -825,7 +794,7 @@ do_action:  /* This label is used only to access EOF actions. */
 
 case 1:
 YY_RULE_SETUP
-#line 188 "./x-java.l"
+#line 157 "./x-java.l"
 {
   int c;
   int last;
@@ -851,12 +820,12 @@ YY_RULE_SETUP
        YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 211 "./x-java.l"
+#line 180 "./x-java.l"
 
        YY_BREAK
 case 3:
 YY_RULE_SETUP
-#line 212 "./x-java.l"
+#line 181 "./x-java.l"
 {
   int c;
   char *str;
@@ -874,7 +843,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 4:
 YY_RULE_SETUP
-#line 227 "./x-java.l"
+#line 196 "./x-java.l"
 {
   parser_global->word = yytext;
   return JAVA_WORD;
@@ -882,7 +851,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 5:
 YY_RULE_SETUP
-#line 232 "./x-java.l"
+#line 201 "./x-java.l"
 {
   parser_global->flow = yytext;
   return JAVA_FLOW;
@@ -890,7 +859,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 6:
 YY_RULE_SETUP
-#line 237 "./x-java.l"
+#line 206 "./x-java.l"
 {
   parser_global->operator = yytext;
   return JAVA_OPERATOR;
@@ -898,12 +867,12 @@ YY_RULE_SETUP
        YY_BREAK
 case 7:
 YY_RULE_SETUP
-#line 242 "./x-java.l"
+#line 211 "./x-java.l"
 /* ignore whitespace */
        YY_BREAK
 case 8:
 YY_RULE_SETUP
-#line 244 "./x-java.l"
+#line 213 "./x-java.l"
 {
   parser_global->comment = xstrdup (yytext + 2);
   return JAVA_COMMENT;
@@ -911,29 +880,29 @@ YY_RULE_SETUP
        YY_BREAK
 case 9:
 YY_RULE_SETUP
-#line 248 "./x-java.l"
+#line 217 "./x-java.l"
 parser_global->line_no++;
        YY_BREAK
 case 10:
 YY_RULE_SETUP
-#line 249 "./x-java.l"
+#line 218 "./x-java.l"
 
        YY_BREAK
 case 11:
 YY_RULE_SETUP
-#line 250 "./x-java.l"
+#line 219 "./x-java.l"
 
        YY_BREAK
 case YY_STATE_EOF(INITIAL):
-#line 251 "./x-java.l"
+#line 220 "./x-java.l"
 return -1;
        YY_BREAK
 case 12:
 YY_RULE_SETUP
-#line 252 "./x-java.l"
+#line 221 "./x-java.l"
 ECHO;
        YY_BREAK
-#line 937 "x-java.c-tmp"
+#line 906 "x-java.c-tmp"
 
        case YY_END_OF_BUFFER:
                {
@@ -1817,13 +1786,11 @@ int main()
        return 0;
        }
 #endif
-#line 252 "./x-java.l"
+#line 221 "./x-java.l"
 
 
 static char *
-append_strings (a, b)
-     char *a;
-     char *b;
+append_strings (char *a, char *b)
 {
   int total_size = strlen (a) + strlen (b) + 1;
   char *new_string = (char *) xmalloc (total_size);
@@ -1833,23 +1800,20 @@ append_strings (a, b)
 }
 
 static inline bool
-isplus (s)
-     char *s;
+isplus (char *s)
 {
   return *s == '+';
 }
 
 static inline bool
-isdot (s)
-     char *s;
+isdot (char *s)
 {
   return *s == '.';
 }
 
 
 static char *
-translate_esc (s)
-     char *s;
+translate_esc (char *s)
 {
   char *n = (char *) xmalloc (strlen (s) + 1);
   size_t i;
@@ -1883,32 +1847,26 @@ object_list_alloc ()
 }
 
 static void
-object_list_destroy (list)
-     object_list *list;
+object_list_destroy (object_list *list)
 {
   free (list->objects);
   free (list);
 }
 
 static int
-get_num_objects (list)
-     const object_list *list;
+get_num_objects (const object_list *list)
 {
   return list->num_obj;
 }
 
 static void *
-get_object (list, i)
-     const object_list *list;
-     int i;
+get_object (const object_list *list, int i)
 {
   return list->objects[i];
 }
 
 static void
-add_object (list, object)
-     object_list *list;
-     void *object;
+add_object (object_list *list, void *object)
 {
   if (list->num_obj + 1 >= list->max_num_obj)
     {
@@ -1931,10 +1889,7 @@ x_java_extract_all ()
 
 
 static java_keyword *
-alloc_keyword (keyword, arg1, arg2)
-     const char *keyword;
-     int arg1;
-     int arg2;
+alloc_keyword (const char *keyword, int arg1, int arg2)
 {
   java_keyword *jk = xmalloc (sizeof (java_keyword));
   jk->keyword = xstrdup (keyword);
@@ -1950,9 +1905,7 @@ static object_list *java_keywords = NULL;
  * Backwards substring match.
  */
 static bool
-tailcmp (s1, s2)
-     const char *s1;
-     const char *s2;
+tailcmp (const char *s1, const char *s2)
 {
   int len1 = strlen (s1);
   int len2 = strlen (s2);
@@ -1967,9 +1920,7 @@ tailcmp (s1, s2)
  * true substring match is used.
  */
 static bool
-do_compare (s1, s2)
-     const char *s1;
-     const char *s2;
+do_compare (const char *s1, const char *s2)
 {
   if (substring_match)
     return strstr (s1, s2) != NULL;
@@ -1981,8 +1932,7 @@ do_compare (s1, s2)
  * Check if a string is a keyword or not.
  */
 static java_keyword *
-is_keyword (s)
-     const char *s;
+is_keyword (const char *s)
 {
   int i;
   int num_keywords = get_num_objects (java_keywords);
@@ -2002,8 +1952,7 @@ is_keyword (s)
  * Add a keyword to the list of possible keywords.
  */
 void
-x_java_keyword (keyword)
-     const char *keyword;
+x_java_keyword (const char *keyword)
 {
   const char *keyword_end;
   int arg1;
@@ -2068,11 +2017,9 @@ free_global ()
  * Main java keyword extract function.
  */
 void
-extract_java (f, real_filename, logical_filename, mdlp)
-     FILE *f;
-     const char *real_filename;
-     const char *logical_filename;
-     msgdomain_list_ty *mdlp;
+extract_java (FILE *f,
+             const char *real_filename, const char *logical_filename,
+             msgdomain_list_ty *mdlp)
 {
   char *logical_file_name = xstrdup (logical_filename);
   int token;