File Coverage

tstr_cparse_asn1gt.c
Criterion Covered Total %
statement 150 254 59.0
branch 82 166 49.4
condition n/a
subroutine n/a
pod n/a
total 232 420 55.2


line stmt bran cond sub pod time code
1              
2             #line 1 "ragel/tstr_cparse_asn1gt.rl"
3             #include
4             #include
5             #include
6              
7             #include "tstr_parsed.h"
8             #include "tstr_token_parse.h"
9             #include "tstr_cparse.h"
10              
11              
12             #line 29 "ragel/tstr_cparse_asn1gt.rl"
13              
14              
15              
16             #line 17 "tstr_cparse_asn1gt.c"
17             static const int asn1gt_start = 1;
18             static const int asn1gt_first_final = 17;
19             static const int asn1gt_error = 0;
20              
21             static const int asn1gt_en_main = 1;
22              
23              
24             #line 32 "ragel/tstr_cparse_asn1gt.rl"
25              
26             tstr_parse_result_t tstr_cparse_asn1gt(const char* p,
27             size_t len,
28             tstr_parsed_t* parsed) {
29             int cs, v;
30             const char* pe = p + len;
31             const char* eof = pe;
32             const char* mark = NULL;
33             tstr_parse_result_t result = TSTR_PARSE_OK;
34              
35             (void)tstr_parsed_init(parsed);
36              
37            
38             #line 39 "tstr_cparse_asn1gt.c"
39             {
40 109           cs = asn1gt_start;
41             }
42              
43             #line 45 "ragel/tstr_cparse_asn1gt.rl"
44            
45             #line 46 "tstr_cparse_asn1gt.c"
46             {
47 109 50         if ( p == pe )
48 0           goto _test_eof;
49 109           switch ( cs )
50             {
51 109           case 1:
52 109 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
53 109           goto tr0;
54 0           goto st0;
55 0           st0:
56 0           cs = 0;
57 0           goto _out;
58 109           tr0:
59             #line 4 "ragel/tstr_common.rl"
60             { mark = p; }
61             goto st2;
62             st2:
63             if ( ++p == pe )
64             goto _test_eof2;
65             case 2:
66             #line 67 "tstr_cparse_asn1gt.c"
67 109 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
68 109           goto st3;
69 0           goto st0;
70 109           st3:
71 109 50         if ( ++p == pe )
72 0           goto _test_eof3;
73             case 3:
74 109 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
75 109           goto st4;
76 0           goto st0;
77 109           st4:
78 109 50         if ( ++p == pe )
79 0           goto _test_eof4;
80             case 4:
81 109 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
82 109           goto st5;
83 0           goto st0;
84 109           st5:
85 109 50         if ( ++p == pe )
86 0           goto _test_eof5;
87             case 5:
88 109 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
89 109           goto tr5;
90 0           goto st0;
91 109           tr5:
92             #line 6 "ragel/tstr_common.rl"
93             {
94             if (!tstr_token_parse_year(mark, p - mark, &v)) {
95             result = TSTR_PARSE_ERR_YEAR;
96             {p++; cs = 6; goto _out;}
97             }
98             tstr_parsed_set_year4(parsed, v);
99             }
100             #line 4 "ragel/tstr_common.rl"
101             { mark = p; }
102             goto st6;
103             st6:
104             if ( ++p == pe )
105             goto _test_eof6;
106             case 6:
107             #line 108 "tstr_cparse_asn1gt.c"
108 109 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
109 109           goto st7;
110 0           goto st0;
111 109           st7:
112 109 50         if ( ++p == pe )
113 0           goto _test_eof7;
114             case 7:
115 109 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
116 109           goto tr7;
117 0           goto st0;
118 109           tr7:
119             #line 22 "ragel/tstr_common.rl"
120             {
121             if (!tstr_token_parse_month(mark, p - mark, &v)) {
122             result = TSTR_PARSE_ERR_MONTH;
123             {p++; cs = 8; goto _out;}
124             }
125             tstr_parsed_set_month(parsed, v);
126             }
127             #line 4 "ragel/tstr_common.rl"
128             { mark = p; }
129             goto st8;
130             st8:
131             if ( ++p == pe )
132             goto _test_eof8;
133             case 8:
134             #line 135 "tstr_cparse_asn1gt.c"
135 109 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
136 109           goto st9;
137 0           goto st0;
138 109           st9:
139 109 50         if ( ++p == pe )
140 0           goto _test_eof9;
141             case 9:
142 109 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
143 109           goto tr9;
144 0           goto st0;
145 109           tr9:
146             #line 30 "ragel/tstr_common.rl"
147             {
148             if (!tstr_token_parse_day(mark, p - mark, &v)) {
149             result = TSTR_PARSE_ERR_DAY;
150             {p++; cs = 10; goto _out;}
151             }
152             tstr_parsed_set_day(parsed, v);
153             }
154             #line 4 "ragel/tstr_common.rl"
155             { mark = p; }
156             goto st10;
157             st10:
158             if ( ++p == pe )
159             goto _test_eof10;
160             case 10:
161             #line 162 "tstr_cparse_asn1gt.c"
162 109 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
163 109           goto st17;
164 0           goto st0;
165 109           st17:
166 109 50         if ( ++p == pe )
167 0           goto _test_eof17;
168             case 17:
169 109           switch( (*p) ) {
170 1           case 44: goto tr18;
171 7           case 46: goto tr18;
172 1           case 90: goto tr20;
173             }
174 100 50         if ( (*p) > 45 ) {
175 100 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
176 100           goto tr19;
177 0 0         } else if ( (*p) >= 43 )
178 0           goto tr17;
179 0           goto st0;
180 0           tr17:
181             #line 46 "ragel/tstr_common.rl"
182             {
183             if (!tstr_token_parse_hour(mark, p - mark, &v)) {
184             result = TSTR_PARSE_ERR_HOUR;
185             {p++; cs = 11; goto _out;}
186             }
187             tstr_parsed_set_hour(parsed, v);
188             }
189             #line 4 "ragel/tstr_common.rl"
190             { mark = p; }
191             goto st11;
192             tr22:
193             #line 70 "ragel/tstr_common.rl"
194             {
195             if (!tstr_token_parse_fraction(mark, p - mark, &v)) {
196             result = TSTR_PARSE_ERR_FRACTION;
197             {p++; cs = 11; goto _out;}
198             }
199             tstr_parsed_set_fraction(parsed, v);
200             }
201             #line 4 "ragel/tstr_common.rl"
202             { mark = p; }
203             goto st11;
204             tr32:
205             #line 54 "ragel/tstr_common.rl"
206             {
207             if (!tstr_token_parse_minute(mark, p - mark, &v)) {
208             result = TSTR_PARSE_ERR_MINUTE;
209             {p++; cs = 11; goto _out;}
210             }
211             tstr_parsed_set_minute(parsed, v);
212             }
213             #line 4 "ragel/tstr_common.rl"
214             { mark = p; }
215             goto st11;
216             tr36:
217             #line 62 "ragel/tstr_common.rl"
218             {
219             if (!tstr_token_parse_second(mark, p - mark, &v)) {
220             result = TSTR_PARSE_ERR_SECOND;
221             {p++; cs = 11; goto _out;}
222             }
223             tstr_parsed_set_second(parsed, v);
224             }
225             #line 4 "ragel/tstr_common.rl"
226             { mark = p; }
227             goto st11;
228             st11:
229             if ( ++p == pe )
230             goto _test_eof11;
231             case 11:
232             #line 233 "tstr_cparse_asn1gt.c"
233 22 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
234 22           goto st12;
235 0           goto st0;
236 22           st12:
237 22 50         if ( ++p == pe )
238 0           goto _test_eof12;
239             case 12:
240 22 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
241 22           goto st18;
242 0           goto st0;
243 22           st18:
244 22 100         if ( ++p == pe )
245 5           goto _test_eof18;
246             case 18:
247 17 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
248 17           goto st13;
249 0           goto st0;
250 17           st13:
251 17 50         if ( ++p == pe )
252 0           goto _test_eof13;
253             case 13:
254 17 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
255 17           goto st19;
256 0           goto st0;
257 17           st19:
258 17 50         if ( ++p == pe )
259 17           goto _test_eof19;
260             case 19:
261 0           goto st0;
262 8           tr18:
263             #line 46 "ragel/tstr_common.rl"
264             {
265             if (!tstr_token_parse_hour(mark, p - mark, &v)) {
266             result = TSTR_PARSE_ERR_HOUR;
267             {p++; cs = 14; goto _out;}
268             }
269             tstr_parsed_set_hour(parsed, v);
270             }
271             goto st14;
272             tr33:
273             #line 54 "ragel/tstr_common.rl"
274             {
275             if (!tstr_token_parse_minute(mark, p - mark, &v)) {
276             result = TSTR_PARSE_ERR_MINUTE;
277             {p++; cs = 14; goto _out;}
278             }
279             tstr_parsed_set_minute(parsed, v);
280             }
281             goto st14;
282             tr37:
283             #line 62 "ragel/tstr_common.rl"
284             {
285             if (!tstr_token_parse_second(mark, p - mark, &v)) {
286             result = TSTR_PARSE_ERR_SECOND;
287             {p++; cs = 14; goto _out;}
288             }
289             tstr_parsed_set_second(parsed, v);
290             }
291             goto st14;
292             st14:
293             if ( ++p == pe )
294             goto _test_eof14;
295             case 14:
296             #line 297 "tstr_cparse_asn1gt.c"
297 78 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
298 78           goto tr14;
299 0           goto st0;
300 78           tr14:
301             #line 4 "ragel/tstr_common.rl"
302             { mark = p; }
303             goto st20;
304             st20:
305             if ( ++p == pe )
306             goto _test_eof20;
307             case 20:
308             #line 309 "tstr_cparse_asn1gt.c"
309 78           switch( (*p) ) {
310 0           case 43: goto tr22;
311 0           case 45: goto tr22;
312 7           case 90: goto tr24;
313             }
314 71 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
315 71           goto st21;
316 0           goto st0;
317 71           st21:
318 71 50         if ( ++p == pe )
319 0           goto _test_eof21;
320             case 21:
321 71           switch( (*p) ) {
322 0           case 43: goto tr22;
323 0           case 45: goto tr22;
324 12           case 90: goto tr24;
325             }
326 59 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
327 59           goto st22;
328 0           goto st0;
329 59           st22:
330 59 50         if ( ++p == pe )
331 0           goto _test_eof22;
332             case 22:
333 59           switch( (*p) ) {
334 0           case 43: goto tr22;
335 0           case 45: goto tr22;
336 10           case 90: goto tr24;
337             }
338 49 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
339 49           goto st23;
340 0           goto st0;
341 49           st23:
342 49 50         if ( ++p == pe )
343 0           goto _test_eof23;
344             case 23:
345 49           switch( (*p) ) {
346 0           case 43: goto tr22;
347 0           case 45: goto tr22;
348 10           case 90: goto tr24;
349             }
350 39 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
351 39           goto st24;
352 0           goto st0;
353 39           st24:
354 39 50         if ( ++p == pe )
355 0           goto _test_eof24;
356             case 24:
357 39           switch( (*p) ) {
358 0           case 43: goto tr22;
359 0           case 45: goto tr22;
360 5           case 90: goto tr24;
361             }
362 34 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
363 34           goto st25;
364 0           goto st0;
365 34           st25:
366 34 50         if ( ++p == pe )
367 0           goto _test_eof25;
368             case 25:
369 34           switch( (*p) ) {
370 0           case 43: goto tr22;
371 0           case 45: goto tr22;
372 8           case 90: goto tr24;
373             }
374 26 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
375 26           goto st26;
376 0           goto st0;
377 26           st26:
378 26 50         if ( ++p == pe )
379 0           goto _test_eof26;
380             case 26:
381 26           switch( (*p) ) {
382 0           case 43: goto tr22;
383 0           case 45: goto tr22;
384 5           case 90: goto tr24;
385             }
386 21 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
387 21           goto st27;
388 0           goto st0;
389 21           st27:
390 21 50         if ( ++p == pe )
391 0           goto _test_eof27;
392             case 27:
393 21           switch( (*p) ) {
394 0           case 43: goto tr22;
395 0           case 45: goto tr22;
396 5           case 90: goto tr24;
397             }
398 16 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
399 16           goto st28;
400 0           goto st0;
401 16           st28:
402 16 50         if ( ++p == pe )
403 0           goto _test_eof28;
404             case 28:
405 16           switch( (*p) ) {
406 0           case 43: goto tr22;
407 0           case 45: goto tr22;
408 16           case 90: goto tr24;
409             }
410 0           goto st0;
411 1           tr20:
412             #line 46 "ragel/tstr_common.rl"
413             {
414             if (!tstr_token_parse_hour(mark, p - mark, &v)) {
415             result = TSTR_PARSE_ERR_HOUR;
416             {p++; cs = 29; goto _out;}
417             }
418             tstr_parsed_set_hour(parsed, v);
419             }
420             #line 4 "ragel/tstr_common.rl"
421             { mark = p; }
422             goto st29;
423             tr24:
424             #line 70 "ragel/tstr_common.rl"
425             {
426             if (!tstr_token_parse_fraction(mark, p - mark, &v)) {
427             result = TSTR_PARSE_ERR_FRACTION;
428             {p++; cs = 29; goto _out;}
429             }
430             tstr_parsed_set_fraction(parsed, v);
431             }
432             #line 4 "ragel/tstr_common.rl"
433             { mark = p; }
434             goto st29;
435             tr35:
436             #line 54 "ragel/tstr_common.rl"
437             {
438             if (!tstr_token_parse_minute(mark, p - mark, &v)) {
439             result = TSTR_PARSE_ERR_MINUTE;
440             {p++; cs = 29; goto _out;}
441             }
442             tstr_parsed_set_minute(parsed, v);
443             }
444             #line 4 "ragel/tstr_common.rl"
445             { mark = p; }
446             goto st29;
447             tr38:
448             #line 62 "ragel/tstr_common.rl"
449             {
450             if (!tstr_token_parse_second(mark, p - mark, &v)) {
451             result = TSTR_PARSE_ERR_SECOND;
452             {p++; cs = 29; goto _out;}
453             }
454             tstr_parsed_set_second(parsed, v);
455             }
456             #line 4 "ragel/tstr_common.rl"
457             { mark = p; }
458             goto st29;
459             st29:
460             if ( ++p == pe )
461             goto _test_eof29;
462             case 29:
463             #line 464 "tstr_cparse_asn1gt.c"
464 0           goto st0;
465 100           tr19:
466             #line 46 "ragel/tstr_common.rl"
467             {
468             if (!tstr_token_parse_hour(mark, p - mark, &v)) {
469             result = TSTR_PARSE_ERR_HOUR;
470             {p++; cs = 15; goto _out;}
471             }
472             tstr_parsed_set_hour(parsed, v);
473             }
474             #line 4 "ragel/tstr_common.rl"
475             { mark = p; }
476             goto st15;
477             st15:
478             if ( ++p == pe )
479             goto _test_eof15;
480             case 15:
481             #line 482 "tstr_cparse_asn1gt.c"
482 100 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
483 100           goto st30;
484 0           goto st0;
485 100           st30:
486 100 50         if ( ++p == pe )
487 0           goto _test_eof30;
488             case 30:
489 100           switch( (*p) ) {
490 1           case 44: goto tr33;
491 9           case 46: goto tr33;
492 1           case 90: goto tr35;
493             }
494 89 50         if ( (*p) > 45 ) {
495 89 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
496 89           goto tr34;
497 0 0         } else if ( (*p) >= 43 )
498 0           goto tr32;
499 0           goto st0;
500 89           tr34:
501             #line 54 "ragel/tstr_common.rl"
502             {
503             if (!tstr_token_parse_minute(mark, p - mark, &v)) {
504             result = TSTR_PARSE_ERR_MINUTE;
505             {p++; cs = 16; goto _out;}
506             }
507             tstr_parsed_set_minute(parsed, v);
508             }
509             #line 4 "ragel/tstr_common.rl"
510             { mark = p; }
511             goto st16;
512             st16:
513             if ( ++p == pe )
514             goto _test_eof16;
515             case 16:
516             #line 517 "tstr_cparse_asn1gt.c"
517 89 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
518 89           goto st31;
519 0           goto st0;
520 89           st31:
521 89 50         if ( ++p == pe )
522 0           goto _test_eof31;
523             case 31:
524 89           switch( (*p) ) {
525 2           case 44: goto tr37;
526 58           case 46: goto tr37;
527 7           case 90: goto tr38;
528             }
529 22 50         if ( 43 <= (*p) && (*p) <= 45 )
    50          
530 22           goto tr36;
531 0           goto st0;
532             }
533 0           _test_eof2: cs = 2; goto _test_eof;
534 0           _test_eof3: cs = 3; goto _test_eof;
535 0           _test_eof4: cs = 4; goto _test_eof;
536 0           _test_eof5: cs = 5; goto _test_eof;
537 0           _test_eof6: cs = 6; goto _test_eof;
538 0           _test_eof7: cs = 7; goto _test_eof;
539 0           _test_eof8: cs = 8; goto _test_eof;
540 0           _test_eof9: cs = 9; goto _test_eof;
541 0           _test_eof10: cs = 10; goto _test_eof;
542 0           _test_eof17: cs = 17; goto _test_eof;
543 0           _test_eof11: cs = 11; goto _test_eof;
544 0           _test_eof12: cs = 12; goto _test_eof;
545 5           _test_eof18: cs = 18; goto _test_eof;
546 0           _test_eof13: cs = 13; goto _test_eof;
547 17           _test_eof19: cs = 19; goto _test_eof;
548 0           _test_eof14: cs = 14; goto _test_eof;
549 0           _test_eof20: cs = 20; goto _test_eof;
550 0           _test_eof21: cs = 21; goto _test_eof;
551 0           _test_eof22: cs = 22; goto _test_eof;
552 0           _test_eof23: cs = 23; goto _test_eof;
553 0           _test_eof24: cs = 24; goto _test_eof;
554 0           _test_eof25: cs = 25; goto _test_eof;
555 0           _test_eof26: cs = 26; goto _test_eof;
556 0           _test_eof27: cs = 27; goto _test_eof;
557 0           _test_eof28: cs = 28; goto _test_eof;
558 87           _test_eof29: cs = 29; goto _test_eof;
559 0           _test_eof15: cs = 15; goto _test_eof;
560 0           _test_eof30: cs = 30; goto _test_eof;
561 0           _test_eof16: cs = 16; goto _test_eof;
562 0           _test_eof31: cs = 31; goto _test_eof;
563              
564 109           _test_eof: {}
565 109 50         if ( p == eof )
566             {
567 109           switch ( cs ) {
568 0           case 17:
569             #line 46 "ragel/tstr_common.rl"
570             {
571             if (!tstr_token_parse_hour(mark, p - mark, &v)) {
572             result = TSTR_PARSE_ERR_HOUR;
573             {p++; cs = 0; goto _out;}
574             }
575             tstr_parsed_set_hour(parsed, v);
576             }
577             break;
578             case 30:
579             #line 54 "ragel/tstr_common.rl"
580             {
581             if (!tstr_token_parse_minute(mark, p - mark, &v)) {
582             result = TSTR_PARSE_ERR_MINUTE;
583             {p++; cs = 0; goto _out;}
584             }
585             tstr_parsed_set_minute(parsed, v);
586             }
587             break;
588             case 31:
589             #line 62 "ragel/tstr_common.rl"
590             {
591             if (!tstr_token_parse_second(mark, p - mark, &v)) {
592             result = TSTR_PARSE_ERR_SECOND;
593             {p++; cs = 0; goto _out;}
594             }
595             tstr_parsed_set_second(parsed, v);
596             }
597             break;
598             case 20:
599             case 21:
600             case 22:
601             case 23:
602             case 24:
603             case 25:
604             case 26:
605             case 27:
606             case 28:
607             #line 70 "ragel/tstr_common.rl"
608             {
609             if (!tstr_token_parse_fraction(mark, p - mark, &v)) {
610             result = TSTR_PARSE_ERR_FRACTION;
611             {p++; cs = 0; goto _out;}
612             }
613             tstr_parsed_set_fraction(parsed, v);
614             }
615             break;
616             case 18:
617             case 19:
618             #line 78 "ragel/tstr_common.rl"
619             {
620             if (!tstr_token_parse_tz_offset(mark, p - mark, &v)) {
621             result = TSTR_PARSE_ERR_OFFSET;
622             {p++; cs = 0; goto _out;}
623             }
624             tstr_parsed_set_offset(parsed, v);
625             }
626             break;
627             case 29:
628             #line 86 "ragel/tstr_common.rl"
629             {
630             tstr_parsed_set_tz_utc(parsed, mark, p - mark);
631             }
632             break;
633             #line 634 "tstr_cparse_asn1gt.c"
634             }
635             }
636              
637 109 50         _out: {}
638             }
639              
640             #line 46 "ragel/tstr_cparse_asn1gt.rl"
641              
642             if (result != TSTR_PARSE_OK)
643             return result;
644              
645             return (cs >= asn1gt_first_final) ? TSTR_PARSE_OK : TSTR_PARSE_NOMATCH;
646             }