diff options
Diffstat (limited to 'src/ccl.c')
-rw-r--r-- | src/ccl.c | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/src/ccl.c b/src/ccl.c index b3423e852e1..8bb8a78fe3d 100644 --- a/src/ccl.c +++ b/src/ccl.c @@ -35,11 +35,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ #include "coding.h" #include "keyboard.h" -/* Avoid GCC 12 bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105784>. */ -#if GNUC_PREREQ (12, 0, 0) -# pragma GCC diagnostic ignored "-Wanalyzer-use-of-uninitialized-value" -#endif - /* Table of registered CCL programs. Each element is a vector of NAME, CCL_PROG, RESOLVEDP, and UPDATEDP, where NAME (symbol) is the name of the program, CCL_PROG (vector) is the compiled code of the @@ -51,7 +46,7 @@ static Lisp_Object Vccl_program_table; /* Return a hash table of id number ID. */ #define GET_HASH_TABLE(id) \ - (XHASH_TABLE (XCDR (AREF (Vtranslation_hash_table_vector, (id))))) + XHASH_TABLE (XCDR (AREF (Vtranslation_hash_table_vector, id))) /* CCL (Code Conversion Language) is a simple language which has operations on one input buffer, one output buffer, and 7 registers. @@ -605,6 +600,14 @@ do \ } \ while (0) +/* Work around GCC bug 109579 + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109579 + which causes GCC to mistakenly complain about + popping the mapping stack. */ +#if __GNUC__ == 13 +# pragma GCC diagnostic ignored "-Wanalyzer-out-of-bounds" +#endif + #define POP_MAPPING_STACK(restlen, orig) \ do \ { \ @@ -619,7 +622,7 @@ do \ { \ struct ccl_program called_ccl; \ if (stack_idx >= 256 \ - || ! setup_ccl_program (&called_ccl, (symbol))) \ + || ! setup_ccl_program (&called_ccl, symbol)) \ { \ if (stack_idx > 0) \ { \ @@ -810,7 +813,7 @@ while (0) #define CCL_DECODE_CHAR(id, code) \ ((id) == 0 ? (code) \ - : (charset = CHARSET_FROM_ID ((id)), DECODE_CHAR (charset, (code)))) + : (charset = CHARSET_FROM_ID (id), DECODE_CHAR (charset, code))) /* Encode character C by some of charsets in CHARSET_LIST. Set ID to the id of the used charset, ENCODED to the result of encoding. @@ -820,9 +823,9 @@ while (0) do { \ unsigned ncode; \ \ - charset = char_charset ((c), (charset_list), &ncode); \ + charset = char_charset (c, charset_list, &ncode); \ if (! charset && ! NILP (charset_list)) \ - charset = char_charset ((c), Qnil, &ncode); \ + charset = char_charset (c, Qnil, &ncode); \ if (charset) \ { \ (id) = CHARSET_ID (charset); \ @@ -865,7 +868,7 @@ static struct ccl_prog_stack ccl_prog_stack_struct[256]; static inline Lisp_Object GET_TRANSLATION_TABLE (int id) { - return XCDR (XVECTOR (Vtranslation_table_vector)->contents[id]); + return XCDR (AREF (Vtranslation_table_vector, id)); } void @@ -1148,9 +1151,9 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size ccl_expr_self: switch (op) { - case CCL_PLUS: INT_ADD_WRAPV (reg[rrr], i, ®[rrr]); break; - case CCL_MINUS: INT_SUBTRACT_WRAPV (reg[rrr], i, ®[rrr]); break; - case CCL_MUL: INT_MULTIPLY_WRAPV (reg[rrr], i, ®[rrr]); break; + case CCL_PLUS: ckd_add (®[rrr], reg[rrr], i); break; + case CCL_MINUS: ckd_sub (®[rrr], reg[rrr], i); break; + case CCL_MUL: ckd_mul (®[rrr], reg[rrr], i); break; case CCL_DIV: if (!i) CCL_INVALID_CMD; @@ -1186,7 +1189,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size if (i == -1) { reg[7] = 0; - INT_SUBTRACT_WRAPV (0, reg[rrr], ®[rrr]); + ckd_sub (®[rrr], 0, reg[rrr]); } else { @@ -1243,9 +1246,9 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size ccl_set_expr: switch (op) { - case CCL_PLUS: INT_ADD_WRAPV (i, j, ®[rrr]); break; - case CCL_MINUS: INT_SUBTRACT_WRAPV (i, j, ®[rrr]); break; - case CCL_MUL: INT_MULTIPLY_WRAPV (i, j, ®[rrr]); break; + case CCL_PLUS: ckd_add (®[rrr], i, j); break; + case CCL_MINUS: ckd_sub (®[rrr], i, j); break; + case CCL_MUL: ckd_mul (®[rrr], i, j); break; case CCL_DIV: if (!j) CCL_INVALID_CMD; @@ -1280,7 +1283,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size CCL_INVALID_CMD; if (j == -1) { - INT_SUBTRACT_WRAPV (0, reg[rrr], ®[rrr]); + ckd_sub (®[rrr], 0, reg[rrr]); reg[7] = 0; } else @@ -1372,7 +1375,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size eop = (FIXNUM_OVERFLOW_P (reg[RRR]) ? -1 - : hash_lookup (h, make_fixnum (reg[RRR]), NULL)); + : hash_lookup (h, make_fixnum (reg[RRR]))); if (eop >= 0) { Lisp_Object opl; @@ -1401,7 +1404,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size eop = (FIXNUM_OVERFLOW_P (i) ? -1 - : hash_lookup (h, make_fixnum (i), NULL)); + : hash_lookup (h, make_fixnum (i))); if (eop >= 0) { Lisp_Object opl; @@ -2161,8 +2164,8 @@ usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBY buf_magnification = ccl.buf_magnification ? ccl.buf_magnification : 1; outbufsize = str_bytes; - if (INT_MULTIPLY_WRAPV (buf_magnification, outbufsize, &outbufsize) - || INT_ADD_WRAPV (256, outbufsize, &outbufsize)) + if (ckd_mul (&outbufsize, outbufsize, buf_magnification) + || ckd_add (&outbufsize, outbufsize, 256)) memory_full (SIZE_MAX); outp = outbuf = xmalloc (outbufsize); |