/*++\r
\r
-Copyright (c) 2006, Intel Corporation \r
+Copyright (c) 2006 - 2007, Intel Corporation \r
All rights reserved. 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
EFI_HII_GLOBAL_DATA *GlobalData;\r
EFI_HII_DATA *HiiData;\r
- UINTN Count;\r
- BOOLEAN Narrow;\r
- UINTN Location;\r
- UINT8 GlyphCol1[19];\r
+ BOOLEAN WideChar;\r
+ INT32 Location;\r
\r
if (This == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
HiiData = EFI_HII_DATA_FROM_THIS (This);\r
-\r
GlobalData = HiiData->GlobalData;\r
- Count = 0;\r
- Narrow = TRUE;\r
\r
- ZeroMem (GlyphCol1, sizeof (GlyphCol1));\r
+ \r
+ //\r
+ // Rewind through the string looking for a glyph width identifier\r
+ // If no width identifier exists, we assume string has narrow width identifier\r
+ //\r
+ for (WideChar = FALSE, Location = (INT32) *FirstMissing; Location >= 0; Location--) {\r
+ if ((StringToTest[Location] == NARROW_CHAR) || (StringToTest[Location] == WIDE_CHAR)) {\r
+ //\r
+ // We found something that identifies what glyph database to look in\r
+ //\r
+ WideChar = (BOOLEAN) (StringToTest[Location] == WIDE_CHAR);\r
+ break;\r
+ }\r
+ }\r
\r
//\r
// Walk through the string until you hit the null terminator\r
//\r
- for (; StringToTest[*FirstMissing] != 0x00; (*FirstMissing)++) {\r
- Location = *FirstMissing;\r
+ for (*GlyphBufferSize = 0; StringToTest[*FirstMissing] != CHAR_NULL; (*FirstMissing)++) {\r
//\r
- // Rewind through the string looking for a glyph width identifier\r
+ // We found something that identifies what glyph database to look in\r
//\r
- for (; Location != 0; Location--) {\r
- if (StringToTest[Location] == NARROW_CHAR || StringToTest[Location] == WIDE_CHAR) {\r
- //\r
- // We found something that identifies what glyph database to look in\r
- //\r
- if (StringToTest[Location] == WIDE_CHAR) {\r
- Narrow = FALSE;\r
- } else {\r
- Narrow = TRUE;\r
- }\r
- }\r
+ if ((StringToTest[*FirstMissing] == NARROW_CHAR) || (StringToTest[*FirstMissing] == WIDE_CHAR)) {\r
+ WideChar = (BOOLEAN) (StringToTest[*FirstMissing] == WIDE_CHAR);\r
+ continue;\r
}\r
\r
- if (Narrow) {\r
+ if (!WideChar) {\r
if (CompareMem (\r
GlobalData->NarrowGlyphs[StringToTest[*FirstMissing]].GlyphCol1,\r
&mUnknownGlyph,\r
}\r
}\r
\r
- Count++;\r
- }\r
-\r
- if (Narrow) {\r
- *GlyphBufferSize = (UINT32) (Count * sizeof (EFI_NARROW_GLYPH));\r
- } else {\r
- *GlyphBufferSize = (UINT32) (Count * sizeof (EFI_WIDE_GLYPH));\r
+ *GlyphBufferSize += (WideChar ? sizeof (EFI_WIDE_GLYPH) : sizeof (EFI_NARROW_GLYPH));\r
}\r
\r
return EFI_SUCCESS;\r