summaryrefslogtreecommitdiffstats
path: root/scripts/gettext.patch
blob: 9470c6f992922058cc6d622dda1334bd6f5bc1f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
diff -ru src.orig/xget-lex.c src/xget-lex.c
--- src.orig/xget-lex.c	Fri May  1 06:45:12 1998
+++ src/xget-lex.c	Fri Apr 27 16:05:06 2001
@@ -78,17 +78,18 @@
 
 enum token_type_ty
 {
-  token_type_character_constant,
-  token_type_eof,
-  token_type_eoln,
-  token_type_hash,
-  token_type_lp,
-  token_type_comma,
-  token_type_name,
-  token_type_number,
-  token_type_string_literal,
-  token_type_symbol,
-  token_type_white_space
+  token_type_character_constant = 0,
+  token_type_eof = 1,
+  token_type_eoln = 2,
+  token_type_hash = 3,
+  token_type_lp = 4,
+  token_type_rp = 5,
+  token_type_comma = 6,
+  token_type_name = 7,
+  token_type_number = 8,
+  token_type_string_literal = 9,
+  token_type_symbol = 10,
+  token_type_white_space = 11
 };
 typedef enum token_type_ty token_type_ty;
 
@@ -941,6 +942,10 @@
       tp->type = token_type_lp;
       return;
 
+    case ')':
+      tp->type = token_type_rp;
+      return;
+
     case ',':
       tp->type = token_type_comma;
       return;
@@ -1236,6 +1241,11 @@
 	  tp->type = xgettext_token_type_lp;
 	  return;
 
+	case token_type_rp:
+	  last_non_comment_line = newline_count;
+	  tp->type = xgettext_token_type_rp;
+	  return;
+
 	case token_type_comma:
 	  last_non_comment_line = newline_count;
 
diff -ru src.orig/xget-lex.h src/xget-lex.h
--- src.orig/xget-lex.h	Fri May  1 06:45:23 1998
+++ src/xget-lex.h	Fri Apr 27 16:05:06 2001
@@ -22,13 +22,14 @@
 
 enum xgettext_token_type_ty
 {
-  xgettext_token_type_eof,
-  xgettext_token_type_keyword1,
-  xgettext_token_type_keyword2,
-  xgettext_token_type_lp,
-  xgettext_token_type_comma,
-  xgettext_token_type_string_literal,
-  xgettext_token_type_symbol
+  xgettext_token_type_eof = 0,
+  xgettext_token_type_keyword1 = 1,
+  xgettext_token_type_keyword2 = 2,
+  xgettext_token_type_lp = 3,
+  xgettext_token_type_rp = 4,
+  xgettext_token_type_comma = 5,
+  xgettext_token_type_string_literal = 6,
+  xgettext_token_type_symbol = 7
 };
 typedef enum xgettext_token_type_ty xgettext_token_type_ty;
 
diff -ru src.orig/xgettext.c src/xgettext.c
--- src.orig/xgettext.c	Wed Apr 29 18:57:50 1998
+++ src/xgettext.c	Fri Apr 27 16:33:46 2001
@@ -835,7 +835,8 @@
      int is_cpp_file;
 {
   int state;
-
+  char *msgid = 0;
+  
   /* Inform scanner whether we have C++ files or not.  */
   if (is_cpp_file)
     xgettext_lex_cplusplus ();
@@ -861,8 +862,12 @@
 	State 3 = seen one of our keywords with string in second parameter
 	State 4 = was in state 3 and now saw a left paren
 	State 5 = waiting for comma after being in state 4
-	State 6 = saw comma after being in state 5  */
+	State 6 = saw comma after being in state 5  
+	State 7 = after comma and being in state 2
+        State 8 = after string and being in state 7
+     */
      xgettext_lex (&token);
+
      switch (token.type)
        {
        case xgettext_token_type_keyword1:
@@ -886,18 +891,62 @@
 	     state = 0;
 	   }
 	 continue;
+       
+       case xgettext_token_type_rp:
+	 if (state == 2 || state == 8) {
+	   token.string = strdup(msgid);
+	   remember_a_message (mlp, &token);
+	   free(msgid);
+	   msgid = 0;
+	   state = 0;
+	 }
+	 continue;   
 
        case xgettext_token_type_comma:
-	 state = state == 5 ? 6 : 0;
+	 switch (state) {
+	 case 5:
+	   state = 6;
+	   break;
+	 case 2:
+           state = 7;
+	   break;
+         case 8: {
+	     char *newstring = (char*)malloc(strlen(msgid) + 2);
+	     strcpy(newstring, "_n:");
+	     strcat(newstring, msgid + 2);
+	     free(msgid);
+	     token.string = newstring;
+	     remember_a_message (mlp, &token);
+	     msgid = 0;
+	     state = 0;
+	     break;
+	 }
+	 default:
+	   state = 0;
+	   break;
+	 }
 	 continue;
 
        case xgettext_token_type_string_literal:
 	 if (extract_all || state == 2 || state == 6)
 	   {
-	     remember_a_message (mlp, &token);
-	     state = 0;
+	     if (msgid)
+	       free(msgid);
+	     msgid = strdup(token.string);
+	     //	     state = 0;
 	   }
-	 else
+	 else if (state == 7)
+	   {
+	     if (msgid) {
+	       char *newstring = (char*)malloc(strlen(msgid) + strlen(token.string) + 20);
+	       sprintf(newstring, "_: %s\n%s", msgid, token.string);
+	       free(msgid);
+	       free(token.string);
+	       token.string = msgid = newstring;
+	       state = 8;
+	     }
+	   }
+	 else 
 	   {
 	     free (token.string);
 	     state = (state == 4 || state == 5) ? 5 : 0;
@@ -905,8 +954,8 @@
 	 continue;
 
        case xgettext_token_type_symbol:
-	 state = (state == 4 || state == 5) ? 5 : 0;
-	 continue;
+	   state = (state == 4 || state == 5) ? 5 : 0;
+	   continue;
 
        default:
 	 state = 0;
@@ -915,6 +964,7 @@
        case xgettext_token_type_eof:
 	 break;
        }
+     
      break;
    }