diff options
| author | Paul Eggert | 2023-05-17 15:36:54 -0700 |
|---|---|---|
| committer | Paul Eggert | 2023-05-17 15:41:00 -0700 |
| commit | 5ef169ed701fa4f850fdca5563cdd468207d5d4f (patch) | |
| tree | 949560affb29a8d9b114bac310a317a8209542ab /src/editfns.c | |
| parent | afbdae00ab59bbda971780fa04dd75dc7d1e7df7 (diff) | |
| download | emacs-5ef169ed701fa4f850fdca5563cdd468207d5d4f.tar.gz emacs-5ef169ed701fa4f850fdca5563cdd468207d5d4f.zip | |
Prefer C23 ckd_* to Gnulib *_WRAPV macros
C23 has added ckd_add etc. macros with functionality equivalent to
the older Gnulib INT_ADD_WRAPV macros, so switch to the
more-standard names.
* admin/merge-gnulib (GNULIB_MODULES): Add stdckdint.
This merely makes the dependency explicit, as we were already
using this Gnulib module indirectly.
* lib-src/etags.c, src/lisp.h: Include stdckdint.h.
* lib-src/etags.c (xnmalloc, xnrealloc):
* src/alloc.c (xnmalloc, xnrealloc, xpalloc, Fmake_string)
(mark_memory):
* src/bignum.c (emacs_mpz_pow_ui):
* src/buffer.c (record_overlay_string, overlay_strings):
* src/bytecode.c (exec_byte_code):
* src/casefiddle.c (do_casify_multibyte_string):
* src/ccl.c (ccl_driver, Fccl_execute_on_string):
* src/character.c (char_width, c_string_width)
(lisp_string_width, count_size_as_multibyte)
(string_escape_byte8):
* src/cmds.c (internal_self_insert):
* src/coding.c (coding_alloc_by_realloc, produce_chars):
* src/data.c (arith_driver):
* src/dispnew.c (realloc_glyph_pool, init_display_interactive):
* src/doprnt.c (parse_format_integer):
* src/editfns.c (Freplace_buffer_contents, str2num)
(styled_format):
* src/emacs-module.c (module_global_reference_p)
(module_make_global_ref, module_funcall):
* src/eval.c (max_ensure_room):
* src/fileio.c (blocks_to_bytes):
* src/fns.c (Ffillarray):
* src/font.c (font_intern_prop):
* src/frame.c (check_frame_pixels):
* src/gnutls.c (gnutls_hex_string, gnutls_symmetric_aead):
* src/gtkutil.c (get_utf8_string):
* src/haikuterm.c (haiku_term_init):
* src/image.c (xbm_scan, image_to_emacs_colors)
(image_detect_edges, png_load_body):
* src/keyboard.c (Frecursion_depth):
* src/keymap.c (Flookup_key, Fkey_description):
* src/lisp.h (modiff_incr, SAFE_ALLOCA_LISP_EXTRA):
* src/lread.c (read_bool_vector):
* src/pgtkterm.c (pgtk_term_init):
* src/regex-emacs.c (regex_compile):
* src/term.c (encode_terminal_code):
* src/termcap.c (tputs):
* src/textconv.c (textconv_query):
* src/timefns.c (timespec_ticks, lisp_time_hz_ticks)
(Fdecode_time, check_tm_member):
* src/tparam.c (tparam1):
* src/w32term.c (w32_initialize_display_info):
* src/xdisp.c (fill_column_indicator_column, decode_mode_spec):
* src/xselect.c (selection_data_size, x_property_data_to_lisp):
* src/xsmfns.c (smc_save_yourself_CB):
* src/xterm.c (xm_setup_dnd_targets, x_sync_get_monotonic_time)
(x_sync_current_monotonic_time, x_sync_note_frame_times)
(x_display_set_last_user_time, x_term_init):
Prefer the C23 stdckdint macros to their
Gnulib intprops.h counterparts, since C23 is standard.
Diffstat (limited to 'src/editfns.c')
| -rw-r--r-- | src/editfns.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/editfns.c b/src/editfns.c index d02cce4aef3..44e11841faa 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -2027,8 +2027,8 @@ nil. */) | |||
| 2027 | ptrdiff_t ins_bytes = size_b / CHAR_BIT + 1; | 2027 | ptrdiff_t ins_bytes = size_b / CHAR_BIT + 1; |
| 2028 | ptrdiff_t *buffer; | 2028 | ptrdiff_t *buffer; |
| 2029 | ptrdiff_t bytes_needed; | 2029 | ptrdiff_t bytes_needed; |
| 2030 | if (INT_MULTIPLY_WRAPV (diags, 2 * sizeof *buffer, &bytes_needed) | 2030 | if (ckd_mul (&bytes_needed, diags, 2 * sizeof *buffer) |
| 2031 | || INT_ADD_WRAPV (del_bytes + ins_bytes, bytes_needed, &bytes_needed)) | 2031 | || ckd_add (&bytes_needed, bytes_needed, del_bytes + ins_bytes)) |
| 2032 | memory_full (SIZE_MAX); | 2032 | memory_full (SIZE_MAX); |
| 2033 | USE_SAFE_ALLOCA; | 2033 | USE_SAFE_ALLOCA; |
| 2034 | buffer = SAFE_ALLOCA (bytes_needed); | 2034 | buffer = SAFE_ALLOCA (bytes_needed); |
| @@ -3296,7 +3296,7 @@ str2num (char *str, char **str_end) | |||
| 3296 | { | 3296 | { |
| 3297 | ptrdiff_t n = 0; | 3297 | ptrdiff_t n = 0; |
| 3298 | for (; c_isdigit (*str); str++) | 3298 | for (; c_isdigit (*str); str++) |
| 3299 | if (INT_MULTIPLY_WRAPV (n, 10, &n) || INT_ADD_WRAPV (n, *str - '0', &n)) | 3299 | if (ckd_mul (&n, n, 10) || ckd_add (&n, n, *str - '0')) |
| 3300 | n = PTRDIFF_MAX; | 3300 | n = PTRDIFF_MAX; |
| 3301 | *str_end = str; | 3301 | *str_end = str; |
| 3302 | return n; | 3302 | return n; |
| @@ -3464,8 +3464,8 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) | |||
| 3464 | 3464 | ||
| 3465 | /* Allocate the info and discarded tables. */ | 3465 | /* Allocate the info and discarded tables. */ |
| 3466 | ptrdiff_t info_size, alloca_size; | 3466 | ptrdiff_t info_size, alloca_size; |
| 3467 | if (INT_MULTIPLY_WRAPV (nspec_bound, sizeof *info, &info_size) | 3467 | if (ckd_mul (&info_size, nspec_bound, sizeof *info) |
| 3468 | || INT_ADD_WRAPV (formatlen, info_size, &alloca_size) | 3468 | || ckd_add (&alloca_size, formatlen, info_size) |
| 3469 | || SIZE_MAX < alloca_size) | 3469 | || SIZE_MAX < alloca_size) |
| 3470 | memory_full (SIZE_MAX); | 3470 | memory_full (SIZE_MAX); |
| 3471 | info = SAFE_ALLOCA (alloca_size); | 3471 | info = SAFE_ALLOCA (alloca_size); |
| @@ -4012,8 +4012,8 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) | |||
| 4012 | /* Compute the total bytes needed for this item, including | 4012 | /* Compute the total bytes needed for this item, including |
| 4013 | excess precision and padding. */ | 4013 | excess precision and padding. */ |
| 4014 | ptrdiff_t numwidth; | 4014 | ptrdiff_t numwidth; |
| 4015 | if (INT_ADD_WRAPV (prefixlen + sprintf_bytes, excess_precision, | 4015 | if (ckd_add (&numwidth, prefixlen + sprintf_bytes, |
| 4016 | &numwidth)) | 4016 | excess_precision)) |
| 4017 | numwidth = PTRDIFF_MAX; | 4017 | numwidth = PTRDIFF_MAX; |
| 4018 | ptrdiff_t padding | 4018 | ptrdiff_t padding |
| 4019 | = numwidth < field_width ? field_width - numwidth : 0; | 4019 | = numwidth < field_width ? field_width - numwidth : 0; |
| @@ -4173,7 +4173,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) | |||
| 4173 | 4173 | ||
| 4174 | ptrdiff_t used = p - buf; | 4174 | ptrdiff_t used = p - buf; |
| 4175 | ptrdiff_t buflen_needed; | 4175 | ptrdiff_t buflen_needed; |
| 4176 | if (INT_ADD_WRAPV (used, convbytes, &buflen_needed)) | 4176 | if (ckd_add (&buflen_needed, used, convbytes)) |
| 4177 | string_overflow (); | 4177 | string_overflow (); |
| 4178 | if (bufsize <= buflen_needed) | 4178 | if (bufsize <= buflen_needed) |
| 4179 | { | 4179 | { |