From 7037c4e3f8bf46f21bd3c18da0a39a67a871d26d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 26 Jun 2024 10:59:33 +0000 Subject: Sync nmakehelp.c with Tcl --- win/nmakehlp.c | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/win/nmakehlp.c b/win/nmakehlp.c index 4d95662..4fc9f7a 100644 --- a/win/nmakehlp.c +++ b/win/nmakehlp.c @@ -19,7 +19,6 @@ #pragma comment (lib, "kernel32.lib") #endif #include -#include /* * This library is required for x64 builds with _some_ versions of MSVC @@ -91,7 +90,7 @@ main( case 'c': if (argc != 3) { chars = snprintf(msg, sizeof(msg) - 1, - "usage: %s -c \n" + "usage: %s -c \n" "Tests for whether cl.exe supports an option\n" "exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]); WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, @@ -319,11 +318,11 @@ CheckForCompilerFeature( */ return !(strstr(Out.buffer, "D4002") != NULL - || strstr(Err.buffer, "D4002") != NULL - || strstr(Out.buffer, "D9002") != NULL - || strstr(Err.buffer, "D9002") != NULL - || strstr(Out.buffer, "D2021") != NULL - || strstr(Err.buffer, "D2021") != NULL); + || strstr(Err.buffer, "D4002") != NULL + || strstr(Out.buffer, "D9002") != NULL + || strstr(Err.buffer, "D9002") != NULL + || strstr(Out.buffer, "D2021") != NULL + || strstr(Err.buffer, "D2021") != NULL); } static int @@ -601,9 +600,9 @@ list_free(list_item_t **listPtrPtr) * * Usage is something like: * nmakehlp -S << $** > $@ - * @PACKAGE_NAME@ $(PACKAGE_NAME) - * @PACKAGE_VERSION@ $(PACKAGE_VERSION) - * << + * @PACKAGE_NAME@ $(PACKAGE_NAME) + * @PACKAGE_VERSION@ $(PACKAGE_VERSION) + * << */ static int @@ -727,11 +726,13 @@ static int LocateDependencyHelper(const char *dir, const char *keypath) int keylen, ret; WIN32_FIND_DATA finfo; - if (dir == NULL || keypath == NULL) + if (dir == NULL || keypath == NULL) { return 2; /* Have no real error reporting mechanism into nmake */ + } dirlen = strlen(dir); - if ((dirlen + 3) > sizeof(path)) + if ((dirlen + 3) > sizeof(path)) { return 2; + } strncpy(path, dir, dirlen); strncpy(path+dirlen, "\\*", 3); /* Including terminating \0 */ keylen = strlen(keypath); @@ -746,8 +747,9 @@ static int LocateDependencyHelper(const char *dir, const char *keypath) #else hSearch = FindFirstFile(path, &finfo); #endif - if (hSearch == INVALID_HANDLE_VALUE) + if (hSearch == INVALID_HANDLE_VALUE) { return 1; /* Not found */ + } /* Loop through all subdirs checking if the keypath is under there */ ret = 1; /* Assume not found */ @@ -757,11 +759,13 @@ static int LocateDependencyHelper(const char *dir, const char *keypath) * We need to check it is a directory despite the * FindExSearchLimitToDirectories in the above call. See SDK docs */ - if ((finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) + if ((finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) { continue; + } sublen = strlen(finfo.cFileName); - if ((dirlen+1+sublen+1+keylen+1) > sizeof(path)) + if ((dirlen+1+sublen+1+keylen+1) > sizeof(path)) { continue; /* Path does not fit, assume not matched */ + } strncpy(path+dirlen+1, finfo.cFileName, sublen); path[dirlen+1+sublen] = '\\'; strncpy(path+dirlen+1+sublen+1, keypath, keylen+1); @@ -781,13 +785,13 @@ static int LocateDependencyHelper(const char *dir, const char *keypath) * LocateDependency -- * * Locates a dependency for a package. - * keypath - a relative path within the package directory - * that is used to confirm it is the correct directory. + * keypath - a relative path within the package directory + * that is used to confirm it is the correct directory. * The search path for the package directory is currently only - * the parent and grandparent of the current working directory. - * If found, the command prints - * name_DIRPATH= - * and returns 0. If not found, does not print anything and returns 1. + * the parent and grandparent of the current working directory. + * If found, the command prints + * name_DIRPATH= + * and returns 0. If not found, does not print anything and returns 1. */ static int LocateDependency(const char *keypath) { @@ -797,8 +801,9 @@ static int LocateDependency(const char *keypath) for (i = 0; i < (sizeof(paths)/sizeof(paths[0])); ++i) { ret = LocateDependencyHelper(paths[i], keypath); - if (ret == 0) + if (ret == 0) { return ret; + } } return ret; } -- cgit v0.12