From 167b1559a4bff64345ba0484551bf59bcecaa55ce3e2bca1bb277d25780b9166 Mon Sep 17 00:00:00 2001 From: Stefan Dirsch Date: Tue, 6 Dec 2022 11:06:16 +0000 Subject: [PATCH] - issue2-mr7.patch * Bug #2: fix regression introduced by fix for bug #1 OBS-URL: https://build.opensuse.org/package/show/X11:XOrg/makedepend?expand=0&rev=14 --- issue2-mr7.patch | 163 +++++++++++++++++++++++++++++++++++++++++++++ makedepend.changes | 6 ++ makedepend.spec | 2 + 3 files changed, 171 insertions(+) create mode 100644 issue2-mr7.patch diff --git a/issue2-mr7.patch b/issue2-mr7.patch new file mode 100644 index 0000000..48971d6 --- /dev/null +++ b/issue2-mr7.patch @@ -0,0 +1,163 @@ +From 654f6355d501153fe1fbdbc073cb72fd6355e194 Mon Sep 17 00:00:00 2001 +From: Alan Coopersmith +Date: Mon, 5 Dec 2022 15:48:17 -0800 +Subject: [PATCH] Bug #2: fix regression introduced by fix for bug #1 + +Refactor code to find the full file path before comparing against +existing items in the list so that we stop adding duplicate entries +for all the files in the system include path and with larger amounts +of code hitting the MAXFILES limit. + +Fixes: 3dc64b0 ("Add test case for bug #1 + proposed fix.") +Closes: #2 + +Signed-off-by: Alan Coopersmith +--- + include.c | 101 ++++++++++++++++++++++++++---------------------------- + 1 file changed, 49 insertions(+), 52 deletions(-) + +diff --git a/include.c b/include.c +index 697e9de..57e2b24 100644 +--- a/include.c ++++ b/include.c +@@ -222,60 +222,17 @@ inc_clean (void) + } + } + +-struct inclist * +-inc_path(const char *file, const char *include, int type) ++/* ++ * Return full path for the "include" file of the given "type", ++ * which may be found relative to the source file "file". ++ */ ++static const char * ++find_full_inc_path(const char *file, const char *include, int type) + { + static char path[ BUFSIZ ]; + register const char **pp, *p; +- register struct inclist *ip; + struct stat st; + +- /* +- * Check all previously found include files for a path that +- * has already been expanded. +- */ +- if ((type == INCLUDE) || (type == INCLUDEDOT)) +- inclistnext = inclist; +- ip = inclistnext; +- +- for (; ip->i_file; ip++) { +- if ((strcmp(ip->i_incstring, include) == 0) && +- !(ip->i_flags & INCLUDED_SYM)) { +- /* +- * 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; +- } +- } +- } +- + if (inclistnext == inclist) { + /* + * If the path was surrounded by "" or is an absolute path, +@@ -285,7 +242,7 @@ inc_path(const char *file, const char *include, int type) + (type == INCLUDENEXTDOT) || + (*include == '/')) { + if (stat(include, &st) == 0 && !S_ISDIR(st.st_mode)) +- return newinclude(include, include); ++ return include; + if (show_where_not) + warning1("\tnot in %s\n", include); + } +@@ -307,7 +264,7 @@ inc_path(const char *file, const char *include, int type) + } + remove_dotdot(path); + if (stat(path, &st) == 0 && !S_ISDIR(st.st_mode)) +- return newinclude(path, include); ++ return path; + if (show_where_not) + warning1("\tnot in %s\n", path); + } +@@ -326,7 +283,7 @@ inc_path(const char *file, const char *include, int type) + remove_dotdot(path); + if (stat(path, &st) == 0 && !S_ISDIR(st.st_mode)) { + includedirsnext = pp + 1; +- return newinclude(path, include); ++ return path; + } + if (show_where_not) + warning1("\tnot in %s\n", path); +@@ -334,3 +291,43 @@ inc_path(const char *file, const char *include, int type) + + return NULL; + } ++ ++struct inclist * ++inc_path(const char *file, const char *include, int type) ++{ ++ const char *fp; ++ struct inclist *ip; ++ char r_include[PATHMAX+1]; ++ ++ /* ++ * Check all previously found include files for a path that ++ * has already been expanded. ++ */ ++ if ((type == INCLUDE) || (type == INCLUDEDOT)) ++ inclistnext = inclist; ++ ip = inclistnext; ++ ++ fp = find_full_inc_path(file, include, type); ++ if (fp == NULL) ++ return NULL; ++ if (realpath(fp, r_include) == NULL) ++ return NULL; ++ ++ for (; ip->i_file; ip++) { ++ if ((strcmp(ip->i_incstring, include) == 0) && ++ !(ip->i_flags & INCLUDED_SYM)) { ++ /* ++ * Same filename but same file ? ++ */ ++ char r_saved_path[PATHMAX+1]; ++ if (realpath(ip->i_file, r_saved_path) == NULL) ++ continue; ++ if (!strcmp(r_include, r_saved_path)) { ++ inclistnext = ip + 1; ++ return ip; ++ } ++ } ++ } ++ ++ return newinclude(fp, include); ++} +-- +GitLab + diff --git a/makedepend.changes b/makedepend.changes index 7edb1ef..7919e4f 100644 --- a/makedepend.changes +++ b/makedepend.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Dec 6 11:04:15 UTC 2022 - Stefan Dirsch + +- issue2-mr7.patch + * Bug #2: fix regression introduced by fix for bug #1 + ------------------------------------------------------------------- Sat Oct 29 17:18:03 UTC 2022 - Stefan Dirsch diff --git a/makedepend.spec b/makedepend.spec index 14dfffb..47c9270 100644 --- a/makedepend.spec +++ b/makedepend.spec @@ -24,6 +24,7 @@ License: MIT Group: Development/Tools/Building URL: http://xorg.freedesktop.org/ Source0: http://xorg.freedesktop.org/releases/individual/util/%{name}-%{version}.tar.xz +Patch0: issue2-mr7.patch BuildRequires: pkg-config BuildRequires: pkgconfig(xproto) >= 7.0.17 # This was part of the xorg-x11-util-devel package up to version 7.6 @@ -41,6 +42,7 @@ has changed. %prep %setup -q +%patch0 -p1 %build %configure