diff options
| author | Michael R. Mauger | 2017-07-05 23:37:13 -0400 |
|---|---|---|
| committer | Michael R. Mauger | 2017-07-05 23:37:13 -0400 |
| commit | 7f62a4a7440aee6aacf04036feb3384a6515e48f (patch) | |
| tree | eedee2b54ffce3756f9ca3ef5a1e6e48d83472b6 /src/image.c | |
| parent | 776635c01abd4aa759e7aa9584b513146978568c (diff) | |
| parent | 7a0170de20fe1225d3eeac099d1e61a0c0410bf3 (diff) | |
| download | emacs-7f62a4a7440aee6aacf04036feb3384a6515e48f.tar.gz emacs-7f62a4a7440aee6aacf04036feb3384a6515e48f.zip | |
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/image.c b/src/image.c index 07c4769e9e3..91749fb8733 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -2444,7 +2444,8 @@ static struct image_type xbm_type = | |||
| 2444 | enum xbm_token | 2444 | enum xbm_token |
| 2445 | { | 2445 | { |
| 2446 | XBM_TK_IDENT = 256, | 2446 | XBM_TK_IDENT = 256, |
| 2447 | XBM_TK_NUMBER | 2447 | XBM_TK_NUMBER, |
| 2448 | XBM_TK_OVERFLOW | ||
| 2448 | }; | 2449 | }; |
| 2449 | 2450 | ||
| 2450 | 2451 | ||
| @@ -2586,6 +2587,7 @@ xbm_scan (char **s, char *end, char *sval, int *ival) | |||
| 2586 | else if (c_isdigit (c)) | 2587 | else if (c_isdigit (c)) |
| 2587 | { | 2588 | { |
| 2588 | int value = 0, digit; | 2589 | int value = 0, digit; |
| 2590 | bool overflow = false; | ||
| 2589 | 2591 | ||
| 2590 | if (c == '0' && *s < end) | 2592 | if (c == '0' && *s < end) |
| 2591 | { | 2593 | { |
| @@ -2595,23 +2597,22 @@ xbm_scan (char **s, char *end, char *sval, int *ival) | |||
| 2595 | while (*s < end) | 2597 | while (*s < end) |
| 2596 | { | 2598 | { |
| 2597 | c = *(*s)++; | 2599 | c = *(*s)++; |
| 2598 | if (c_isdigit (c)) | 2600 | digit = char_hexdigit (c); |
| 2599 | digit = c - '0'; | 2601 | if (digit < 0) |
| 2600 | else if (c >= 'a' && c <= 'f') | ||
| 2601 | digit = c - 'a' + 10; | ||
| 2602 | else if (c >= 'A' && c <= 'F') | ||
| 2603 | digit = c - 'A' + 10; | ||
| 2604 | else | ||
| 2605 | break; | 2602 | break; |
| 2606 | value = 16 * value + digit; | 2603 | overflow |= INT_MULTIPLY_WRAPV (value, 16, &value); |
| 2604 | value += digit; | ||
| 2607 | } | 2605 | } |
| 2608 | } | 2606 | } |
| 2609 | else if (c_isdigit (c)) | 2607 | else if ('0' <= c && c <= '7') |
| 2610 | { | 2608 | { |
| 2611 | value = c - '0'; | 2609 | value = c - '0'; |
| 2612 | while (*s < end | 2610 | while (*s < end |
| 2613 | && (c = *(*s)++, c_isdigit (c))) | 2611 | && (c = *(*s)++, '0' <= c && c <= '7')) |
| 2614 | value = 8 * value + c - '0'; | 2612 | { |
| 2613 | overflow |= INT_MULTIPLY_WRAPV (value, 8, &value); | ||
| 2614 | value += c - '0'; | ||
| 2615 | } | ||
| 2615 | } | 2616 | } |
| 2616 | } | 2617 | } |
| 2617 | else | 2618 | else |
| @@ -2619,13 +2620,16 @@ xbm_scan (char **s, char *end, char *sval, int *ival) | |||
| 2619 | value = c - '0'; | 2620 | value = c - '0'; |
| 2620 | while (*s < end | 2621 | while (*s < end |
| 2621 | && (c = *(*s)++, c_isdigit (c))) | 2622 | && (c = *(*s)++, c_isdigit (c))) |
| 2622 | value = 10 * value + c - '0'; | 2623 | { |
| 2624 | overflow |= INT_MULTIPLY_WRAPV (value, 10, &value); | ||
| 2625 | overflow |= INT_ADD_WRAPV (value, c - '0', &value); | ||
| 2626 | } | ||
| 2623 | } | 2627 | } |
| 2624 | 2628 | ||
| 2625 | if (*s < end) | 2629 | if (*s < end) |
| 2626 | *s = *s - 1; | 2630 | *s = *s - 1; |
| 2627 | *ival = value; | 2631 | *ival = value; |
| 2628 | return XBM_TK_NUMBER; | 2632 | return overflow ? XBM_TK_OVERFLOW : XBM_TK_NUMBER; |
| 2629 | } | 2633 | } |
| 2630 | else if (c_isalpha (c) || c == '_') | 2634 | else if (c_isalpha (c) || c == '_') |
| 2631 | { | 2635 | { |