comparison src/editfns.c @ 110484:7ca55779eeef

Fix some more uses of int instead of EMACS_INT. editfns.c (Fsubst_char_in_region, Ftranslate_region_internal) (check_translation): Use EMACS_INT for buffer positions and length. undo.c (record_marker_adjustment, record_delete) (record_change, record_point, record_insert) (record_property_change, Fprimitive_undo): Use EMACS_INT for buffer positions. lisp.h (record_marker_adjustment, record_delete) (record_change, record_point, record_insert) (record_property_change, Fprimitive_undo): Adjust prototypes.
author Eli Zaretskii <eliz@gnu.org>
date Wed, 22 Sep 2010 15:22:06 -0400
parents 5290c80fda43
children 0fdd992ff057
comparison
equal deleted inserted replaced
110483:2892adf3a65b 110484:7ca55779eeef
2703 If optional arg NOUNDO is non-nil, don't record this change for undo 2703 If optional arg NOUNDO is non-nil, don't record this change for undo
2704 and don't mark the buffer as really changed. 2704 and don't mark the buffer as really changed.
2705 Both characters must have the same length of multi-byte form. */) 2705 Both characters must have the same length of multi-byte form. */)
2706 (Lisp_Object start, Lisp_Object end, Lisp_Object fromchar, Lisp_Object tochar, Lisp_Object noundo) 2706 (Lisp_Object start, Lisp_Object end, Lisp_Object fromchar, Lisp_Object tochar, Lisp_Object noundo)
2707 { 2707 {
2708 register int pos, pos_byte, stop, i, len, end_byte; 2708 register EMACS_INT pos, pos_byte, stop, i, len, end_byte;
2709 /* Keep track of the first change in the buffer: 2709 /* Keep track of the first change in the buffer:
2710 if 0 we haven't found it yet. 2710 if 0 we haven't found it yet.
2711 if < 0 we've found it and we've run the before-change-function. 2711 if < 0 we've found it and we've run the before-change-function.
2712 if > 0 we've actually performed it and the value is its position. */ 2712 if > 0 we've actually performed it and the value is its position. */
2713 int changed = 0; 2713 int changed = 0;
2774 2774
2775 if (pos_byte < GPT_BYTE) 2775 if (pos_byte < GPT_BYTE)
2776 stop = min (stop, GPT_BYTE); 2776 stop = min (stop, GPT_BYTE);
2777 while (1) 2777 while (1)
2778 { 2778 {
2779 int pos_byte_next = pos_byte; 2779 EMACS_INT pos_byte_next = pos_byte;
2780 2780
2781 if (pos_byte >= stop) 2781 if (pos_byte >= stop)
2782 { 2782 {
2783 if (pos_byte >= end_byte) break; 2783 if (pos_byte >= end_byte) break;
2784 stop = end_byte; 2784 stop = end_byte;
2877 unbind_to (count, Qnil); 2877 unbind_to (count, Qnil);
2878 return Qnil; 2878 return Qnil;
2879 } 2879 }
2880 2880
2881 2881
2882 static Lisp_Object check_translation (int, int, int, Lisp_Object); 2882 static Lisp_Object check_translation (EMACS_INT, EMACS_INT, EMACS_INT,
2883 Lisp_Object);
2883 2884
2884 /* Helper function for Ftranslate_region_internal. 2885 /* Helper function for Ftranslate_region_internal.
2885 2886
2886 Check if a character sequence at POS (POS_BYTE) matches an element 2887 Check if a character sequence at POS (POS_BYTE) matches an element
2887 of VAL. VAL is a list (([FROM-CHAR ...] . TO) ...). If a matching 2888 of VAL. VAL is a list (([FROM-CHAR ...] . TO) ...). If a matching
2888 element is found, return it. Otherwise return Qnil. */ 2889 element is found, return it. Otherwise return Qnil. */
2889 2890
2890 static Lisp_Object 2891 static Lisp_Object
2891 check_translation (int pos, int pos_byte, int end, Lisp_Object val) 2892 check_translation (EMACS_INT pos, EMACS_INT pos_byte, EMACS_INT end,
2893 Lisp_Object val)
2892 { 2894 {
2893 int buf_size = 16, buf_used = 0; 2895 int buf_size = 16, buf_used = 0;
2894 int *buf = alloca (sizeof (int) * buf_size); 2896 int *buf = alloca (sizeof (int) * buf_size);
2895 2897
2896 for (; CONSP (val); val = XCDR (val)) 2898 for (; CONSP (val); val = XCDR (val))
2897 { 2899 {
2898 Lisp_Object elt; 2900 Lisp_Object elt;
2899 int len, i; 2901 EMACS_INT len, i;
2900 2902
2901 elt = XCAR (val); 2903 elt = XCAR (val);
2902 if (! CONSP (elt)) 2904 if (! CONSP (elt))
2903 continue; 2905 continue;
2904 elt = XCAR (elt); 2906 elt = XCAR (elt);
2910 for (i = 0; i < len; i++) 2912 for (i = 0; i < len; i++)
2911 { 2913 {
2912 if (buf_used <= i) 2914 if (buf_used <= i)
2913 { 2915 {
2914 unsigned char *p = BYTE_POS_ADDR (pos_byte); 2916 unsigned char *p = BYTE_POS_ADDR (pos_byte);
2915 int len; 2917 int len1;
2916 2918
2917 if (buf_used == buf_size) 2919 if (buf_used == buf_size)
2918 { 2920 {
2919 int *newbuf; 2921 int *newbuf;
2920 2922
2921 buf_size += 16; 2923 buf_size += 16;
2922 newbuf = alloca (sizeof (int) * buf_size); 2924 newbuf = alloca (sizeof (int) * buf_size);
2923 memcpy (newbuf, buf, sizeof (int) * buf_used); 2925 memcpy (newbuf, buf, sizeof (int) * buf_used);
2924 buf = newbuf; 2926 buf = newbuf;
2925 } 2927 }
2926 buf[buf_used++] = STRING_CHAR_AND_LENGTH (p, len); 2928 buf[buf_used++] = STRING_CHAR_AND_LENGTH (p, len1);
2927 pos_byte += len; 2929 pos_byte += len1;
2928 } 2930 }
2929 if (XINT (AREF (elt, i)) != buf[i]) 2931 if (XINT (AREF (elt, i)) != buf[i])
2930 break; 2932 break;
2931 } 2933 }
2932 if (i == len) 2934 if (i == len)
2948 { 2950 {
2949 register unsigned char *tt; /* Trans table. */ 2951 register unsigned char *tt; /* Trans table. */
2950 register int nc; /* New character. */ 2952 register int nc; /* New character. */
2951 int cnt; /* Number of changes made. */ 2953 int cnt; /* Number of changes made. */
2952 int size; /* Size of translate table. */ 2954 int size; /* Size of translate table. */
2953 int pos, pos_byte, end_pos; 2955 EMACS_INT pos, pos_byte, end_pos;
2954 int multibyte = !NILP (current_buffer->enable_multibyte_characters); 2956 int multibyte = !NILP (current_buffer->enable_multibyte_characters);
2955 int string_multibyte; 2957 int string_multibyte;
2956 Lisp_Object val; 2958 Lisp_Object val;
2957 2959
2958 validate_region (&start, &end); 2960 validate_region (&start, &end);