cURL-build-win32/patch/curl_tool_parsecfg.diff

68 lines
2.5 KiB
Diff
Raw Normal View History

2021-06-09 19:47:18 +02:00
diff --git "a/D:\\_Sandbox\\curl\\curl-src\\src\\tool_parsecfg.c.orig" "b/D:\\_Sandbox\\curl\\curl-src\\src\\tool_parsecfg.c"
2021-06-10 01:54:46 +02:00
index d26774f..6b26101 100644
2021-06-09 16:54:23 +02:00
--- "a/src/tool_parsecfg.c"
+++ "b/src/tool_parsecfg.c"
2021-06-10 01:54:46 +02:00
@@ -45,29 +45,22 @@ static const char *unslashquote(const char *line, char *param);
2021-06-10 01:50:43 +02:00
static bool my_get_line(FILE *fp, struct curlx_dynbuf *, bool *error);
2021-06-09 16:11:19 +02:00
#ifdef WIN32
2021-06-10 01:50:43 +02:00
-static FILE *execpath(const char *filename)
+static FILE *execpath(const TCHAR *filename)
2021-06-09 16:11:19 +02:00
{
- char filebuffer[512];
2021-06-09 19:47:18 +02:00
- /* Get the filename of our executable. GetModuleFileName is already declared
2021-06-09 16:11:19 +02:00
- * via inclusions done in setup header file. We assume that we are using
- * the ASCII version here.
2021-06-09 19:47:18 +02:00
- */
2021-06-09 16:11:19 +02:00
- unsigned long len = GetModuleFileNameA(0, filebuffer, sizeof(filebuffer));
- if(len > 0 && len < sizeof(filebuffer)) {
- /* We got a valid filename - get the directory part */
2021-06-10 01:45:25 +02:00
- char *lastdirchar = strrchr(filebuffer, '\\');
2021-06-09 19:47:18 +02:00
+ static const size_t BUFFSIZE = 512;
+ TCHAR filebuffer[BUFFSIZE];
+ unsigned long len = GetModuleFileName(0, filebuffer, BUFFSIZE);
2021-06-10 01:45:25 +02:00
+ if((len > 0) && (len < BUFFSIZE)) {
+ TCHAR *lastdirchar = _tcsrchr(filebuffer, TEXT('\\'));
2021-06-09 19:47:18 +02:00
if(lastdirchar) {
2021-06-09 16:11:19 +02:00
- size_t remaining;
- *lastdirchar = 0;
- /* If we have enough space, build the RC filename */
- remaining = sizeof(filebuffer) - strlen(filebuffer);
- if(strlen(filename) < remaining - 1) {
- msnprintf(lastdirchar, remaining, "%s%s", DIR_CHAR, filename);
2021-06-10 01:50:43 +02:00
- return fopen(filebuffer, FOPEN_READTEXT);
- }
2021-06-10 01:45:25 +02:00
+ *lastdirchar = TEXT('\0');
2021-06-09 19:47:18 +02:00
+ }
2021-06-10 01:45:25 +02:00
+ if (_tcslen(filebuffer) + _tcslen(filename) + 2U < BUFFSIZE) {
+ _tcscat(filebuffer, TEXT("\\"));
+ _tcscat(filebuffer, filename);
2021-06-10 01:54:46 +02:00
+ return _tfopen(filebuffer, TEXT(FOPEN_READTEXT));
2021-06-10 01:45:25 +02:00
}
2021-06-09 16:11:19 +02:00
}
2021-06-09 19:47:18 +02:00
-
2021-06-10 01:45:25 +02:00
return NULL;
2021-06-09 16:11:19 +02:00
}
#endif
2021-06-10 01:54:46 +02:00
@@ -85,7 +78,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
2021-06-08 22:24:45 +02:00
if(!filename || !*filename) {
/* NULL or no file name attempts to load .curlrc from the homedir! */
- char *home = homedir(".curlrc");
+ char *home = NULL; /* homedir(".curlrc"); */
#ifndef WIN32
if(home) {
pathalloc = curl_maprintf("%s%s.curlrc", home, DIR_CHAR);
2021-06-10 01:54:46 +02:00
@@ -120,9 +113,9 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
2021-06-10 01:50:43 +02:00
}
if(!filename) {
/* check for .curlrc then _curlrc in the dir of the executable */
- file = execpath(".curlrc");
+ file = execpath(TEXT(".curlrc"));
if(!file)
- file = execpath("_curlrc");
+ file = execpath(TEXT("_curlrc"));
}
#endif