/** @file\r
\r
-Copyright (c) 2007 - 2016, Intel Corporation All rights reserved.<BR>\r
+Copyright (c) 2007 - 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
\r
Convert hex string to uint.\r
\r
- @param str - The string\r
+ @param Str - The string\r
\r
**/\r
UINTN\r
EFIAPI\r
Xtoi (\r
- CHAR16 *str\r
+ CHAR16 *Str\r
)\r
{\r
- UINTN u;\r
- CHAR16 c;\r
- UINTN m;\r
+ UINTN RetVal;\r
+ CHAR16 TempChar;\r
+ UINTN MaxVal;\r
\r
- ASSERT (str != NULL);\r
+ ASSERT (Str != NULL);\r
\r
- m = (UINTN) -1 >> 4;\r
+ MaxVal = (UINTN) -1 >> 4;\r
//\r
// skip preceeding white space\r
//\r
- while (*str && *str == ' ') {\r
- str += 1;\r
+ while (*Str != '\0' && *Str == ' ') {\r
+ Str += 1;\r
}\r
//\r
// skip preceeding zeros\r
//\r
- while (*str && *str == '0') {\r
- str += 1;\r
+ while (*Str != '\0' && *Str == '0') {\r
+ Str += 1;\r
}\r
//\r
// skip preceeding white space\r
//\r
- if (*str && (*str == 'x' || *str == 'X')) {\r
- str += 1;\r
+ if (*Str != '\0' && (*Str == 'x' || *Str == 'X')) {\r
+ Str += 1;\r
}\r
//\r
// convert hex digits\r
//\r
- u = 0;\r
- c = *(str++);\r
- while (c) {\r
- if (c >= 'a' && c <= 'f') {\r
- c -= 'a' - 'A';\r
+ RetVal = 0;\r
+ TempChar = *(Str++);\r
+ while (TempChar != '\0') {\r
+ if (TempChar >= 'a' && TempChar <= 'f') {\r
+ TempChar -= 'a' - 'A';\r
}\r
\r
- if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) {\r
- if (u > m) {\r
+ if ((TempChar >= '0' && TempChar <= '9') || (TempChar >= 'A' && TempChar <= 'F')) {\r
+ if (RetVal > MaxVal) {\r
return (UINTN) -1;\r
}\r
\r
- u = (u << 4) | (c - (c >= 'A' ? 'A' - 10 : '0'));\r
+ RetVal = (RetVal << 4) | (TempChar - (TempChar >= 'A' ? 'A' - 10 : '0'));\r
} else {\r
break;\r
}\r
\r
- c = *(str++);\r
+ TempChar = *(Str++);\r
}\r
\r
- return u;\r
+ return RetVal;\r
}\r
\r
/**\r
\r
Convert hex string to uint.\r
\r
- @param str - The string\r
+ @param Str - The string\r
\r
**/\r
-\r
UINT64\r
EFIAPI\r
LXtoi (\r
- CHAR16 *str\r
+ CHAR16 *Str\r
)\r
{\r
- UINT64 u;\r
- CHAR16 c;\r
- UINT64 m;\r
+ UINT64 RetVal;\r
+ CHAR16 TempChar;\r
+ UINT64 MaxVal;\r
\r
- ASSERT (str != NULL);\r
+ ASSERT (Str != NULL);\r
\r
- m = RShiftU64 ((UINT64) -1, 4);\r
+ MaxVal = RShiftU64 ((UINT64) -1, 4);\r
//\r
// skip preceeding white space\r
//\r
- while (*str && *str == ' ') {\r
- str += 1;\r
+ while (*Str != '\0' && *Str == ' ') {\r
+ Str += 1;\r
}\r
//\r
// skip preceeding zeros\r
//\r
- while (*str && *str == '0') {\r
- str += 1;\r
+ while (*Str != '\0' && *Str == '0') {\r
+ Str += 1;\r
}\r
//\r
// skip preceeding white space\r
//\r
- if (*str && (*str == 'x' || *str == 'X')) {\r
- str += 1;\r
+ if (*Str != '\0' && (*Str == 'x' || *Str == 'X')) {\r
+ Str += 1;\r
}\r
//\r
// convert hex digits\r
//\r
- u = 0;\r
- c = *(str++);\r
- while (c) {\r
- if (c >= 'a' && c <= 'f') {\r
- c -= 'a' - 'A';\r
+ RetVal = 0;\r
+ TempChar = *(Str++);\r
+ while (TempChar != '\0') {\r
+ if (TempChar >= 'a' && TempChar <= 'f') {\r
+ TempChar -= 'a' - 'A';\r
}\r
\r
- if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) {\r
- if (u > m) {\r
+ if ((TempChar >= '0' && TempChar <= '9') || (TempChar >= 'A' && TempChar <= 'F')) {\r
+ if (RetVal > MaxVal) {\r
return (UINT64) -1;\r
}\r
\r
- u = LShiftU64 (u, 4);\r
- u = u + (c - (c >= 'A' ? 'A' - 10 : '0'));\r
+ RetVal = LShiftU64 (RetVal, 4);\r
+ RetVal = RetVal + (TempChar - (TempChar >= 'A' ? 'A' - 10 : '0'));\r
} else {\r
break;\r
}\r
\r
- c = *(str++);\r
+ TempChar = *(Str++);\r
}\r
\r
- return u;\r
+ return RetVal;\r
}\r
\r
/**\r
\r
Convert hex string to uint.\r
\r
- @param str - The string\r
+ @param Str - The string\r
\r
**/\r
UINTN\r
EFIAPI\r
Atoi (\r
- CHAR16 *str\r
+ CHAR16 *Str\r
)\r
{\r
- UINTN u;\r
- CHAR16 c;\r
- UINTN m;\r
- UINTN n;\r
+ UINTN RetVal;\r
+ CHAR16 TempChar;\r
+ UINTN MaxVal;\r
+ UINTN ResteVal;\r
\r
- ASSERT (str != NULL);\r
+ ASSERT (Str != NULL);\r
\r
- m = (UINTN) -1 / 10;\r
- n = (UINTN) -1 % 10;\r
+ MaxVal = (UINTN) -1 / 10;\r
+ ResteVal = (UINTN) -1 % 10;\r
//\r
// skip preceeding white space\r
//\r
- while (*str && *str == ' ') {\r
- str += 1;\r
+ while (*Str != '\0' && *Str == ' ') {\r
+ Str += 1;\r
}\r
//\r
// convert digits\r
//\r
- u = 0;\r
- c = *(str++);\r
- while (c) {\r
- if (c >= '0' && c <= '9') {\r
- if (u > m || (u == m && c - '0' > (INTN) n)) {\r
+ RetVal = 0;\r
+ TempChar = *(Str++);\r
+ while (TempChar != '\0') {\r
+ if (TempChar >= '0' && TempChar <= '9') {\r
+ if (RetVal > MaxVal || (RetVal == MaxVal && TempChar - '0' > (INTN) ResteVal)) {\r
return (UINTN) -1;\r
}\r
\r
- u = (u * 10) + c - '0';\r
+ RetVal = (RetVal * 10) + TempChar - '0';\r
} else {\r
break;\r
}\r
\r
- c = *(str++);\r
+ TempChar = *(Str++);\r
}\r
\r
- return u;\r
+ return RetVal;\r
}\r
\r
/**\r
\r
Convert hex string to uint.\r
\r
- @param str - The string\r
+ @param Str - The string\r
\r
**/\r
UINTN\r
EFIAPI\r
AsciiXtoi (\r
- CHAR8 *str\r
+ CHAR8 *Str\r
)\r
{\r
- UINTN u;\r
- CHAR8 c;\r
- UINTN m;\r
+ UINTN RetVal;\r
+ CHAR8 TempChar;\r
+ UINTN MaxVal;\r
\r
- ASSERT (str != NULL);\r
+ ASSERT (Str != NULL);\r
\r
- m = (UINTN) -1 >> 4;\r
+ MaxVal = (UINTN) -1 >> 4;\r
//\r
// skip preceeding white space\r
//\r
- while (*str && *str == ' ') {\r
- str += 1;\r
+ while (*Str != '\0' && *Str == ' ') {\r
+ Str += 1;\r
}\r
//\r
// skip preceeding zeros\r
//\r
- while (*str && *str == '0') {\r
- str += 1;\r
+ while (*Str != '\0' && *Str == '0') {\r
+ Str += 1;\r
}\r
//\r
// skip preceeding white space\r
//\r
- if (*str && (*str == 'x' || *str == 'X')) {\r
- str += 1;\r
+ if (*Str != '\0' && (*Str == 'x' || *Str == 'X')) {\r
+ Str += 1;\r
}\r
//\r
// convert hex digits\r
//\r
- u = 0;\r
- c = *(str++);\r
- while (c) {\r
- if (c >= 'a' && c <= 'f') {\r
- c -= 'a' - 'A';\r
+ RetVal = 0;\r
+ TempChar = *(Str++);\r
+ while (TempChar != '\0') {\r
+ if (TempChar >= 'a' && TempChar <= 'f') {\r
+ TempChar -= 'a' - 'A';\r
}\r
\r
- if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) {\r
- if (u > m) {\r
+ if ((TempChar >= '0' && TempChar <= '9') || (TempChar >= 'A' && TempChar <= 'F')) {\r
+ if (RetVal > MaxVal) {\r
return (UINTN) -1;\r
}\r
\r
- u = (u << 4) | (c - (c >= 'A' ? 'A' - 10 : '0'));\r
+ RetVal = (RetVal << 4) | (TempChar - (TempChar >= 'A' ? 'A' - 10 : '0'));\r
} else {\r
break;\r
}\r
\r
- c = *(str++);\r
+ TempChar = *(Str++);\r
}\r
\r
- return u;\r
+ return RetVal;\r
}\r
\r
/**\r
\r
Convert hex string to uint.\r
\r
- @param str - The string\r
+ @param Str - The string\r
\r
**/\r
UINTN\r
EFIAPI\r
AsciiAtoi (\r
- CHAR8 *str\r
+ CHAR8 *Str\r
)\r
{\r
- UINTN u;\r
- CHAR8 c;\r
- UINTN m;\r
- UINTN n;\r
+ UINTN RetVal;\r
+ CHAR8 TempChar;\r
+ UINTN MaxVal;\r
+ UINTN ResteVal;\r
\r
- ASSERT (str != NULL);\r
+ ASSERT (Str != NULL);\r
\r
- m = (UINTN) -1 / 10;\r
- n = (UINTN) -1 % 10;\r
+ MaxVal = (UINTN) -1 / 10;\r
+ ResteVal = (UINTN) -1 % 10;\r
//\r
// skip preceeding white space\r
//\r
- while (*str && *str == ' ') {\r
- str += 1;\r
+ while (*Str != '\0' && *Str == ' ') {\r
+ Str += 1;\r
}\r
//\r
// convert digits\r
//\r
- u = 0;\r
- c = *(str++);\r
- while (c) {\r
- if (c >= '0' && c <= '9') {\r
- if (u > m || (u == m && c - '0' > (INTN) n)) {\r
+ RetVal = 0;\r
+ TempChar = *(Str++);\r
+ while (TempChar != '\0') {\r
+ if (TempChar >= '0' && TempChar <= '9') {\r
+ if (RetVal > MaxVal || (RetVal == MaxVal && TempChar - '0' > (INTN) ResteVal)) {\r
return (UINTN) -1;\r
}\r
\r
- u = (u * 10) + c - '0';\r
+ RetVal = (RetVal * 10) + TempChar - '0';\r
} else {\r
break;\r
}\r
\r
- c = *(str++);\r
+ TempChar = *(Str++);\r
}\r
\r
- return u;\r
+ return RetVal;\r
}\r
\r
+/**\r
+\r
+ Convert the character to upper case.\r
+\r
+ @param Chr the character to be converted.\r
+\r
+**/\r
STATIC\r
CHAR16\r
UnicodeToUpper (\r
return (Chr >= L'a' && Chr <= L'z') ? Chr - (L'a' - L'A') : Chr;\r
}\r
\r
+/**\r
+\r
+ Convert the character to upper case.\r
+\r
+ @param Chr the character to be converted.\r
+\r
+**/\r
STATIC\r
CHAR8\r
AsciiToUpper (\r
IN CHAR8 *String2\r
)\r
{\r
- while (*String) {\r
+ while (*String != '\0') {\r
if (*String != (CHAR16)*String2) {\r
break;\r
}\r
\r
Size = (StrLen(Src) + 1) * sizeof(CHAR16);\r
Dest = AllocateZeroPool (Size);\r
- if (Dest) {\r
+ if (Dest != NULL) {\r
CopyMem (Dest, Src, Size);\r
}\r
return Dest;\r
@param CharSet Point to the string to be found.\r
\r
**/\r
-\r
CHAR16 *\r
EFIAPI\r
StrBrk (\r
@param CharSet Point to the string to be found.\r
\r
**/\r
-\r
CHAR16 *\r
EFIAPI\r
StrTokenField (\r
return Begin;\r
}\r
\r
+/**\r
+\r
+ Find the next token after one or more specified characters.\r
+\r
+ @param String Point to the string where to find the substring.\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR16 *\r
EFIAPI\r
StrGetNewTokenLine (\r
return StrTokenLine (String, CharSet);\r
}\r
\r
+/**\r
+\r
+ Find the next token after one or more specified characters.\r
+\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR16 *\r
EFIAPI\r
StrGetNextTokenLine (\r
return StrTokenLine (NULL, CharSet);\r
}\r
\r
+/**\r
+\r
+ Find the next token after one specificed characters.\r
+\r
+ @param String Point to the string where to find the substring.\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR16 *\r
EFIAPI\r
StrGetNewTokenField (\r
return StrTokenField (String, CharSet);\r
}\r
\r
+/**\r
+\r
+ Find the next token after one specificed characters.\r
+\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR16 *\r
EFIAPI\r
StrGetNextTokenField (\r
return StrTokenField (NULL, CharSet);\r
}\r
\r
+/**\r
+\r
+ Patch a character to the end of a string.\r
+\r
+ @param Buffer The string to be patched.\r
+ @param Patch The patch character.\r
+\r
+**/\r
VOID\r
EFIAPI\r
PatchForStrTokenAfter (\r
}\r
*Str = Patch;\r
\r
- while (*(Str ++)) {\r
+ while (*(Str ++) != '\0') {\r
if (*Str == 0) {\r
*Str = Patch;\r
} else {\r
return ;\r
}\r
\r
+/**\r
+ Patch a character at the beginning of a string.\r
+\r
+ @param Buffer The string to be patched.\r
+ @param Patch The patch character.\r
+\r
+**/\r
VOID\r
EFIAPI\r
PatchForStrTokenBefore (\r
}\r
\r
Str = Buffer;\r
- while (*(Str --)) {\r
+ while (*(Str --) != '\0') {\r
if ((*Str == 0) || (*Str == Patch)) {\r
*Str = Patch;\r
} else {\r
@param CharSet Point to the string to be found.\r
\r
**/\r
-\r
CHAR8 *\r
EFIAPI\r
AsciiStrTokenField (\r
return Begin;\r
}\r
\r
+/**\r
+\r
+ Find the next token after one or more specified characters.\r
+\r
+ @param String Point to the string where to find the substring.\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR8 *\r
EFIAPI\r
AsciiStrGetNewTokenLine (\r
return AsciiStrTokenLine (String, CharSet);\r
}\r
\r
+/**\r
+\r
+ Find the next token after one or more specified characters.\r
+\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR8 *\r
EFIAPI\r
AsciiStrGetNextTokenLine (\r
return AsciiStrTokenLine (NULL, CharSet);\r
}\r
\r
+/**\r
+\r
+ Find the next token after one specificed characters.\r
+\r
+ @param String Point to the string where to find the substring.\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR8 *\r
EFIAPI\r
AsciiStrGetNewTokenField (\r
return AsciiStrTokenField (String, CharSet);\r
}\r
\r
+/**\r
+\r
+ Find the next token after one specificed characters.\r
+\r
+ @param CharSet Point to the string to be found.\r
+\r
+**/\r
CHAR8 *\r
EFIAPI\r
AsciiStrGetNextTokenField (\r
return AsciiStrTokenField (NULL, CharSet);\r
}\r
\r
+/**\r
+\r
+ Patch a character to the end of a string.\r
+\r
+ @param Buffer The string to be patched.\r
+ @param Patch The patch character.\r
+\r
+**/\r
VOID\r
EFIAPI\r
PatchForAsciiStrTokenAfter (\r
}\r
*Str = Patch;\r
\r
- while (*(Str ++)) {\r
+ while (*(Str ++) != '\0') {\r
if (*Str == 0) {\r
*Str = Patch;\r
} else {\r
return ;\r
}\r
\r
+/**\r
+ Patch a character at the beginning of a string.\r
+\r
+ @param Buffer The string to be patched.\r
+ @param Patch The patch character.\r
+\r
+**/\r
VOID\r
EFIAPI\r
PatchForAsciiStrTokenBefore (\r
}\r
\r
Str = Buffer;\r
- while (*(Str --)) {\r
+ while (*(Str --) != '\0') {\r
if ((*Str == 0) || (*Str == Patch)) {\r
*Str = Patch;\r
} else {\r