]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - utf8lib.c
gl_rsurf: Don't cull geometry that leaves the view frustum with r_lockvisibility
[xonotic/darkplaces.git] / utf8lib.c
index e552785d2a52376698b828d3ab7b0334aa197c0e..c66f06e1787207d3763fb804371904103ad4eb85 100644 (file)
--- a/utf8lib.c
+++ b/utf8lib.c
@@ -231,20 +231,11 @@ static int colorcode_skipwidth(const unsigned char *s)
        if(*s == STRING_COLOR_TAG)
        {
                if(s[1] <= '9' && s[1] >= '0') // ^[0-9] found
-               {
                        return 2;
-               }
-               else if(s[1] == STRING_COLOR_RGB_TAG_CHAR &&
-                       ((s[2] >= '0' && s[2] <= '9') || (s[2] >= 'a' && s[2] <= 'f') || (s[2] >= 'A' && s[2] <= 'F')) &&
-                       ((s[3] >= '0' && s[3] <= '9') || (s[3] >= 'a' && s[3] <= 'f') || (s[3] >= 'A' && s[3] <= 'F')) &&
-                       ((s[4] >= '0' && s[4] <= '9') || (s[4] >= 'a' && s[4] <= 'f') || (s[4] >= 'A' && s[4] <= 'F')))
-               {
+               else if(s[1] == STRING_COLOR_RGB_TAG_CHAR && isxdigit(s[2]) && isxdigit(s[3]) && isxdigit(s[4]))
                        return 5;
-               }
                else if(s[1] == STRING_COLOR_TAG)
-               {
                        return 1; // special case, do NOT call colorcode_skipwidth for next char
-               }
        }
        return 0;
 }
@@ -800,7 +791,7 @@ u8_COM_StringLengthNoColors(const char *_s, size_t size_s, qboolean *valid)
                {
                        case 0:
                                if(valid)
-                                       *valid = TRUE;
+                                       *valid = true;
                                return len;
                        case STRING_COLOR_TAG:
                                ++s;
@@ -820,7 +811,7 @@ u8_COM_StringLengthNoColors(const char *_s, size_t size_s, qboolean *valid)
                                        case 0: // ends with unfinished color code!
                                                ++len;
                                                if(valid)
-                                                       *valid = FALSE;
+                                                       *valid = false;
                                                return len;
                                        case STRING_COLOR_TAG: // escaped ^
                                                ++len;
@@ -858,7 +849,7 @@ u8_COM_StringLengthNoColors(const char *_s, size_t size_s, qboolean *valid)
                {
                        // we CAN end up here, if an invalid char is between this one and the end of the string
                        if(valid)
-                               *valid = TRUE;
+                               *valid = true;
                        return len;
                }
 
@@ -866,7 +857,7 @@ u8_COM_StringLengthNoColors(const char *_s, size_t size_s, qboolean *valid)
                {
                        // string length exceeded by new character
                        if(valid)
-                               *valid = TRUE;
+                               *valid = true;
                        return len;
                }