diff options
author | andris <andris@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-10-21 15:52:25 +0000 |
---|---|---|
committer | andris <andris@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-10-21 15:52:25 +0000 |
commit | d8e3fcc2ed043a3c7135e3c8bc7134f59fb5ed51 (patch) | |
tree | 81baa4513d64c40182e0f4e142ce0714f4552d4d /libcpp | |
parent | d7e26a392f0c899f514d6b50c4fbca0d194dab17 (diff) | |
download | gcc-d8e3fcc2ed043a3c7135e3c8bc7134f59fb5ed51.tar.gz |
2016-10-21 Andris Pavenis <andris.pavenis@iki.fi>
PR preprocessor/71681
* files.c (remap_filename): Fix handling -remap in subdirectories.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241413 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 5 | ||||
-rw-r--r-- | libcpp/files.c | 12 |
2 files changed, 14 insertions, 3 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 40bd5cdc02e..87dae8496e2 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,8 @@ +2016-10-21 Andris Pavenis <andris.pavenis@iki.fi> + + PR preprocessor/71681 + * files.c (remap_filename): Fix handling -remap in subdirectories. + 2016-10-12 Jakub Jelinek <jakub@redhat.com> * include/cpplib.h (struct cpp_options): Add diff --git a/libcpp/files.c b/libcpp/files.c index c8bb637fb58..e859dfe3693 100644 --- a/libcpp/files.c +++ b/libcpp/files.c @@ -1672,7 +1672,7 @@ static char * remap_filename (cpp_reader *pfile, _cpp_file *file) { const char *fname, *p; - char *new_dir; + char *new_dir, *p3; cpp_dir *dir; size_t index, len; @@ -1701,9 +1701,15 @@ remap_filename (cpp_reader *pfile, _cpp_file *file) return NULL; len = dir->len + (p - fname + 1); - new_dir = XNEWVEC (char, len + 1); + new_dir = XNEWVEC (char, len + 2); + p3 = new_dir + dir->len; memcpy (new_dir, dir->name, dir->len); - memcpy (new_dir + dir->len, fname, p - fname + 1); + if (dir->len && !IS_DIR_SEPARATOR (dir->name[dir->len - 1])) + { + *p3++ = '/'; + len++; + } + memcpy (p3, fname, p - fname + 1); new_dir[len] = '\0'; dir = make_cpp_dir (pfile, new_dir, dir->sysp); |