Source-Changes-HG archive

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

[src/trunk]: src/external/gpl3 restore -iremap functionality which was omitte...



details:   https://anonhg.NetBSD.org/src/rev/e856da031529
branches:  trunk
changeset: 379199:e856da031529
user:      christos <christos%NetBSD.org@localhost>
date:      Tue May 18 21:34:03 2021 +0000

description:
restore -iremap functionality which was omitted by a merge botch, and then
remove as unused later.

diffstat:

 external/gpl3/gcc.old/dist/libcpp/macro.c |  31 +++++++++++++++++++++++++++++++
 external/gpl3/gcc/dist/libcpp/macro.c     |  31 +++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+), 0 deletions(-)

diffs (120 lines):

diff -r de46447a8ae7 -r e856da031529 external/gpl3/gcc.old/dist/libcpp/macro.c
--- a/external/gpl3/gcc.old/dist/libcpp/macro.c Tue May 18 20:34:20 2021 +0000
+++ b/external/gpl3/gcc.old/dist/libcpp/macro.c Tue May 18 21:34:03 2021 +0000
@@ -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 @@ const uchar *
       {
        unsigned int len;
        const char *name;
+       char *tmp_name;
        uchar *buf;
        
        if (node->value.builtin == BT_FILE)
@@ -482,11 +510,14 @@ const uchar *
          }
        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';
       }
diff -r de46447a8ae7 -r e856da031529 external/gpl3/gcc/dist/libcpp/macro.c
--- a/external/gpl3/gcc/dist/libcpp/macro.c     Tue May 18 20:34:20 2021 +0000
+++ b/external/gpl3/gcc/dist/libcpp/macro.c     Tue May 18 21:34:03 2021 +0000
@@ -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 @@ const uchar *
       {
        unsigned int len;
        const char *name;
+       char *tmp_name;
        uchar *buf;
        
        if (node->value.builtin == BT_FILE)
@@ -578,11 +606,14 @@ const uchar *
          }
        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';
       }



Home | Main Index | Thread Index | Old Index