29 |
29 |
30 /* Compiles a list of strings into a compiled string list */ |
30 /* Compiles a list of strings into a compiled string list */ |
31 |
31 |
32 typedef void (*ParseCmdProc)(char *buf, int value); |
32 typedef void (*ParseCmdProc)(char *buf, int value); |
33 |
33 |
34 typedef struct LanguagePackHeader { |
34 struct LanguagePackHeader { |
35 uint32 ident; |
35 uint32 ident; |
36 uint32 version; // 32-bits of auto generated version info which is basically a hash of strings.h |
36 uint32 version; // 32-bits of auto generated version info which is basically a hash of strings.h |
37 char name[32]; // the international name of this language |
37 char name[32]; // the international name of this language |
38 char own_name[32]; // the localized name of this language |
38 char own_name[32]; // the localized name of this language |
39 char isocode[16]; // the ISO code for the language (not country code) |
39 char isocode[16]; // the ISO code for the language (not country code) |
40 uint16 offsets[32]; // the offsets |
40 uint16 offsets[32]; // the offsets |
41 byte plural_form; // plural form index |
41 byte plural_form; // plural form index |
42 byte pad[3]; // pad header to be a multiple of 4 |
42 byte pad[3]; // pad header to be a multiple of 4 |
43 } LanguagePackHeader; |
43 }; |
44 |
44 |
45 typedef struct CmdStruct { |
45 struct CmdStruct { |
46 const char *cmd; |
46 const char *cmd; |
47 ParseCmdProc proc; |
47 ParseCmdProc proc; |
48 long value; |
48 long value; |
49 int8 consumes; |
49 int8 consumes; |
50 byte flags; |
50 byte flags; |
51 } CmdStruct; |
51 }; |
52 |
52 |
53 enum { |
53 enum { |
54 C_DONTCOUNT = 1, |
54 C_DONTCOUNT = 1, |
55 C_CASE = 2, |
55 C_CASE = 2, |
56 }; |
56 }; |
57 |
57 |
58 |
58 |
59 typedef struct Case { |
59 struct Case { |
60 int caseidx; |
60 int caseidx; |
61 char *string; |
61 char *string; |
62 struct Case *next; |
62 Case *next; |
63 } Case; |
63 }; |
64 |
64 |
65 static bool _masterlang; |
65 static bool _masterlang; |
66 static bool _translated; |
66 static bool _translated; |
67 static const char* _file = "(unknown file)"; |
67 static const char* _file = "(unknown file)"; |
68 static int _cur_line; |
68 static int _cur_line; |
69 static int _errors, _warnings; |
69 static int _errors, _warnings; |
70 |
70 |
71 typedef struct LangString { |
71 struct LangString { |
72 char *name; // Name of the string |
72 char *name; // Name of the string |
73 char *english; // English text |
73 char *english; // English text |
74 char *translated; // Translated text |
74 char *translated; // Translated text |
75 uint16 hash_next; // next hash entry |
75 uint16 hash_next; // next hash entry |
76 uint16 index; |
76 uint16 index; |
77 int line; // line of string in source-file |
77 int line; // line of string in source-file |
78 Case *english_case; // cases for english |
78 Case *english_case; // cases for english |
79 Case *translated_case; // cases for foreign |
79 Case *translated_case; // cases for foreign |
80 } LangString; |
80 }; |
81 |
81 |
82 static LangString *_strings[65536]; |
82 static LangString *_strings[65536]; |
83 |
83 |
84 |
84 |
85 #define HASH_SIZE 32767 |
85 #define HASH_SIZE 32767 |
104 // for each plural value, this is the number of plural forms. |
104 // for each plural value, this is the number of plural forms. |
105 static const byte _plural_form_counts[] = { 2, 1, 2, 3, 3, 3, 3, 3, 4 }; |
105 static const byte _plural_form_counts[] = { 2, 1, 2, 3, 3, 3, 3, 3, 4 }; |
106 |
106 |
107 static const char *_cur_ident; |
107 static const char *_cur_ident; |
108 |
108 |
109 typedef struct CmdPair { |
109 struct CmdPair { |
110 const CmdStruct *a; |
110 const CmdStruct *a; |
111 const char *v; |
111 const char *v; |
112 } CmdPair; |
112 }; |
113 |
113 |
114 typedef struct ParsedCommandStruct { |
114 struct ParsedCommandStruct { |
115 int np; |
115 int np; |
116 CmdPair pairs[32]; |
116 CmdPair pairs[32]; |
117 const CmdStruct *cmd[32]; // ordered by param # |
117 const CmdStruct *cmd[32]; // ordered by param # |
118 } ParsedCommandStruct; |
118 }; |
119 |
119 |
120 // Used when generating some advanced commands. |
120 // Used when generating some advanced commands. |
121 static ParsedCommandStruct _cur_pcs; |
121 static ParsedCommandStruct _cur_pcs; |
122 static int _cur_argidx; |
122 static int _cur_argidx; |
123 |
123 |