Mercurial > hg > index.cgi
diff lwasm/input.c @ 10:127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
author | lost@l-w.ca |
---|---|
date | Sat, 22 Jan 2011 10:37:53 -0700 |
parents | 7317fbe024af |
children | 1f77ae5c3590 |
line wrap: on
line diff
--- a/lwasm/input.c Sat Jan 22 10:04:32 2011 -0700 +++ b/lwasm/input.c Sat Jan 22 10:37:53 2011 -0700 @@ -58,6 +58,16 @@ char *filespec; }; +static char *make_filename(char *p, char *f) +{ + int l; + char *r; + l = strlen(p) + strlen(f) + 1; + r = lw_alloc(l + 1); + sprintf(r, "%s/%s", p, f); + return r; +} + #define IS ((struct input_stack *)(as -> input_data)) void input_init(asmstate_t *as) @@ -179,7 +189,7 @@ /* relative path, check relative to "current file" directory */ p = lw_stack_top(as -> file_dir); - (void)(0 == asprintf(&p2, "%s/%s", p, s)); + p2 = make_filename(p, s); debug_message(as, 1, "Open: (cd) %s\n", p2); IS -> data = fopen(p2, "rb"); if (IS -> data) @@ -195,7 +205,7 @@ lw_stringlist_reset(as -> include_list); while ((p = lw_stringlist_current(as -> include_list))) { - (void)(0 == asprintf(&p2, "%s/%s", p, s)); + p2 = make_filename(p, s); debug_message(as, 1, "Open (sp): %s\n", p2); IS -> data = fopen(p2, "rb"); if (IS -> data) @@ -247,7 +257,7 @@ /* relative path, check relative to "current file" directory */ p = lw_stack_top(as -> file_dir); - (void)(0 == asprintf(&p2, "%s/%s", p, s)); + p2 = make_filename(p, s); debug_message(as, 2, "Open file (st cd) %s", p2); fp = fopen(p2, "rb"); if (fp) @@ -261,7 +271,7 @@ lw_stringlist_reset(as -> include_list); while ((p = lw_stringlist_current(as -> include_list))) { - (void)(0 == asprintf(&p2, "%s/%s", p, s)); + p2 = make_filename(p, s); debug_message(as, 2, "Open file (st ip) %s", p2); fp = fopen(p2, "rb"); if (fp)