Mercurial > hg-old > index.cgi
changeset 257:e27279180a73 2.x
Added support for include path to LWASM
author | lost |
---|---|
date | Tue, 22 Dec 2009 04:53:20 +0000 |
parents | 6e2d03188d24 |
children | be5a84c8f4e4 16c73b13ee0b |
files | ChangeLog lwasm/instab.c lwasm/lwasm.h lwasm/main.c lwasm/pseudo.c |
diffstat | 5 files changed, 46 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Dec 22 04:52:59 2009 +0000 +++ b/ChangeLog Tue Dec 22 04:53:20 2009 +0000 @@ -35,8 +35,10 @@ [ ] Added rejection for comment not starting at start of line but which looks like a symbol (single word ending in :, no space after ; or *) [LWASM] -[ ] Support input files with line numbers for compatibility with EDTASM +[+] Support input files with line numbers for compatibility with EDTASM and others that use line numbers [LWASM] +[+] Add support for an include path, always include from current dir + unless file not found [LWASM] Version 2.5
--- a/lwasm/instab.c Tue Dec 22 04:52:59 2009 +0000 +++ b/lwasm/instab.c Tue Dec 22 04:53:20 2009 +0000 @@ -408,7 +408,6 @@ { "endm", { -1, -1, -1, -1}, pseudo_endm, 1, 1, 1 }, { "struct", { -1, -1, -1, -1}, pseudo_struct, 0, 0, 0 }, - { "ends", { -1, -1, -1, -1}, pseudo_endstruct, 0, 0, 0, 0, 1}, { "endstruct", { -1, -1, -1, -1}, pseudo_endstruct, 0, 0, 0, 0, 1 }, { "setdp", { -1, -1, -1, -1}, pseudo_setdp },
--- a/lwasm/lwasm.h Tue Dec 22 04:52:59 2009 +0000 +++ b/lwasm/lwasm.h Tue Dec 22 04:53:20 2009 +0000 @@ -216,6 +216,9 @@ int nextdeps; // number forced external deps char **extdeps; // external dependencies + + char **includedirs; // include path + int nincludedirs; // number of entries in include path } asmstate_t; // do not rewrite XXX,r to ,r if XXX evaluates to 0
--- a/lwasm/main.c Tue Dec 22 04:52:59 2009 +0000 +++ b/lwasm/main.c Tue Dec 22 04:53:20 2009 +0000 @@ -31,6 +31,7 @@ #include <unistd.h> #include "lwasm.h" +#include "util.h" // external declarations extern void lwasm_pass1(asmstate_t *as); @@ -50,6 +51,11 @@ switch (key) { + case 'I': + as -> includedirs = lwasm_realloc(as -> includedirs, (as -> nincludedirs + 1) * sizeof(char *)); + as -> includedirs[as -> nincludedirs++] = arg; + break; + case 'o': // output if (as -> outfile) @@ -166,6 +172,8 @@ "Set assembler to 6809 only mode" }, { "6309", '3', 0, 0, "Set assembler to 6309 mode (default)" }, + { "includedir", 'I', "PATH", 0, + "Add entry to include path" }, { 0 } };
--- a/lwasm/pseudo.c Tue Dec 22 04:52:59 2009 +0000 +++ b/lwasm/pseudo.c Tue Dec 22 04:53:20 2009 +0000 @@ -130,6 +130,38 @@ if (**p == '"') (*p)++; + // resolve file name + if (*fn != '/') + { + char *path; + int i; + FILE *fp; + + fp = fopen(fn, "r"); + if (!fp) + { + + + for (i = 0; i < as -> nincludedirs; i++) + { + 0 == asprintf(&path, "%s/%s", as -> includedirs[i], fn); + fp = fopen(path, "r"); + if (fp) + { + fclose(fp); + lwasm_free(fn); + fn = path; + break; + } + lwasm_free(path); + } + } + else + { + fclose(fp); + } + } + // end local label context on include as -> context = lwasm_next_context(as); if (lwasm_read_file(as, fn) < 0)