MCPcopy Create free account
hub / github.com/JACoders/OpenJK / Com_HexStrToInt

Function Com_HexStrToInt

code/qcommon/q_shared.cpp:592–624  ·  view source on GitHub ↗

=================== Com_HexStrToInt =================== */

Source from the content-addressed store, hash-verified

590 ===================
591 */
592int Com_HexStrToInt( const char *str )
593{
594 if ( !str || !str[ 0 ] )
595 return -1;
596
597 // check for hex code
598 if( str[ 0 ] == '0' && str[ 1 ] == 'x' )
599 {
600 size_t i, n = 0;
601
602 for( i = 2; i < strlen( str ); i++ )
603 {
604 char digit;
605
606 n *= 16;
607
608 digit = tolower( str[ i ] );
609
610 if( digit >= '0' && digit <= '9' )
611 digit -= '0';
612 else if( digit >= 'a' && digit <= 'f' )
613 digit = digit - 'a' + 10;
614 else
615 return -1;
616
617 n += digit;
618 }
619
620 return n;
621 }
622
623 return -1;
624}
625
626
627/*

Callers 1

Key_StringToKeynumFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected