From 9fd2164e34b9f3e1aa6bde07f513f43a6a08e588 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Wed, 25 May 2011 10:45:15 +0000 Subject: Sync BaseTools Branch (version r2157) to EDKII main trunk. BaseTool Branch: https://edk2-buildtools.svn.sourceforge.net/svnroot/edk2-buildtools/branches/Releases/BaseTools_r2100 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11702 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Source/C/GenVtf/GenVtf.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'BaseTools/Source/C') diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c b/BaseTools/Source/C/GenVtf/GenVtf.c index 428158ebb8..035c268a2c 100644 --- a/BaseTools/Source/C/GenVtf/GenVtf.c +++ b/BaseTools/Source/C/GenVtf/GenVtf.c @@ -119,28 +119,37 @@ Returns: --*/ { - CHAR8 StrPtr[40]; - CHAR8 *Token; + CHAR8 TemStr[5] = "0000"; unsigned Major; unsigned Minor; + UINTN Length; Major = 0; Minor = 0; - memset (StrPtr, 0, 40); - Token = strtok (Str, "."); - while (Token != NULL) { - strcat (StrPtr, Token); - Token = strtok (NULL, "."); + if (strstr (Str, ".") != NULL) { + sscanf ( + Str, + "%02x.%02x", + &Major, + &Minor + ); + } else { + Length = strlen(Str); + if (Length < 4) { + strncpy (TemStr + 4 - Length, Str, Length); + } else { + strncpy (TemStr, Str + Length - 4, 4); + } + + sscanf ( + TemStr, + "%02x%02x", + &Major, + &Minor + ); } - sscanf ( - StrPtr, - "%02d%02d", - &Major, - &Minor - ); - *MajorVer = (UINT8) Major; *MinorVer = (UINT8) Minor; return EFI_SUCCESS; -- cgit v1.2.3