if(tag_start >= 0)
{
if(tag_start + 5 < len)
- if(strstrofs("0123456789abcdefABCDEF", substring(theText, tag_start + 2, 1), 0) >= 0)
- if(strstrofs("0123456789abcdefABCDEF", substring(theText, tag_start + 3, 1), 0) >= 0)
- if(strstrofs("0123456789abcdefABCDEF", substring(theText, tag_start + 4, 1), 0) >= 0)
+ if(IS_HEXDIGIT(substring(theText, tag_start + 2, 1)))
+ if(IS_HEXDIGIT(substring(theText, tag_start + 3, 1)))
+ if(IS_HEXDIGIT(substring(theText, tag_start + 4, 1)))
{
if(!isCaretEscaped(theText, tag_start))
return 5 - (pos - tag_start); // ^xRGB color code found
if(i+4 <= len)
if(substring(s, i+1, 1) == "x")
- if(strstrofs("0123456789abcdefABCDEF", substring(s, i+2, 1), 0) >= 0)
- if(strstrofs("0123456789abcdefABCDEF", substring(s, i+3, 1), 0) >= 0)
- if(strstrofs("0123456789abcdefABCDEF", substring(s, i+4, 1), 0) >= 0)
+ if(IS_HEXDIGIT(substring(s, i + 2, 1)))
+ if(IS_HEXDIGIT(substring(s, i + 3, 1)))
+ if(IS_HEXDIGIT(substring(s, i + 4, 1)))
return substring(s, i, 5);
}
i -= carets; // this also skips one char before the carets
return vercmp_recursive(v1, v2);
}
+const string HEXDIGITS_MINSET = "0123456789ABCDEFabcdef";
const string HEXDIGITS = "0123456789ABCDEF0123456789abcdef";
#define HEXDIGIT_TO_DEC_RAW(d) (strstrofs(HEXDIGITS, (d), 0))
#define HEXDIGIT_TO_DEC(d) ((HEXDIGIT_TO_DEC_RAW(d) | 0x10) - 0x10)
-#define DEC_TO_HEXDIGIT(d) (substring(HEXDIGITS, (d), 1))
+#define DEC_TO_HEXDIGIT(d) (substring(HEXDIGITS_MINSET, (d), 1))
+#define IS_HEXDIGIT(d) (strstrofs(HEXDIGITS_MINSET, (d), 0) >= 0)
while (i - 5 - carets >= 0 && substring(me.controlledTextbox.text, i - 5 - carets, 1) == "^")
++carets;
if (carets & 1)
- if(strstrofs("0123456789abcdefABCDEF", substring(me.controlledTextbox.text, i-3, 1), 0) >= 0)
- if(strstrofs("0123456789abcdefABCDEF", substring(me.controlledTextbox.text, i-2, 1), 0) >= 0)
- if(strstrofs("0123456789abcdefABCDEF", substring(me.controlledTextbox.text, i-1, 1), 0) >= 0)
+ if(IS_HEXDIGIT(substring(me.controlledTextbox.text, i - 3, 1)))
+ if(IS_HEXDIGIT(substring(me.controlledTextbox.text, i - 2, 1)))
+ if(IS_HEXDIGIT(substring(me.controlledTextbox.text, i - 1, 1)))
{
me.controlledTextbox.keyDown(me.controlledTextbox, K_BACKSPACE, 8, 0);
me.controlledTextbox.keyDown(me.controlledTextbox, K_BACKSPACE, 8, 0);