ShellPkg: Fix timezone command

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by : Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Tapan Shah <tapandshah@hp.com>
Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16300 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jcarsey 2014-11-04 22:33:16 +00:00
parent f9080cdd08
commit 658bf43ecf
4 changed files with 25 additions and 14 deletions

View File

@ -1,7 +1,7 @@
/** @file
Provides interface to shell functionality for shell commands and applications.
Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -668,6 +668,7 @@ typedef enum {
TypeStart, ///< A flag that has variable value appended to the end (IE "-ad", "-afd", "-adf", etc...).
TypeDoubleValue, ///< A flag that has 2 space seperated value data following it (IE "-a 1 2").
TypeMaxValue, ///< A flag followed by all the command line data before the next flag.
TypeTimeValue, ///< A flag that has a time value following it (IE "-a -5:00").
TypeMax,
} SHELL_PARAM_TYPE;

View File

@ -2,7 +2,7 @@
Main file for time, timezone, and date shell level 2 and shell level 3 functions.
(C) Copyright 2012-2014, Hewlett-Packard Development Company, L.P.
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -647,7 +647,7 @@ STATIC CONST SHELL_PARAM_ITEM TimeZoneParamList2[] = {
STATIC CONST SHELL_PARAM_ITEM TimeZoneParamList3[] = {
{L"-l", TypeFlag},
{L"-f", TypeFlag},
{L"-s", TypeValue},
{L"-s", TypeTimeValue},
{NULL, TypeMax}
};

View File

@ -1903,6 +1903,7 @@ InternalIsOnCheckList (
@param[in] Name pointer to Name of parameter found
@param[in] AlwaysAllowNumbers TRUE to allow numbers, FALSE to not.
@param[in] TimeNumbers TRUE to allow numbers with ":", FALSE otherwise.
@retval TRUE the Parameter is a flag.
@retval FALSE the Parameter not a flag.
@ -1911,7 +1912,8 @@ BOOLEAN
EFIAPI
InternalIsFlag (
IN CONST CHAR16 *Name,
IN BOOLEAN AlwaysAllowNumbers
IN CONST BOOLEAN AlwaysAllowNumbers,
IN CONST BOOLEAN TimeNumbers
)
{
//
@ -1922,7 +1924,7 @@ InternalIsFlag (
//
// If we accept numbers then dont return TRUE. (they will be values)
//
if (((Name[0] == L'-' || Name[0] == L'+') && InternalShellIsHexOrDecimalNumber(Name+1, FALSE, FALSE)) && AlwaysAllowNumbers) {
if (((Name[0] == L'-' || Name[0] == L'+') && InternalShellIsHexOrDecimalNumber(Name+1, FALSE, FALSE, TimeNumbers)) && AlwaysAllowNumbers) {
return (FALSE);
}
@ -2056,6 +2058,7 @@ InternalCommandLineParse (
// possibly trigger the next loop(s) to populate the value of this item
//
case TypeValue:
case TypeTimeValue:
GetItemValue = 1;
ValueSize = 0;
break;
@ -2075,7 +2078,7 @@ InternalCommandLineParse (
ASSERT(GetItemValue == 0);
break;
}
} else if (GetItemValue != 0 && !InternalIsFlag(Argv[LoopCounter], AlwaysAllowNumbers)) {
} else if (GetItemValue != 0 && !InternalIsFlag(Argv[LoopCounter], AlwaysAllowNumbers, CurrentItemPackage->Type == TypeTimeValue)) {
ASSERT(CurrentItemPackage != NULL);
//
// get the item VALUE for a previous flag
@ -2114,7 +2117,7 @@ InternalCommandLineParse (
if (GetItemValue == 0) {
InsertHeadList(*CheckPackage, &CurrentItemPackage->Link);
}
} else if (!InternalIsFlag(Argv[LoopCounter], AlwaysAllowNumbers) ){ //|| ProblemParam == NULL) {
} else if (!InternalIsFlag(Argv[LoopCounter], AlwaysAllowNumbers, FALSE)){
//
// add this one as a non-flag
//
@ -3134,7 +3137,7 @@ ShellStrToUintn(
Hex = FALSE;
if (!InternalShellIsHexOrDecimalNumber(String, Hex, TRUE)) {
if (!InternalShellIsHexOrDecimalNumber(String, Hex, TRUE, FALSE)) {
Hex = TRUE;
}
@ -3551,6 +3554,7 @@ ShellPromptForResponseHii (
@param[in] String The string to evaluate.
@param[in] ForceHex TRUE - always assume hex.
@param[in] StopAtSpace TRUE to halt upon finding a space, FALSE to keep going.
@param[in] TimeNumbers TRUE to allow numbers with ":", FALSE otherwise.
@retval TRUE It is all numeric (dec/hex) characters.
@retval FALSE There is a non-numeric character.
@ -3560,7 +3564,8 @@ EFIAPI
InternalShellIsHexOrDecimalNumber (
IN CONST CHAR16 *String,
IN CONST BOOLEAN ForceHex,
IN CONST BOOLEAN StopAtSpace
IN CONST BOOLEAN StopAtSpace,
IN CONST BOOLEAN TimeNumbers
)
{
BOOLEAN Hex;
@ -3604,6 +3609,9 @@ InternalShellIsHexOrDecimalNumber (
// loop through the remaining characters and use the lib function
//
for ( ; String != NULL && *String != CHAR_NULL && !(StopAtSpace && *String == L' ') ; String++){
if (TimeNumbers && (String[0] == L':')) {
continue;
}
if (Hex) {
if (!ShellIsHexaDecimalDigitCharacter(*String)) {
return (FALSE);
@ -3927,10 +3935,10 @@ ShellConvertStringToUint64(
Hex = ForceHex;
if (!InternalShellIsHexOrDecimalNumber(String, Hex, StopAtSpace)) {
if (!InternalShellIsHexOrDecimalNumber(String, Hex, StopAtSpace, FALSE)) {
if (!Hex) {
Hex = TRUE;
if (!InternalShellIsHexOrDecimalNumber(String, Hex, StopAtSpace)) {
if (!InternalShellIsHexOrDecimalNumber(String, Hex, StopAtSpace, FALSE)) {
return (EFI_INVALID_PARAMETER);
}
} else {
@ -3946,7 +3954,7 @@ ShellConvertStringToUint64(
//
// make sure we have something left that is numeric.
//
if (Walker == NULL || *Walker == CHAR_NULL || !InternalShellIsHexOrDecimalNumber(Walker, Hex, StopAtSpace)) {
if (Walker == NULL || *Walker == CHAR_NULL || !InternalShellIsHexOrDecimalNumber(Walker, Hex, StopAtSpace, FALSE)) {
return (EFI_INVALID_PARAMETER);
}

View File

@ -1,7 +1,7 @@
/** @file
Provides interface to shell functionality for shell commands and applications.
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -60,6 +60,7 @@ typedef struct {
@param[in] String The string to evaluate.
@param[in] ForceHex TRUE - always assume hex.
@param[in] StopAtSpace TRUE to halt upon finding a space, FALSE to keep going.
@param[in] TimeNumbers TRUE to allow numbers with ":", FALSE otherwise.
@retval TRUE It is all numeric (dec/hex) characters.
@retval FALSE There is a non-numeric character.
@ -69,7 +70,8 @@ EFIAPI
InternalShellIsHexOrDecimalNumber (
IN CONST CHAR16 *String,
IN CONST BOOLEAN ForceHex,
IN CONST BOOLEAN StopAtSpace
IN CONST BOOLEAN StopAtSpace,
IN CONST BOOLEAN TimeNumbers
);
/**