summaryrefslogtreecommitdiff
path: root/source/q_shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/q_shared.c')
-rw-r--r--source/q_shared.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/source/q_shared.c b/source/q_shared.c
index 4a6703e..4b4a519 100644
--- a/source/q_shared.c
+++ b/source/q_shared.c
@@ -886,28 +886,18 @@ qboolean COM_HasSpaces( const char *string ) {
* illegible symbol or end of string.
* Does not check for overflow.
*/
-uint32 COM_ParseHex( const char *string ) {
- int ch;
- uint32 result, digit;
-
- result = 0;
- while( *string ) {
- ch = *string++;
- if( ch >= '0' && ch <= '9' ) {
- digit = ch - '0';
- } else if( ch >= 'a' && ch <= 'f' ) {
- digit = ch - 'a' + 10;
- } else if( ch >= 'A' && ch <= 'F' ) {
- digit = ch - 'A' + 10;
- } else {
- break;
- }
+uint32 COM_ParseHex( const char *s ) {
+ int c;
+ uint32 result;
- result = digit | ( result << 4 );
+ for( result = 0; *s; s++ ) {
+ if( ( c = Q_charhex( *s ) ) == -1 ) {
+ break;
+ }
+ result = c | ( result << 4 );
}
return result;
-
}
/*