Changeset 1106


Ignore:
Timestamp:
Sep 23, 2007, 6:20:22 AM (18 years ago)
Author:
bird
Message:

fixed sed bustage after converting to msvc*.dll.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/startuphacks-win.c

    r813 r1106  
    4646*******************************************************************************/
    4747/** argument count found by parse_args(). */
    48 static int g_cArgs;
     48static int  g_cArgs = 0;
     49/** the argument vector, for __getmainargs(). */
     50static char **g_papszArgs = NULL;
    4951
    5052
     
    5557    const char *pszCmdLine;
    5658    char       *pszCmdLineBuf;
    57     char      **papszArgs = NULL;
    5859    int         cb;
    5960
     
    6364    GetModuleFileName(NULL, s_szProgramName, MAX_PATH);
    6465    s_szProgramName[MAX_PATH] = '\0';
    65 #if _MSC_VER >= 1400
     66#if _MSC_VER >= 1400 && !defined(CRTDLL) && !defined(_DLL)
    6667    _set_pgmptr(s_szProgramName);
    6768#endif
     
    7879     */
    7980    cb = parse_args(pszCmdLine, NULL, NULL);
    80     papszArgs = malloc(sizeof(*papszArgs) * (g_cArgs + 2));
    81     if (!papszArgs)
     81    g_papszArgs = malloc(sizeof(*g_papszArgs) * (g_cArgs + 2));
     82    if (!g_papszArgs)
    8283        return -1;
    8384    pszCmdLineBuf = malloc(cb);
    8485    if (!pszCmdLineBuf)
    8586        return -1;
    86     parse_args(pszCmdLine, papszArgs, pszCmdLineBuf);
    87     papszArgs[g_cArgs] = papszArgs[g_cArgs + 1] = NULL;
     87    parse_args(pszCmdLine, g_papszArgs, pszCmdLineBuf);
     88    g_papszArgs[g_cArgs] = g_papszArgs[g_cArgs + 1] = NULL;
    8889
    8990    /* set return variables */
    9091    __argc = g_cArgs;
    91     __argv = papszArgs;
     92    __argv = g_papszArgs;
    9293    return 0;
    9394}
     95
     96
     97/* when linking with the crtexe.c, the __getmainargs() call will redo the _setargv job inside the msvc*.dll. */
     98int __cdecl __getmainargs(int *pargc, char ***pargv, char ***penvp, int dowildcard, /*_startupinfo*/ void *startinfo)
     99{
     100    __argc = *pargc = g_cArgs;
     101    __argv = *pargv = g_papszArgs;
     102    *penvp = _environ;
     103    return 0;
     104}
     105
     106#if defined(_M_IX86)
     107int (__cdecl * _imp____getmainargs)(int *, char ***, char ***, int, /*_startupinfo*/ void *) = __getmainargs;
     108#else
     109int (__cdecl * __imp___getmainargs)(int *, char ***, char ***, int, /*_startupinfo*/ void *) = __getmainargs;
     110#endif
     111
    94112
    95113
Note: See TracChangeset for help on using the changeset viewer.