mirror of
https://github.com/reactos/reactos.git
synced 2024-07-28 23:29:19 +00:00
- Fix build by converting everything to use TCHAR's
- Bugfix: Previously macros like "gotoroot=cd \" weren't passed correctly as we just used argv[1]. Now use GetCommandLine and pass the full command line. - Fix indentation svn path=/trunk/; revision=33379
This commit is contained in:
parent
b26bf1b115
commit
4198aafc54
|
@ -77,59 +77,63 @@ INT SetMacro (LPTSTR param)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static VOID ReadFromFile(LPSTR param)
|
||||
static VOID ReadFromFile(LPTSTR param)
|
||||
{
|
||||
FILE* fp;
|
||||
char line[MAX_PATH];
|
||||
#ifdef UNICODE
|
||||
WCHAR lineW[MAX_PATH];
|
||||
#endif
|
||||
TCHAR line[MAX_PATH];
|
||||
|
||||
/* FIXME */
|
||||
/* Skip the "/macrofile=" prefix */
|
||||
param += 11;
|
||||
|
||||
fp = fopen(param,"r");
|
||||
while ( fgets(line, MAX_PATH, fp) != NULL)
|
||||
{
|
||||
#ifdef UNICODE
|
||||
MultiByteToWideChar(CP_ACP, 0, line, -1, lineW, MAX_PATH);
|
||||
SetMacro(lineW);
|
||||
#else
|
||||
fp = _tfopen(param, _T("r"));
|
||||
|
||||
while ( _fgetts(line, MAX_PATH, fp) != NULL)
|
||||
SetMacro(line);
|
||||
#endif
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
_tmain (int argc, LPTSTR argv[])
|
||||
{
|
||||
#ifdef UNICODE
|
||||
WCHAR lineW[MAX_PATH];
|
||||
#endif
|
||||
|
||||
if (argc < 2)
|
||||
return 0;
|
||||
|
||||
if (argv[1][0] == '/')
|
||||
{
|
||||
if (strnicmp(argv[1], "/macrofile", 10) == 0)
|
||||
if (_tcsnicmp(argv[1], _T("/macrofile"), 10) == 0)
|
||||
ReadFromFile(argv[1]);
|
||||
if (stricmp(argv[1], "/macros") == 0)
|
||||
if (_tcscmp(argv[1], _T("/macros")) == 0)
|
||||
PrintAlias();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef UNICODE
|
||||
MultiByteToWideChar(CP_ACP, 0, argv[1], -1, lineW, MAX_PATH);
|
||||
SetMacro(lineW);
|
||||
#else
|
||||
SetMacro(argv[1]);
|
||||
#endif
|
||||
/* Get the full command line using GetCommandLine().
|
||||
We can't just pass argv[1] here, because then a parameter like "gotoroot=cd \" wouldn't be passed completely. */
|
||||
TCHAR* szCommandLine = GetCommandLine();
|
||||
|
||||
/* Skip the application name */
|
||||
if(*szCommandLine == '\"')
|
||||
{
|
||||
do
|
||||
{
|
||||
szCommandLine++;
|
||||
}
|
||||
while(*szCommandLine != '\"');
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
szCommandLine++;
|
||||
}
|
||||
while(*szCommandLine != ' ');
|
||||
}
|
||||
|
||||
/* Skip the trailing quotation mark/whitespace and pass the command line to SetMacro */
|
||||
SetMacro(++szCommandLine);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue