From: Po Lu Date: Fri, 18 Feb 2022 01:12:48 +0000 (+0800) Subject: Parse XBM images which use character escapes for hex literals X-Git-Tag: emacs-29.0.90~2259 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2236ee40ea78973d9377e845bfd0ee3a58cd4386;p=emacs.git Parse XBM images which use character escapes for hex literals * src/image.c (xbm_scan): Implement parsing of hex escapes in character literals. --- diff --git a/src/image.c b/src/image.c index 5c1bf8d7be6..d012fcea6a7 100644 --- a/src/image.c +++ b/src/image.c @@ -3681,6 +3681,48 @@ xbm_scan (char **s, char *end, char *sval, int *ival) *ival = value; return overflow ? XBM_TK_OVERFLOW : XBM_TK_NUMBER; } + /* Character literal. XBM images typically contain hex escape + sequences and not actual characters, so we only try to handle + that here. */ + else if (c == '\'') + { + int value = 0, digit; + bool overflow = false; + + if (*s == end) + return 0; + + c = *(*s)++; + + if (c != '\\' || *s == end) + return 0; + + c = *(*s)++; + + if (c == 'x') + { + while (*s < end) + { + c = *(*s)++; + + if (c == '\'') + { + *ival = value; + return overflow ? XBM_TK_OVERFLOW : XBM_TK_NUMBER; + } + + digit = char_hexdigit (c); + + if (digit < 0) + return 0; + + overflow |= INT_MULTIPLY_WRAPV (value, 16, &value); + value += digit; + } + + return 0; + } + } else if (c_isalpha (c) || c == '_') { *sval++ = c;