summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2021-06-22 11:48:39 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2021-06-22 11:48:39 (GMT)
commit16bd4d34db152f96e795372527e080a7a5380e2d (patch)
tree5410fee568aadb0228bc4094c9df718453d2eaef
parent6eac9c2f48c934ccb300208994845259d88e1ebf (diff)
parent33bdf9c83be075275d217b9fc75c158fae0c42e5 (diff)
downloadtk-16bd4d34db152f96e795372527e080a7a5380e2d.zip
tk-16bd4d34db152f96e795372527e080a7a5380e2d.tar.gz
tk-16bd4d34db152f96e795372527e080a7a5380e2d.tar.bz2
Merge 8.5
-rw-r--r--win/nmakehlp.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/win/nmakehlp.c b/win/nmakehlp.c
index 4e3d792..4021346 100644
--- a/win/nmakehlp.c
+++ b/win/nmakehlp.c
@@ -14,13 +14,8 @@
#define _CRT_SECURE_NO_DEPRECATE
#include <windows.h>
-#define NO_SHLWAPI_GDI
-#define NO_SHLWAPI_STREAM
-#define NO_SHLWAPI_REG
-#include <shlwapi.h>
#pragma comment (lib, "user32.lib")
#pragma comment (lib, "kernel32.lib")
-#pragma comment (lib, "shlwapi.lib")
#include <stdio.h>
#include <math.h>
@@ -74,7 +69,7 @@ main(
char msg[300];
DWORD dwWritten;
int chars;
- char *s;
+ const char *s;
/*
* Make sure children (cl.exe and link.exe) are kept quiet.
@@ -542,7 +537,7 @@ GetVersionFromFile(
++q;
}
- memcpy(szBuffer, p, q - p);
+ memmove(szBuffer, p, q - p);
szBuffer[q-p] = 0;
szResult = szBuffer;
break;
@@ -648,7 +643,7 @@ SubstituteFile(
}
/* debug: dump the list */
-#ifdef _DEBUG
+#ifndef NDEBUG
{
int n = 0;
list_item_t *p = NULL;
@@ -679,7 +674,7 @@ SubstituteFile(
memcpy(szBuffer, szCopy, sizeof(szCopy));
}
}
- printf(szBuffer);
+ printf("%s", szBuffer);
}
list_free(&substPtr);
@@ -688,6 +683,17 @@ SubstituteFile(
return 0;
}
+BOOL FileExists(LPCTSTR szPath)
+{
+#ifndef INVALID_FILE_ATTRIBUTES
+ #define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
+#endif
+ DWORD pathAttr = GetFileAttributes(szPath);
+ return (pathAttr != INVALID_FILE_ATTRIBUTES &&
+ !(pathAttr & FILE_ATTRIBUTE_DIRECTORY));
+}
+
+
/*
* QualifyPath --
*
@@ -701,13 +707,8 @@ QualifyPath(
const char *szPath)
{
char szCwd[MAX_PATH + 1];
- char szTmp[MAX_PATH + 1];
- char *p;
- GetCurrentDirectory(MAX_PATH, szCwd);
- while ((p = strchr(szPath, '/')) && *p)
- *p = '\\';
- PathCombine(szTmp, szCwd, szPath);
- PathCanonicalize(szCwd, szTmp);
+
+ GetFullPathName(szPath, sizeof(szCwd)-1, szCwd, NULL);
printf("%s\n", szCwd);
return 0;
}
@@ -765,7 +766,7 @@ static int LocateDependencyHelper(const char *dir, const char *keypath)
strncpy(path+dirlen+1, finfo.cFileName, sublen);
path[dirlen+1+sublen] = '\\';
strncpy(path+dirlen+1+sublen+1, keypath, keylen+1);
- if (PathFileExists(path)) {
+ if (FileExists(path)) {
/* Found a match, print to stdout */
path[dirlen+1+sublen] = '\0';
QualifyPath(path);
@@ -792,7 +793,7 @@ static int LocateDependencyHelper(const char *dir, const char *keypath)
static int LocateDependency(const char *keypath)
{
int i, ret;
- static char *paths[] = {"..", "..\\..", "..\\..\\.."};
+ static const char *paths[] = {"..", "..\\..", "..\\..\\.."};
for (i = 0; i < (sizeof(paths)/sizeof(paths[0])); ++i) {
ret = LocateDependencyHelper(paths[i], keypath);