~ubuntu-branches/ubuntu/hardy/php5/hardy-updates

« back to all changes in this revision

Viewing changes to ext/ircg/ircg_scanner.c

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-10-09 03:14:32 UTC
  • Revision ID: james.westby@ubuntu.com-20051009031432-kspik3lobxstafv9
Tags: upstream-5.0.5
ImportĀ upstreamĀ versionĀ 5.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Generated by re2c 0.5 on Wed Jun 18 02:07:15 2003 */
 
2
#line 1 "ircg_scanner.re"
 
3
/*
 
4
   +----------------------------------------------------------------------+
 
5
   | PHP Version 5                                                        |
 
6
   +----------------------------------------------------------------------+
 
7
   | Copyright (c) 1997-2004 The PHP Group                                |
 
8
   +----------------------------------------------------------------------+
 
9
   | This source file is subject to version 3.0 of the PHP license,       |
 
10
   | that is bundled with this package in the file LICENSE, and is        |
 
11
   | available through the world-wide-web at the following url:           |
 
12
   | http://www.php.net/license/3_0.txt.                                  |
 
13
   | If you did not receive a copy of the PHP license and are unable to   |
 
14
   | obtain it through the world-wide-web, please send a note to          |
 
15
   | license@php.net so we can mail you a copy immediately.               |
 
16
   +----------------------------------------------------------------------+
 
17
   | Author: Sascha Schumann <sascha@schumann.cx>                         |
 
18
   +----------------------------------------------------------------------+
 
19
 */
 
20
 
 
21
/* $Id: ircg_scanner.c,v 1.31 2004/01/08 08:15:53 andi Exp $ */
 
22
 
 
23
 
 
24
#include <stdio.h>
 
25
#include <string.h>
 
26
 
 
27
#include "php_ircg_smart_str.h"
 
28
#include "php_ircg_alloc.h"
 
29
 
 
30
static const char *color_list[] = {
 
31
    "white",
 
32
    "black",
 
33
    "blue",
 
34
    "green",
 
35
    "red",
 
36
    "brown",
 
37
    "purple",
 
38
    "orange",
 
39
    "yellow",
 
40
    "lightgreen",
 
41
    "teal",
 
42
    "lightcyan",
 
43
    "lightblue",
 
44
    "#ff00ff",
 
45
    "#bebebe",
 
46
    "lightgrey"
 
47
};
 
48
 
 
49
 
 
50
typedef struct {
 
51
        int bg_code;
 
52
        int fg_code;
 
53
        int font_tag_open;
 
54
        int bold_tag_open;
 
55
        int underline_tag_open;
 
56
        int italic_tag_open;
 
57
        char fg_color[6];
 
58
        char bg_color[6];
 
59
        
 
60
        smart_str scheme;
 
61
        smart_str *result;
 
62
} ircg_msg_scanner;
 
63
 
 
64
#line 79
 
65
 
 
66
 
 
67
#define YYFILL(n) do { } while (0)
 
68
#define YYCTYPE unsigned char
 
69
#define YYCURSOR xp
 
70
#define YYLIMIT end
 
71
#define YYMARKER q
 
72
 
 
73
#define STD_PARA ircg_msg_scanner *ctx, const char *start, const char *YYCURSOR
 
74
#define STD_ARGS ctx, start, YYCURSOR
 
75
 
 
76
#define PASSTHRU() do {                                                                         \
 
77
        smart_str_appendl_ex(mctx.result, start, xp-start, 1); \
 
78
} while (0)
 
79
 
 
80
static inline void handle_scheme(STD_PARA)
 
81
{
 
82
        ctx->scheme.len = 0;
 
83
        smart_str_appendl_ex(&ctx->scheme, start, YYCURSOR - start, 1);
 
84
        smart_str_0(&ctx->scheme);
 
85
}
 
86
 
 
87
static inline void handle_url(STD_PARA)
 
88
{
 
89
        smart_str_appends_ex(ctx->result, "<a target=blank href=\"", 1);
 
90
        smart_str_append_ex(ctx->result, &ctx->scheme, 1);
 
91
        smart_str_appendl_ex(ctx->result, start, YYCURSOR - start, 1);
 
92
        smart_str_appends_ex(ctx->result, "\">", 1);
 
93
        smart_str_append_ex(ctx->result, &ctx->scheme, 1);
 
94
        smart_str_appendl_ex(ctx->result, start, YYCURSOR - start, 1);
 
95
        smart_str_appends_ex(ctx->result, "</a>", 1);
 
96
}
 
97
 
 
98
static void handle_color_digit(STD_PARA, int mode)
 
99
{
 
100
        int len;
 
101
        int nr;
 
102
 
 
103
        len = YYCURSOR - start;
 
104
        switch (len) {
 
105
                case 2:
 
106
                        nr = (start[0] - '0') * 10 + (start[1] - '0');
 
107
                        break;
 
108
                case 1:
 
109
                        nr = start[0] - '0';
 
110
                        break;
 
111
        }
 
112
        
 
113
        switch (mode) {
 
114
                case 0: ctx->fg_code = nr; break;
 
115
                case 1: ctx->bg_code = nr; break;
 
116
        }
 
117
}
 
