From: Paul Eggert Date: Sun, 6 Feb 2011 19:44:36 +0000 (-0800) Subject: * insdel.c: conform to C89 pointer rules X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~1007 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b68864e5b9b695570d35dd7c41d5d010ba7cc87d;p=emacs.git * insdel.c: conform to C89 pointer rules --- diff --git a/src/ChangeLog b/src/ChangeLog index ffd669b4ad7..35883220197 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -17,6 +17,13 @@ * image.c (xbm_read_bitmap_data, xbm_load_image, xbm_load): Likewise. * keyboard.c (echo_char, MULTI_LETTER_MOD, tty_read_avail_input): Likewise. + * insdel.c (insert, insert_and_inherit, insert_before_markers): + (insert_before_markers_and_inherit, insert_1, insert_1_both): + Likewise. This changes these functions' signatures, which is + more convenient since most callers use char *. All remaining + callers changed. + * editfns.c (general_insert_function): Change signature to + match changes to insert functions' signatures. 2011-02-05 Paul Eggert diff --git a/src/buffer.c b/src/buffer.c index 2c6eb7b84e3..f8008195498 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -2401,7 +2401,7 @@ current buffer is cleared. */) *p = tmp[0]; TEMP_SET_PT_BOTH (pos + 1, pos + 1); bytes--; - insert_1_both (tmp + 1, bytes, bytes, 1, 0, 0); + insert_1_both ((char *) tmp + 1, bytes, bytes, 1, 0, 0); /* Now the gap is after the just inserted data. */ pos = GPT; p = GAP_END_ADDR; diff --git a/src/cmds.c b/src/cmds.c index ce05b19e1c2..93b7e2b7651 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -466,15 +466,15 @@ internal_self_insert (int c, EMACS_INT n) else if (n > 1) { USE_SAFE_ALLOCA; - unsigned char *strn, *p; - SAFE_ALLOCA (strn, unsigned char*, n * len); + char *strn, *p; + SAFE_ALLOCA (strn, char *, n * len); for (p = strn; n > 0; n--, p += len) memcpy (p, str, len); insert_and_inherit (strn, p - strn); SAFE_FREE (); } else if (n > 0) - insert_and_inherit (str, len); + insert_and_inherit ((char *) str, len); if ((CHAR_TABLE_P (Vauto_fill_chars) ? !NILP (CHAR_TABLE_REF (Vauto_fill_chars, c)) @@ -559,4 +559,3 @@ keys_of_cmds (void) initial_define_key (global_map, Ctl ('E'), "end-of-line"); initial_define_key (global_map, Ctl ('F'), "forward-char"); } - diff --git a/src/coding.c b/src/coding.c index 3a3ba11ee9d..a9f16de56f3 100644 --- a/src/coding.c +++ b/src/coding.c @@ -7880,7 +7880,7 @@ encode_coding_object (struct coding_system *coding, else if (BUFFERP (src_object)) insert_from_buffer (XBUFFER (src_object), from, chars, 0); else - insert_1_both (coding->source + from, chars, bytes, 0, 0, 0); + insert_1_both ((char *) coding->source + from, chars, bytes, 0, 0, 0); if (EQ (src_object, dst_object)) { diff --git a/src/editfns.c b/src/editfns.c index f70b3312a69..3b14379be11 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -94,7 +94,7 @@ static void update_buffer_properties (EMACS_INT, EMACS_INT); static Lisp_Object region_limit (int); static size_t emacs_nmemftime (char *, size_t, const char *, size_t, const struct tm *, int, int); -static void general_insert_function (void (*) (const unsigned char *, EMACS_INT), +static void general_insert_function (void (*) (const char *, EMACS_INT), void (*) (Lisp_Object, EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, int), @@ -2118,7 +2118,7 @@ set_time_zone_rule (const char *tzstring) static void general_insert_function (void (*insert_func) - (const unsigned char *, EMACS_INT), + (const char *, EMACS_INT), void (*insert_from_string_func) (Lisp_Object, EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, int), @@ -2144,7 +2144,7 @@ general_insert_function (void (*insert_func) : multibyte_char_to_unibyte (XINT (val), Qnil)); len = 1; } - (*insert_func) (str, len); + (*insert_func) ((char *) str, len); } else if (STRINGP (val)) { @@ -2257,7 +2257,7 @@ The optional third arg INHERIT, if non-nil, says to inherit text properties from adjoining text, if those properties are sticky. */) (Lisp_Object character, Lisp_Object count, Lisp_Object inherit) { - register unsigned char *string; + register char *string; register EMACS_INT strlen; register int i; register EMACS_INT n; @@ -2277,7 +2277,7 @@ from adjoining text, if those properties are sticky. */) if (n <= 0) return Qnil; strlen = min (n, 256 * len); - string = (unsigned char *) alloca (strlen); + string = (char *) alloca (strlen); for (i = 0; i < strlen; i++) string[i] = str[i % len]; while (n >= strlen) diff --git a/src/fileio.c b/src/fileio.c index 3c61ee57bf2..53732f7180f 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -3412,7 +3412,7 @@ variable `last-coding-system-used' to the coding system actually used. */) Ferase_buffer (); buf->enable_multibyte_characters = Qnil; - insert_1_both (read_buf, nread, nread, 0, 0, 0); + insert_1_both ((char *) read_buf, nread, nread, 0, 0, 0); TEMP_SET_PT_BOTH (BEG, BEG_BYTE); coding_system = call2 (Vset_auto_coding_function, filename, make_number (nread)); diff --git a/src/insdel.c b/src/insdel.c index 8923a9e12e5..db76f770dad 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -668,11 +668,11 @@ count_size_as_multibyte (const unsigned char *ptr, EMACS_INT nbytes) prepare_to_modify_buffer could relocate the text. */ void -insert (const unsigned char *string, EMACS_INT nbytes) +insert (const char *string, EMACS_INT nbytes) { if (nbytes > 0) { - EMACS_INT len = chars_in_text (string, nbytes), opoint; + EMACS_INT len = chars_in_text ((unsigned char *) string, nbytes), opoint; insert_1_both (string, len, nbytes, 0, 1, 0); opoint = PT - len; signal_after_change (opoint, 0, len); @@ -683,11 +683,11 @@ insert (const unsigned char *string, EMACS_INT nbytes) /* Likewise, but inherit text properties from neighboring characters. */ void -insert_and_inherit (const unsigned char *string, EMACS_INT nbytes) +insert_and_inherit (const char *string, EMACS_INT nbytes) { if (nbytes > 0) { - EMACS_INT len = chars_in_text (string, nbytes), opoint; + EMACS_INT len = chars_in_text ((unsigned char *) string, nbytes), opoint; insert_1_both (string, len, nbytes, 1, 1, 0); opoint = PT - len; signal_after_change (opoint, 0, len); @@ -711,7 +711,7 @@ insert_char (int c) str[0] = c; } - insert (str, len); + insert ((char *) str, len); } /* Insert the null-terminated string S before point. */ @@ -728,11 +728,11 @@ insert_string (const char *s) since gc could happen and relocate it. */ void -insert_before_markers (const unsigned char *string, EMACS_INT nbytes) +insert_before_markers (const char *string, EMACS_INT nbytes) { if (nbytes > 0) { - EMACS_INT len = chars_in_text (string, nbytes), opoint; + EMACS_INT len = chars_in_text ((unsigned char *) string, nbytes), opoint; insert_1_both (string, len, nbytes, 0, 1, 1); opoint = PT - len; signal_after_change (opoint, 0, len); @@ -743,12 +743,12 @@ insert_before_markers (const unsigned char *string, EMACS_INT nbytes) /* Likewise, but inherit text properties from neighboring characters. */ void -insert_before_markers_and_inherit (const unsigned char *string, +insert_before_markers_and_inherit (const char *string, EMACS_INT nbytes) { if (nbytes > 0) { - EMACS_INT len = chars_in_text (string, nbytes), opoint; + EMACS_INT len = chars_in_text ((unsigned char *) string, nbytes), opoint; insert_1_both (string, len, nbytes, 1, 1, 1); opoint = PT - len; signal_after_change (opoint, 0, len); @@ -759,11 +759,11 @@ insert_before_markers_and_inherit (const unsigned char *string, /* Subroutine used by the insert functions above. */ void -insert_1 (const unsigned char *string, EMACS_INT nbytes, +insert_1 (const char *string, EMACS_INT nbytes, int inherit, int prepare, int before_markers) { - insert_1_both (string, chars_in_text (string, nbytes), nbytes, - inherit, prepare, before_markers); + insert_1_both (string, chars_in_text ((unsigned char *) string, nbytes), + nbytes, inherit, prepare, before_markers); } @@ -884,7 +884,7 @@ count_combining_after (const unsigned char *string, are the same as in insert_1. */ void -insert_1_both (const unsigned char *string, +insert_1_both (const char *string, EMACS_INT nchars, EMACS_INT nbytes, int inherit, int prepare, int before_markers) { @@ -2382,4 +2382,3 @@ as well as hooks attached to text properties and overlays. */); defsubr (&Scombine_after_change_execute); } - diff --git a/src/lisp.h b/src/lisp.h index cfff42a84a4..7821efff8ef 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2555,10 +2555,10 @@ extern int count_combining_before (const unsigned char *, EMACS_INT, EMACS_INT, EMACS_INT); extern int count_combining_after (const unsigned char *, EMACS_INT, EMACS_INT, EMACS_INT); -extern void insert (const unsigned char *, EMACS_INT); -extern void insert_and_inherit (const unsigned char *, EMACS_INT); -extern void insert_1 (const unsigned char *, EMACS_INT, int, int, int); -extern void insert_1_both (const unsigned char *, EMACS_INT, EMACS_INT, +extern void insert (const char *, EMACS_INT); +extern void insert_and_inherit (const char *, EMACS_INT); +extern void insert_1 (const char *, EMACS_INT, int, int, int); +extern void insert_1_both (const char *, EMACS_INT, EMACS_INT, int, int, int); extern void insert_from_gap (EMACS_INT, EMACS_INT); extern void insert_from_string (Lisp_Object, EMACS_INT, EMACS_INT, @@ -2566,9 +2566,8 @@ extern void insert_from_string (Lisp_Object, EMACS_INT, EMACS_INT, extern void insert_from_buffer (struct buffer *, EMACS_INT, EMACS_INT, int); extern void insert_char (int); extern void insert_string (const char *); -extern void insert_before_markers (const unsigned char *, EMACS_INT); -extern void insert_before_markers_and_inherit (const unsigned char *, - EMACS_INT); +extern void insert_before_markers (const char *, EMACS_INT); +extern void insert_before_markers_and_inherit (const char *, EMACS_INT); extern void insert_from_string_before_markers (Lisp_Object, EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, int); diff --git a/src/print.c b/src/print.c index 8bef7a76f4d..09904e078b8 100644 --- a/src/print.c +++ b/src/print.c @@ -179,7 +179,7 @@ int print_output_debug_flag EXTERNALLY_VISIBLE = 1; = (unsigned char *) alloca (print_buffer_pos + 1); \ copy_text (print_buffer, temp, print_buffer_pos_byte, \ 1, 0); \ - insert_1_both (temp, print_buffer_pos, \ + insert_1_both ((char *) temp, print_buffer_pos, \ print_buffer_pos, 0, 1, 0); \ } \ else \ diff --git a/src/xdisp.c b/src/xdisp.c index adf0d1b8745..630c1dcda85 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -7930,7 +7930,7 @@ message_dolog (const char *m, EMACS_INT nbytes, int nlflag, int multibyte) { EMACS_INT i; int c, char_bytes; - unsigned char work[1]; + char work[1]; /* Convert a multibyte string to single-byte for the *Message* buffer. */ @@ -7956,17 +7956,17 @@ message_dolog (const char *m, EMACS_INT nbytes, int nlflag, int multibyte) c = msg[i]; MAKE_CHAR_MULTIBYTE (c); char_bytes = CHAR_STRING (c, str); - insert_1_both (str, 1, char_bytes, 1, 0, 0); + insert_1_both ((char *) str, 1, char_bytes, 1, 0, 0); } } else if (nbytes) - insert_1 (msg, nbytes, 1, 0, 0); + insert_1 (m, nbytes, 1, 0, 0); if (nlflag) { EMACS_INT this_bol, this_bol_byte, prev_bol, prev_bol_byte; int dup; - insert_1 ((const unsigned char *) "\n", 1, 1, 0, 0); + insert_1 ("\n", 1, 1, 0, 0); scan_newline (Z, Z_BYTE, BEG, BEG_BYTE, -2, 0); this_bol = PT; @@ -7996,7 +7996,7 @@ message_dolog (const char *m, EMACS_INT nbytes, int nlflag, int multibyte) sprintf (dupstr, " [%d times]", dup); duplen = strlen (dupstr); TEMP_SET_PT_BOTH (Z - 1, Z_BYTE - 1); - insert_1 ((unsigned char *) dupstr, duplen, 1, 0, 1); + insert_1 (dupstr, duplen, 1, 0, 1); } } } @@ -9193,7 +9193,7 @@ set_message_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT nbytes, EMACS_INT multiby /* Convert from multi-byte to single-byte. */ EMACS_INT i; int c, n; - unsigned char work[1]; + char work[1]; /* Convert a multibyte string to single-byte. */ for (i = 0; i < nbytes; i += n) @@ -9219,11 +9219,11 @@ set_message_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT nbytes, EMACS_INT multiby c = msg[i]; MAKE_CHAR_MULTIBYTE (c); n = CHAR_STRING (c, str); - insert_1_both (str, 1, n, 1, 0, 0); + insert_1_both ((char *) str, 1, n, 1, 0, 0); } } else - insert_1 (msg, nbytes, 1, 0, 0); + insert_1 (s, nbytes, 1, 0, 0); } return 0;