Dynamic allocation of needed user variables (exehead grew 512 bytes).

Independed user vars in uninstaller and installer


git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2656 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
ramon18 2003-06-17 23:59:13 +00:00
parent 2ff0e96a38
commit ab91077049
10 changed files with 197 additions and 92 deletions

View file

@ -98,9 +98,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
unsigned int verify_time=GetTickCount()+1000;
#endif
char *cmdline=state_command_line;
char *realcmds;
char seekchar=' ';
char *cmdline;
#ifdef NSIS_SUPPORT_NAMED_USERVARS
g_usrvars = (NSIS_STRING*)my_GlobalAlloc(USER_VARS_COUNT*sizeof(NSIS_STRING));
#endif
InitCommonControls();
@ -108,40 +112,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
lstrcpyn(state_command_line,GetCommandLine(),NSIS_MAX_STRLEN);
if (*cmdline == '\"') seekchar = *cmdline++;
while (*cmdline && *cmdline != seekchar) cmdline=CharNext(cmdline);
cmdline=CharNext(cmdline);
realcmds=cmdline;
for (;;)
{
// skip over any spaces
while (*cmdline == ' ') cmdline=CharNext(cmdline);
if (cmdline[0] != '/') break;
cmdline++;
#define END_OF_ARG(c) (((c)|' ')==' ')
#if defined(NSIS_CONFIG_VISIBLE_SUPPORT) && defined(NSIS_CONFIG_SILENT_SUPPORT)
if (cmdline[0] == 'S' && END_OF_ARG(cmdline[1])) silent++;
#endif//NSIS_CONFIG_SILENT_SUPPORT && NSIS_CONFIG_VISIBLE_SUPPORT
#ifdef NSIS_CONFIG_CRC_SUPPORT
if (*(DWORD*)cmdline == CHAR4_TO_DWORD('N','C','R','C') && END_OF_ARG(cmdline[4])) no_crc++;
#endif//NSIS_CONFIG_CRC_SUPPORT
if (*(WORD*)cmdline == CHAR2_TO_WORD('D','='))
{
cmdline[-2]=0; // keep this from being passed to uninstaller if necessary
mystrcpy(state_install_directory,cmdline+2);
cmdline=""; // prevent further processing of cmdline
break; // not necessary, but for some reason makes smaller exe :)
}
// skip over our parm
while (!END_OF_ARG(*cmdline)) cmdline=CharNext(cmdline);
}
mystrcpy(g_caption,_LANG_GENERIC_ERROR);
g_hInstance=GetModuleHandle(NULL);
@ -269,14 +239,49 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
}
if (m_Err) goto end;
cmdline = state_command_line;
if (*cmdline == '\"') seekchar = *cmdline++;
while (*cmdline && *cmdline != seekchar) cmdline=CharNext(cmdline);
cmdline=CharNext(cmdline);
realcmds=cmdline;
for (;;)
{
// skip over any spaces
while (*cmdline == ' ') cmdline=CharNext(cmdline);
if (cmdline[0] != '/') break;
cmdline++;
#define END_OF_ARG(c) (((c)|' ')==' ')
#if defined(NSIS_CONFIG_VISIBLE_SUPPORT) && defined(NSIS_CONFIG_SILENT_SUPPORT)
if (cmdline[0] == 'S' && END_OF_ARG(cmdline[1])) silent++;
#endif//NSIS_CONFIG_SILENT_SUPPORT && NSIS_CONFIG_VISIBLE_SUPPORT
#ifdef NSIS_CONFIG_CRC_SUPPORT
if (*(DWORD*)cmdline == CHAR4_TO_DWORD('N','C','R','C') && END_OF_ARG(cmdline[4])) no_crc++;
#endif//NSIS_CONFIG_CRC_SUPPORT
if (*(WORD*)cmdline == CHAR2_TO_WORD('D','='))
{
cmdline[-2]=0; // keep this from being passed to uninstaller if necessary
mystrcpy(state_install_directory,cmdline+2);
cmdline=""; // prevent further processing of cmdline
break; // not necessary, but for some reason makes smaller exe :)
}
// skip over our parm
while (!END_OF_ARG(*cmdline)) cmdline=CharNext(cmdline);
}
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
if (g_is_uninstaller)
{
char *p=cmdline;
while (*p) p++;
while (p >= cmdline && (p[0] != '_' || p[1] != '?' || p[2] != '=')) p--;
while (p >= cmdline && (p[0] != '_' || p[1] != '?' || p[2] != '=')) p--;
if (p >= cmdline)
{
*(p-1)=0; // terminate before the " _?="