Revision: 14854
          http://sourceforge.net/p/edk2/code/14854
Author:   jcarsey
Date:     2013-11-15 20:28:58 +0000 (Fri, 15 Nov 2013)
Log Message:
-----------
ShellPkg: "For Run" fix for spaces between numerals
Since this is expected to use a string with spaces between some of the numbers, 
the function must halt on spaces and not skip them.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <[email protected]>
Reviewed-by: Erik Bjorge <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c

Modified: trunk/edk2/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
===================================================================
--- trunk/edk2/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c        
2013-11-15 20:21:34 UTC (rev 14853)
+++ trunk/edk2/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c        
2013-11-15 20:28:58 UTC (rev 14854)
@@ -254,6 +254,29 @@
 }
 
 /**
+  Function to determine whether a string is decimal or hex representation of a 
number
+  and return the number converted from the string.
+
+  @param[in] String   String representation of a number
+
+  @return             the number
+  @retval (UINTN)(-1) An error ocurred.
+**/
+UINTN
+EFIAPI
+ReturnUintn(
+  IN CONST CHAR16 *String
+  )
+{
+  UINT64        RetVal;
+
+  if (!EFI_ERROR(ShellConvertStringToUint64(String, &RetVal, FALSE, FALSE))) {
+    return ((UINTN)RetVal);
+  }
+  return ((UINTN)(-1));
+}
+
+/**
   Function for 'for' command.
 
   @param[in] ImageHandle  Handle to the Image (NULL if Internal).
@@ -486,9 +509,9 @@
               ShellStatus = SHELL_INVALID_PARAMETER;
             } else {
               if (ArgSetWalker[0] == L'-') {
-                Info->Current = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);
+                Info->Current = 0 - (INTN)ReturnUintn(ArgSetWalker+1);
               } else {
-                Info->Current = (INTN)ShellStrToUintn(ArgSetWalker);
+                Info->Current = (INTN)ReturnUintn(ArgSetWalker);
               }
               ArgSetWalker  = StrStr(ArgSetWalker, L" ");
               while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {
@@ -508,9 +531,9 @@
                 ShellStatus = SHELL_INVALID_PARAMETER;
               } else {
                 if (ArgSetWalker[0] == L'-') {
-                  Info->End = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);
+                  Info->End = 0 - (INTN)ReturnUintn(ArgSetWalker+1);
                 } else {
-                  Info->End = (INTN)ShellStrToUintn(ArgSetWalker);
+                  Info->End = (INTN)ReturnUintn(ArgSetWalker);
                 }
                 if (Info->Current < Info->End) {
                   Info->Step            = 1;
@@ -540,9 +563,9 @@
                       ASSERT(Info->Step == 1 || Info->Step == -1);
                     } else {
                       if (ArgSetWalker[0] == L'-') {
-                        Info->Step = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);
+                        Info->Step = 0 - (INTN)ReturnUintn(ArgSetWalker+1);
                       } else {
-                        Info->Step = (INTN)ShellStrToUintn(ArgSetWalker);
+                        Info->Step = (INTN)ReturnUintn(ArgSetWalker);
                       }
 
                       if (StrStr(ArgSetWalker, L" ") != NULL) {

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to