- 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:
Colin Finck 2008-05-08 18:11:56 +00:00
parent b26bf1b115
commit 4198aafc54

View file

@ -77,59 +77,63 @@ INT SetMacro (LPTSTR param)
return 0; return 0;
} }
static VOID ReadFromFile(LPSTR param) static VOID ReadFromFile(LPTSTR param)
{ {
FILE* fp; FILE* fp;
char line[MAX_PATH]; TCHAR line[MAX_PATH];
#ifdef UNICODE
WCHAR lineW[MAX_PATH];
#endif
/* FIXME */ /* Skip the "/macrofile=" prefix */
param += 11; param += 11;
fp = fopen(param,"r"); fp = _tfopen(param, _T("r"));
while ( fgets(line, MAX_PATH, fp) != NULL)
{ while ( _fgetts(line, MAX_PATH, fp) != NULL)
#ifdef UNICODE
MultiByteToWideChar(CP_ACP, 0, line, -1, lineW, MAX_PATH);
SetMacro(lineW);
#else
SetMacro(line); SetMacro(line);
#endif
}
fclose(fp); fclose(fp);
return; return;
} }
int int
main (int argc, char **argv) _tmain (int argc, LPTSTR argv[])
{ {
#ifdef UNICODE
WCHAR lineW[MAX_PATH];
#endif
if (argc < 2) if (argc < 2)
return 0; return 0;
if (argv[1][0] == '/') if (argv[1][0] == '/')
{ {
if (strnicmp(argv[1], "/macrofile", 10) == 0) if (_tcsnicmp(argv[1], _T("/macrofile"), 10) == 0)
ReadFromFile(argv[1]); ReadFromFile(argv[1]);
if (stricmp(argv[1], "/macros") == 0) if (_tcscmp(argv[1], _T("/macros")) == 0)
PrintAlias(); PrintAlias();
} }
else else
{ {
#ifdef UNICODE /* Get the full command line using GetCommandLine().
MultiByteToWideChar(CP_ACP, 0, argv[1], -1, lineW, MAX_PATH); We can't just pass argv[1] here, because then a parameter like "gotoroot=cd \" wouldn't be passed completely. */
SetMacro(lineW); TCHAR* szCommandLine = GetCommandLine();
#else
SetMacro(argv[1]); /* Skip the application name */
#endif 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; return 0;
} }