made the command line parser not ignore any switch just before it didn't have a switch before it

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3461 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2004-02-04 20:03:30 +00:00
parent 1214352131
commit b1a527c4ce
5 changed files with 51 additions and 29 deletions

View file

@ -104,39 +104,50 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
cmdline = state_command_line;
if (*cmdline == '\"') seekchar = *cmdline++;
while (*cmdline && *cmdline != seekchar) cmdline=CharNext(cmdline);
cmdline=findchar(cmdline, seekchar);
cmdline=CharNext(cmdline);
realcmds=cmdline;
for (;;)
while (*cmdline)
{
// skip over any spaces
while (*cmdline == ' ') cmdline=CharNext(cmdline);
if (cmdline[0] != '/') break;
cmdline++;
// find out if this parm is quoted
if (cmdline[0] == '"')
{
cmdline++;
seekchar = '\"';
}
else seekchar = ' ';
if (cmdline[0] == '/')
{
cmdline++;
// this only works with spaces because they have just one bit on
#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]))
cl_flags |= FH_FLAGS_SILENT;
if (cmdline[0] == 'S' && END_OF_ARG(cmdline[1]))
cl_flags |= FH_FLAGS_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]))
cl_flags |= FH_FLAGS_NO_CRC;
if (*(DWORD*)cmdline == CHAR4_TO_DWORD('N','C','R','C') && END_OF_ARG(cmdline[4]))
cl_flags |= FH_FLAGS_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 :)
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
}
}
// skip over our parm
while (!END_OF_ARG(*cmdline)) cmdline=CharNext(cmdline);
cmdline = findchar(cmdline, seekchar);
// skip the quote
if (*cmdline = '\"')
cmdline++;
}
m_Err = loadHeaders(cl_flags);

View file

@ -230,7 +230,7 @@ __forceinline int NSISCALL ui_doinstall(void)
{
char *p2=CharNext(p);
p=p2;
while (*p2 && *p2 != '\"') p2=CharNext(p2);
p2 = findchar(p2, '"');
*p2=0;
}
// p is the path now, check for .exe extension

View file

@ -251,7 +251,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
while (c)
{
WIN32_FIND_DATA *fd;
while (*p != '\\' && *p) p=CharNext(p);
p = findchar(p, '\\');
c=*p;
*p=0;
fd = file_exists(buf1);

View file

@ -132,6 +132,15 @@ char *NSISCALL addtrailingslash(char *str)
return *CharPrev(str,str+mystrlen(str));
}*/
char * NSISCALL findchar(char *str, char c)
{
while (*str && *str != c)
{
str = CharNext(str);
}
return str;
}
void NSISCALL trimslashtoend(char *buf)
{
char *p = buf + mystrlen(buf);
@ -166,12 +175,9 @@ char * NSISCALL skip_root(char *path)
int x = 2;
while (x--)
{
while (*p2 != '\\')
{
if (!*p2)
return NULL;
p2 = CharNext(p2);
}
p2 = findchar(p2, '\\');
if (!*p2)
return NULL;
p2 = CharNext(p2);
}
@ -580,28 +586,32 @@ char * NSISCALL GetNSISString(char *outbuf, int strtab)
char * NSISCALL validate_filename(char *in) {
char *nono = "*?|<>/\":";
short cur_char = 0;
char *out;
char *out_save;
while (*in == ' ') in = CharNext(in);
if (in[0] == '\\' && in[1] == '\\' && in[2] == '?' && in[3] == '\\') {
if (in[0] == '\\' && in[1] == '\\' && in[2] == '?' && in[3] == '\\')
{
// at least four bytes
in += 4;
}
if (*in) {
if (*in)
{
// at least two bytes
if (validpathspec(in)) in += 2;
}
out = out_save = in;
while (*(char*)&cur_char = *in) {
if (cur_char > 31 && !mystrstri(nono, (char*)&cur_char)) {
while (*in)
{
if (*in > 31 && !*findchar(nono, *in))
{
mini_memcpy(out, in, CharNext(in) - in);
out = CharNext(out);
}
in = CharNext(in);
}
*out = 0;
do {
do
{
out = CharPrev(out_save, out);
if (*out == ' ' || *out == '\\')
*out = 0;

View file

@ -60,6 +60,7 @@ int NSISCALL validpathspec(char *ubuf);
char * NSISCALL addtrailingslash(char *str);
//char NSISCALL lastchar(const char *str);
#define lastchar(str) *CharPrev(str,str+mystrlen(str))
char * NSISCALL findchar(char *str, char c);
void NSISCALL trimslashtoend(char *buf);
char * NSISCALL skip_root(char *path);
int NSISCALL is_valid_instpath(char *s);