diff options
author | Thibault DUPONCHELLE <thibault.duponchelle@gmail.com> | 2019-03-20 09:26:47 +0100 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-04-10 09:48:37 -0700 |
commit | 3dc64b0b0a7d4e14ccea6b9d1d11bf871c47a7e0 (patch) | |
tree | f10a95192d492478917e18938142d4fad36b713b /include.c | |
parent | 54559e73e27e532535dea2a60e615f99c694343f (diff) |
Add test case for bug #1 + proposed fix.
Fixes: https://gitlab.freedesktop.org/xorg/util/makedepend/issues/1
Diffstat (limited to 'include.c')
-rw-r--r-- | include.c | 34 |
1 files changed, 32 insertions, 2 deletions
@@ -241,8 +241,38 @@ inc_path(const char *file, const char *include, int type) for (; ip->i_file; ip++) { if ((strcmp(ip->i_incstring, include) == 0) && !(ip->i_flags & INCLUDED_SYM)) { - inclistnext = ip + 1; - return ip; + /* + * Same filename but same file ? + */ + char r_include[PATHMAX+1]; + char r_saved_path[PATHMAX+1]; + char* ptr; + ptr = realpath(include, r_include); + ptr = realpath(ip->i_file, r_saved_path); + if (!strcmp(r_include, r_saved_path)) { + inclistnext = ip + 1; + return ip; + } + + /* + * Check if we have a header in the same dir + */ + for (p=file+strlen(file); p>file; p--) + if (*p == '/') + break; + if (p == file) { + strcpy(path, include); + } else { + strncpy(path, file, (p-file) + 1); + path[ (p-file) + 1 ] = '\0'; + strcpy(path + (p-file) + 1, include); + } + remove_dotdot(path); + ptr = realpath(path, r_include); + if (!strcmp(r_include, r_saved_path)) { + inclistnext = ip + 1; + return ip; + } } } |