File Coverage

tstr_cparse_iso9075.c
Criterion Covered Total %
statement 164 254 64.5
branch 104 186 55.9
condition n/a
subroutine n/a
pod n/a
total 268 440 60.9


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