File Coverage

tstr_cparse_rfc4287.c
Criterion Covered Total %
statement 152 271 56.0
branch 84 168 50.0
condition n/a
subroutine n/a
pod n/a
total 236 439 53.7


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