aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-02-18 09:12:48 +0800
committerPo Lu2022-02-18 09:12:48 +0800
commit2236ee40ea78973d9377e845bfd0ee3a58cd4386 (patch)
treeb1f3c9a7ea4516f74687c8645368fc64e208d393 /src
parent246f627a4125d8b3ae5e88748a439f3f594340b5 (diff)
downloademacs-2236ee40ea78973d9377e845bfd0ee3a58cd4386.tar.gz
emacs-2236ee40ea78973d9377e845bfd0ee3a58cd4386.zip
Parse XBM images which use character escapes for hex literals
* src/image.c (xbm_scan): Implement parsing of hex escapes in character literals.
Diffstat (limited to 'src')
-rw-r--r--src/image.c42
1 files changed, 42 insertions, 0 deletions
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)
3681 *ival = value; 3681 *ival = value;
3682 return overflow ? XBM_TK_OVERFLOW : XBM_TK_NUMBER; 3682 return overflow ? XBM_TK_OVERFLOW : XBM_TK_NUMBER;
3683 } 3683 }
3684 /* Character literal. XBM images typically contain hex escape
3685 sequences and not actual characters, so we only try to handle
3686 that here. */
3687 else if (c == '\'')
3688 {
3689 int value = 0, digit;
3690 bool overflow = false;
3691
3692 if (*s == end)
3693 return 0;
3694
3695 c = *(*s)++;
3696
3697 if (c != '\\' || *s == end)
3698 return 0;
3699
3700 c = *(*s)++;
3701
3702 if (c == 'x')
3703 {
3704 while (*s < end)
3705 {
3706 c = *(*s)++;
3707
3708 if (c == '\'')
3709 {
3710 *ival = value;
3711 return overflow ? XBM_TK_OVERFLOW : XBM_TK_NUMBER;
3712 }
3713
3714 digit = char_hexdigit (c);
3715
3716 if (digit < 0)
3717 return 0;
3718
3719 overflow |= INT_MULTIPLY_WRAPV (value, 16, &value);
3720 value += digit;
3721 }
3722
3723 return 0;
3724 }
3725 }
3684 else if (c_isalpha (c) || c == '_') 3726 else if (c_isalpha (c) || c == '_')
3685 { 3727 {
3686 *sval++ = c; 3728 *sval++ = c;