diff --git "a/D:\\_Sandbox\\curl\\curl-src\\src\\tool_parsecfg.c.orig" "b/D:\\_Sandbox\\curl\\curl-src\\src\\tool_parsecfg.c" index d26774f..92c2299 100644 --- "a/src/tool_parsecfg.c" +++ "b/src/tool_parsecfg.c" @@ -45,29 +45,26 @@ static const char *unslashquote(const char *line, char *param); static bool my_get_line(FILE *fp, struct curlx_dynbuf *, bool *error); #ifdef WIN32 -static FILE *execpath(const char *filename) +static FILE *execpath(const TCHAR *filename) { - char filebuffer[512]; - /* Get the filename of our executable. GetModuleFileName is already declared - * via inclusions done in setup header file. We assume that we are using - * the ASCII version here. - */ - unsigned long len = GetModuleFileNameA(0, filebuffer, sizeof(filebuffer)); - if(len > 0 && len < sizeof(filebuffer)) { - /* We got a valid filename - get the directory part */ - char *lastdirchar = strrchr(filebuffer, '\\'); + static const size_t BUFFSIZE = 512; + TCHAR filebuffer[BUFFSIZE]; + unsigned long len = GetModuleFileName(0, filebuffer, BUFFSIZE); + if((len > 0) && (len < BUFFSIZE)) { + TCHAR *lastdirchar = _tcsrchr(filebuffer, TEXT('\\')); if(lastdirchar) { - 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); - return fopen(filebuffer, FOPEN_READTEXT); - } + *lastdirchar = TEXT('\0'); + } + if (_tcslen(filebuffer) + _tcslen(filename) + 2U < BUFFSIZE) { + _tcscat(filebuffer, TEXT("\\")); + _tcscat(filebuffer, filename); +#ifdef UNICODE + return _wfopen(filebuffer, TEXT(FOPEN_READTEXT)); +#else + return fopen(filebuffer, FOPEN_READTEXT); +#endif } } - return NULL; } #endif @@ -85,7 +82,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global) 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); @@ -120,9 +117,9 @@ int parseconfig(const char *filename, struct GlobalConfig *global) } 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