]>
git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportString.c
3 Copyright (c) 2007 - 2016, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
32 Convert hex string to uint
50 // skip preceeding white space
52 while (*str
&& *str
== ' ') {
56 // skip preceeding zeros
58 while (*str
&& *str
== '0') {
62 // skip preceeding white space
64 if (*str
&& (*str
== 'x' || *str
== 'X')) {
73 if (c
>= 'a' && c
<= 'f') {
77 if ((c
>= '0' && c
<= '9') || (c
>= 'A' && c
<= 'F')) {
82 u
= (u
<< 4) | (c
- (c
>= 'A' ? 'A' - 10 : '0'));
102 Convert hex string to uint
116 ASSERT (str
!= NULL
);
118 m
= RShiftU64 ((UINT64
) -1, 4);
120 // skip preceeding white space
122 while (*str
&& *str
== ' ') {
126 // skip preceeding zeros
128 while (*str
&& *str
== '0') {
132 // skip preceeding white space
134 if (*str
&& (*str
== 'x' || *str
== 'X')) {
138 // convert hex digits
143 if (c
>= 'a' && c
<= 'f') {
147 if ((c
>= '0' && c
<= '9') || (c
>= 'A' && c
<= 'F')) {
152 u
= LShiftU64 (u
, 4);
153 u
= u
+ (c
- (c
>= 'A' ? 'A' - 10 : '0'));
173 Convert hex string to uint
188 ASSERT (str
!= NULL
);
193 // skip preceeding white space
195 while (*str
&& *str
== ' ') {
204 if (c
>= '0' && c
<= '9') {
205 if (u
> m
|| (u
== m
&& c
- '0' > (INTN
) n
)) {
209 u
= (u
* 10) + c
- '0';
229 Convert hex string to uint
243 ASSERT (str
!= NULL
);
247 // skip preceeding white space
249 while (*str
&& *str
== ' ') {
253 // skip preceeding zeros
255 while (*str
&& *str
== '0') {
259 // skip preceeding white space
261 if (*str
&& (*str
== 'x' || *str
== 'X')) {
265 // convert hex digits
270 if (c
>= 'a' && c
<= 'f') {
274 if ((c
>= '0' && c
<= '9') || (c
>= 'A' && c
<= 'F')) {
279 u
= (u
<< 4) | (c
- (c
>= 'A' ? 'A' - 10 : '0'));
299 Convert hex string to uint
314 ASSERT (str
!= NULL
);
319 // skip preceeding white space
321 while (*str
&& *str
== ' ') {
330 if (c
>= '0' && c
<= '9') {
331 if (u
> m
|| (u
== m
&& c
- '0' > (INTN
) n
)) {
335 u
= (u
* 10) + c
- '0';
352 return (Chr
>= L
'a' && Chr
<= L
'z') ? Chr
- (L
'a' - L
'A') : Chr
;
361 return (Chr
>= 'a' && Chr
<= 'z') ? Chr
- ('a' - 'A') : Chr
;
366 StrCmpUnicodeAndAscii (
373 Compare the Unicode and Ascii string pointed by String to the string pointed by String2.
376 String - Unicode String to process
378 String2 - Ascii string to process
381 Return a positive integer if String is lexicall greater than String2; Zero if
382 the two strings are identical; and a negative interger if String is lexically
388 if (*String
!= (CHAR16
)*String2
) {
396 return (*String
- (CHAR16
)*String2
);
408 Compare the Unicode string pointed by String to the string pointed by String2.
411 String - Unicode String to process
412 String2 - Unicode string to process
415 Return a positive integer if String is lexically greater than String2; Zero if
416 the two strings are identical; and a negative integer if String is lexically
421 while ((*String
!= L
'\0') &&
422 (UnicodeToUpper (*String
) == UnicodeToUpper (*String2
))) {
427 return UnicodeToUpper (*String
) - UnicodeToUpper (*String2
);
432 StriCmpUnicodeAndAscii (
439 Compare the Unicode and Ascii string pointed by String to the string pointed by String2.
442 String - Unicode String to process
444 String2 - Ascii string to process
447 Return a positive integer if String is lexically greater than String2; Zero if
448 the two strings are identical; and a negative integer if String is lexically
453 while ((*String
!= L
'\0') &&
454 (UnicodeToUpper (*String
) == (CHAR16
)AsciiToUpper (*String2
))) {
459 return UnicodeToUpper (*String
) - (CHAR16
)AsciiToUpper (*String2
);
472 Verify if the string is end with the sub string.
478 if ((Str
== NULL
) || (SubStr
== NULL
) || (StrLen(Str
) < StrLen(SubStr
))) {
482 Temp
= Str
+ StrLen(Str
) - StrLen(SubStr
);
487 if (StriCmp (Temp
, SubStr
) == 0) {
499 // duplicate a string
504 Size
= (StrLen(Src
) + 1) * sizeof(CHAR16
);
505 Dest
= AllocateZeroPool (Size
);
507 CopyMem (Dest
, Src
, Size
);
513 CHAR16
*mLineBuffer
= NULL
;
514 CHAR16
*mFieldBuffer
= NULL
;
526 Find the first substring.
536 for (Str1
= String
; *Str1
!= L
'\0'; Str1
++) {
537 for (Str2
= CharSet
; *Str2
!= L
'\0'; Str2
++) {
538 if (*Str1
== *Str2
) {
543 if (*Str2
== L
'\0') {
564 Searches a string for the first occurrence of a character contained in a
572 for (Str1
= String
; *Str1
!= L
'\0'; Str1
++) {
573 for (Str2
= CharSet
; *Str2
!= L
'\0'; Str2
++) {
574 if (*Str1
== *Str2
) {
575 return (CHAR16
*) Str1
;
586 IN CHAR16
*String OPTIONAL
,
593 Find the next token after one or more specified characters.
600 Begin
= (String
== NULL
) ? mLineBuffer
: String
;
605 Begin
+= StrSpn (Begin
, CharSet
);
606 if (*Begin
== L
'\0') {
611 End
= StrBrk (Begin
, CharSet
);
612 if ((End
!= NULL
) && (*End
!= L
'\0')) {
625 IN CHAR16
*String OPTIONAL
,
632 Find the next token after one specificed characters.
640 Begin
= (String
== NULL
) ? mFieldBuffer
: String
;
645 if (*Begin
== L
'\0') {
650 End
= StrBrk (Begin
, CharSet
);
651 if ((End
!= NULL
) && (*End
!= L
'\0')) {
667 return StrTokenLine (String
, CharSet
);
672 StrGetNextTokenLine (
676 return StrTokenLine (NULL
, CharSet
);
681 StrGetNewTokenField (
686 return StrTokenField (String
, CharSet
);
691 StrGetNextTokenField (
695 return StrTokenField (NULL
, CharSet
);
700 PatchForStrTokenAfter (
707 if (Buffer
== NULL
) {
730 PatchForStrTokenBefore (
737 if (Buffer
== NULL
) {
743 if ((*Str
== 0) || (*Str
== Patch
)) {
753 CHAR8
*mAsciiLineBuffer
= NULL
;
754 CHAR8
*mAsciiFieldBuffer
= NULL
;
766 Find the first substring.
776 for (Str1
= String
; *Str1
!= '\0'; Str1
++) {
777 for (Str2
= CharSet
; *Str2
!= '\0'; Str2
++) {
778 if (*Str1
== *Str2
) {
804 Searches a string for the first occurrence of a character contained in a
812 for (Str1
= String
; *Str1
!= '\0'; Str1
++) {
813 for (Str2
= CharSet
; *Str2
!= '\0'; Str2
++) {
814 if (*Str1
== *Str2
) {
815 return (CHAR8
*) Str1
;
826 IN CHAR8
*String OPTIONAL
,
833 Find the next token after one or more specified characters.
840 Begin
= (String
== NULL
) ? mAsciiLineBuffer
: String
;
845 Begin
+= AsciiStrSpn (Begin
, CharSet
);
846 if (*Begin
== '\0') {
847 mAsciiLineBuffer
= NULL
;
851 End
= AsciiStrBrk (Begin
, CharSet
);
852 if ((End
!= NULL
) && (*End
!= '\0')) {
857 mAsciiLineBuffer
= End
;
865 IN CHAR8
*String OPTIONAL
,
872 Find the next token after one specificed characters.
880 Begin
= (String
== NULL
) ? mAsciiFieldBuffer
: String
;
885 if (*Begin
== '\0') {
886 mAsciiFieldBuffer
= NULL
;
890 End
= AsciiStrBrk (Begin
, CharSet
);
891 if ((End
!= NULL
) && (*End
!= '\0')) {
896 mAsciiFieldBuffer
= End
;
902 AsciiStrGetNewTokenLine (
907 return AsciiStrTokenLine (String
, CharSet
);
912 AsciiStrGetNextTokenLine (
916 return AsciiStrTokenLine (NULL
, CharSet
);
921 AsciiStrGetNewTokenField (
926 return AsciiStrTokenField (String
, CharSet
);
931 AsciiStrGetNextTokenField (
935 return AsciiStrTokenField (NULL
, CharSet
);
940 PatchForAsciiStrTokenAfter (
947 if (Buffer
== NULL
) {
970 PatchForAsciiStrTokenBefore (
977 if (Buffer
== NULL
) {
983 if ((*Str
== 0) || (*Str
== Patch
)) {