]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Remove UNICODE file tag (FEFF) from files used for input redirection
authorJaben Carsey <jaben.carsey@intel.com>
Mon, 13 Jan 2014 18:52:48 +0000 (18:52 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 13 Jan 2014 18:52:48 +0000 (18:52 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15109 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Application/Shell/ShellParametersProtocol.c

index 9b385bee154e14cb0014a27ac958b8632968f283..ab435a126313da06da9eaecfe3e8c478e3617430 100644 (file)
@@ -3,7 +3,7 @@
   manipulation, and initialization of EFI_SHELL_PARAMETERS_PROTOCOL.\r
 \r
   Copyright (c) 2013 Hewlett-Packard Development Company, L.P.\r
-  Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2014, 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
@@ -567,6 +567,28 @@ FixVarName (
   return (FixFileName(Copy));\r
 }\r
 \r
+/**\r
+  Remove the unicode file tag from the begining of the file buffer since that will not be\r
+  used by StdIn.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+RemoveFileTag(\r
+  IN SHELL_FILE_HANDLE *Handle\r
+  )\r
+{\r
+  UINTN             CharSize;\r
+  CHAR16            CharBuffer;\r
+\r
+  CharSize    = sizeof(CHAR16);\r
+  CharBuffer  = 0;\r
+  gEfiShellProtocol->ReadFile(*Handle, &CharSize, &CharBuffer);\r
+  if (CharBuffer != gUnicodeFileTag) {\r
+    gEfiShellProtocol->SetFilePosition(*Handle, 0);\r
+  }\r
+  return (EFI_SUCCESS);\r
+}\r
+\r
 /**\r
   Funcion will replace the current StdIn and StdOut in the ShellParameters protocol\r
   structure by parsing NewCommandLine.  The current values are returned to the\r
@@ -1148,7 +1170,15 @@ UpdateStdInStdOutStdErr(
           &TempHandle,\r
           EFI_FILE_MODE_READ,\r
           0);\r
-        if (!InUnicode && !EFI_ERROR(Status)) {\r
+        if (InUnicode) {\r
+          //\r
+          // Chop off the 0xFEFF if it's there...\r
+          //\r
+          RemoveFileTag(&TempHandle);\r
+        } else if (!EFI_ERROR(Status)) {\r
+          //\r
+          // Create the ASCII->Unicode conversion layer\r
+          //\r
           TempHandle = CreateFileInterfaceFile(TempHandle, FALSE);\r
         }\r
         if (!EFI_ERROR(Status)) {\r