From 80844dc18586d4a11bec4509edd324293eaf19f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 12 Jul 2020 18:23:57 +0200 Subject: [PATCH] [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);