aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2018-11-24 14:33:48 +0300
committerCyrill Gorcunov <gorcunov@gmail.com>2018-11-24 14:33:48 +0300
commit8c0666b0e6896c79ae2e4d2390962c951a1bea83 (patch)
tree1cf45c54e4a021b4af9413404906fdd829a3eec6
parentb7bb5acdaf942acd2c4030a32dd21017678f1c3e (diff)
downloadnasm-8c0666b0e6896c79ae2e4d2390962c951a1bea83.tar.gz
nasm-8c0666b0e6896c79ae2e4d2390962c951a1bea83.tar.xz
nasm-8c0666b0e6896c79ae2e4d2390962c951a1bea83.zip
preproc: Pass include paths as strlist
Instead of copying data just reuse already allocated paths. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-rw-r--r--asm/nasm.c13
-rw-r--r--asm/preproc-nop.c4
-rw-r--r--asm/preproc.c17
-rw-r--r--include/nasm.h2
4 files changed, 14 insertions, 22 deletions
diff --git a/asm/nasm.c b/asm/nasm.c
index 37c82d64..8f23b4b3 100644
--- a/asm/nasm.c
+++ b/asm/nasm.c
@@ -328,18 +328,11 @@ static void define_macros(void)
* Command-line specified preprocessor directives (-p, -d, -u,
* --pragma, --before) are processed after this function.
*/
-static void preproc_init(struct strlist **ipath)
+static void preproc_init(struct strlist *ipath)
{
- struct strlist_entry *l;
-
preproc->init();
define_macros();
-
- list_for_each(l, (*ipath)->head)
- preproc->include_path(l->str);
-
- strlist_free(*ipath);
- *ipath = strlist_alloc();
+ preproc->include_path(ipath);
}
static void emit_dependencies(struct strlist *list)
@@ -503,7 +496,7 @@ int main(int argc, char **argv)
}
}
- preproc_init(&include_path);
+ preproc_init(include_path);
parse_cmdline(argc, argv, 2);
if (terminate_after_phase) {
diff --git a/asm/preproc-nop.c b/asm/preproc-nop.c
index 90f18e60..655eff7f 100644
--- a/asm/preproc-nop.c
+++ b/asm/preproc-nop.c
@@ -170,9 +170,9 @@ static void nop_pre_command(const char *what, char *string)
(void)string;
}
-static void nop_include_path(const char *path)
+static void nop_include_path(struct strlist *list)
{
- (void)path;
+ (void)list;
}
static void nop_error_list_macros(int severity)
diff --git a/asm/preproc.c b/asm/preproc.c
index 3d54c075..76bd7223 100644
--- a/asm/preproc.c
+++ b/asm/preproc.c
@@ -386,7 +386,7 @@ static int LocalOffset = 0;
static Context *cstk;
static Include *istk;
-static struct strlist *ipath;
+static const struct strlist *ipath_list;
static int pass; /* HACK: pass 0 = generate dependencies only */
static struct strlist *deplist;
@@ -1501,12 +1501,15 @@ enum incopen_mode {
static FILE *inc_fopen_search(const char *file, char **slpath,
enum incopen_mode omode, enum file_flags fmode)
{
+ const struct strlist_entry *ip = NULL;
FILE *fp;
const char *prefix = "";
- const struct strlist_entry *ip = ipath->head;
char *sp;
bool found;
+ if (ipath_list)
+ ip = ipath_list->head;
+
while (1) {
sp = nasm_catfile(prefix, file);
if (omode == INC_PROBE) {
@@ -4993,7 +4996,6 @@ pp_reset(const char *file, int apass, struct strlist *dep_list)
static void pp_init(void)
{
hash_init(&FileHash, HASH_MEDIUM);
- ipath = strlist_alloc();
}
static char *pp_getline(void)
@@ -5261,16 +5263,13 @@ static void pp_cleanup(int pass)
predef = NULL;
delete_Blocks();
freeTokens = NULL;
- strlist_free(ipath);
+ ipath_list = NULL;
}
}
-static void pp_include_path(const char *path)
+static void pp_include_path(struct strlist *list)
{
- if (!path)
- path = "";
-
- strlist_add(ipath, path);
+ ipath_list = list;
}
static void pp_pre_include(char *fname)
diff --git a/include/nasm.h b/include/nasm.h
index a6ff11ce..ebbf6c44 100644
--- a/include/nasm.h
+++ b/include/nasm.h
@@ -362,7 +362,7 @@ struct preproc_ops {
void (*pre_command)(const char *what, char *str);
/* Include path from command line */
- void (*include_path)(const char *path);
+ void (*include_path)(struct strlist *ipath);
/* Unwind the macro stack when printing an error message */
void (*error_list_macros)(int severity);