tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] [PATCH v3] Introduce VIP sysinclude paths which are a


From: YX Hao
Subject: Re: [Tinycc-devel] [PATCH v3] Introduce VIP sysinclude paths which are always searched first
Date: Sun, 8 Oct 2017 15:24:53 +0800

Hi Steffen,

There is a bug of your commit:
You leave ' tcc_add_sysinclude_path(s, CONFIG_TCC_SYSINCLUDEPATHS);' in
'libtcc.c' which isn't available anymore ...

Best Regards,
YX Hao

-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of
Steffen Nurpmeso
Sent: 2017年10月3日 3:09
To: address@hidden
Subject: [Tinycc-devel] [PATCH v3] Introduce VIP sysinclude paths which are
always searched first

---
Changes:
   grischka suggested using TCC specific names instead of
   "VIP system" ones.

 libtcc.c | 10 +++++++++-
 libtcc.h |  3 +++
 tcc.c    |  1 +
 tcc.h    | 18 +++++++++++++-----
 tccpp.c  | 12 +++++++++---
 5 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/libtcc.c b/libtcc.c
index dcc398f..9ef538e 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -906,6 +906,7 @@ LIBTCCAPI void tcc_delete(TCCState *s1)
 
     /* free include paths */
     dynarray_reset(&s1->cached_includes, &s1->nb_cached_includes);
+    dynarray_reset(&s1->tccinclude_paths, &s1->nb_tccinclude_paths);
     dynarray_reset(&s1->include_paths, &s1->nb_include_paths);
     dynarray_reset(&s1->sysinclude_paths, &s1->nb_sysinclude_paths);
     dynarray_reset(&s1->cmd_include_files, &s1->nb_cmd_include_files); @@
-946,6 +947,7 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int
output_type)
     if (!s->nostdinc) {
         /* default include paths */
         /* -isystem paths have already been handled */
+        tcc_add_tccinclude_path(s, CONFIG_TCC_TCCINCLUDEPATHS);
         tcc_add_sysinclude_path(s, CONFIG_TCC_SYSINCLUDEPATHS);
     }
 
@@ -983,6 +985,12 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int
output_type)
     return 0;
 }
 
+LIBTCCAPI int tcc_add_tccinclude_path(TCCState *s, const char 
+*pathname) {
+    tcc_split_path(s, &s->tccinclude_paths, &s->nb_tccinclude_paths,
pathname);
+    return 0;
+}
+
 LIBTCCAPI int tcc_add_include_path(TCCState *s, const char *pathname)  {
     tcc_split_path(s, &s->include_paths, &s->nb_include_paths, pathname);
@@ -1821,7 +1829,7 @@ reparse:
             break;
         case TCC_OPTION_iwithprefix:
             snprintf(buf, sizeof buf, "{B}/%s", optarg);
-            tcc_add_sysinclude_path(s, buf);
+            tcc_add_tccinclude_path(s, buf);
             break;
        case TCC_OPTION_include:
            dynarray_add(&s->cmd_include_files,
diff --git a/libtcc.h b/libtcc.h
index a1b31e3..fc37251 100644
--- a/libtcc.h
+++ b/libtcc.h
@@ -32,6 +32,9 @@ LIBTCCAPI void tcc_set_options(TCCState *s, const char
*str);  /*****************************/
 /* preprocessor */
 
+/* add in tcc include path, searched before anything else */ LIBTCCAPI 
+int tcc_add_tccinclude_path(TCCState *s, const char *pathname);
+
 /* add include path */
 LIBTCCAPI int tcc_add_include_path(TCCState *s, const char *pathname);
 
diff --git a/tcc.c b/tcc.c
index 4c7235a..53ee84e 100644
--- a/tcc.c
+++ b/tcc.c
@@ -181,6 +181,7 @@ static void print_search_dirs(TCCState *s)  {
     printf("install: %s\n", s->tcc_lib_path);
     /* print_dirs("programs", NULL, 0); */
+    print_dirs("tcc-include", s->tccinclude_paths, 
+ s->nb_tccinclude_paths);
     print_dirs("include", s->sysinclude_paths, s->nb_sysinclude_paths);
     print_dirs("libraries", s->library_paths, s->nb_library_paths);
#ifndef TCC_TARGET_PE diff --git a/tcc.h b/tcc.h index c25d342..90d73eb
100644
--- a/tcc.h
+++ b/tcc.h
@@ -195,13 +195,18 @@ extern long double strtold (const char *__nptr, char
**__endptr);
 /* Below: {B} is substituted by CONFIG_TCCDIR (rsp. -B option) */
 
 /* system include paths */
-#ifndef CONFIG_TCC_SYSINCLUDEPATHS
+#ifndef CONFIG_TCC_TCCINCLUDEPATHS
 # ifdef TCC_TARGET_PE
-#  define CONFIG_TCC_SYSINCLUDEPATHS "{B}/include;{B}/include/winapi"
+#  define CONFIG_TCC_TCCINCLUDEPATHS "{B}/include;{B}/include/winapi"
 # else
+#  define CONFIG_TCC_TCCINCLUDEPATHS "{B}/include"
+# endif
+#endif
+
+#ifndef CONFIG_TCC_SYSINCLUDEPATHS
+# ifndef TCC_TARGET_PE
 #  define CONFIG_TCC_SYSINCLUDEPATHS \
-        "{B}/include" \
-    ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \
+    ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \
     ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/include")  # endif  #endif @@
-715,7 +720,10 @@ struct TCCState {
     DLLReference **loaded_dlls;
     int nb_loaded_dlls;
 
-    /* include paths */
+    /* include paths, search order */
+    char **tccinclude_paths;
+    int nb_tccinclude_paths;
+
     char **include_paths;
     int nb_include_paths;
 
diff --git a/tccpp.c b/tccpp.c
index 39386f4..e207b0e 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -1803,7 +1803,8 @@ ST_FUNC void preprocess(int is_bof)
         /* store current file in stack, but increment stack later below */
         *s1->include_stack_ptr = file;
         i = tok == TOK_INCLUDE_NEXT ? file->include_next_index : 0;
-        n = 2 + s1->nb_include_paths + s1->nb_sysinclude_paths;
+        n = 2 + s1->nb_tccinclude_paths + s1->nb_include_paths +
+               s1->nb_sysinclude_paths;
         for (; i < n; ++i) {
             char buf1[sizeof file->filename];
             CachedInclude *e;
@@ -1825,8 +1826,13 @@ ST_FUNC void preprocess(int is_bof)
 
             } else {
                 /* search in all the include paths */
-                int j = i - 2, k = j - s1->nb_include_paths;
-                path = k < 0 ? s1->include_paths[j] :
s1->sysinclude_paths[k];
+                int k, j = i - 2;
+               if (j < (k = s1->nb_tccinclude_paths))
+                       path = s1->tccinclude_paths[j];
+               else if ((j -= k) < s1->nb_include_paths)
+                       path = s1->include_paths[j];
+               else if ((j -= s1->nb_include_paths) <
s1->nb_sysinclude_paths)
+                       path = s1->sysinclude_paths[j];
                 pstrcpy(buf1, sizeof(buf1), path);
                 pstrcat(buf1, sizeof(buf1), "/");
             }
--
2.14.2


--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)

_______________________________________________
Tinycc-devel mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/tinycc-devel





reply via email to

[Prev in Thread] Current Thread [Next in Thread]