MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / hex_to_value

Function hex_to_value

src/common/cvt.cpp:3579–3626  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3577
3578
3579static void hex_to_value(const char*& string, const char* end, RetPtr* retValue)
3580/*************************************
3581 *
3582 * hex_to_value
3583 *
3584 *************************************
3585 *
3586 * Functional description
3587 * Convert a hex string to a numeric value. This code only
3588 * converts a hex string into a numeric value, and the
3589 * size of biggest hex string depends upon RetPtr.
3590 *
3591 *************************************/
3592{
3593 // we already know this is a hex string, and there is no prefix.
3594 // So, string is something like DEADBEEF.
3595
3596 UCHAR byte = 0;
3597 int nibble = ((end - string) & 1);
3598 char ch;
3599
3600 while ((string < end) && ((DIGIT((ch = UPPER(*string)))) || ((ch >= 'A') && (ch <= 'F'))))
3601 {
3602 // Now convert the character to a nibble
3603 SSHORT c;
3604
3605 if (ch >= 'A')
3606 c = (ch - 'A') + 10;
3607 else
3608 c = (ch - '0');
3609
3610 if (nibble)
3611 {
3612 byte = (byte << 4) + (UCHAR) c;
3613 nibble = 0;
3614 retValue->nextDigit(byte, 256);
3615 }
3616 else
3617 {
3618 byte = c;
3619 nibble = 1;
3620 }
3621
3622 ++string;
3623 }
3624
3625 fb_assert(string <= end);
3626}
3627
3628
3629static void localError(const Firebird::Arg::StatusVector&)

Callers 2

cvt_decomposeFunction · 0.85
CVT_hex_to_int128Function · 0.85

Calls 1

nextDigitMethod · 0.80

Tested by

no test coverage detected