diff options
Diffstat (limited to 'lib/skin_parser')
-rw-r--r-- | lib/skin_parser/skin_debug.c | 18 | ||||
-rw-r--r-- | lib/skin_parser/skin_debug.h | 3 | ||||
-rw-r--r-- | lib/skin_parser/skin_parser.c | 26 |
3 files changed, 33 insertions, 14 deletions
diff --git a/lib/skin_parser/skin_debug.c b/lib/skin_parser/skin_debug.c index 4abe6252f0..c03b32e910 100644 --- a/lib/skin_parser/skin_debug.c +++ b/lib/skin_parser/skin_debug.c | |||
@@ -30,15 +30,25 @@ | |||
30 | /* Global variables for debug output */ | 30 | /* Global variables for debug output */ |
31 | int debug_indent_level = 0; | 31 | int debug_indent_level = 0; |
32 | extern int skin_line; | 32 | extern int skin_line; |
33 | extern char* skin_start; | ||
33 | 34 | ||
34 | /* Global error variables */ | 35 | /* Global error variables */ |
35 | int error_line; | 36 | int error_line; |
37 | int error_col; | ||
36 | char* error_message; | 38 | char* error_message; |
37 | 39 | ||
38 | /* Debugging functions */ | 40 | /* Debugging functions */ |
39 | void skin_error(enum skin_errorcode error) | 41 | void skin_error(enum skin_errorcode error, char* cursor) |
40 | { | 42 | { |
41 | 43 | ||
44 | error_col = 0; | ||
45 | |||
46 | while(cursor > skin_start && *cursor != '\n') | ||
47 | { | ||
48 | cursor--; | ||
49 | error_col++; | ||
50 | } | ||
51 | |||
42 | error_line = skin_line; | 52 | error_line = skin_line; |
43 | 53 | ||
44 | switch(error) | 54 | switch(error) |
@@ -91,6 +101,11 @@ int skin_error_line() | |||
91 | return error_line; | 101 | return error_line; |
92 | } | 102 | } |
93 | 103 | ||
104 | int skin_error_col() | ||
105 | { | ||
106 | return error_col; | ||
107 | } | ||
108 | |||
94 | char* skin_error_message() | 109 | char* skin_error_message() |
95 | { | 110 | { |
96 | return error_message; | 111 | return error_message; |
@@ -99,6 +114,7 @@ char* skin_error_message() | |||
99 | void skin_clear_errors() | 114 | void skin_clear_errors() |
100 | { | 115 | { |
101 | error_line = 0; | 116 | error_line = 0; |
117 | error_col = 0; | ||
102 | error_message = NULL; | 118 | error_message = NULL; |
103 | } | 119 | } |
104 | 120 | ||
diff --git a/lib/skin_parser/skin_debug.h b/lib/skin_parser/skin_debug.h index 8fc061a9f9..fbff5cbb4c 100644 --- a/lib/skin_parser/skin_debug.h +++ b/lib/skin_parser/skin_debug.h | |||
@@ -31,8 +31,9 @@ extern "C" | |||
31 | #include "skin_parser.h" | 31 | #include "skin_parser.h" |
32 | #ifndef ROCKBOX | 32 | #ifndef ROCKBOX |
33 | /* Debugging functions */ | 33 | /* Debugging functions */ |
34 | void skin_error(enum skin_errorcode error); | 34 | void skin_error(enum skin_errorcode error, char* cursor); |
35 | int skin_error_line(void); | 35 | int skin_error_line(void); |
36 | int skin_error_col(void); | ||
36 | char* skin_error_message(void); | 37 | char* skin_error_message(void); |
37 | void skin_clear_errors(void); | 38 | void skin_clear_errors(void); |
38 | void skin_debug_tree(struct skin_element* root); | 39 | void skin_debug_tree(struct skin_element* root); |
diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c index 5bc5984fb7..3e23067258 100644 --- a/lib/skin_parser/skin_parser.c +++ b/lib/skin_parser/skin_parser.c | |||
@@ -34,6 +34,7 @@ | |||
34 | 34 | ||
35 | /* Global variables for the parser */ | 35 | /* Global variables for the parser */ |
36 | int skin_line = 0; | 36 | int skin_line = 0; |
37 | char* skin_start = 0; | ||
37 | int viewport_line = 0; | 38 | int viewport_line = 0; |
38 | 39 | ||
39 | /* Auxiliary parsing functions (not visible at global scope) */ | 40 | /* Auxiliary parsing functions (not visible at global scope) */ |
@@ -66,6 +67,7 @@ struct skin_element* skin_parse(const char* document) | |||
66 | char* cursor = (char*)document; /*Keeps track of location in the document*/ | 67 | char* cursor = (char*)document; /*Keeps track of location in the document*/ |
67 | 68 | ||
68 | skin_line = 1; | 69 | skin_line = 1; |
70 | skin_start = (char*)document; | ||
69 | viewport_line = 0; | 71 | viewport_line = 0; |
70 | 72 | ||
71 | skin_clear_errors(); | 73 | skin_clear_errors(); |
@@ -381,7 +383,7 @@ static struct skin_element* skin_parse_sublines_optional(char** document, | |||
381 | 383 | ||
382 | if(*cursor != MULTILINESYM && i != sublines - 1) | 384 | if(*cursor != MULTILINESYM && i != sublines - 1) |
383 | { | 385 | { |
384 | skin_error(MULTILINE_EXPECTED); | 386 | skin_error(MULTILINE_EXPECTED, cursor); |
385 | return NULL; | 387 | return NULL; |
386 | } | 388 | } |
387 | else if(i != sublines - 1) | 389 | else if(i != sublines - 1) |
@@ -433,7 +435,7 @@ static int skin_parse_tag(struct skin_element* element, char** document) | |||
433 | 435 | ||
434 | if(!tag) | 436 | if(!tag) |
435 | { | 437 | { |
436 | skin_error(ILLEGAL_TAG); | 438 | skin_error(ILLEGAL_TAG, cursor); |
437 | return 0; | 439 | return 0; |
438 | } | 440 | } |
439 | 441 | ||
@@ -464,7 +466,7 @@ static int skin_parse_tag(struct skin_element* element, char** document) | |||
464 | /* Checking the number of arguments and allocating args */ | 466 | /* Checking the number of arguments and allocating args */ |
465 | if(*cursor != ARGLISTOPENSYM && tag_args[0] != '|') | 467 | if(*cursor != ARGLISTOPENSYM && tag_args[0] != '|') |
466 | { | 468 | { |
467 | skin_error(ARGLIST_EXPECTED); | 469 | skin_error(ARGLIST_EXPECTED, cursor); |
468 | return 0; | 470 | return 0; |
469 | } | 471 | } |
470 | else | 472 | else |
@@ -512,7 +514,7 @@ static int skin_parse_tag(struct skin_element* element, char** document) | |||
512 | /* Making sure we haven't run out of arguments */ | 514 | /* Making sure we haven't run out of arguments */ |
513 | if(*tag_args == '\0') | 515 | if(*tag_args == '\0') |
514 | { | 516 | { |
515 | skin_error(TOO_MANY_ARGS); | 517 | skin_error(TOO_MANY_ARGS, cursor); |
516 | return 0; | 518 | return 0; |
517 | } | 519 | } |
518 | 520 | ||
@@ -545,7 +547,7 @@ static int skin_parse_tag(struct skin_element* element, char** document) | |||
545 | } | 547 | } |
546 | else | 548 | else |
547 | { | 549 | { |
548 | skin_error(DEFAULT_NOT_ALLOWED); | 550 | skin_error(DEFAULT_NOT_ALLOWED, cursor); |
549 | return 0; | 551 | return 0; |
550 | } | 552 | } |
551 | } | 553 | } |
@@ -554,7 +556,7 @@ static int skin_parse_tag(struct skin_element* element, char** document) | |||
554 | /* Scanning an int argument */ | 556 | /* Scanning an int argument */ |
555 | if(!isdigit(*cursor) && *cursor != '-') | 557 | if(!isdigit(*cursor) && *cursor != '-') |
556 | { | 558 | { |
557 | skin_error(INT_EXPECTED); | 559 | skin_error(INT_EXPECTED, cursor); |
558 | return 0; | 560 | return 0; |
559 | } | 561 | } |
560 | 562 | ||
@@ -610,12 +612,12 @@ static int skin_parse_tag(struct skin_element* element, char** document) | |||
610 | 612 | ||
611 | if(*cursor != ARGLISTSEPERATESYM && i < num_args - 1) | 613 | if(*cursor != ARGLISTSEPERATESYM && i < num_args - 1) |
612 | { | 614 | { |
613 | skin_error(SEPERATOR_EXPECTED); | 615 | skin_error(SEPERATOR_EXPECTED, cursor); |
614 | return 0; | 616 | return 0; |
615 | } | 617 | } |
616 | else if(*cursor != ARGLISTCLOSESYM && i == num_args - 1) | 618 | else if(*cursor != ARGLISTCLOSESYM && i == num_args - 1) |
617 | { | 619 | { |
618 | skin_error(CLOSE_EXPECTED); | 620 | skin_error(CLOSE_EXPECTED, cursor); |
619 | return 0; | 621 | return 0; |
620 | } | 622 | } |
621 | else | 623 | else |
@@ -639,7 +641,7 @@ static int skin_parse_tag(struct skin_element* element, char** document) | |||
639 | /* Checking for a premature end */ | 641 | /* Checking for a premature end */ |
640 | if(*tag_args != '\0' && !optional) | 642 | if(*tag_args != '\0' && !optional) |
641 | { | 643 | { |
642 | skin_error(INSUFFICIENT_ARGS); | 644 | skin_error(INSUFFICIENT_ARGS, cursor); |
643 | return 0; | 645 | return 0; |
644 | } | 646 | } |
645 | 647 | ||
@@ -724,7 +726,7 @@ static int skin_parse_conditional(struct skin_element* element, char** document) | |||
724 | /* Counting the children */ | 726 | /* Counting the children */ |
725 | if(*(cursor++) != ENUMLISTOPENSYM) | 727 | if(*(cursor++) != ENUMLISTOPENSYM) |
726 | { | 728 | { |
727 | skin_error(ARGLIST_EXPECTED); | 729 | skin_error(ARGLIST_EXPECTED, cursor); |
728 | return 0; | 730 | return 0; |
729 | } | 731 | } |
730 | bookmark = cursor; | 732 | bookmark = cursor; |
@@ -768,12 +770,12 @@ static int skin_parse_conditional(struct skin_element* element, char** document) | |||
768 | 770 | ||
769 | if(i < children - 1 && *cursor != ENUMLISTSEPERATESYM) | 771 | if(i < children - 1 && *cursor != ENUMLISTSEPERATESYM) |
770 | { | 772 | { |
771 | skin_error(SEPERATOR_EXPECTED); | 773 | skin_error(SEPERATOR_EXPECTED, cursor); |
772 | return 0; | 774 | return 0; |
773 | } | 775 | } |
774 | else if(i == children - 1 && *cursor != ENUMLISTCLOSESYM) | 776 | else if(i == children - 1 && *cursor != ENUMLISTCLOSESYM) |
775 | { | 777 | { |
776 | skin_error(CLOSE_EXPECTED); | 778 | skin_error(CLOSE_EXPECTED, cursor); |
777 | return 0; | 779 | return 0; |
778 | } | 780 | } |
779 | else | 781 | else |