Skip to content

Commit 954b6d1

Browse files
author
Kyle Maxwell
committed
handle typoed functions, etc with internal error message
1 parent 491a655 commit 954b6d1

File tree

7 files changed

+860
-0
lines changed

7 files changed

+860
-0
lines changed

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@ check-am:
4444
@echo "test..."; ./dexter -x test/test.dex test/test.xml | diff test/test.json - && echo " success."
4545
@echo "yelp..."; ./dexter test/yelp.dex test/yelp.html | diff test/yelp.json - && echo " success."
4646
@echo "optional..."; ./dexter test/optional.dex test/optional.html | diff test/optional.json - && echo " success."
47+
@echo "malformed-function..."; ./dexter test/malformed-function.dex test/malformed-function.html | diff test/malformed-function.json - && echo " success."
4748

Makefile.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,7 @@ check-am:
747747
@echo "test..."; ./dexter -x test/test.dex test/test.xml | diff test/test.json - && echo " success."
748748
@echo "yelp..."; ./dexter test/yelp.dex test/yelp.html | diff test/yelp.json - && echo " success."
749749
@echo "optional..."; ./dexter test/optional.dex test/optional.html | diff test/optional.json - && echo " success."
750+
@echo "malformed-function..."; ./dexter test/malformed-function.dex test/malformed-function.html | diff test/malformed-function.json - && echo " success."
750751
# Tell versions [3.59,3.63) of GNU make to not export all variables.
751752
# Otherwise a system limit (for SysV at least) may be exceeded.
752753
.NOEXPORT:

dexter.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ parsedDexPtr dex_parse_doc(dexPtr dex, xmlDocPtr doc) {
145145
ptr->dex = dex;
146146
ptr->xml = xsltApplyStylesheet(dex->stylesheet, doc, NULL);
147147
if(ptr->xml != NULL && ptr->error == NULL) visit(ptr, ptr->xml->children, false);
148+
if(ptr->xml == NULL && ptr->error == NULL) { // == NULL
149+
ptr->error = strdup("Internal runtime error");
150+
}
148151
return ptr;
149152
}
150153

dexter_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ int main (int argc, char **argv) {
123123
}
124124

125125
parsedDexPtr ptr = dex_parse_file(compiled, arguments.input_file, !(arguments.input_xml));
126+
126127
if(ptr->error != NULL) {
127128
fprintf(stderr, "Parsing failed: %s\n", ptr->error);
128129
exit(1);

test/malformed-function.dex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"row(tr)": [
3+
{
4+
"class": "str:replace(td:nth-child(1), 'w', 'W')",
5+
"default": "td:nth-child(3)"
6+
}
7+
]
8+
}

test/malformed-function.html

Lines changed: 845 additions & 0 deletions
Large diffs are not rendered by default.

test/malformed-function.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

0 commit comments

Comments
 (0)