You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdesdk/scripts/gettext.patch

195 lines
4.6 KiB

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;
}