aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael R. Mauger2017-07-05 23:37:13 -0400
committerMichael R. Mauger2017-07-05 23:37:13 -0400
commit7f62a4a7440aee6aacf04036feb3384a6515e48f (patch)
treeeedee2b54ffce3756f9ca3ef5a1e6e48d83472b6 /src
parent776635c01abd4aa759e7aa9584b513146978568c (diff)
parent7a0170de20fe1225d3eeac099d1e61a0c0410bf3 (diff)
downloademacs-7f62a4a7440aee6aacf04036feb3384a6515e48f.tar.gz
emacs-7f62a4a7440aee6aacf04036feb3384a6515e48f.zip
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'src')
-rw-r--r--src/bytecode.c12
-rw-r--r--src/character.c17
-rw-r--r--src/character.h18
-rw-r--r--src/charset.c12
-rw-r--r--src/editfns.c6
-rw-r--r--src/image.c32
-rw-r--r--src/lread.c25
-rw-r--r--src/regex.c4
8 files changed, 68 insertions, 58 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index e781a87d16f..a473dfb9c8c 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -452,14 +452,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
452 the table clearer. */ 452 the table clearer. */
453#define LABEL(OP) [OP] = &&insn_ ## OP 453#define LABEL(OP) [OP] = &&insn_ ## OP
454 454
455#if GNUC_PREREQ (4, 6, 0)
456# pragma GCC diagnostic push
457# pragma GCC diagnostic ignored "-Woverride-init"
458#elif defined __clang__
459# pragma GCC diagnostic push
460# pragma GCC diagnostic ignored "-Winitializer-overrides"
461#endif
462
463 /* This is the dispatch table for the threaded interpreter. */ 455 /* This is the dispatch table for the threaded interpreter. */
464 static const void *const targets[256] = 456 static const void *const targets[256] =
465 { 457 {
@@ -471,10 +463,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
471#undef DEFINE 463#undef DEFINE
472 }; 464 };
473 465
474#if GNUC_PREREQ (4, 6, 0) || defined __clang__
475# pragma GCC diagnostic pop
476#endif
477
478#endif 466#endif
479 467
480 468
diff --git a/src/character.c b/src/character.c
index cf460540725..1c6020ee468 100644
--- a/src/character.c
+++ b/src/character.c
@@ -1050,9 +1050,26 @@ blankp (int c)
1050 return XINT (category) == UNICODE_CATEGORY_Zs; /* separator, space */ 1050 return XINT (category) == UNICODE_CATEGORY_Zs; /* separator, space */
1051} 1051}
1052 1052
1053signed char HEXDIGIT_CONST hexdigit[UCHAR_MAX + 1] =
1054 {
1055#if HEXDIGIT_IS_CONST
1056 [0 ... UCHAR_MAX] = -1,
1057#endif
1058 ['0'] = 0, ['1'] = 1, ['2'] = 2, ['3'] = 3, ['4'] = 4,
1059 ['5'] = 5, ['6'] = 6, ['7'] = 7, ['8'] = 8, ['9'] = 9,
1060 ['A'] = 10, ['B'] = 11, ['C'] = 12, ['D'] = 13, ['E'] = 14, ['F'] = 15,
1061 ['a'] = 10, ['b'] = 11, ['c'] = 12, ['d'] = 13, ['e'] = 14, ['f'] = 15
1062 };
1063
1053void 1064void
1054syms_of_character (void) 1065syms_of_character (void)
1055{ 1066{
1067#if !HEXDIGIT_IS_CONST
1068 /* Set the non-hex digit values to -1. */
1069 for (int i = 0; i <= UCHAR_MAX; i++)
1070 hexdigit[i] -= i != '0' && !hexdigit[i];
1071#endif
1072
1056 DEFSYM (Qcharacterp, "characterp"); 1073 DEFSYM (Qcharacterp, "characterp");
1057 DEFSYM (Qauto_fill_chars, "auto-fill-chars"); 1074 DEFSYM (Qauto_fill_chars, "auto-fill-chars");
1058 1075
diff --git a/src/character.h b/src/character.h
index 62d252e91ba..b073a0dd1e4 100644
--- a/src/character.h
+++ b/src/character.h
@@ -700,6 +700,24 @@ char_table_translate (Lisp_Object obj, int ch)
700 return CHARACTERP (obj) ? XINT (obj) : ch; 700 return CHARACTERP (obj) ? XINT (obj) : ch;
701} 701}
702 702
703#if defined __GNUC__ && !defined __STRICT_ANSI__
704# define HEXDIGIT_CONST const
705# define HEXDIGIT_IS_CONST true
706#else
707# define HEXDIGIT_CONST
708# define HEXDIGIT_IS_CONST false
709#endif
710extern signed char HEXDIGIT_CONST hexdigit[];
711
712/* If C is a hexadecimal digit ('0'-'9', 'a'-'f', 'A'-'F'), return its
713 value (0-15). Otherwise return -1. */
714
715INLINE int
716char_hexdigit (int c)
717{
718 return 0 <= c && c <= UCHAR_MAX ? hexdigit[c] : -1;
719}
720
703INLINE_HEADER_END 721INLINE_HEADER_END
704 722
705#endif /* EMACS_CHARACTER_H */ 723#endif /* EMACS_CHARACTER_H */
diff --git a/src/charset.c b/src/charset.c
index d0840f7d2a9..9c3b8db2a53 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -33,7 +33,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
33#include <unistd.h> 33#include <unistd.h>
34#include <limits.h> 34#include <limits.h>
35#include <sys/types.h> 35#include <sys/types.h>
36#include <c-ctype.h>
37#include "lisp.h" 36#include "lisp.h"
38#include "character.h" 37#include "character.h"
39#include "charset.h" 38#include "charset.h"
@@ -434,14 +433,15 @@ read_hex (FILE *fp, bool *eof, bool *overflow)
434 return 0; 433 return 0;
435 } 434 }
436 n = 0; 435 n = 0;
437 while (c_isxdigit (c = getc_unlocked (fp))) 436 while (true)
438 { 437 {
438 c = getc_unlocked (fp);
439 int digit = char_hexdigit (c);
440 if (digit < 0)
441 break;
439 if (INT_LEFT_SHIFT_OVERFLOW (n, 4)) 442 if (INT_LEFT_SHIFT_OVERFLOW (n, 4))
440 *overflow = 1; 443 *overflow = 1;
441 n = ((n << 4) 444 n = (n << 4) + digit;
442 | (c - ('0' <= c && c <= '9' ? '0'
443 : 'A' <= c && c <= 'F' ? 'A' - 10
444 : 'a' - 10)));
445 } 445 }
446 if (c != EOF) 446 if (c != EOF)
447 ungetc (c, fp); 447 ungetc (c, fp);
diff --git a/src/editfns.c b/src/editfns.c
index da99c055b54..d599fcfec80 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -4704,10 +4704,8 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
4704 char src0 = src[0]; 4704 char src0 = src[0];
4705 int exponent_bytes = 0; 4705 int exponent_bytes = 0;
4706 bool signedp = src0 == '-' || src0 == '+' || src0 == ' '; 4706 bool signedp = src0 == '-' || src0 == '+' || src0 == ' ';
4707 if (zero_flag 4707 unsigned char after_sign = src[signedp];
4708 && ((src[signedp] >= '0' && src[signedp] <= '9') 4708 if (zero_flag && 0 <= char_hexdigit (after_sign))
4709 || (src[signedp] >= 'a' && src[signedp] <= 'f')
4710 || (src[signedp] >= 'A' && src[signedp] <= 'F')))
4711 { 4709 {
4712 leading_zeros += padding; 4710 leading_zeros += padding;
4713 padding = 0; 4711 padding = 0;
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 =
2444enum xbm_token 2444enum 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 {
diff --git a/src/lread.c b/src/lread.c
index 182f96223a5..7c554ba8536 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -2426,25 +2426,13 @@ read_escape (Lisp_Object readcharfun, bool stringp)
2426 while (1) 2426 while (1)
2427 { 2427 {
2428 c = READCHAR; 2428 c = READCHAR;
2429 if (c >= '0' && c <= '9') 2429 int digit = char_hexdigit (c);
2430 { 2430 if (digit < 0)
2431 i *= 16;
2432 i += c - '0';
2433 }
2434 else if ((c >= 'a' && c <= 'f')
2435 || (c >= 'A' && c <= 'F'))
2436 {
2437 i *= 16;
2438 if (c >= 'a' && c <= 'f')
2439 i += c - 'a' + 10;
2440 else
2441 i += c - 'A' + 10;
2442 }
2443 else
2444 { 2431 {
2445 UNREAD (c); 2432 UNREAD (c);
2446 break; 2433 break;
2447 } 2434 }
2435 i = (i << 4) + digit;
2448 /* Allow hex escapes as large as ?\xfffffff, because some 2436 /* Allow hex escapes as large as ?\xfffffff, because some
2449 packages use them to denote characters with modifiers. */ 2437 packages use them to denote characters with modifiers. */
2450 if ((CHAR_META | (CHAR_META - 1)) < i) 2438 if ((CHAR_META | (CHAR_META - 1)) < i)
@@ -2474,11 +2462,10 @@ read_escape (Lisp_Object readcharfun, bool stringp)
2474 c = READCHAR; 2462 c = READCHAR;
2475 /* `isdigit' and `isalpha' may be locale-specific, which we don't 2463 /* `isdigit' and `isalpha' may be locale-specific, which we don't
2476 want. */ 2464 want. */
2477 if (c >= '0' && c <= '9') i = (i << 4) + (c - '0'); 2465 int digit = char_hexdigit (c);
2478 else if (c >= 'a' && c <= 'f') i = (i << 4) + (c - 'a') + 10; 2466 if (digit < 0)
2479 else if (c >= 'A' && c <= 'F') i = (i << 4) + (c - 'A') + 10;
2480 else
2481 error ("Non-hex digit used for Unicode escape"); 2467 error ("Non-hex digit used for Unicode escape");
2468 i = (i << 4) + digit;
2482 } 2469 }
2483 if (i > 0x10FFFF) 2470 if (i > 0x10FFFF)
2484 error ("Non-Unicode character: 0x%x", i); 2471 error ("Non-Unicode character: 0x%x", i);
diff --git a/src/regex.c b/src/regex.c
index 240a91f2ba8..fb48765c96c 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -306,9 +306,7 @@ enum syntaxcode { Swhitespace = 0, Sword = 1, Ssymbol = 2 };
306/* In Emacs, these are only used for single-byte characters. */ 306/* In Emacs, these are only used for single-byte characters. */
307# define ISDIGIT(c) ((c) >= '0' && (c) <= '9') 307# define ISDIGIT(c) ((c) >= '0' && (c) <= '9')
308# define ISCNTRL(c) ((c) < ' ') 308# define ISCNTRL(c) ((c) < ' ')
309# define ISXDIGIT(c) (((c) >= '0' && (c) <= '9') \ 309# define ISXDIGIT(c) (0 <= char_hexdigit (c))
310 || ((c) >= 'a' && (c) <= 'f') \
311 || ((c) >= 'A' && (c) <= 'F'))
312 310
313/* The rest must handle multibyte characters. */ 311/* The rest must handle multibyte characters. */
314 312