+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
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;
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);