Larry Doolittle wrote:
3.  I put together a brain-dead patch to tinycc mob HEAD,
that touches three lines total and seems to do the job.
It is arguably somewhat wasteful of scratch memory.
Here it is, sorry if the mail pipeline mangles it:

Push to mob if you want it in the release.

(After all, if it works, and, what else could we do.  I think I had
a quite similar patch somewhere, some (long) time ago.)

-- gr

diff --git a/libtcc.c b/libtcc.c
index 99bf783..302ce39 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -581,6 +581,7 @@ ST_FUNC void tcc_open_bf(TCCState *s1, const char 
*filename, int initlen)
     bf->buf_end = bf->buffer + initlen;
     bf->buf_end[0] = CH_EOB; /* put eob symbol */
     pstrcpy(bf->filename, sizeof(bf->filename), filename);
+    pstrcpy(bf->filename2, sizeof(bf->filename2), filename);
 #ifdef _WIN32
     normalize_slashes(bf->filename);
 #endif
diff --git a/tcc.h b/tcc.h
index 5b9d4a3..92b9060 100644
--- a/tcc.h
+++ b/tcc.h
@@ -546,6 +546,7 @@ typedef struct BufferedFile {
     int *ifdef_stack_ptr; /* ifdef_stack value at the start of the file */
     int include_next_index; /* next search path */
     char filename[1024];    /* filename */
+    char filename2[1024];    /* filename not modified by # line directive */
     unsigned char unget[4];
     unsigned char buffer[1]; /* extra size for CH_EOB char */
 } BufferedFile;
diff --git a/tccpp.c b/tccpp.c
index 7e5cdcf..4495752 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -1791,7 +1791,8 @@ ST_FUNC void preprocess(int is_bof)
                 /* search in file's dir if "header.h" */
                 if (c != '\"')
                     continue;
-                path = file->filename;
+                /* https://savannah.nongnu.org/bugs/index.php?50847 */
+                path = file->filename2;
                 pstrncpy(buf1, path, tcc_basename(path) - path);
} else {

_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel



_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to