]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLib/UefiShellLib.c
ShellPkg: Series of patches to fix typos - apropriate to appropriate
[mirror_edk2.git] / ShellPkg / Library / UefiShellLib / UefiShellLib.c
index dac0524fcbdd98652f4fb43368290b1bada372e4..5e5e6271bf24d418aaa7f04ff29925aee0be1754 100644 (file)
@@ -2,7 +2,7 @@
   Provides interface to shell functionality for shell commands and applications.\r
 \r
   Copyright 2016 Dell Inc.\r
-  Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2016, 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
@@ -373,6 +373,8 @@ EFIAPI
 ShellInitialize (\r
   )\r
 {\r
+  EFI_STATUS Status;\r
+\r
   //\r
   // if auto initialize is not false then skip\r
   //\r
@@ -383,7 +385,8 @@ ShellInitialize (
   //\r
   // deinit the current stuff\r
   //\r
-  ASSERT_EFI_ERROR(ShellLibDestructor(gImageHandle, gST));\r
+  Status = ShellLibDestructor (gImageHandle, gST);\r
+  ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
   // init the new stuff\r
@@ -3283,7 +3286,7 @@ StrnCatGrow (
   Prompt the user and return the resultant answer to the requestor.\r
 \r
   This function will display the requested question on the shell prompt and then\r
-  wait for an apropriate answer to be input from the console.\r
+  wait for an appropriate answer to be input from the console.\r
 \r
   if the SHELL_PROMPT_REQUEST_TYPE is SHELL_PROMPT_REQUEST_TYPE_YESNO, ShellPromptResponseTypeQuitContinue\r
   or SHELL_PROMPT_REQUEST_TYPE_YESNOCANCEL then *Response is of type SHELL_PROMPT_RESPONSE.\r
@@ -4071,6 +4074,9 @@ ShellFileHandleReturnLine(
     Status = ShellFileHandleReadLine(Handle, RetVal, &Size, FALSE, Ascii);\r
 \r
   }\r
+  if (Status == EFI_END_OF_FILE && RetVal != NULL && *RetVal != CHAR_NULL) {\r
+    Status = EFI_SUCCESS;\r
+  }\r
   if (EFI_ERROR(Status) && (RetVal != NULL)) {\r
     FreePool(RetVal);\r
     RetVal = NULL;\r
@@ -4176,43 +4182,27 @@ ShellFileHandleReadLine(
     //\r
     // if we have space save it...\r
     //\r
-    if ((CountSoFar + 1) * CharSize < *Size){\r
+    if ((CountSoFar+1)*sizeof(CHAR16) < *Size){\r
       ASSERT(Buffer != NULL);\r
-      if (*Ascii) {\r
-        ((CHAR8*)Buffer)[CountSoFar] = (CHAR8) CharBuffer;\r
-        ((CHAR8*)Buffer)[CountSoFar+1] = '\0';\r
-      }\r
-      else {\r
-        ((CHAR16*)Buffer)[CountSoFar] = CharBuffer;\r
-        ((CHAR16*)Buffer)[CountSoFar+1] = CHAR_NULL;\r
-      }\r
+      ((CHAR16*)Buffer)[CountSoFar] = CharBuffer;\r
+      ((CHAR16*)Buffer)[CountSoFar+1] = CHAR_NULL;\r
     }\r
   }\r
 \r
   //\r
   // if we ran out of space tell when...\r
   //\r
-  if (Status != EFI_END_OF_FILE){\r
-    if ((CountSoFar + 1) * CharSize > *Size){\r
-      *Size = (CountSoFar + 1) * CharSize;\r
-      if (!Truncate) {\r
-        gEfiShellProtocol->SetFilePosition(Handle, OriginalFilePosition);\r
-      } else {\r
-        DEBUG((DEBUG_WARN, "The line was truncated in ShellFileHandleReadLine"));\r
-      }\r
-      return (EFI_BUFFER_TOO_SMALL);\r
-    }\r
-\r
-    if (*Ascii) {\r
-      if (CountSoFar && ((CHAR8*)Buffer)[CountSoFar - 1] == '\r') {\r
-        ((CHAR8*)Buffer)[CountSoFar - 1] = '\0';\r
-      }\r
-    }\r
-    else {\r
-      if (CountSoFar && Buffer[CountSoFar - 1] == L'\r') {\r
-        Buffer[CountSoFar - 1] = CHAR_NULL;\r
-      }\r
+  if ((CountSoFar+1)*sizeof(CHAR16) > *Size){\r
+    *Size = (CountSoFar+1)*sizeof(CHAR16);\r
+    if (!Truncate) {\r
+      gEfiShellProtocol->SetFilePosition(Handle, OriginalFilePosition);\r
+    } else {\r
+      DEBUG((DEBUG_WARN, "The line was truncated in ShellFileHandleReadLine"));\r
     }\r
+    return (EFI_BUFFER_TOO_SMALL);\r
+  }\r
+  while(Buffer[StrLen(Buffer)-1] == L'\r') {\r
+    Buffer[StrLen(Buffer)-1] = CHAR_NULL;\r
   }\r
 \r
   return (Status);\r