X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=utf8lib.c;h=155b4aea9a8f949ecf8e2a583487c4fa122896cc;hp=ebb06776f8bbe65bc23b04bb3fbf64c5ce91f5fa;hb=c573a47a538a3a90cb34ccf2e3e21a0d1b129d20;hpb=c29be2ab7e92f63b899fcc6ac5a2db1ac6707f12 diff --git a/utf8lib.c b/utf8lib.c index ebb06776..155b4aea 100644 --- a/utf8lib.c +++ b/utf8lib.c @@ -1,5 +1,6 @@ -#include "quakedef.h" +#include "darkplaces.h" #include "utf8lib.h" +#include "draw.h" /* ================================================================================ @@ -7,9 +8,9 @@ Initialization of UTF-8 support and new cvars. ================================================================================ */ // for compatibility this defaults to 0 -cvar_t utf8_enable = {CVAR_CLIENT | CVAR_SERVER | CVAR_SAVE, "utf8_enable", "0", "Enable UTF-8 support. For compatibility, this is disabled by default in most games."}; +cvar_t utf8_enable = {CF_CLIENT | CF_SERVER | CF_ARCHIVE, "utf8_enable", "0", "Enable UTF-8 support. For compatibility, this is disabled by default in most games."}; -void u8_Init_Commands(void) +void u8_Init(void) { Cvar_RegisterVariable(&utf8_enable); } @@ -59,7 +60,7 @@ Uchar utf8_range[5] = { * @return Whether or not another valid character is in the string */ #define U8_ANALYZE_INFINITY 7 -static qboolean u8_analyze(const char *_s, size_t *_start, size_t *_len, Uchar *_ch, size_t _maxlen) +static qbool u8_analyze(const char *_s, size_t *_start, size_t *_len, Uchar *_ch, size_t _maxlen) { const unsigned char *s = (const unsigned char*)_s; size_t i, j; @@ -231,20 +232,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; } @@ -780,9 +772,9 @@ all characters until the zero terminator. ============ */ size_t -COM_StringLengthNoColors(const char *s, size_t size_s, qboolean *valid); +COM_StringLengthNoColors(const char *s, size_t size_s, qbool *valid); size_t -u8_COM_StringLengthNoColors(const char *_s, size_t size_s, qboolean *valid) +u8_COM_StringLengthNoColors(const char *_s, size_t size_s, qbool *valid) { const unsigned char *s = (const unsigned char*)_s; const unsigned char *end; @@ -886,7 +878,7 @@ u8_COM_StringLengthNoColors(const char *_s, size_t size_s, qboolean *valid) * @param maxwidth The maximum output width * @return The number of bytes written, not including the terminating \0 */ -size_t u8_strpad(char *out, size_t outsize, const char *in, qboolean leftalign, size_t minwidth, size_t maxwidth) +size_t u8_strpad(char *out, size_t outsize, const char *in, qbool leftalign, size_t minwidth, size_t maxwidth) { if(!utf8_enable.integer) { @@ -904,7 +896,7 @@ size_t u8_strpad(char *out, size_t outsize, const char *in, qboolean leftalign, } } -size_t u8_strpad_colorcodes(char *out, size_t outsize, const char *in, qboolean leftalign, size_t minwidth, size_t maxwidth) +size_t u8_strpad_colorcodes(char *out, size_t outsize, const char *in, qbool leftalign, size_t minwidth, size_t maxwidth) { size_t l = u8_bytelen_colorcodes(in, maxwidth); size_t actual_width = u8_strnlen_colorcodes(in, l);