+2020-08-07 Keith Marshall <keith@users.osdn.me>
+
+ Initialize MSVCRT.DLL's _pgmptr reference.
+
+ * setargv.c (_setargv) [__CRT_GLOB_USE_MINGW__]: Check for...
+ [_pgmptr == NULL] (_pgmptr): ...uninitialized; initialize it from...
+ (GetModuleFileName): ...this.
+
2020-07-23 Keith Marshall <keith@users.osdn.me>
Prepare and publish MinGW.org WSL-5.4.1 release.
*
* $Id$
*
- * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2014, 2017, 2018, MinGW.org Project
+ * Written by Keith Marshall <keith@users.osdn.me>
+ * Copyright (C) 2014, 2017, 2018, 2020, MinGW.org Project
*
* ---------------------------------------------------------------------------
*
#define _ISOC99_SOURCE
#include <glob.h>
+#include <stdlib.h>
#include <string.h>
#include <ctype.h>
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#include <winbase.h>
/* Access to a standard 'main'-like argument count and list.
*/
* MSVCRT.DLL
*/
__mingw32_setargv( GetCommandLine() );
+
+ /* In addition to setting up _argc and _argv, Microsoft's
+ * setup routine, as invoked by __mingw32_init_mainargs(),
+ * appears to initialize MSVCRT.DLL's _pgmptr reference, to
+ * point to a string representing the full path name of the
+ * calling executable; mimic this behaviour.
+ */
+ if( _pgmptr == NULL )
+ { char buf[MAX_PATH];
+ unsigned int len = GetModuleFileName( NULL, buf, MAX_PATH );
+ if( (len != 0) && (len < MAX_PATH) )
+ _pgmptr = strdup( buf );
+ }
}
}