118
 
 
119
static void handle_hex(STD_PARA, int mode)
 
120
{
 
121
        memcpy(mode == 0 ? ctx->fg_color : ctx->bg_color, start, 6);
 
122
}
 
123
 
 
124
#define IS_VALID_CODE(n) (n >= 0 && n <= 15)
 
125
 
 
126
static void finish_color_stuff(STD_PARA)
 
127
{
 
128
        if (ctx->font_tag_open) {
 
129
                smart_str_appends_ex(ctx->result, "</font>", 1);
 
130
                ctx->font_tag_open = 0;
 
131
        }
 
132
}
 
133
 
 
134
static void handle_bold(STD_PARA, int final)
 
135
{
 
136
        switch (ctx->bold_tag_open) {
 
137
        case 0:
 
138
                if (!final) smart_str_appends_ex(ctx->result, "<b>", 1);
 
139
                break;
 
140
        case 1:
 
141
                smart_str_appends_ex(ctx->result, "</b>", 1);
 
142
                break;
 
143
        }
 
144
 
 
145
        ctx->bold_tag_open = 1 - ctx->bold_tag_open;
 
146
}
 
147
 
 
148
static void handle_underline(STD_PARA, int final)
 
149
{
 
150
        switch (ctx->underline_tag_open) {
 
151
        case 0:
 
152
                if (!final) smart_str_appends_ex(ctx->result, "<u>", 1);
 
153
                break;
 
154
        case 1:
 
155
                smart_str_appends_ex(ctx->result, "</u>", 1);
 
156
                break;
 
157
        }
 
158
 
 
159
        ctx->underline_tag_open = 1 - ctx->underline_tag_open;
 
160
}
 
161
 
 
162
static void handle_italic(STD_PARA, int final)
 
163
{
 
164
        switch (ctx->italic_tag_open) {
 
165
        case 0:
 
166
                if (!final) smart_str_appends_ex(ctx->result, "<i>", 1);
 
167
                break;
 
168
        case 1:
 
169
                smart_str_appends_ex(ctx->result, "</i>", 1);
 
170
                break;
 
171
        }
 
172
 
 
173
        ctx->italic_tag_open = 1 - ctx->italic_tag_open;
 
174
}
 
175
 
 
176
static void commit_color_stuff(STD_PARA)
 
177
{
 
178
        finish_color_stuff(STD_ARGS);
 
179
 
 
180
        if (IS_VALID_CODE(ctx->fg_code)) {
 
181
                smart_str_appends_ex(ctx->result, "<font color=\"", 1);
 
182
                smart_str_appends_ex(ctx->result, color_list[ctx->fg_code], 1);
 
183
                smart_str_appends_ex(ctx->result, "\">", 1);
 
184
                ctx->font_tag_open = 1;
 
185
        }
 
186
}
 
187
 
 
188
#define ADD_CONST(entity) do {                                                                  \
 
189
        smart_str_appends_ex(result, entity, 1);                                        \
 
190
} while (0)
 
191
 
 
192
static void commit_color_hex(STD_PARA)
 
193
{
 
194
        finish_color_stuff(STD_ARGS);
 
195
 
 
196
        if (ctx->fg_color[0] != 0) {
 
197
                smart_str_appends_ex(ctx->result, "<font color=\"", 1);
 
198
                smart_str_appendl_ex(ctx->result, ctx->fg_color, 6, 1);
 
199
                smart_str_appends_ex(ctx->result, "\">", 1);
 
200
                ctx->font_tag_open = 1;
 
201
        }
 
202
}
 
203
 
 
204
static void do_reset(STD_PARA)
 
205
{
 
206
        finish_color_stuff(STD_ARGS);
 
207
        handle_bold(STD_ARGS, 1);
 
208
        handle_underline(STD_ARGS, 1);
 
209
        handle_italic(STD_ARGS, 1);
 
210
}
 
211
 
 
212
void ircg_mirc_color(const char *msg, smart_str *result, size_t msg_len, int auto_links, int gen_br) 
 
