File Coverage

tstr_cparse_rfc3339.c
Criterion Covered Total %
statement 165 283 58.3
branch 85 166 51.2
condition n/a
subroutine n/a
pod n/a
total 250 449 55.6


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