add %DATE% example echo %date% are working now. Bugfix date so it print
out the week days names.
Modified: trunk/reactos/subsys/system/cmd/cmd.c
Modified: trunk/reactos/subsys/system/cmd/locale.c
_____
Modified: trunk/reactos/subsys/system/cmd/cmd.c
--- trunk/reactos/subsys/system/cmd/cmd.c 2005-07-07 15:05:36 UTC
(rev 16484)
+++ trunk/reactos/subsys/system/cmd/cmd.c 2005-07-07 16:06:43 UTC
(rev 16485)
@@ -990,10 +990,8 @@
*tp = _T('\0');
/* FIXME: Correct error handling when it can not alloc
memmory */
- evar = malloc ( size * sizeof(TCHAR));
- if (evar==NULL)
- return 1;
-
+
+ /* %CD% */
if (_tcsicmp(ip,_T("cd")) ==0)
{
TCHAR szPath[MAX_PATH];
@@ -1001,21 +999,47 @@
cp = _stpcpy (cp, szPath);
}
+ /* %TIME% */
else if (_tcsicmp(ip,_T("time")) ==0)
{
TCHAR szTime[40];
GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, NULL, szTime,
sizeof(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)
- {
+ {
+ evar = malloc ( size * sizeof(TCHAR));
+ if (evar==NULL)
+ return 1;
+
memset(evar,0,512 * sizeof(TCHAR));
_itot(nErrorLevel,evar,10);
cp = _stpcpy (cp, evar);
+
+ free(evar);
}
else
{
+ evar = malloc ( size * sizeof(TCHAR));
+ if (evar==NULL)
+ return 1;
+
size = GetEnvironmentVariable (ip, evar, size);
if (size!=0)
{
@@ -1030,12 +1054,10 @@
{
cp =
_stpcpy (cp, evar);
}
- }
- if (evar!=NULL)
- {
free(evar);
- }
+ }
+
ip = tp + 1;
}
_____
Modified: trunk/reactos/subsys/system/cmd/locale.c
--- trunk/reactos/subsys/system/cmd/locale.c 2005-07-07 15:05:36 UTC
(rev 16484)
+++ trunk/reactos/subsys/system/cmd/locale.c 2005-07-07 16:06:43 UTC
(rev 16485)
@@ -58,11 +58,13 @@
VOID PrintDate (VOID)
{
+ TCHAR szDateDay[32];
TCHAR szDate[32];
- GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL,
- szDate, sizeof (szDate));
- ConOutPrintf(_T("%s"), szDate);
+ GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, _T("ddd"), szDateDay,
sizeof (szDateDay));
+
+ GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL,
NULL,szDate, sizeof (szDate));
+ ConOutPrintf(_T("%s %s"),szDateDay, szDate);
}