213
{
 
214
        const char *end, *xp, *q, *start;
 
215
        ircg_msg_scanner mctx, *ctx = &mctx;
 
216
 
 
217
        mctx.result = result;
 
218
        mctx.scheme.c = NULL;
 
219
        mctx.italic_tag_open = mctx.font_tag_open = mctx.bold_tag_open = mctx.underline_tag_open = 0;
 
220
        
 
221
        if (msg_len == -1)
 
222
                msg_len = strlen(msg);
 
223
        end = msg + msg_len;
 
224
        xp = msg;
 
225
        
 
226
 
 
227
state_plain:
 
228
        if (xp >= end) goto stop;
 
229
        start = YYCURSOR;
 
230
{
 
231
        YYCTYPE yych;
 
232
        unsigned int yyaccept;
 
233
        goto yy0;
 
234
yy1:    ++YYCURSOR;
 
235
yy0:
 
236
        if((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
 
237
        yych = *YYCURSOR;
 
238
        switch(yych){
 
239
        case '\000':    goto yy2;
 
240
        case '\002':    goto yy19;
 
241
        case '\003':    goto yy5;
 
242
        case '\004':    goto yy17;
 
243
        case '\017':    goto yy25;
 
244
        case '\035':    goto yy23;
 
245
        case '\036':    goto yy15;
 
246
        case '\037':    goto yy21;
 
247
        case '&':       goto yy11;
 
248
        case '<':       goto yy7;
 
249
        case '>':       goto yy9;
 
250
        case 'A':
 
251
        case 'B':
 
252
        case 'C':
 
253
        case 'D':
 
254
        case 'E':
 
255
        case 'F':
 
256
        case 'G':
 
257
        case 'H':
 
258
        case 'I':
 
259
        case 'J':
 
260
        case 'K':
 
261
        case 'L':
 
262
        case 'M':
 
263
        case 'N':
 
264
        case 'O':
 
265
        case 'P':
 
266
        case 'Q':
 
267
        case 'R':
 
268
        case 'S':
 
269
        case 'T':
 
270
        case 'U':
 
271
        case 'V':
 
272
        case 'W':
 
273
        case 'X':
 
274
        case 'Y':
 
275
        case 'Z':       case 'a':
 
276
        case 'b':
 
277
        case 'c':
 
278
        case 'd':
 
279
        case 'e':
 
280
        case 'f':
 
281
        case 'g':
 
282
        case 'h':
 
283
        case 'i':
 
284
        case 'j':
 
285
        case 'k':
 
286
        case 'l':
 
287
        case 'm':
 
288
        case 'n':
 
289
        case 'o':
 
290
        case 'p':
 
291
        case 'q':
 
292
        case 'r':
 
293
        case 's':
 
294
        case 't':
 
295
        case 'u':
 
296
        case 'v':
 
297
        case 'w':
 
298
        case 'x':
 
299
        case 'y':
 
300
        case 'z':       goto yy3;
 
301
        case '\204':    case '\223':
 
302
        case '\224':    goto yy13;
 
303
        default:        goto yy27;
 
304
        }
 
305
yy2:    YYCURSOR = YYMARKER;
 
306
        switch(yyaccept){
 
307
        case 0: goto yy4;
 
308
        }
 
309
yy3:    yyaccept = 0;
 
310
        yych = *(YYMARKER = ++YYCURSOR);
 
311
        switch(yych){
 
312
        case '0':
 
313
        case '1':
 
314
        case '2':
 
315
        case '3':
 
316
        case '4':
 
317
        case '5':
 
318
        case '6':
 
319
        case '7':
 
320
        case '8':
 
321
        case '9':
 
322
        case ':':       case 'A':
 
323
        case 'B':
 
324
        case 'C':
 
325
        case 'D':
 
326
        case 'E':
 
327
        case 'F':
 
328
        case 'G':
 
329
        case 'H':
 
330
        case 'I':
 
331
        case 'J':
 
332
        case 'K':
 
333
        case 'L':
 
334
        case 'M':
 
335
        case 'N':
 
336
        case 'O':
 
337
        case 'P':
 
338
        case 'Q':
 
339
        case 'R':
 
340
        case 'S':
 
341
        case 'T':
 
342
        case 'U':
 
343
        case 'V':
 
344
        case 'W':
 
345
        case 'X':
 
346
        case 'Y':
 
347
        case 'Z':       case 'a':
 
348
        case 'b':
 
349
        case 'c':
 
350
        case 'd':
 
351
        case 'e':
 
352
        case 'f':
 
353
        case 'g':
 
354
        case 'h':
 
355
        case 'i':
 
356
        case 'j':
 
357
        case 'k':
 
358
        case 'l':
 
359
        case 'm':
 
360
        case 'n':
 
361
        case 'o':
 
362
        case 'p':
 
363
        case 'q':
 
364
        case 'r':
 
365
        case 's':
 
366
        case 't':
 
367
        case 'u':
 
368
        case 'v':
 
369
        case 'w':
 
370
        case 'x':
 
371
        case 'y':
 
372
        case 'z':       goto yy29;
 
373
        default:        goto yy4;
 
374
        }
 
375
yy4:
 
376
#line 257
 
377
        { PASSTHRU(); goto state_plain; }
 
378
yy5:    yych = *++YYCURSOR;
 
379
yy6:
 
380
#line 246
 
381
        { mctx.fg_code = mctx.bg_code = -1; goto state_color_fg; }
 
382
yy7:    yych = *++YYCURSOR;
 
383
yy8:
 
384
#line 247
 
385
        { ADD_CONST("&lt;"); goto state_plain; }
 
386
yy9:    yych = *++YYCURSOR;
 
387
yy10:
 
388
#line 248
 
389
        { ADD_CONST("&gt;"); goto state_plain; }
 
390
yy11:   yych = *++YYCURSOR;
 
391
yy12:
 
392
#line 249
 
393
        { ADD_CONST("&amp;"); goto state_plain; }
 
394
yy13:   yych = *++YYCURSOR;
 
395
yy14:
 
396
#line 250
 
397
        { ADD_CONST("&quot;"); goto state_plain; }
 
398
yy15:   yych = *++YYCURSOR;
 
399
yy16:
 
400
#line 251
 
401
        { if (gen_br) ADD_CONST("<br>"); goto state_plain; }
 
402
yy17:   yych = *++YYCURSOR;
 
403
yy18:
 
404
#line 252
 
405
        { mctx.fg_color[0] = mctx.bg_color[0] = 0; goto state_color_hex; }
 
406
yy19:   yych = *++YYCURSOR;
 
407
yy20:
 
408
#line 253
 
409
        { handle_bold(STD_ARGS, 0); goto state_plain; }
 
410
yy21:   yych = *++YYCURSOR;
 
411
yy22:
 
412
#line 254
 
413
        { handle_underline(STD_ARGS, 0); goto state_plain; }
 
414
yy23:   yych = *++YYCURSOR;
 
415
yy24:
 
416
#line 255
 
417
        { handle_italic(STD_ARGS, 0); goto state_plain; }
 
418
yy25:   yych = *++YYCURSOR;
 
419
yy26:
 
420
#line 256
 
421
        { do_reset(STD_ARGS); goto state_plain; }
 
422
yy27:   yych = *++YYCURSOR;
 
423
        goto yy4;
 
424
yy28:   ++YYCURSOR;
 
425
        if(YYLIMIT == YYCURSOR) YYFILL(1);
 
426
        yych = *YYCURSOR;
 
427
yy29:   switch(yych){
 
428
        case '0':
 
429
        case '1':
 
430
        case '2':
 
431
        case '3':
 
432
        case '4':
 
433
        case '5':
 
434
        case '6':
 
435
        case '7':
 
436
        case '8':
 
437
        case '9':       case 'A':
 
438
        case 'B':
 
439
        case 'C':
 
440
        case 'D':
 
441
        case 'E':
 
442
        case 'F':
 
443
        case 'G':
 
444
        case 'H':
 
445
        case 'I':
 
446
        case 'J':
 
447
        case 'K':
 
448
        case 'L':
 
449
        case 'M':
 
450
        case 'N':
 
451
        case 'O':
 
452
        case 'P':
 
453
        case 'Q':
 
454
        case 'R':
 
455
        case 'S':
 
456
        case 'T':
 
457
        case 'U':
 
458
        case 'V':
 
459
        case 'W':
 
460
        case 'X':
 
461
        case 'Y':
 
462
        case 'Z':       case 'a':
 
463
        case 'b':
 
464
        case 'c':
 
465
        case 'd':
 
466
        case 'e':
 
467
        case 'f':
 
468
        case 'g':
 
469
        case 'h':
 
470
        case 'i':
 
471
        case 'j':
 
472
        case 'k':
 
473
        case 'l':
 
474
        case 'm':
 
475
        case 'n':
 
476
        case 'o':
 
477
        case 'p':
 
478
        case 'q':
 
479
        case 'r':
 
480
        case 's':
 
481
        case 't':
 
482
        case 'u':
 
483
        case 'v':
 
484
        case 'w':
 
485
        case 'x':
 
486
        case 'y':
 
487
        case 'z':       goto yy28;
 
488
        case ':':       goto yy30;
 
489
        default:        goto yy2;
 
490
        }
 
491
yy30:   yych = *++YYCURSOR;
 
492
        switch(yych){
 
493
        case '/':       goto yy31;
 
494
        default:        goto yy2;
 
495
        }
 
496
yy31:   yych = *++YYCURSOR;
 
497
        switch(yych){
 
498
        case '/':       goto yy32;
 
499
        default:        goto yy2;
 
500
        }
 
501
yy32:   yych = *++YYCURSOR;
 
502
yy33:
 
503
#line 245
 
504
        { if (auto_links) { handle_scheme(STD_ARGS); goto state_url; } else { PASSTHRU(); goto state_plain; } }
 
505
}
 
506
#line 258
 
507
 
 
508
 
 
509
state_color_hex:
 
510
        start = YYCURSOR;
 
511
{
 
512
        YYCTYPE yych;
 
513
        unsigned int yyaccept;
 
514
        goto yy34;
 
515
yy35:   ++YYCURSOR;
 
516
yy34:
 
517
        if((YYLIMIT - YYCURSOR) < 6) YYFILL(6);
 
518
        yych = *YYCURSOR;
 
519
        switch(yych){
 
520
        case ',':       goto yy38;
 
521
        case '0':
 
522
        case '1':
 
523
        case '2':
 
524
        case '3':
 
525
        case '4':
 
526
        case '5':
 
527
        case '6':
 
528
        case '7':
 
529
        case '8':
 
530
        case '9':       case 'A':
 
531
        case 'B':
 
532
        case 'C':
 
533
        case 'D':
 
534
        case 'E':
 
535
        case 'F':       case 'a':
 
536
        case 'b':
 
537
        case 'c':
 
538
        case 'd':
 
539
        case 'e':
 
540
        case 'f':       goto yy36;
 
541
        default:        goto yy40;
 
542
        }
 
543
yy36:   yyaccept = 0;
 
544
        yych = *(YYMARKER = ++YYCURSOR);
 
545
        switch(yych){
 
546
        case '0':
 
547
        case '1':
 
548
        case '2':
 
549
        case '3':
 
550
        case '4':
 
551
        case '5':
 
552
        case '6':
 
553
        case '7':
 
554
        case '8':
 
555
        case '9':       case 'A':
 
556
        case 'B':
 
557
        case 'C':
 
558
        case 'D':
 
559
        case 'E':
 
560
        case 'F':       case 'a':
 
561
        case 'b':
 
562
        case 'c':
 
563
        case 'd':
 
564
        case 'e':
 
565
        case 'f':       goto yy41;
 
566
        default:        goto yy37;
 
567
        }
 
568
yy37:
 
569
#line 265
 
570
        { finish_color_stuff(STD_ARGS); PASSTHRU(); goto state_plain; }
 
571
yy38:   yych = *++YYCURSOR;
 
572
yy39:
 
573
#line 264
 
574
        { goto state_color_hex_bg; }
 
575
yy40:   yych = *++YYCURSOR;
 
576
        goto yy37;
 
577
yy41:   yych = *++YYCURSOR;
 
578
        switch(yych){
 
579
        case '0':
 
580
        case '1':
 
581
        case '2':
 
582
        case '3':
 
583
        case '4':
 
584
        case '5':
 
585
        case '6':
 
586
        case '7':
 
587
        case '8':
 
588
        case '9':       case 'A':
 
589
        case 'B':
 
590
        case 'C':
 
591
        case 'D':
 
592
        case 'E':
 
593
        case 'F':       case 'a':
 
594
        case 'b':
 
595
        case 'c':
 
596
        case 'd':
 
597
        case 'e':
 
598
        case 'f':       goto yy43;
 
599
        default:        goto yy42;
 
600
        }
 
601
yy42:   YYCURSOR = YYMARKER;
 
602
        switch(yyaccept){
 
603
        case 0: goto yy37;
 
604
        }
 
605
yy43:   yych = *++YYCURSOR;
 
606
        switch(yych){
 
607
        case '0':
 
608
        case '1':
 
609
        case '2':
 
610
        case '3':
 
611
        case '4':
 
612
        case '5':
 
613
        case '6':
 
614
        case '7':
 
615
        case '8':
 
616
        case '9':       case 'A':
 
617
        case 'B':
 
618
        case 'C':
 
619
        case 'D':
 
620
        case 'E':
 
621
        case 'F':       case 'a':
 
622
        case 'b':
 
623
        case 'c':
 
624
        case 'd':
 
625
        case 'e':
 
626
        case 'f':       goto yy44;
 
627
        default:        goto yy42;
 
628
        }
 
629
yy44:   yych = *++YYCURSOR;
 
630
        switch(yych){
 
631
        case '0':
 
632
        case '1':
 
633
        case '2':
 
634
        case '3':
 
635
        case '4':
 
636
        case '5':
 
637
        case '6':
 
638
        case '7':
 
639
        case '8':
 
640
        case '9':       case 'A':
 
641
        case 'B':
 
642
        case 'C':
 
643
        case 'D':
 
644
        case 'E':
 
645
        case 'F':       case 'a':
 
646
        case 'b':
 
647
        case 'c':
 
648
        case 'd':
 
649
        case 'e':
 
650
        case 'f':       goto yy45;
 
651
        default:        goto yy42;
 
652
        }
 
653
yy45:   yych = *++YYCURSOR;
 
654
        switch(yych){
 
655
        case '0':
 
656
        case '1':
 
657
        case '2':
 
658
        case '3':
 
659
        case '4':
 
660
        case '5':
 
661
        case '6':
 
662
        case '7':
 
663
        case '8':
 
664
        case '9':       case 'A':
 
665
        case 'B':
 
666
        case 'C':
 
667
        case 'D':
 
668
        case 'E':
 
669
        case 'F':       case 'a':
 
670
        case 'b':
 
671
        case 'c':
 
672
        case 'd':
 
673
        case 'e':
 
674
        case 'f':       goto yy46;
 
675
        default:        goto yy42;
 
676
        }
 
677
yy46:   yych = *++YYCURSOR;
 
678
yy47:
 
679
#line 263
 
680
        { handle_hex(STD_ARGS, 0); goto state_color_hex_bg; }
 
681
}
 
682
#line 266
 
683
 
 
684
 
 
685
        
 
686
state_color_hex_comma:  
 
687
        start = YYCURSOR;
 
688
{
 
689
        YYCTYPE yych;
 
690
        unsigned int yyaccept;
 
691
        goto yy48;
 
692
yy49:   ++YYCURSOR;
 
693
yy48:
 
694
        if(YYLIMIT == YYCURSOR) YYFILL(1);
 
695
        yych = *YYCURSOR;
 
696
        switch(yych){
 
697
        case ',':       goto yy50;
 
698
        default:        goto yy52;
 
699
        }
 
700
yy50:   yych = *++YYCURSOR;
 
701
yy51:
 
702
#line 272
 
703
        { goto state_color_hex_bg; }
 
704
yy52:   yych = *++YYCURSOR;
 
705
yy53:
 
706
#line 273
 
707
        { YYCURSOR--; commit_color_hex(STD_ARGS); goto state_plain; }
 
708
}
 
709
#line 274
 
710
 
 
711
 
 
712
 
 
713
state_color_hex_bg:
 
714
        start = YYCURSOR;
 
715
{
 
716
        YYCTYPE yych;
 
717
        unsigned int yyaccept;
 
718
        goto yy54;
 
719
yy55:   ++YYCURSOR;
 
720
yy54:
 
721
        if((YYLIMIT - YYCURSOR) < 6) YYFILL(6);
 
722
        yych = *YYCURSOR;
 
723
        switch(yych){
 
724
        case '0':
 
725
        case '1':
 
726
        case '2':
 
727
        case '3':
 
728
        case '4':
 
729
        case '5':
 
730
        case '6':
 
731
        case '7':
 
732
        case '8':
 
733
        case '9':       case 'A':
 
734
        case 'B':
 
735
        case 'C':
 
736
        case 'D':
 
737
        case 'E':
 
738
        case 'F':       case 'a':
 
739
        case 'b':
 
740
        case 'c':
 
741
        case 'd':
 
742
        case 'e':
 
743
        case 'f':       goto yy56;
 
744
        default:        goto yy58;
 
745
        }
 
746
yy56:   yyaccept = 0;
 
747
        yych = *(YYMARKER = ++YYCURSOR);
 
748
        switch(yych){
 
749
        case '0':
 
750
        case '1':
 
751
        case '2':
 
752
        case '3':
 
753
        case '4':
 
754
        case '5':
 
755
        case '6':
 
756
        case '7':
 
757
        case '8':
 
758
        case '9':       case 'A':
 
759
        case 'B':
 
760
        case 'C':
 
761
        case 'D':
 
762
        case 'E':
 
763
        case 'F':       case 'a':
 
764
        case 'b':
 
765
        case 'c':
 
766
        case 'd':
 
767
        case 'e':
 
768
        case 'f':       goto yy59;
 
769
        default:        goto yy57;
 
770
        }
 
771
yy57:
 
772
#line 281
 
773
        { commit_color_hex(STD_ARGS); PASSTHRU(); goto state_plain; }
 
774
yy58:   yych = *++YYCURSOR;
 
775
        goto yy57;
 
776
yy59:   yych = *++YYCURSOR;
 
777
        switch(yych){
 
778
        case '0':
 
779
        case '1':
 
780
        case '2':
 
781
        case '3':
 
782
        case '4':
 
783
        case '5':
 
784
        case '6':
 
785
        case '7':
 
786
        case '8':
 
787
        case '9':       case 'A':
 
788
        case 'B':
 
789
        case 'C':
 
790
        case 'D':
 
791
        case 'E':
 
792
        case 'F':       case 'a':
 
793
        case 'b':
 
794
        case 'c':
 
795
        case 'd':
 
796
        case 'e':
 
797
        case 'f':       goto yy61;
 
798
        default:        goto yy60;
 
799
        }
 
800
yy60:   YYCURSOR = YYMARKER;
 
801
        switch(yyaccept){
 
802
        case 0: goto yy57;
 
803
        }
 
804
yy61:   yych = *++YYCURSOR;
 
805
        switch(yych){
 
806
        case '0':
 
807
        case '1':
 
808
        case '2':
 
809
        case '3':
 
810
        case '4':
 
811
        case '5':
 
812
        case '6':
 
813
        case '7':
 
814
        case '8':
 
815
        case '9':       case 'A':
 
816
        case 'B':
 
817
        case 'C':
 
818
        case 'D':
 
819
        case 'E':
 
820
        case 'F':       case 'a':
 
821
        case 'b':
 
822
        case 'c':
 
823
        case 'd':
 
824
        case 'e':
 
825
        case 'f':       goto yy62;
 
826
        default:        goto yy60;
 
827
        }
 
828
yy62:   yych = *++YYCURSOR;
 
829
        switch(yych){
 
830
        case '0':
 
831
        case '1':
 
832
        case '2':
 
833
        case '3':
 
834
        case '4':
 
835
        case '5':
 
836
        case '6':
 
837
        case '7':
 
838
        case '8':
 
839
        case '9':       case 'A':
 
840
        case 'B':
 
841
        case 'C':
 
842
        case 'D':
 
843
        case 'E':
 
844
        case 'F':       case 'a':
 
845
        case 'b':
 
846
        case 'c':
 
847
        case 'd':
 
848
        case 'e':
 
849
        case 'f':       goto yy63;
 
850
        default:        goto yy60;
 
851
        }
 
852
yy63:   yych = *++YYCURSOR;
 
853
        switch(yych){
 
854
        case '0':
 
855
        case '1':
 
856
        case '2':
 
857
        case '3':
 
858
        case '4':
 
859
        case '5':
 
860
        case '6':
 
861
        case '7':
 
862
        case '8':
 
863
        case '9':       case 'A':
 
864
        case 'B':
 
865
        case 'C':
 
866
        case 'D':
 
867
        case 'E':
 
868
        case 'F':       case 'a':
 
869
        case 'b':
 
870
        case 'c':
 
871
        case 'd':
 
872
        case 'e':
 
873
        case 'f':       goto yy64;
 
874
        default:        goto yy60;
 
875
        }
 
876
yy64:   yych = *++YYCURSOR;
 
877
yy65:
 
878
#line 280
 
879
        { handle_hex(STD_ARGS, 1); commit_color_hex(STD_ARGS); goto state_plain; }
 
880
}
 
881
#line 282
 
882
 
 
883
 
 
884
state_url:
 
885
        start = YYCURSOR;
 
886
{
 
887
        YYCTYPE yych;
 
888
        unsigned int yyaccept;
 
889
        goto yy66;
 
890
yy67:   ++YYCURSOR;
 
891
yy66:
 
892
        if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
 
893
        yych = *YYCURSOR;
 
894
        switch(yych){
 
895
        case '!':       case '#':
 
896
        case '$':
 
897
        case '%':
 
898
        case '&':
 
899
        case '\'':
 
900
        case '(':
 
901
        case ')':
 
902
        case '*':
 
903
        case '+':
 
904
        case ',':
 
905
        case '-':
 
906
        case '.':
 
907
        case '/':
 
908
        case '0':
 
909
        case '1':
 
910
        case '2':
 
911
        case '3':
 
912
        case '4':
 
913
        case '5':
 
914
        case '6':
 
915
        case '7':
 
916
        case '8':
 
917
        case '9':
 
918
        case ':':
 
919
        case ';':       case '=':       case '?':
 
920
        case '@':
 
921
        case 'A':
 
922
        case 'B':
 
923
        case 'C':
 
924
        case 'D':
 
925
        case 'E':
 
926
        case 'F':
 
927
        case 'G':
 
928
        case 'H':
 
929
        case 'I':
 
930
        case 'J':
 
931
        case 'K':
 
932
        case 'L':
 
933
        case 'M':
 
934
        case 'N':
 
935
        case 'O':
 
936
        case 'P':
 
937
        case 'Q':
 
938
        case 'R':
 
939
        case 'S':
 
940
        case 'T':
 
941
        case 'U':
 
942
        case 'V':
 
943
        case 'W':
 
944
        case 'X':
 
945
        case 'Y':
 
946
        case 'Z':       case '_':       case 'a':
 
947
        case 'b':
 
948
        case 'c':
 
949
        case 'd':
 
950
        case 'e':
 
951
        case 'f':
 
952
        case 'g':
 
953
        case 'h':
 
954
        case 'i':
 
955
        case 'j':
 
956
        case 'k':
 
957
        case 'l':
 
958
        case 'm':
 
959
        case 'n':
 
960
        case 'o':
 
961
        case 'p':
 
962
        case 'q':
 
963
        case 'r':
 
964
        case 's':
 
965
        case 't':
 
966
        case 'u':
 
967
        case 'v':
 
968
        case 'w':
 
969
        case 'x':
 
970
        case 'y':
 
971
        case 'z':       case '~':       goto yy68;
 
972
        default:        goto yy70;
 
973
        }
 
974
yy68:   yych = *++YYCURSOR;
 
975
        goto yy73;
 
976
yy69:
 
977
#line 287
 
978
        { handle_url(STD_ARGS); goto state_plain; }
 
979
yy70:   yych = *++YYCURSOR;
 
980
yy71:
 
981
#line 288
 
982
        { PASSTHRU(); goto state_plain; }
 
983
yy72:   ++YYCURSOR;
 
984
        if(YYLIMIT == YYCURSOR) YYFILL(1);
 
985
        yych = *YYCURSOR;
 
986
yy73:   switch(yych){
 
987
        case '!':       case '#':
 
988
        case '$':
 
989
        case '%':
 
990
        case '&':
 
991
        case '\'':
 
992
        case '(':
 
993
        case ')':
 
994
        case '*':
 
995
        case '+':
 
996
        case ',':
 
997
        case '-':
 
998
        case '.':
 
999
        case '/':
 
1000
        case '0':
 
1001
        case '1':
 
1002
        case '2':
 
1003
        case '3':
 
1004
        case '4':
 
1005
        case '5':
 
1006
        case '6':
 
1007
        case '7':
 
1008
        case '8':
 
1009
        case '9':
 
1010
        case ':':
 
1011
        case ';':       case '=':       case '?':
 
1012
        case '@':
 
1013
        case 'A':
 
1014
        case 'B':
 
1015
        case 'C':
 
1016
        case 'D':
 
1017
        case 'E':
 
1018
        case 'F':
 
1019
        case 'G':
 
1020
        case 'H':
 
1021
        case 'I':
 
1022
        case 'J':
 
1023
        case 'K':
 
1024
        case 'L':
 
1025
        case 'M':
 
1026
        case 'N':
 
1027
        case 'O':
 
1028
        case 'P':
 
1029
        case 'Q':
 
1030
        case 'R':
 
1031
        case 'S':
 
1032
        case 'T':
 
1033
        case 'U':
 
1034
        case 'V':
 
1035
        case 'W':
 
1036
        case 'X':
 
1037
        case 'Y':
 
1038
        case 'Z':       case '_':       case 'a':
 
1039
        case 'b':
 
1040
        case 'c':
 
1041
        case 'd':
 
1042
        case 'e':
 
1043
        case 'f':
 
1044
        case 'g':
 
1045
        case 'h':
 
1046
        case 'i':
 
1047
        case 'j':
 
1048
        case 'k':
 
1049
        case 'l':
 
1050
        case 'm':
 
1051
        case 'n':
 
1052
        case 'o':
 
1053
        case 'p':
 
1054
        case 'q':
 
1055
        case 'r':
 
1056
        case 's':
 
1057
        case 't':
 
1058
        case 'u':
 
1059
        case 'v':
 
1060
        case 'w':
 
1061
        case 'x':
 
1062
        case 'y':
 
1063
        case 'z':       case '~':       goto yy72;
 
1064
        default:        goto yy69;
 
1065
        }
 
1066
}
 
1067
#line 289
 
1068
 
 
1069
 
 
1070
 
 
1071
state_color_fg:         
 
1072
        start = YYCURSOR;
 
1073
{
 
1074
        YYCTYPE yych;
 
1075
        unsigned int yyaccept;
 
1076
        goto yy74;
 
1077
yy75:   ++YYCURSOR;
 
1078
yy74:
 
1079
        if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
 
1080
        yych = *YYCURSOR;
 
1081
        switch(yych){
 
1082
        case ',':       goto yy78;
 
1083
        case '0':
 
1084
        case '1':
 
1085
        case '2':
 
1086
        case '3':
 
1087
        case '4':
 
1088
        case '5':
 
1089
        case '6':
 
1090
        case '7':
 
1091
        case '8':
 
1092
        case '9':       goto yy76;
 
1093
        default:        goto yy80;
 
1094
        }
 
1095
yy76:   yych = *++YYCURSOR;
 
1096
        switch(yych){
 
1097
        case '0':
 
1098
        case '1':
 
1099
        case '2':
 
1100
        case '3':
 
1101
        case '4':
 
1102
        case '5':
 
1103
        case '6':
 
1104
        case '7':
 
1105
        case '8':
 
1106
        case '9':       goto yy82;
 
1107
        default:        goto yy77;
 
1108
        }
 
1109
yy77:
 
1110
#line 295
 
1111
        { handle_color_digit(STD_ARGS, 0); goto state_color_comma; }
 
1112
yy78:   yych = *++YYCURSOR;
 
1113
yy79:
 
1114
#line 296
 
1115
        { goto state_color_bg; }
 
1116
yy80:   yych = *++YYCURSOR;
 
1117
yy81:
 
1118
#line 297
 
1119
        { finish_color_stuff(STD_ARGS); PASSTHRU(); goto state_plain; }
 
1120
yy82:   yych = *++YYCURSOR;
 
1121
        goto yy77;
 
1122
}
 
1123
#line 298
 
1124
 
 
1125
 
 
1126
        
 
1127
state_color_comma:      
 
1128
        start = YYCURSOR;
 
1129
{
 
1130
        YYCTYPE yych;
 
1131
        unsigned int yyaccept;
 
1132
        goto yy83;
 
1133
yy84:   ++YYCURSOR;
 
1134
yy83:
 
1135
        if(YYLIMIT == YYCURSOR) YYFILL(1);
 
1136
        yych = *YYCURSOR;
 
1137
        switch(yych){
 
1138
        case ',':       goto yy85;
 
1139
        default:        goto yy87;
 
1140
        }
 
1141
yy85:   yych = *++YYCURSOR;
 
1142
yy86:
 
1143
#line 304
 
1144
        { goto state_color_bg; }
 
1145
yy87:   yych = *++YYCURSOR;
 
1146
yy88:
 
1147
#line 305
 
1148
        { YYCURSOR--; commit_color_stuff(STD_ARGS); goto state_plain; }
 
1149
}
 
1150
#line 306
 
1151
 
 
1152
        
 
1153
 
 
1154
state_color_bg:
 
1155
        start = YYCURSOR;
 
1156
{
 
1157
        YYCTYPE yych;
 
1158
        unsigned int yyaccept;
 
1159
        goto yy89;
 
1160
yy90:   ++YYCURSOR;
 
1161
yy89:
 
1162
        if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
 
1163
        yych = *YYCURSOR;
 
1164
        switch(yych){
 
1165
        case '0':
 
1166
        case '1':
 
1167
        case '2':
 
1168
        case '3':
 
1169
        case '4':
 
1170
        case '5':
 
1171
        case '6':
 
1172
        case '7':
 
1173
        case '8':
 
1174
        case '9':       goto yy91;
 
1175
        default:        goto yy93;
 
1176
        }
 
1177
yy91:   yych = *++YYCURSOR;
 
1178
        switch(yych){
 
1179
        case '0':
 
1180
        case '1':
 
1181
        case '2':
 
1182
        case '3':
 
1183
        case '4':
 
1184
        case '5':
 
1185
        case '6':
 
1186
        case '7':
 
1187
        case '8':
 
1188
        case '9':       goto yy95;
 
1189
        default:        goto yy92;
 
1190
        }
 
1191
yy92:
 
1192
#line 312
 
1193
        { handle_color_digit(STD_ARGS, 1); commit_color_stuff(STD_ARGS); goto state_plain; }
 
1194
yy93:   yych = *++YYCURSOR;
 
1195
yy94:
 
1196
#line 313
 
1197
        { commit_color_stuff(STD_ARGS); PASSTHRU(); goto state_plain; }
 
1198
yy95:   yych = *++YYCURSOR;
 
1199
        goto yy92;
 
1200
}
 
1201
#line 314
 
1202
 
 
1203
 
 
1204
stop:
 
1205
        smart_str_free_ex(&mctx.scheme, 1);
 
1206
 
 
1207
        do_reset(STD_ARGS);
 
1208
}