1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-07 02:42:49 +03:00

Fix finding current program name with clang > 4.0

Use CRT _splitpath() to get program name on Windows, rather than
nonstandard functions from shell32
This commit is contained in:
Vladislav Vaintroub
2017-11-24 14:37:24 +01:00
parent de56d3309a
commit 63f841f78f
3 changed files with 14 additions and 10 deletions

View File

@@ -2663,17 +2663,16 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
case MYSQL_READ_DEFAULT_GROUP:
if (!arg1 || !((char *)arg1)[0])
{
#if defined(__APPLE__) || defined(__FreeBSD__)
const char * appname = getprogname();
#elif defined(_GNU_SOURCE)
#if defined(HAVE_PROGRAM_INVOCATION_SHORT_NAME)
const char * appname = program_invocation_short_name;
#elif defined(HAVE_GETPROGNAME)
const char * appname = getprogname();
#elif defined(WIN32)
char appname[FN_REFLEN]= "";
if (GetModuleFileName(NULL, appname, FN_REFLEN))
char module_filename[MAX_PATH];
char appname[MAX_PATH]="";
if (GetModuleFileName(NULL, module_filename, MAX_PATH))
{
PathStripPath(appname);
PathRemoveExtension(appname);
_splitpath(module_filename,NULL, NULL, appname, NULL);
}
#else
const char * appname = "";