From 5a6c6bbbb2eb8b5d60069f033d405ab2f9147467 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Fri, 17 Feb 2023 21:12:17 +0000 Subject: [PATCH] Fix name comparison when search for libraries --- src/lib.c | 7 +++++-- test/regress/libdir4.sh | 2 -- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib.c b/src/lib.c index 7a80022f..656c5bb0 100644 --- a/src/lib.c +++ b/src/lib.c @@ -345,6 +345,7 @@ static lib_t lib_find_at(const char *name, const char *path) char *best LOCAL = NULL; const char *std_suffix = standard_suffix(standard()); + const size_t namelen = strlen(name); struct dirent *e; while ((e = readdir(d))) { @@ -353,7 +354,9 @@ static lib_t lib_find_at(const char *name, const char *path) const char *dot = strchr(e->d_name, '.'); if (dot != NULL) { - if (strncasecmp(name, e->d_name, dot - e->d_name) != 0) + if (namelen != dot - e->d_name) + continue; + else if (strncasecmp(name, e->d_name, namelen) != 0) continue; else if (strcmp(dot + 1, std_suffix) != 0) continue; @@ -413,7 +416,7 @@ lib_t lib_new(const char *spec) #ifdef __MINGW32__ // Ignore a leading drive letter in the path - if (split == spec + 1 && (spec[2] == '/' || spec[2] == '\\')) + if (split == copy + 1 && (copy[2] == '/' || copy[2] == '\\')) split = NULL; #endif diff --git a/test/regress/libdir4.sh b/test/regress/libdir4.sh index 42e6b161..c4f985aa 100644 --- a/test/regress/libdir4.sh +++ b/test/regress/libdir4.sh @@ -31,6 +31,4 @@ nvc --std=2008 --map foo:subdir/foo.08 -a test.vhd nvc --std=1993 --map foo:subdir/foo.93 --work=foo -a test.vhd nvc --std=1993 --work=subdir/foo -a test.vhd -ls -l subdir - [ ! -d subdir/foo ] -- 2.39.2