https://git.reactos.org/?p=reactos.git;a=commitdiff;h=80844dc18586d4a11bec4509edd324293eaf19f7

commit 80844dc18586d4a11bec4509edd324293eaf19f7
Author:     Hermès Bélusca-Maïto <[email protected]>
AuthorDate: Sun Jul 12 18:23:57 2020 +0200
Commit:     Hermès Bélusca-Maïto <[email protected]>
CommitDate: Wed Aug 19 20:36:10 2020 +0200

    [CMD] DATE: Simplify the input loop, based on the TIME command.
    
    Set also the ERRORLEVEL in case of error.
---
 base/shell/cmd/date.c | 33 ++++++++++++---------------------
 1 file changed, 12 insertions(+), 21 deletions(-)

diff --git a/base/shell/cmd/date.c b/base/shell/cmd/date.c
index 0cecf8d9292..5f509b28f5b 100644
--- a/base/shell/cmd/date.c
+++ b/base/shell/cmd/date.c
@@ -212,9 +212,9 @@ INT cmd_date(LPTSTR param)
         return 0;
     }
 
-    if (nDateString == -1)
+    while (TRUE)
     {
-        while (TRUE)
+        if (nDateString == -1)
         {
             PrintDateString();
             ConInString(szDate, ARRAYSIZE(szDate));
@@ -229,30 +229,21 @@ INT cmd_date(LPTSTR param)
                 freep(arg);
                 return 0;
             }
-            ConErrResPuts(STRING_DATE_ERROR);
         }
-    }
-    else
-    {
-        if (!ParseDate(arg[nDateString]))
+        else
         {
-            while (TRUE)
+            if (ParseDate(arg[nDateString]))
             {
-                ConErrResPuts(STRING_DATE_ERROR);
-
-                PrintDateString();
-                ConInString(szDate, ARRAYSIZE(szDate));
-
-                while (*szDate && szDate[_tcslen(szDate) - 1] < _T(' '))
-                    szDate[_tcslen(szDate) - 1] = _T('\0');
-
-                if (ParseDate(szDate))
-                {
-                    freep(arg);
-                    return 0;
-                }
+                freep(arg);
+                return 0;
             }
+
+            /* Force input the next time around */
+            nDateString = -1;
         }
+
+        ConErrResPuts(STRING_DATE_ERROR);
+        nErrorLevel = 1;
     }
 
     freep(arg);

Reply via email to