diff options
Diffstat (limited to 'utils/skinupdater')
-rw-r--r-- | utils/skinupdater/skinupdater.c | 94 | ||||
-rw-r--r-- | utils/skinupdater/tag_table.c | 2 |
2 files changed, 82 insertions, 14 deletions
diff --git a/utils/skinupdater/skinupdater.c b/utils/skinupdater/skinupdater.c index a7f7cfd96a..01d01886a2 100644 --- a/utils/skinupdater/skinupdater.c +++ b/utils/skinupdater/skinupdater.c | |||
@@ -6,6 +6,14 @@ | |||
6 | 6 | ||
7 | #define PUTCH(out, c) fprintf(out, "%c", c) | 7 | #define PUTCH(out, c) fprintf(out, "%c", c) |
8 | extern struct tag_info legal_tags[]; | 8 | extern struct tag_info legal_tags[]; |
9 | |||
10 | |||
11 | /** Command line setting **/ | ||
12 | bool is_mono_display = false; | ||
13 | |||
14 | |||
15 | |||
16 | |||
9 | /* dump "count" args to output replacing '|' with ',' except after the last count. | 17 | /* dump "count" args to output replacing '|' with ',' except after the last count. |
10 | * return the amount of chars read. (start+return will be after the last | ) | 18 | * return the amount of chars read. (start+return will be after the last | ) |
11 | */ | 19 | */ |
@@ -30,8 +38,9 @@ int dump_arg(FILE* out, const char* start, int count, bool close) | |||
30 | } | 38 | } |
31 | return l; | 39 | return l; |
32 | } | 40 | } |
41 | |||
33 | #define MATCH(s) (!strcmp(tag->name, s)) | 42 | #define MATCH(s) (!strcmp(tag->name, s)) |
34 | int parse_tag(FILE* out, const char* start) | 43 | int parse_tag(FILE* out, const char* start, bool in_conditional) |
35 | { | 44 | { |
36 | struct tag_info *tag; | 45 | struct tag_info *tag; |
37 | int len = 0; | 46 | int len = 0; |
@@ -49,11 +58,11 @@ int parse_tag(FILE* out, const char* start) | |||
49 | len += strlen(tag->name); | 58 | len += strlen(tag->name); |
50 | start += len; | 59 | start += len; |
51 | /* handle individual tags which accept params */ | 60 | /* handle individual tags which accept params */ |
52 | if (MATCH("bl") || MATCH("pb") || MATCH("pv")) | 61 | if ((MATCH("bl") || MATCH("pb") || MATCH("pv")) && !in_conditional) |
53 | { | 62 | { |
54 | start++; len++; | ||
55 | if (*start == '|') | 63 | if (*start == '|') |
56 | { | 64 | { |
65 | len++; start++; | ||
57 | PUTCH(out, '('); | 66 | PUTCH(out, '('); |
58 | /* TODO: need to verify that we are actually using the long form... */ | 67 | /* TODO: need to verify that we are actually using the long form... */ |
59 | len += dump_arg(out, start, 5, true); | 68 | len += dump_arg(out, start, 5, true); |
@@ -76,8 +85,16 @@ int parse_tag(FILE* out, const char* start) | |||
76 | } | 85 | } |
77 | else if (MATCH("xl")) | 86 | else if (MATCH("xl")) |
78 | { | 87 | { |
88 | /* THIS IS BLOODY WRONG! */ | ||
79 | PUTCH(out, '('); | 89 | PUTCH(out, '('); |
80 | len += 1+dump_arg(out, start+1, 5, true); | 90 | len += 1+dump_arg(out, start+1, 4, false); |
91 | start += len+1; | ||
92 | if (*start>= '0' && *start <= '9') | ||
93 | { | ||
94 | PUTCH(out, ','); | ||
95 | len += dump_arg(out, start, 1, false); | ||
96 | } | ||
97 | PUTCH(out, ')'); | ||
81 | } | 98 | } |
82 | else if (MATCH("xd")) | 99 | else if (MATCH("xd")) |
83 | { | 100 | { |
@@ -86,7 +103,9 @@ int parse_tag(FILE* out, const char* start) | |||
86 | PUTCH(out, *start++); len++; | 103 | PUTCH(out, *start++); len++; |
87 | if ((*start >= 'a' && *start <= 'z') || | 104 | if ((*start >= 'a' && *start <= 'z') || |
88 | (*start >= 'A' && *start <= 'Z')) | 105 | (*start >= 'A' && *start <= 'Z')) |
89 | PUTCH(out, *start); len++; | 106 | { |
107 | PUTCH(out, *start); len++; | ||
108 | } | ||
90 | PUTCH(out, ')'); | 109 | PUTCH(out, ')'); |
91 | } | 110 | } |
92 | else if (MATCH("x")) | 111 | else if (MATCH("x")) |
@@ -119,12 +138,12 @@ int parse_tag(FILE* out, const char* start) | |||
119 | else if (MATCH("Vl") || MATCH("Vi")) | 138 | else if (MATCH("Vl") || MATCH("Vi")) |
120 | { | 139 | { |
121 | PUTCH(out, '('); | 140 | PUTCH(out, '('); |
122 | len += 1+dump_arg(out, start+1, 8, true); | 141 | len += 1+dump_arg(out, start+1, is_mono_display?6:8, true); |
123 | } | 142 | } |
124 | else if (MATCH("V")) | 143 | else if (MATCH("V")) |
125 | { | 144 | { |
126 | PUTCH(out, '('); | 145 | PUTCH(out, '('); |
127 | len += 1+dump_arg(out, start+1, 7, true); | 146 | len += 1+dump_arg(out, start+1, is_mono_display?5:7, true); |
128 | } | 147 | } |
129 | else if (MATCH("X")) | 148 | else if (MATCH("X")) |
130 | { | 149 | { |
@@ -156,6 +175,8 @@ int parse_tag(FILE* out, const char* start) | |||
156 | void parse_text(const char* in, FILE* out) | 175 | void parse_text(const char* in, FILE* out) |
157 | { | 176 | { |
158 | const char* end = in+strlen(in); | 177 | const char* end = in+strlen(in); |
178 | int level = 0; | ||
179 | int len; | ||
159 | top: | 180 | top: |
160 | while (in < end && *in) | 181 | while (in < end && *in) |
161 | { | 182 | { |
@@ -178,7 +199,25 @@ top: | |||
178 | PUTCH(out, *in++); | 199 | PUTCH(out, *in++); |
179 | break; | 200 | break; |
180 | } | 201 | } |
181 | in += parse_tag(out, in); | 202 | len = parse_tag(out, in, level>0); |
203 | if (len < 0) | ||
204 | { | ||
205 | PUTCH(out, *in++); | ||
206 | } | ||
207 | else | ||
208 | { | ||
209 | in += len; | ||
210 | } | ||
211 | } | ||
212 | else if (*in == '<') | ||
213 | { | ||
214 | level++; | ||
215 | PUTCH(out, *in++); | ||
216 | } | ||
217 | else if (*in == '>') | ||
218 | { | ||
219 | level--; | ||
220 | PUTCH(out, *in++); | ||
182 | } | 221 | } |
183 | else if (*in == '#') | 222 | else if (*in == '#') |
184 | { | 223 | { |
@@ -198,28 +237,57 @@ int main(int argc, char* argv[]) | |||
198 | { | 237 | { |
199 | char buffer[10*1024], temp[512]; | 238 | char buffer[10*1024], temp[512]; |
200 | FILE *in, *out = stdout; | 239 | FILE *in, *out = stdout; |
240 | int filearg = 1, i=0; | ||
201 | if( (argc < 2) || | 241 | if( (argc < 2) || |
202 | strcmp(argv[1],"-h") == 0 || | 242 | strcmp(argv[1],"-h") == 0 || |
203 | strcmp(argv[1],"--help") == 0 ) | 243 | strcmp(argv[1],"--help") == 0 ) |
204 | { | 244 | { |
205 | printf("Usage: %s infile [outfile]\n", argv[0]); | 245 | printf("Usage: %s [OPTIONS] infile [outfile]\n", argv[0]); |
246 | printf("\nOPTIONS:\n"); | ||
247 | printf("\t-m\tSkin is for a mono display (different viewport tags)\n"); | ||
206 | return 0; | 248 | return 0; |
207 | } | 249 | } |
208 | in = fopen(argv[1], "r"); | 250 | |
251 | while ((argc > filearg) && argv[filearg][0] == '-') | ||
252 | { | ||
253 | i=1; | ||
254 | while (argv[filearg][i]) | ||
255 | { | ||
256 | switch(argv[filearg][i]) | ||
257 | { | ||
258 | case 'm': /* skin is for a mono display */ | ||
259 | is_mono_display = true; | ||
260 | break; | ||
261 | } | ||
262 | i++; | ||
263 | } | ||
264 | filearg++; | ||
265 | } | ||
266 | if (argc == filearg) | ||
267 | { | ||
268 | printf("Missing input filename\n"); | ||
269 | return 1; | ||
270 | } | ||
271 | |||
272 | in = fopen(argv[filearg], "r"); | ||
209 | if (!in) | 273 | if (!in) |
210 | return 1; | 274 | return 1; |
211 | while (fgets(temp, 512, in)) | 275 | while (fgets(temp, 512, in)) |
212 | strcat(buffer, temp); | 276 | strcat(buffer, temp); |
277 | fclose(in); | ||
278 | filearg++; | ||
213 | 279 | ||
214 | if (argc == 3) | 280 | if (argc > filearg) |
215 | { | 281 | { |
216 | out = fopen(argv[2], "w"); | 282 | out = fopen(argv[filearg], "w"); |
217 | if (!out) | 283 | if (!out) |
284 | { | ||
285 | printf("Couldn't open %s\n", argv[filearg]); | ||
218 | return 1; | 286 | return 1; |
287 | } | ||
219 | } | 288 | } |
220 | 289 | ||
221 | parse_text(buffer, out); | 290 | parse_text(buffer, out); |
222 | fclose(in); | ||
223 | if (out != stdout) | 291 | if (out != stdout) |
224 | fclose(out); | 292 | fclose(out); |
225 | return 0; | 293 | return 0; |
diff --git a/utils/skinupdater/tag_table.c b/utils/skinupdater/tag_table.c index 1f5015feae..96b237d80e 100644 --- a/utils/skinupdater/tag_table.c +++ b/utils/skinupdater/tag_table.c | |||
@@ -31,7 +31,7 @@ struct tag_info legal_tags[] = | |||
31 | { "aL", "" }, | 31 | { "aL", "" }, |
32 | { "ar", "" }, | 32 | { "ar", "" }, |
33 | { "aR", "" }, | 33 | { "aR", "" }, |
34 | { "aX", "" }, | 34 | { "ax", "" }, |
35 | 35 | ||
36 | { "bl" , "*fIIII" }, | 36 | { "bl" , "*fIIII" }, |
37 | { "bv", "" }, | 37 | { "bv", "" }, |