Mercurial > hg > tinycc
changeset 521:22b60bb22c83
Convert more paths to add_dynarray_path().
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 04 Dec 2007 14:57:15 -0600 |
parents | 647f1a3feb8b |
children | a6abef04cb53 |
files | tcc.c tcc.h |
diffstat | 2 files changed, 17 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/tcc.c Tue Dec 04 14:27:48 2007 -0600 +++ b/tcc.c Tue Dec 04 14:57:15 2007 -0600 @@ -2014,13 +2014,13 @@ if (s1->include_stack_ptr >= s1->include_stack + INCLUDE_STACK_SIZE) error("#include recursion too deep"); /* now search in all the include paths */ - n = s1->nb_include_paths + s1->nb_sysinclude_paths; + n = s1->include_paths.len + s1->sysinclude_paths.len; for(i = 0; i < n; i++) { const char *path; - if (i < s1->nb_include_paths) - path = s1->include_paths[i]; + if (i < s1->include_paths.len) + path = s1->include_paths.data[i]; else - path = s1->sysinclude_paths[i - s1->nb_include_paths]; + path = s1->sysinclude_paths.data[i - s1->include_paths.len]; pstrcpy(buf1, sizeof(buf1), path); pstrcat(buf1, sizeof(buf1), "/"); pstrcat(buf1, sizeof(buf1), buf); @@ -8917,35 +8917,17 @@ free(s1->cached_includes[i]); free(s1->cached_includes); - for(i = 0; i < s1->nb_include_paths; i++) - free(s1->include_paths[i]); - free(s1->include_paths); - - for(i = 0; i < s1->nb_sysinclude_paths; i++) - free(s1->sysinclude_paths[i]); - free(s1->sysinclude_paths); + for(i = 0; i < s1->include_paths.len; i++) + free(s1->include_paths.data[i]); + free(s1->include_paths.data); + + for(i = 0; i < s1->sysinclude_paths.len; i++) + free(s1->sysinclude_paths.data[i]); + free(s1->sysinclude_paths.data); free(s1); } -int tcc_add_include_path(TCCState *s1, const char *pathname) -{ - char *pathname1; - - pathname1 = xstrdup(pathname); - dynarray_add((void ***)&s1->include_paths, &s1->nb_include_paths, pathname1); - return 0; -} - -int tcc_add_sysinclude_path(TCCState *s1, const char *pathname) -{ - char *pathname1; - - pathname1 = xstrdup(pathname); - dynarray_add((void ***)&s1->sysinclude_paths, &s1->nb_sysinclude_paths, pathname1); - return 0; -} - static int tcc_add_file_internal(TCCState *s1, const char *filename, int flags) { const char *ext, *filename1; @@ -9126,10 +9108,10 @@ /* default include paths */ /* XXX: reverse order needed if -isystem support */ - tcc_add_sysinclude_path(s, "/usr/local/include"); - tcc_add_sysinclude_path(s, "/usr/include"); + add_dynarray_path(s, "/usr/local/include:/usr/include", + &(s->sysinclude_paths)); snprintf(buf, sizeof(buf), "%s/include", cc_lib_path); - tcc_add_sysinclude_path(s, buf); + add_dynarray_path(s, buf, &(s->sysinclude_paths)); } /* if bound checking, then add corresponding sections */ @@ -9494,8 +9476,7 @@ help(); exit(1); case TCC_OPTION_I: - if (tcc_add_include_path(s, optarg) < 0) - error("too many include paths"); + add_dynarray_path(s, optarg, &(s->include_paths)); break; case TCC_OPTION_D: {
--- a/tcc.h Tue Dec 04 14:27:48 2007 -0600 +++ b/tcc.h Tue Dec 04 14:57:15 2007 -0600 @@ -319,21 +319,14 @@ int *ifdef_stack_ptr; /* include file handling */ - //struct dynarray include_paths; - char **include_paths; - int nb_include_paths; - - //struct dynarray sysinclude_paths; - char **sysinclude_paths; - int nb_sysinclude_paths; + struct dynarray include_paths; + struct dynarray sysinclude_paths; //struct dynarray cached_includes; CachedInclude **cached_includes; int nb_cached_includes; struct dynarray library_paths; - //char **library_paths; - //int nb_library_paths; /* array of all loaded dlls (including those referenced by loaded dlls) */