diff options
author | jcarsey <jcarsey@Edk2> | 2014-11-04 22:33:16 +0000 |
---|---|---|
committer | jcarsey <jcarsey@Edk2> | 2014-11-04 22:33:16 +0000 |
commit | 658bf43ecfe96df1cdc005a15f0af1dcc79de09b (patch) | |
tree | 2e69ae3dccac7b97902d6b3f5b39408f627b48a2 /ShellPkg | |
parent | f9080cdd088852935fac889fc9fd180a62459e80 (diff) | |
download | edk2-platforms-658bf43ecfe96df1cdc005a15f0af1dcc79de09b.tar.xz |
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
Diffstat (limited to 'ShellPkg')
-rw-r--r-- | ShellPkg/Include/Library/ShellLib.h | 3 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c | 4 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellLib/UefiShellLib.c | 26 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellLib/UefiShellLib.h | 6 |
4 files changed, 25 insertions, 14 deletions
diff --git a/ShellPkg/Include/Library/ShellLib.h b/ShellPkg/Include/Library/ShellLib.h index 4a79acdd57..23da4eeaf6 100644 --- a/ShellPkg/Include/Library/ShellLib.h +++ b/ShellPkg/Include/Library/ShellLib.h @@ -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;
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c index 24dcae4682..25dc6ffb64 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c @@ -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}
};
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index 5e03400aeb..4a4c40a928 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -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);
}
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.h b/ShellPkg/Library/UefiShellLib/UefiShellLib.h index c70e6cb91e..3596f7b011 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.h +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.h @@ -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
);
/**
|