File Coverage

tstr_cparse_w3cdtf.c
Criterion Covered Total %
statement 164 271 60.5
branch 87 168 51.7
condition n/a
subroutine n/a
pod n/a
total 251 439 57.1


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