Compares two Null-terminated ASCII strings with maximum lengths, and returns the difference between the first mismatched ASCII characters. This function compares the Null-terminated ASCII string FirstString to the Null-terminated ASCII string SecondString. At most, Length ASCII characters will be compared. If Length is 0, then 0 is returned. If FirstString is identical to SecondS
| 1454 | |
| 1455 | **/ |
| 1456 | INTN |
| 1457 | EFIAPI |
| 1458 | AsciiStrnCmp ( |
| 1459 | IN CONST CHAR8 *FirstString, |
| 1460 | IN CONST CHAR8 *SecondString, |
| 1461 | IN UINTN Length |
| 1462 | ) |
| 1463 | { |
| 1464 | if (Length == 0) { |
| 1465 | return 0; |
| 1466 | } |
| 1467 | |
| 1468 | // |
| 1469 | // ASSERT both strings are less long than PcdMaximumAsciiStringLength |
| 1470 | // |
| 1471 | // ASSERT (AsciiStrSize (FirstString)); |
| 1472 | // ASSERT (AsciiStrSize (SecondString)); |
| 1473 | if (!AsciiStrSize (FirstString) && !AsciiStrSize (SecondString)) { |
| 1474 | return 0; |
| 1475 | } |
| 1476 | if (!AsciiStrSize (FirstString)) { |
| 1477 | return -1; |
| 1478 | } |
| 1479 | if (!AsciiStrSize (SecondString)) { |
| 1480 | return 1; |
| 1481 | } |
| 1482 | |
| 1483 | // if (PcdGet32 (PcdMaximumAsciiStringLength) != 0) { |
| 1484 | // ASSERT (Length <= PcdGet32 (PcdMaximumAsciiStringLength)); |
| 1485 | if (Length > 100000000ull) { |
| 1486 | Length = 100000000ull; |
| 1487 | } |
| 1488 | |
| 1489 | while ((*FirstString != '\0') && |
| 1490 | (*SecondString != '\0') && |
| 1491 | (*FirstString == *SecondString) && |
| 1492 | (Length > 1)) { |
| 1493 | FirstString++; |
| 1494 | SecondString++; |
| 1495 | Length--; |
| 1496 | } |
| 1497 | return *FirstString - *SecondString; |
| 1498 | } |
| 1499 | |
| 1500 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES |
| 1501 |
no test coverage detected