add %DATE% example echo %date% are working now. Bugfix date so it print out the week days names.

svn path=/trunk/; revision=16485
This commit is contained in:
Magnus Olsen 2005-07-07 16:06:43 +00:00
parent d7990aa664
commit 4e39fcafa0
2 changed files with 36 additions and 12 deletions

View file

@ -990,10 +990,8 @@ ProcessInput (BOOL bFlag)
*tp = _T('\0'); *tp = _T('\0');
/* FIXME: Correct error handling when it can not alloc memmory */ /* FIXME: Correct error handling when it can not alloc memmory */
evar = malloc ( size * sizeof(TCHAR));
if (evar==NULL) /* %CD% */
return 1;
if (_tcsicmp(ip,_T("cd")) ==0) if (_tcsicmp(ip,_T("cd")) ==0)
{ {
TCHAR szPath[MAX_PATH]; TCHAR szPath[MAX_PATH];
@ -1001,21 +999,47 @@ ProcessInput (BOOL bFlag)
cp = _stpcpy (cp, szPath); cp = _stpcpy (cp, szPath);
} }
/* %TIME% */
else if (_tcsicmp(ip,_T("time")) ==0) else if (_tcsicmp(ip,_T("time")) ==0)
{ {
TCHAR szTime[40]; TCHAR szTime[40];
GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, NULL, szTime, sizeof(szTime)); GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, NULL, szTime, sizeof(szTime));
cp = _stpcpy (cp, szTime); cp = _stpcpy (cp, szTime);
} }
else if (_tcsicmp(ip,_T("date")) ==0)
{
TCHAR szDate[40];
GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, _T("ddd"), szDate, sizeof (szDate));
cp = _stpcpy (cp, szDate);
cp = _stpcpy (cp, _T(" "));
GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, szDate, sizeof (szDate));
cp = _stpcpy (cp, szDate);
}
/* %ERRORLEVEL% */
else if (_tcsicmp(ip,_T("errorlevel")) ==0) else if (_tcsicmp(ip,_T("errorlevel")) ==0)
{ {
evar = malloc ( size * sizeof(TCHAR));
if (evar==NULL)
return 1;
memset(evar,0,512 * sizeof(TCHAR)); memset(evar,0,512 * sizeof(TCHAR));
_itot(nErrorLevel,evar,10); _itot(nErrorLevel,evar,10);
cp = _stpcpy (cp, evar); cp = _stpcpy (cp, evar);
free(evar);
} }
else else
{ {
evar = malloc ( size * sizeof(TCHAR));
if (evar==NULL)
return 1;
size = GetEnvironmentVariable (ip, evar, size); size = GetEnvironmentVariable (ip, evar, size);
if (size!=0) if (size!=0)
{ {
@ -1030,12 +1054,10 @@ ProcessInput (BOOL bFlag)
{ {
cp = _stpcpy (cp, evar); cp = _stpcpy (cp, evar);
} }
}
if (evar!=NULL)
{
free(evar); free(evar);
} }
ip = tp + 1; ip = tp + 1;
} }

View file

@ -58,11 +58,13 @@ VOID InitLocale (VOID)
VOID PrintDate (VOID) VOID PrintDate (VOID)
{ {
TCHAR szDateDay[32];
TCHAR szDate[32]; TCHAR szDate[32];
GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, _T("ddd"), szDateDay, sizeof (szDateDay));
szDate, sizeof (szDate));
ConOutPrintf(_T("%s"), szDate); GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL,szDate, sizeof (szDate));
ConOutPrintf(_T("%s %s"),szDateDay, szDate);
} }