Module Name: src Committed By: christos Date: Tue May 18 21:34:04 UTC 2021
Modified Files: src/external/gpl3/gcc.old/dist/libcpp: macro.c src/external/gpl3/gcc/dist/libcpp: macro.c Log Message: restore -iremap functionality which was omitted by a merge botch, and then remove as unused later. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/external/gpl3/gcc.old/dist/libcpp/macro.c cvs rdiff -u -r1.13 -r1.14 src/external/gpl3/gcc/dist/libcpp/macro.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/gpl3/gcc.old/dist/libcpp/macro.c diff -u src/external/gpl3/gcc.old/dist/libcpp/macro.c:1.10 src/external/gpl3/gcc.old/dist/libcpp/macro.c:1.11 --- src/external/gpl3/gcc.old/dist/libcpp/macro.c:1.10 Fri Apr 9 19:14:40 2021 +++ src/external/gpl3/gcc.old/dist/libcpp/macro.c Tue May 18 17:34:03 2021 @@ -406,6 +406,33 @@ add_cpp_remap_path (const char *arg) ++remap_pairs; } +static const char * +cpp_remap_file (const char *arg, char **tmp_name) +{ + char *result; + size_t i, len; + + for (i = 0; i < remap_pairs; ++i) { + len = strlen (remap_src[i]); + if (strncmp (remap_src[i], arg, len)) + continue; + if (arg[len] == '\0') + return remap_dst[i]; + if (arg[len] != '/') + continue; + arg += len; + len = strlen (remap_dst[i]); + result = (char *) xmalloc (len + strlen (arg) + 1); + memcpy(result, remap_dst[i], len); + strcpy(result + len, arg); + *tmp_name = result; + + return result; + } + + return arg; +} + /* Helper function for builtin_macro. Returns the text generated by a builtin macro. */ const uchar * @@ -469,6 +496,7 @@ _cpp_builtin_macro_text (cpp_reader *pfi { unsigned int len; const char *name; + char *tmp_name; uchar *buf; if (node->value.builtin == BT_FILE) @@ -482,11 +510,14 @@ _cpp_builtin_macro_text (cpp_reader *pfi } if (pfile->cb.remap_filename) name = pfile->cb.remap_filename (name); + tmp_name = NULL; + name = cpp_remap_file (name, &tmp_name); len = strlen (name); buf = _cpp_unaligned_alloc (pfile, len * 2 + 3); result = buf; *buf = '"'; buf = cpp_quote_string (buf + 1, (const unsigned char *) name, len); + free (tmp_name); *buf++ = '"'; *buf = '\0'; } Index: src/external/gpl3/gcc/dist/libcpp/macro.c diff -u src/external/gpl3/gcc/dist/libcpp/macro.c:1.13 src/external/gpl3/gcc/dist/libcpp/macro.c:1.14 --- src/external/gpl3/gcc/dist/libcpp/macro.c:1.13 Sat Apr 10 20:02:18 2021 +++ src/external/gpl3/gcc/dist/libcpp/macro.c Tue May 18 17:34:03 2021 @@ -502,6 +502,33 @@ add_cpp_remap_path (const char *arg) ++remap_pairs; } +static const char * +cpp_remap_file (const char *arg, char **tmp_name) +{ + char *result; + size_t i, len; + + for (i = 0; i < remap_pairs; ++i) { + len = strlen (remap_src[i]); + if (strncmp (remap_src[i], arg, len)) + continue; + if (arg[len] == '\0') + return remap_dst[i]; + if (arg[len] != '/') + continue; + arg += len; + len = strlen (remap_dst[i]); + result = (char *) xmalloc (len + strlen (arg) + 1); + memcpy(result, remap_dst[i], len); + strcpy(result + len, arg); + *tmp_name = result; + + return result; + } + + return arg; +} + /* Helper function for builtin_macro. Returns the text generated by a builtin macro. */ const uchar * @@ -565,6 +592,7 @@ _cpp_builtin_macro_text (cpp_reader *pfi { unsigned int len; const char *name; + char *tmp_name; uchar *buf; if (node->value.builtin == BT_FILE) @@ -578,11 +606,14 @@ _cpp_builtin_macro_text (cpp_reader *pfi } if (pfile->cb.remap_filename) name = pfile->cb.remap_filename (name); + tmp_name = NULL; + name = cpp_remap_file (name, &tmp_name); len = strlen (name); buf = _cpp_unaligned_alloc (pfile, len * 2 + 3); result = buf; *buf = '"'; buf = cpp_quote_string (buf + 1, (const unsigned char *) name, len); + free (tmp_name); *buf++ = '"'; *buf = '\0'; }