summaryrefslogtreecommitdiffstats
path: root/MdePkg/Library/BaseLib/String.c
Commit message (Collapse)AuthorAgeFilesLines
* MdePkg/BaseLib: Change a variable type in a bitwise operationShenglei Zhang2019-02-191-1/+1
| | | | | | | | | | | | | Change the type of variable Chr from CHAR8 to UINT32 in a bitwise operation, to make the two variables in the operation have the same size. https://bugzilla.tianocore.org/show_bug.cgi?id=1527 Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* MdePkg/BaseLib: Add Base64Encode() and Base64Decode()Mike Turner2019-02-021-0/+331
| | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce public functions Base64Encode and Base64Decode. https://bugzilla.tianocore.org/show_bug.cgi?id=1370 v2:1.Remove some white space. 2.Add unit test with test vectors in RFC 4648. https://github.com/shenglei10/edk2/tree/encode_test https://github.com/shenglei10/edk2/tree/decode_test v3:1.Align white space. 2.Update comments of Base64Encode and Base64Decode. 3.Change the use of macro RETURN_DEVICE_ERROR to RETURN_INVALID_PARAMETER in string.c. v4:Change parameters' names. v5:1.Update usage of variables. 2.Remove debug message in Base64Decode(). Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* MdePkg/BaseLib: Introduce CharToUpper and AsciiCharToUpper publiclyMike Turner2019-01-311-9/+9
| | | | | | | | | | | | | | Introduce two public functions CharToUpper and AsciiCharToUpper. They have the same functions as InternalCharToUpper and InternalBaseLibAsciiToUpper.Considering the internal functions will be removed,so directly I change their function names to the public ones'. https://bugzilla.tianocore.org/show_bug.cgi?id=1369 Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
* MdePkg/BaseLib: AsciiStrToUnicodeStr(S) not handle EASCII properlyHao Wu2018-10-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1262 Current implementation of BaseLib APIs: AsciiStrToUnicodeStr() AsciiStrToUnicodeStrS() AsciiStrnToUnicodeStrS() do not handle EASCII properly. More specifically, if the value of ASCII character is larger than 0x7F, then the converted Unicode character will have all '1's in the higher 8 bits. An example: 0xC9 => 0xFFC9 (current implementations) and it should be: 0xC9 => 0x00C9 This commit will address this issue. Cc: Bin.Lain <bin_601@mail2000.com.tw> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* MdePkg/BaseLib: Add an additional check within AsciiStriCmpRuiyu Ni2018-08-061-1/+1
| | | | | | | | | | | This commit adds an addtional check in AsciiStriCmp. It explicitly checks the end of the sting pointed by 'SecondString' to make the code logic easier for reading and to prevent possible mis-reports by static code checkers. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Hao Wu <Hao.a.wu@intel.com>
* MdePkg: Clean up source filesLiming Gao2018-06-281-36/+36
| | | | | | | | | 1. Do not use tab characters 2. No trailing white space in one line 3. All files must end with CRLF Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com>
* MdePkg: Refine casting expression result to bigger sizeHao Wu2017-03-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are cases that the operands of an expression are all with rank less than UINT64/INT64 and the result of the expression is explicitly cast to UINT64/INT64 to fit the target size. An example will be: UINT32 a,b; // a and b can be any unsigned int type with rank less than UINT64, like // UINT8, UINT16, etc. UINT64 c; c = (UINT64) (a + b); Some static code checkers may warn that the expression result might overflow within the rank of "int" (integer promotions) and the result is then cast to a bigger size. The commit refines codes by the following rules: 1). When the expression is possible to overflow the range of unsigned int/ int: c = (UINT64)a + b; 2). When the expression will not overflow within the rank of "int", remove the explicit type casts: c = a + b; 3). When the expression will be cast to pointer of possible greater size: UINT32 a,b; VOID *c; c = (VOID *)(UINTN)(a + b); --> c = (VOID *)((UINTN)a + b); 4). When one side of a comparison expression contains only operands with rank less than UINT32: UINT8 a; UINT16 b; UINTN c; if ((UINTN)(a + b) > c) {...} --> if (((UINT32)a + b) > c) {...} For rule 4), if we remove the 'UINTN' type cast like: if (a + b > c) {...} The VS compiler will complain with warning C4018 (signed/unsigned mismatch, level 3 warning) due to promoting 'a + b' to type 'int'. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
* MdePkg/BaseLib: Enhance the return value for string to uint functionsHao Wu2017-01-091-317/+17
| | | | | | | | | | | | | | | | | | | | For the following 8 APIs in MdePkg/BaseLib: [Ascii]StrDecimalToUintn [Ascii]StrDecimalToUint64 [Ascii]StrHexToUintn [Ascii]StrHexToUint64 They will ASSERT for DEBUG build when the input string exceeds the range of UINTN/UINT64. However, for RELEASE build, incorrect value will be returned. This commit refines those APIs to direcly call their enhanced counterparts (with trailing 'S' in API names) so as to remove those exceed-range ASSERT checks and to make those APIs to return MAX_UINTN/MAX_UINT64 instead. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
* MdePkg/BaseLib: Add an additional check within (Ascii)StrnCmpHao Wu2016-12-221-1/+3
| | | | | | | | | | | This commit adds an addtional check in AsciiStrnCmp and StrnCmp. It explicitly checks the end of the sting pointed by 'SecondString' to make the code logic easier for reading and to prevent possible mis-reports by static code checkers. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
* MdePkg: Fix some typing errorsThomas Huth2016-10-071-1/+1
| | | | | | | | | Correct the typos in some files of MdePkg. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
* MdePkg: Indicate UnicodeStrToAsciiStr/AsciiStrToUnicodeStr to be deprecatedStar Zeng2016-06-211-2/+9
| | | | | | | | | | | | Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
* MdePkg: Add deprecate flag for the functions which has a replace function in ↵Eric Dong2014-12-151-0/+26
| | | | | | | | | | safe c library. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16521 6f19259b-4bc3-4df7-8a09-765794883524
* MdePkg BaseLib: Fix a corner case of Source and Destination overlap.Star Zeng2014-07-211-4/+4
| | | | | | | | | | | | The overlap may happen when the address of Destination in UnicodeStrToAsciiStr() or Source in AsciiStrToUnicodeStr() is not two bytes aligned. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15665 6f19259b-4bc3-4df7-8a09-765794883524
* Clarify the requirements for the Destination parameter of UnicodeStrToAsciiStr.jcarsey2011-06-281-1/+4
| | | | | | | signed-off-by:jcarsey Reviewed-by:lgao4 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11917 6f19259b-4bc3-4df7-8a09-765794883524
* Refine code.sfu52010-08-161-44/+8
| | | | git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10799 6f19259b-4bc3-4df7-8a09-765794883524
* Refine code.sfu52010-08-131-8/+9
| | | | git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10793 6f19259b-4bc3-4df7-8a09-765794883524
* Fixed K9 scan issues.hhuan132010-08-091-8/+8
| | | | git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10781 6f19259b-4bc3-4df7-8a09-765794883524
* Minor grammatical work--mostly adding periods. Items with ONLY period added ↵myronporter2010-06-251-6/+6
| | | | | | did not have the heading date changed, but Items with content changes had heading copyright dates updated. Sending separately a list of files missing Doxygen @param and @return information. (PENDING) git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10604 6f19259b-4bc3-4df7-8a09-765794883524
* Minor grammatical work--mostly adding periods. Items with ONLY period added ↵myronporter2010-06-241-48/+48
| | | | | | did not have the heading date changed, but Items with content changes had heading copyright dates updated. Sending separately a list of files missing Doxygen @param and @return information. (PENDING) git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10596 6f19259b-4bc3-4df7-8a09-765794883524
* Update the copyright notice formathhtian2010-04-231-2/+2
| | | | git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10405 6f19259b-4bc3-4df7-8a09-765794883524
* Fix a bug in MdePkg BaseLib: StrnCat() and AsciiStrnCat() should NULL ↵qhuang82009-12-231-2/+10
| | | | | | terminated the final destination string when Length is equal to the length of Source string git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9588 6f19259b-4bc3-4df7-8a09-765794883524
* Rename BaseLib internal functions by adding InternalBaseLib.lgao42009-07-231-8/+8
| | | | git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8980 6f19259b-4bc3-4df7-8a09-765794883524
* Fix the implementation of AsciiStrStr() and StrStr() in MdePkg. If the ↵rsun32009-05-121-2/+2
| | | | | | length of SearchString is zero, then String is returned. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8297 6f19259b-4bc3-4df7-8a09-765794883524
* Fix bugs in StrStr() and AsciiStrStr().rsun32009-05-081-19/+18
| | | | git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8261 6f19259b-4bc3-4df7-8a09-765794883524
* update string function comment to clear the semantic meaning.eric_tian2009-04-231-18/+26
| | | | git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8153 6f19259b-4bc3-4df7-8a09-765794883524
* add assertion condition to satisfy the requirement in MdePkg library spec 0.61peric_tian2009-04-071-41/+60
| | | | git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8033 6f19259b-4bc3-4df7-8a09-765794883524
* Remove incorrect assertion. According to spec, it should not assert and ↵qhuang82009-03-101-1/+0
| | | | | | should return 0. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7853 6f19259b-4bc3-4df7-8a09-765794883524
* Fix some typo.gikidy2008-12-121-5/+5
| | | | git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7007 6f19259b-4bc3-4df7-8a09-765794883524
* Synchronize BaseLib h files to c files.gikidy2008-12-111-16/+16
| | | | git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6983 6f19259b-4bc3-4df7-8a09-765794883524
* Synchronize comment of BaseLib.h and it's implementation to match the Spec.gikidy2008-12-091-2/+2
| | | | git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6929 6f19259b-4bc3-4df7-8a09-765794883524
* Remove NibbleToHexChar() function from BaseLiblgao42008-12-011-247/+0
| | | | | | | | | | | | Move IsHexDigit, BufToHexString, HexStringToBuf from BaseLib to MdeModulePkg IfrSupportLib. The reason is: 1) IsHexDigit function provides the logic to check Hex Digit and convert it to Decimal value, which is required by IScsi LUN and HII user input. But this logic is not provided by any functions in MdeLib. So, it can't be deleted. It is moved to IfrSupportLib. 2) BufToHexString function converts a array of buffers to hex string. If the buffer length is less than sizeof (UINT64), it can be directly replaced by UnicodeValueToString(). But HII modules may use BufToHexString to convert the buffers whose length > sizeof (UINT64). For example: .\MdeModulePkg\Universal\HiiDatabaseDxe\ConfigRouting.c line 201, 1148 .\Universal\SetupBrowserDxe\Setup.c line line 1457, 1503 Like this case, it is not easy to use UnicodeValueToString to replace BufToHexString. So, BufToHexString is still kept. Because such usages are in HII modules, this function is moved to IfrSupportLib. 3) HexStringToBuf is moved to IfrSupportLib. The reason is similar to BufToHexString. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6782 6f19259b-4bc3-4df7-8a09-765794883524
* Synchronize function comment in MdePkg\Library\BaseLib.h with the instance ↵gikidy2008-11-251-261/+258
| | | | | | of this functions. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6718 6f19259b-4bc3-4df7-8a09-765794883524
* Add two EFI Modifier.qwang122008-11-051-0/+2
| | | | git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6388 6f19259b-4bc3-4df7-8a09-765794883524
* Change style of (CONSTANT == Var) to (Var == CONSTANT) for BaseLib/String.c.xli242008-10-201-33/+33
| | | | git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6153 6f19259b-4bc3-4df7-8a09-765794883524
* removed blank lines to refine source codes.vanjeff2008-10-201-5/+0
| | | | git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6135 6f19259b-4bc3-4df7-8a09-765794883524
* Update BaseLib according to code review comments.xli242008-09-241-81/+94
| | | | git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5956 6f19259b-4bc3-4df7-8a09-765794883524
* 1. Change 0 == Length style to Length == 0lgao42008-09-181-3/+3
| | | | | | | 2. Clean BasePeCoff library instance, only keep one copy PeCoffLoaderEx.c file for IA32, X64 and IPF arch 3. Clean the confused comments git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5927 6f19259b-4bc3-4df7-8a09-765794883524
* remove unnecessary comments introduced by tools from MdePkg. The regular ↵vanjeff2008-09-171-3/+1
| | | | | | express is "//^p//[ ]Include[ ]common[ ]header[ ]file[ ]for[ ]this[ ]module[.]^p//" git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5911 6f19259b-4bc3-4df7-8a09-765794883524
* Function description in baselib.h is not clear. change it to comply with ↵eric_tian2008-09-091-15/+19
| | | | | | Doxgen format. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5862 6f19259b-4bc3-4df7-8a09-765794883524
* Code Scrub for MdePkg.yshang12008-07-251-12/+12
| | | | git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5567 6f19259b-4bc3-4df7-8a09-765794883524
* Code scrub:yshang12008-07-081-33/+33
| | | | | | | | | | | | | | | | | MdePkg/Library/BaseCacheMaintenanceLib MdePkg/Library/BaseDebugLibNull MdePkg/Library/BaseIoLibIntrinsic MdePkg/Library/BaseLib MdePkg/Library/BaseMemoryLib MdePkg/Library/BaseMemoryLibMmx MdePkg/Library/BaseMemoryLibOptDxe MdePkg/Library/BaseMemoryLibOptPei MdePkg/Library/BaseMemoryLibRepStr MdePkg/Library/BaseMemoryLibSse2 MdePkg/Library/BasePeCoffGetEntryPointLib git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5426 6f19259b-4bc3-4df7-8a09-765794883524
* 1) Add BufToHexString, HexStringToBuf and IsHexDigit to BaseLib.qwang122008-05-231-0/+239
| | | | | | 2) Remove the duplicated functions implementation from the modules that reference these APIs git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5282 6f19259b-4bc3-4df7-8a09-765794883524
* Fix typo in comment.klu22008-04-221-3/+4
| | | | git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5108 6f19259b-4bc3-4df7-8a09-765794883524
* 1. Add conformance checking to ensure the input & output string are ↵qhuang82008-02-011-102/+102
| | | | | | | | well-defined. 2. Adjust the return value of UnicodeStrToAsciiStr() & AsciiStrToUnicodeStr () to be the original destination string to follow MdeLib spec. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4653 6f19259b-4bc3-4df7-8a09-765794883524
* Removed MdePkg usage of ModuleName: in file headersAJFISH2007-07-121-2/+0
| | | | git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3217 6f19259b-4bc3-4df7-8a09-765794883524
* Removed CommonHeader.h generated file from the MdePkg. AJFISH2007-06-291-1/+1
| | | | git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2922 6f19259b-4bc3-4df7-8a09-765794883524
* Import some basic libraries instances for Mde Packages. vanjeff2007-06-221-0/+2076
| | | | git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2704 6f19259b-4bc3-4df7-8a09-765794883524
* Moved the MdePkg to OldMdePkg so that new code in MdePkg does not break ↵lhauch2007-06-011-2071/+0
| | | | | | existing builds. Also updated the SPD and FPD files UiNames git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2616 6f19259b-4bc3-4df7-8a09-765794883524
* Update all String related functions in BaseLib for this change introduced in ↵qwang122007-02-131-5/+23
| | | | | | | | Mde Library Spec 0.60e: "Updated all functions that take pointers to Unicode strings as parameters to ASSERT() if the pointer is not aligned in a 16-bit boundary." git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2375 6f19259b-4bc3-4df7-8a09-765794883524
* Update MDE and EdkModule packages for ICC build with /W4 /WX /Ox switches, ↵xli242007-02-121-3/+5
| | | | | | for some latest modifications break it. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2366 6f19259b-4bc3-4df7-8a09-765794883524