]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Application/Shell/ShellParametersProtocol.c
ShellPkg: Fix the bug that handling Ctrl-C improperly
[mirror_edk2.git] / ShellPkg / Application / Shell / ShellParametersProtocol.c
index 3684f9cd827b175d2abcde6b07e042c15b6d351e..8d76fb4be7ff0910d333b1814ed471a9e23099f1 100644 (file)
@@ -2,9 +2,10 @@
   Member functions of EFI_SHELL_PARAMETERS_PROTOCOL and functions for creation,\r
   manipulation, and initialization of EFI_SHELL_PARAMETERS_PROTOCOL.\r
 \r
+  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
   Copyright (C) 2014, Red Hat, Inc.\r
   (C) Copyright 2013 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -25,7 +26,6 @@ BOOLEAN AsciiRedirection = FALSE;
   @param[in] String        the string to parse\r
 **/\r
 CONST CHAR16*\r
-EFIAPI\r
 FindEndOfParameter(\r
   IN CONST CHAR16 *String\r
   )\r
@@ -85,7 +85,6 @@ FindEndOfParameter(
   @return   EFI_NOT_FOUND         A closing " could not be found on the specified string\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 GetNextParameter(\r
   IN OUT CHAR16   **Walker,\r
   IN OUT CHAR16   **TempParameter,\r
@@ -195,7 +194,6 @@ DEBUG_CODE_END();
   @return EFI_OUT_OF_RESOURCES  a memory allocation failed.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 ParseCommandLineToArgs(\r
   IN CONST CHAR16 *CommandLine,\r
   IN BOOLEAN      StripQuotation,\r
@@ -295,7 +293,6 @@ Done:
   @sa ParseCommandLineToArgs\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 CreatePopulateInstallShellParametersProtocol (\r
   IN OUT EFI_SHELL_PARAMETERS_PROTOCOL  **NewShellParameters,\r
   IN OUT BOOLEAN                        *RootShellInstance\r
@@ -437,7 +434,6 @@ CreatePopulateInstallShellParametersProtocol (
   @sa UninstallProtocolInterface\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 CleanUpShellParametersProtocol (\r
   IN OUT EFI_SHELL_PARAMETERS_PROTOCOL  *NewShellParameters\r
   )\r
@@ -484,7 +480,6 @@ CleanUpShellParametersProtocol (
   @return An error upon failure.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 IsUnicodeFile(\r
   IN CONST CHAR16 *FileName\r
   )\r
@@ -519,7 +514,6 @@ IsUnicodeFile(
   @param[in, out] TheString  A pointer to the string to update.\r
 **/\r
 VOID\r
-EFIAPI\r
 StripQuotes (\r
   IN OUT CHAR16 *TheString\r
   )\r
@@ -571,7 +565,6 @@ CalculateEfiHdrCrc (
   @return       The modified FileName.\r
 **/\r
 CHAR16*\r
-EFIAPI\r
 FixFileName (\r
   IN CHAR16 *FileName\r
   )\r
@@ -614,7 +607,6 @@ FixFileName (
   @return       The modified FileName.\r
 **/\r
 CHAR16*\r
-EFIAPI\r
 FixVarName (\r
   IN CHAR16 *FileName\r
   )\r
@@ -643,7 +635,6 @@ FixVarName (
   @retval EFI_SUCCESS   The unicode file tag has been moved successfully.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 RemoveFileTag(\r
   IN SHELL_FILE_HANDLE *Handle\r
   )\r
@@ -707,7 +698,6 @@ WriteFileTag (
   @retval   EFI_OUT_OF_RESOURCES        A memory allocation failed.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 UpdateStdInStdOutStdErr(\r
   IN OUT EFI_SHELL_PARAMETERS_PROTOCOL  *ShellParameters,\r
   IN CHAR16                             *NewCommandLine,\r
@@ -1044,9 +1034,9 @@ UpdateStdInStdOutStdErr(
   StrnCpyS(CommandLineCopy, StrSize(CommandLineCopy)/sizeof(CHAR16), NewCommandLine, StrLen(NewCommandLine));\r
 \r
   if (FirstLocation != CommandLineCopy + StrLen(CommandLineCopy)\r
-    && ((UINTN)(FirstLocation - CommandLineCopy) < StrLen(NewCommandLine))\r
+    && (((UINTN)FirstLocation - (UINTN)CommandLineCopy)/sizeof(CHAR16) < StrLen(NewCommandLine))\r
     ){\r
-    *(NewCommandLine + (UINTN)(FirstLocation - CommandLineCopy)) = CHAR_NULL;\r
+    *(NewCommandLine + ((UINTN)FirstLocation - (UINTN)CommandLineCopy)/sizeof(CHAR16)) = CHAR_NULL;\r
   }\r
 \r
   if (!EFI_ERROR(Status)) {\r
@@ -1174,7 +1164,7 @@ UpdateStdInStdOutStdErr(
         if (TempHandle == NULL) {\r
           Status = EFI_INVALID_PARAMETER;\r
         } else {\r
-          if (StrStr(StdOutFileName, L"NUL")==StdOutFileName) {\r
+          if (gUnicodeCollation->MetaiMatch (gUnicodeCollation, StdOutFileName, L"NUL")) {\r
             //no-op\r
           } else if (!OutAppend && OutUnicode && !EFI_ERROR(Status)) {\r
             Status = WriteFileTag (TempHandle);\r
@@ -1307,7 +1297,6 @@ UpdateStdInStdOutStdErr(
   @param[in] SystemTableInfo           Pointer to old system table information.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 RestoreStdInStdOutStdErr (\r
   IN OUT EFI_SHELL_PARAMETERS_PROTOCOL  *ShellParameters,\r
   IN  SHELL_FILE_HANDLE                 *OldStdIn,\r
@@ -1384,7 +1373,6 @@ RestoreStdInStdOutStdErr (
   @retval   EFI_OUT_OF_RESOURCES        A memory allocation failed.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 UpdateArgcArgv(\r
   IN OUT EFI_SHELL_PARAMETERS_PROTOCOL  *ShellParameters,\r
   IN CONST CHAR16                       *NewCommandLine,\r
@@ -1426,7 +1414,6 @@ UpdateArgcArgv(
   @param[in] OldArgc                    pointer to old number of items in Argv list\r
 **/\r
 VOID\r
-EFIAPI\r
 RestoreArgcArgv(\r
   IN OUT EFI_SHELL_PARAMETERS_PROTOCOL  *ShellParameters,\r
   IN CHAR16                             ***OldArgv,\r