]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/LibC/Main/Main.c
StdLib: Fix several problems where characters were not being correctly converted...
[mirror_edk2.git] / StdLib / LibC / Main / Main.c
index 3a5cca5b2461cc379a8a41c0204c7b76bff51243..9afffff7c6b9109ad5e368f8cfba0ec8aa3ddf0f 100644 (file)
@@ -4,7 +4,7 @@
   All of the global data in the gMD structure is initialized to 0, NULL, or\r
   SIG_DFL; as appropriate.\r
 \r
-  Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials are licensed and made available under\r
   the terms and conditions of the BSD License that accompanies this distribution.\r
   The full text of the license may be found at\r
@@ -27,8 +27,9 @@
 #include  <stdio.h>\r
 #include  <stdlib.h>\r
 #include  <string.h>\r
+#include  <time.h>\r
 #include  <MainData.h>\r
-#include  <sys/EfiSysCall.h>\r
+#include  <unistd.h>\r
 \r
 extern int main( int, char**);\r
 extern int __sse2_available;\r
@@ -73,7 +74,7 @@ static
 char **\r
 ArgvConvert(UINTN Argc, CHAR16 **Argv)\r
 {\r
-  size_t  AVsz;       /* Size of a single nArgv string */\r
+  ssize_t  AVsz;       /* Size of a single nArgv string, or -1 */\r
   UINTN   count;\r
   char  **nArgv;\r
   char   *string;\r
@@ -89,7 +90,7 @@ DEBUG_CODE_END();
   nArgvSize = Argc;\r
   /* Determine space needed for narrow Argv strings. */\r
   for(count = 0; count < Argc; ++count) {\r
-    AVsz = wcstombs(NULL, Argv[count], ARG_MAX);\r
+    AVsz = (ssize_t)wcstombs(NULL, Argv[count], ARG_MAX);\r
     if(AVsz < 0) {\r
       Print(L"ABORTING: Argv[%d] contains an unconvertable character.\n", count);\r
       exit(EXIT_FAILURE);\r
@@ -112,10 +113,9 @@ DEBUG_CODE_END();
   for(count = 0; count < Argc; ++count) {\r
     nArgv[count] = string;\r
     AVsz = wcstombs(string, Argv[count], nArgvSize);\r
-    string[AVsz] = 0;   /* NULL terminate the argument */\r
     DEBUG((DEBUG_INFO, "Cvt[%d] %d \"%s\" --> \"%a\"\n", (INT32)count, (INT32)AVsz, Argv[count], nArgv[count]));\r
-    string += AVsz + 1;\r
-    nArgvSize -= AVsz + 1;\r
+    string += AVsz;\r
+    nArgvSize -= AVsz;\r
     if(nArgvSize < 0) {\r
       Print(L"ABORTING: Internal Argv[%d] conversion error.\n", count);\r
       exit(EXIT_FAILURE);\r
@@ -149,13 +149,8 @@ ShellAppMain (
     errno                 = 0;\r
     EFIerrno              = 0;\r
 \r
-#ifdef NT32dvm\r
-    gMD->ClocksPerSecond  = 1;  // For NT32 only\r
-    gMD->AppStartTime     = 1;  // For NT32 only\r
-#else\r
-    gMD->ClocksPerSecond = (clock_t)GetPerformanceCounterProperties( NULL, NULL);\r
-    gMD->AppStartTime = (clock_t)GetPerformanceCounter();\r
-#endif  /* NT32 dvm */\r
+    gMD->ClocksPerSecond  = 1;\r
+    gMD->AppStartTime     = (clock_t)((UINT32)time(NULL));\r
 \r
     // Initialize file descriptors\r
     mfd = gMD->fdarray;\r