ucl_parser.c (242b24828472137ec4411826b86e753d49bd2c39) | ucl_parser.c (11dd9ed6647d821e7b43d4f8e64412a2623fbab5) |
---|---|
1/* Copyright (c) 2013, Vsevolod Stakhov 2 * All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above copyright --- 2455 unchanged lines hidden (view full) --- 2464 2465 parser->flags = flags; 2466 parser->includepaths = NULL; 2467 2468 if (flags & UCL_PARSER_SAVE_COMMENTS) { 2469 parser->comments = ucl_object_typed_new (UCL_OBJECT); 2470 } 2471 | 1/* Copyright (c) 2013, Vsevolod Stakhov 2 * All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above copyright --- 2455 unchanged lines hidden (view full) --- 2464 2465 parser->flags = flags; 2466 parser->includepaths = NULL; 2467 2468 if (flags & UCL_PARSER_SAVE_COMMENTS) { 2469 parser->comments = ucl_object_typed_new (UCL_OBJECT); 2470 } 2471 |
2472 /* Initial assumption about filevars */ 2473 ucl_parser_set_filevars (parser, NULL, false); | 2472 if (!(flags & UCL_PARSER_NO_FILEVARS)) { 2473 /* Initial assumption about filevars */ 2474 ucl_parser_set_filevars (parser, NULL, false); 2475 } |
2474 2475 return parser; 2476} 2477 2478bool 2479ucl_parser_set_default_priority (struct ucl_parser *parser, unsigned prio) 2480{ 2481 if (parser == NULL) { --- 130 unchanged lines hidden (view full) --- 2612 2613 if (parser->state != UCL_STATE_ERROR) { 2614 chunk = UCL_ALLOC (sizeof (struct ucl_chunk)); 2615 if (chunk == NULL) { 2616 ucl_create_err (&parser->err, "cannot allocate chunk structure"); 2617 return false; 2618 } 2619 | 2476 2477 return parser; 2478} 2479 2480bool 2481ucl_parser_set_default_priority (struct ucl_parser *parser, unsigned prio) 2482{ 2483 if (parser == NULL) { --- 130 unchanged lines hidden (view full) --- 2614 2615 if (parser->state != UCL_STATE_ERROR) { 2616 chunk = UCL_ALLOC (sizeof (struct ucl_chunk)); 2617 if (chunk == NULL) { 2618 ucl_create_err (&parser->err, "cannot allocate chunk structure"); 2619 return false; 2620 } 2621 |
2622 if (parse_type == UCL_PARSE_AUTO && len > 0) { 2623 /* We need to detect parse type by the first symbol */ 2624 if ((*data & 0x80) == 0x80 && (*data >= 0xdc && *data <= 0xdf)) { 2625 parse_type = UCL_PARSE_MSGPACK; 2626 } 2627 else if (*data == '(') { 2628 parse_type = UCL_PARSE_CSEXP; 2629 } 2630 else { 2631 parse_type = UCL_PARSE_UCL; 2632 } 2633 } 2634 |
|
2620 chunk->begin = data; 2621 chunk->remain = len; 2622 chunk->pos = chunk->begin; 2623 chunk->end = chunk->begin + len; 2624 chunk->line = 1; 2625 chunk->column = 0; 2626 chunk->priority = priority; 2627 chunk->strategy = strat; --- 10 unchanged lines hidden (view full) --- 2638 if (len > 0) { 2639 /* Need to parse something */ 2640 switch (parse_type) { 2641 default: 2642 case UCL_PARSE_UCL: 2643 return ucl_state_machine (parser); 2644 case UCL_PARSE_MSGPACK: 2645 return ucl_parse_msgpack (parser); | 2635 chunk->begin = data; 2636 chunk->remain = len; 2637 chunk->pos = chunk->begin; 2638 chunk->end = chunk->begin + len; 2639 chunk->line = 1; 2640 chunk->column = 0; 2641 chunk->priority = priority; 2642 chunk->strategy = strat; --- 10 unchanged lines hidden (view full) --- 2653 if (len > 0) { 2654 /* Need to parse something */ 2655 switch (parse_type) { 2656 default: 2657 case UCL_PARSE_UCL: 2658 return ucl_state_machine (parser); 2659 case UCL_PARSE_MSGPACK: 2660 return ucl_parse_msgpack (parser); |
2661 case UCL_PARSE_CSEXP: 2662 return ucl_parse_csexp (parser); |
|
2646 } 2647 } 2648 else { 2649 /* Just add empty chunk and go forward */ 2650 if (parser->top_obj == NULL) { 2651 /* 2652 * In case of empty object, create one to indicate that we've 2653 * read something --- 87 unchanged lines hidden --- | 2663 } 2664 } 2665 else { 2666 /* Just add empty chunk and go forward */ 2667 if (parser->top_obj == NULL) { 2668 /* 2669 * In case of empty object, create one to indicate that we've 2670 * read something --- 87 unchanged lines hidden --- |