# HG changeset patch # User lost@starbug # Date 1274036597 21600 # Node ID af5f2c51db76b7d74ff919849e835a71f0be18bc # Parent cf8c92d70eb150e7d3989afa3ccde5f294af1118 Bugfixing on includes diff -r cf8c92d70eb1 -r af5f2c51db76 lwasm/input.c --- a/lwasm/input.c Sun May 16 11:50:00 2010 -0600 +++ b/lwasm/input.c Sun May 16 13:03:17 2010 -0600 @@ -168,6 +168,7 @@ { /* absolute path */ IS -> data = fopen(s, "rb"); + debug_message(as, 1, "Opening (abs) %s", s); if (!IS -> data) { lw_error("Cannot open file '%s': %s", s, strerror(errno)); @@ -179,6 +180,7 @@ /* relative path, check relative to "current file" directory */ p = lw_stack_top(as -> file_dir); 0 == asprintf(&p2, "%s/%s", p, s); + debug_message(as, 1, "Open: (cd) %s\n", p2); IS -> data = fopen(p2, "rb"); if (IS -> data) { @@ -193,6 +195,7 @@ while (p = lw_stringlist_current(as -> include_list)) { 0 == asprintf(&p2, "%s/%s", p, s); + debug_message(as, 1, "Open (sp): %s\n", p2); IS -> data = fopen(p2, "rb"); if (IS -> data) { @@ -206,6 +209,7 @@ lw_error("Cannot open include file '%s': %s", s, strerror(errno)); case input_type_file: + debug_message(as, 1, "Opening (reg): %s\n", s); IS -> data = fopen(s, "rb"); if (!IS -> data) @@ -229,6 +233,7 @@ if (*s == '/') { /* absolute path */ + debug_message(as, 2, "Open file (st abs) %s", s); fp = fopen(s, "rb"); if (!fp) { @@ -240,6 +245,7 @@ /* relative path, check relative to "current file" directory */ p = lw_stack_top(as -> file_dir); 0 == asprintf(&p2, "%s/%s", p, s); + debug_message(as, 2, "Open file (st cd) %s", p2); fp = fopen(p2, "rb"); if (fp) { @@ -253,6 +259,7 @@ while (p = lw_stringlist_current(as -> include_list)) { 0 == asprintf(&p2, "%s/%s", p, s); + debug_message(as, 2, "Open file (st ip) %s", p2); fp = fopen(p2, "rb"); if (fp) { diff -r cf8c92d70eb1 -r af5f2c51db76 lwasm/pseudo.c --- a/lwasm/pseudo.c Sun May 16 11:50:00 2010 -0600 +++ b/lwasm/pseudo.c Sun May 16 13:03:17 2010 -0600 @@ -912,6 +912,7 @@ /* do nothing */ ; sym = lw_strndup(*p, i); + (*p) += i; s = lookup_symbol(as, l, sym); @@ -1005,6 +1006,7 @@ PARSEFUNC(pseudo_parse_include) { char *fn, *p2; + char *p3; int delim = 0; if (!**p) @@ -1027,11 +1029,13 @@ /* do nothing */ ; } fn = lw_strndup(*p, p2 - *p); - + (*p) = p2; if (delim && **p) (*p)++; - input_open(as, fn); + 0 == asprintf(&p3, "include:%s", fn); + input_open(as, p3); + lw_free(p3); l -> len = 0; }