aboutsummaryrefslogtreecommitdiffstats
path: root/src/editfns.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/editfns.c')
-rw-r--r--src/editfns.c141
1 files changed, 77 insertions, 64 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 1bd6682c3b6..f76beb5e678 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -94,8 +94,9 @@ extern Lisp_Object w32_get_internal_run_time (void);
94#endif 94#endif
95 95
96static int tm_diff (struct tm *, struct tm *); 96static int tm_diff (struct tm *, struct tm *);
97static void find_field (Lisp_Object, Lisp_Object, Lisp_Object, int *, Lisp_Object, int *); 97static void find_field (Lisp_Object, Lisp_Object, Lisp_Object,
98static void update_buffer_properties (int, int); 98 EMACS_INT *, Lisp_Object, EMACS_INT *);
99static void update_buffer_properties (EMACS_INT, EMACS_INT);
99static Lisp_Object region_limit (int); 100static Lisp_Object region_limit (int);
100static size_t emacs_memftimeu (char *, size_t, const char *, 101static size_t emacs_memftimeu (char *, size_t, const char *,
101 size_t, const struct tm *, int); 102 size_t, const struct tm *, int);
@@ -106,7 +107,8 @@ static void general_insert_function (void (*) (const unsigned char *, EMACS_INT)
106 int, int, Lisp_Object *); 107 int, int, Lisp_Object *);
107static Lisp_Object subst_char_in_region_unwind (Lisp_Object); 108static Lisp_Object subst_char_in_region_unwind (Lisp_Object);
108static Lisp_Object subst_char_in_region_unwind_1 (Lisp_Object); 109static Lisp_Object subst_char_in_region_unwind_1 (Lisp_Object);
109static void transpose_markers (int, int, int, int, int, int, int, int); 110static void transpose_markers (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT,
111 EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT);
110 112
111Lisp_Object Vbuffer_access_fontify_functions; 113Lisp_Object Vbuffer_access_fontify_functions;
112Lisp_Object Qbuffer_access_fontify_functions; 114Lisp_Object Qbuffer_access_fontify_functions;
@@ -245,7 +247,7 @@ A multibyte character is handled correctly. */)
245} 247}
246 248
247static Lisp_Object 249static Lisp_Object
248buildmark (int charpos, int bytepos) 250buildmark (EMACS_INT charpos, EMACS_INT bytepos)
249{ 251{
250 register Lisp_Object mark; 252 register Lisp_Object mark;
251 mark = Fmake_marker (); 253 mark = Fmake_marker ();
@@ -270,8 +272,8 @@ DEFUN ("point-marker", Fpoint_marker, Spoint_marker, 0, 0, 0,
270 return buildmark (PT, PT_BYTE); 272 return buildmark (PT, PT_BYTE);
271} 273}
272 274
273int 275EMACS_INT
274clip_to_bounds (int lower, int num, int upper) 276clip_to_bounds (EMACS_INT lower, EMACS_INT num, EMACS_INT upper)
275{ 277{
276 if (num < lower) 278 if (num < lower)
277 return lower; 279 return lower;
@@ -288,7 +290,7 @@ Beginning of buffer is position (point-min), end is (point-max).
288The return value is POSITION. */) 290The return value is POSITION. */)
289 (register Lisp_Object position) 291 (register Lisp_Object position)
290{ 292{
291 int pos; 293 EMACS_INT pos;
292 294
293 if (MARKERP (position) 295 if (MARKERP (position)
294 && current_buffer == XMARKER (position)->buffer) 296 && current_buffer == XMARKER (position)->buffer)
@@ -364,11 +366,11 @@ If you set the marker not to point anywhere, the buffer will have no mark. */)
364 of length LEN. */ 366 of length LEN. */
365 367
366static int 368static int
367overlays_around (int pos, Lisp_Object *vec, int len) 369overlays_around (EMACS_INT pos, Lisp_Object *vec, int len)
368{ 370{
369 Lisp_Object overlay, start, end; 371 Lisp_Object overlay, start, end;
370 struct Lisp_Overlay *tail; 372 struct Lisp_Overlay *tail;
371 int startpos, endpos; 373 EMACS_INT startpos, endpos;
372 int idx = 0; 374 int idx = 0;
373 375
374 for (tail = current_buffer->overlays_before; tail; tail = tail->next) 376 for (tail = current_buffer->overlays_before; tail; tail = tail->next)
@@ -436,7 +438,7 @@ get_pos_property (Lisp_Object position, register Lisp_Object prop, Lisp_Object o
436 return Fget_text_property (position, prop, object); 438 return Fget_text_property (position, prop, object);
437 else 439 else
438 { 440 {
439 int posn = XINT (position); 441 EMACS_INT posn = XINT (position);
440 int noverlays; 442 int noverlays;
441 Lisp_Object *overlay_vec, tem; 443 Lisp_Object *overlay_vec, tem;
442 struct buffer *obuf = current_buffer; 444 struct buffer *obuf = current_buffer;
@@ -515,7 +517,9 @@ get_pos_property (Lisp_Object position, register Lisp_Object prop, Lisp_Object o
515 is not stored. */ 517 is not stored. */
516 518
517static void 519static void
518find_field (Lisp_Object pos, Lisp_Object merge_at_boundary, Lisp_Object beg_limit, int *beg, Lisp_Object end_limit, int *end) 520find_field (Lisp_Object pos, Lisp_Object merge_at_boundary,
521 Lisp_Object beg_limit,
522 EMACS_INT *beg, Lisp_Object end_limit, EMACS_INT *end)
519{ 523{
520 /* Fields right before and after the point. */ 524 /* Fields right before and after the point. */
521 Lisp_Object before_field, after_field; 525 Lisp_Object before_field, after_field;
@@ -631,7 +635,7 @@ A field is a region of text with the same `field' property.
631If POS is nil, the value of point is used for POS. */) 635If POS is nil, the value of point is used for POS. */)
632 (Lisp_Object pos) 636 (Lisp_Object pos)
633{ 637{
634 int beg, end; 638 EMACS_INT beg, end;
635 find_field (pos, Qnil, Qnil, &beg, Qnil, &end); 639 find_field (pos, Qnil, Qnil, &beg, Qnil, &end);
636 if (beg != end) 640 if (beg != end)
637 del_range (beg, end); 641 del_range (beg, end);
@@ -644,7 +648,7 @@ A field is a region of text with the same `field' property.
644If POS is nil, the value of point is used for POS. */) 648If POS is nil, the value of point is used for POS. */)
645 (Lisp_Object pos) 649 (Lisp_Object pos)
646{ 650{
647 int beg, end; 651 EMACS_INT beg, end;
648 find_field (pos, Qnil, Qnil, &beg, Qnil, &end); 652 find_field (pos, Qnil, Qnil, &beg, Qnil, &end);
649 return make_buffer_string (beg, end, 1); 653 return make_buffer_string (beg, end, 1);
650} 654}
@@ -655,7 +659,7 @@ A field is a region of text with the same `field' property.
655If POS is nil, the value of point is used for POS. */) 659If POS is nil, the value of point is used for POS. */)
656 (Lisp_Object pos) 660 (Lisp_Object pos)
657{ 661{
658 int beg, end; 662 EMACS_INT beg, end;
659 find_field (pos, Qnil, Qnil, &beg, Qnil, &end); 663 find_field (pos, Qnil, Qnil, &beg, Qnil, &end);
660 return make_buffer_string (beg, end, 0); 664 return make_buffer_string (beg, end, 0);
661} 665}
@@ -670,7 +674,7 @@ If LIMIT is non-nil, it is a buffer position; if the beginning of the field
670is before LIMIT, then LIMIT will be returned instead. */) 674is before LIMIT, then LIMIT will be returned instead. */)
671 (Lisp_Object pos, Lisp_Object escape_from_edge, Lisp_Object limit) 675 (Lisp_Object pos, Lisp_Object escape_from_edge, Lisp_Object limit)
672{ 676{
673 int beg; 677 EMACS_INT beg;
674 find_field (pos, escape_from_edge, limit, &beg, Qnil, 0); 678 find_field (pos, escape_from_edge, limit, &beg, Qnil, 0);
675 return make_number (beg); 679 return make_number (beg);
676} 680}
@@ -685,7 +689,7 @@ If LIMIT is non-nil, it is a buffer position; if the end of the field
685is after LIMIT, then LIMIT will be returned instead. */) 689is after LIMIT, then LIMIT will be returned instead. */)
686 (Lisp_Object pos, Lisp_Object escape_from_edge, Lisp_Object limit) 690 (Lisp_Object pos, Lisp_Object escape_from_edge, Lisp_Object limit)
687{ 691{
688 int end; 692 EMACS_INT end;
689 find_field (pos, escape_from_edge, Qnil, 0, limit, &end); 693 find_field (pos, escape_from_edge, Qnil, 0, limit, &end);
690 return make_number (end); 694 return make_number (end);
691} 695}
@@ -720,7 +724,7 @@ Field boundaries are not noticed if `inhibit-field-text-motion' is non-nil. */)
720 (Lisp_Object new_pos, Lisp_Object old_pos, Lisp_Object escape_from_edge, Lisp_Object only_in_line, Lisp_Object inhibit_capture_property) 724 (Lisp_Object new_pos, Lisp_Object old_pos, Lisp_Object escape_from_edge, Lisp_Object only_in_line, Lisp_Object inhibit_capture_property)
721{ 725{
722 /* If non-zero, then the original point, before re-positioning. */ 726 /* If non-zero, then the original point, before re-positioning. */
723 int orig_point = 0; 727 EMACS_INT orig_point = 0;
724 int fwd; 728 int fwd;
725 Lisp_Object prev_old, prev_new; 729 Lisp_Object prev_old, prev_new;
726 730
@@ -817,7 +821,7 @@ boundaries bind `inhibit-field-text-motion' to t.
817This function does not move point. */) 821This function does not move point. */)
818 (Lisp_Object n) 822 (Lisp_Object n)
819{ 823{
820 int orig, orig_byte, end; 824 EMACS_INT orig, orig_byte, end;
821 int count = SPECPDL_INDEX (); 825 int count = SPECPDL_INDEX ();
822 specbind (Qinhibit_point_motion_hooks, Qt); 826 specbind (Qinhibit_point_motion_hooks, Qt);
823 827
@@ -858,8 +862,8 @@ boundaries bind `inhibit-field-text-motion' to t.
858This function does not move point. */) 862This function does not move point. */)
859 (Lisp_Object n) 863 (Lisp_Object n)
860{ 864{
861 int end_pos; 865 EMACS_INT end_pos;
862 int orig = PT; 866 EMACS_INT orig = PT;
863 867
864 if (NILP (n)) 868 if (NILP (n))
865 XSETFASTINT (n, 1); 869 XSETFASTINT (n, 1);
@@ -1131,7 +1135,7 @@ At the beginning of the buffer or accessible region, return 0. */)
1131 XSETFASTINT (temp, 0); 1135 XSETFASTINT (temp, 0);
1132 else if (!NILP (current_buffer->enable_multibyte_characters)) 1136 else if (!NILP (current_buffer->enable_multibyte_characters))
1133 { 1137 {
1134 int pos = PT_BYTE; 1138 EMACS_INT pos = PT_BYTE;
1135 DEC_POS (pos); 1139 DEC_POS (pos);
1136 XSETFASTINT (temp, FETCH_CHAR (pos)); 1140 XSETFASTINT (temp, FETCH_CHAR (pos));
1137 } 1141 }
@@ -1185,7 +1189,7 @@ POS is an integer or a marker and defaults to point.
1185If POS is out of range, the value is nil. */) 1189If POS is out of range, the value is nil. */)
1186 (Lisp_Object pos) 1190 (Lisp_Object pos)
1187{ 1191{
1188 register int pos_byte; 1192 register EMACS_INT pos_byte;
1189 1193
1190 if (NILP (pos)) 1194 if (NILP (pos))
1191 { 1195 {
@@ -1218,7 +1222,7 @@ If POS is out of range, the value is nil. */)
1218 (Lisp_Object pos) 1222 (Lisp_Object pos)
1219{ 1223{
1220 register Lisp_Object val; 1224 register Lisp_Object val;
1221 register int pos_byte; 1225 register EMACS_INT pos_byte;
1222 1226
1223 if (NILP (pos)) 1227 if (NILP (pos))
1224 { 1228 {
@@ -2266,8 +2270,9 @@ from adjoining text, if those properties are sticky. */)
2266 (Lisp_Object character, Lisp_Object count, Lisp_Object inherit) 2270 (Lisp_Object character, Lisp_Object count, Lisp_Object inherit)
2267{ 2271{
2268 register unsigned char *string; 2272 register unsigned char *string;
2269 register int strlen; 2273 register EMACS_INT strlen;
2270 register int i, n; 2274 register int i;
2275 register EMACS_INT n;
2271 int len; 2276 int len;
2272 unsigned char str[MAX_MULTIBYTE_LENGTH]; 2277 unsigned char str[MAX_MULTIBYTE_LENGTH];
2273 2278
@@ -2278,6 +2283,8 @@ from adjoining text, if those properties are sticky. */)
2278 len = CHAR_STRING (XFASTINT (character), str); 2283 len = CHAR_STRING (XFASTINT (character), str);
2279 else 2284 else
2280 str[0] = XFASTINT (character), len = 1; 2285 str[0] = XFASTINT (character), len = 1;
2286 if (MOST_POSITIVE_FIXNUM / len < XINT (count))
2287 error ("Maximum buffer size would be exceeded");
2281 n = XINT (count) * len; 2288 n = XINT (count) * len;
2282 if (n <= 0) 2289 if (n <= 0)
2283 return Qnil; 2290 return Qnil;
@@ -2343,10 +2350,10 @@ from adjoining text, if those properties are sticky. */)
2343 buffer substrings. */ 2350 buffer substrings. */
2344 2351
2345Lisp_Object 2352Lisp_Object
2346make_buffer_string (int start, int end, int props) 2353make_buffer_string (EMACS_INT start, EMACS_INT end, int props)
2347{ 2354{
2348 int start_byte = CHAR_TO_BYTE (start); 2355 EMACS_INT start_byte = CHAR_TO_BYTE (start);
2349 int end_byte = CHAR_TO_BYTE (end); 2356 EMACS_INT end_byte = CHAR_TO_BYTE (end);
2350 2357
2351 return make_buffer_string_both (start, start_byte, end, end_byte, props); 2358 return make_buffer_string_both (start, start_byte, end, end_byte, props);
2352} 2359}
@@ -2367,7 +2374,8 @@ make_buffer_string (int start, int end, int props)
2367 buffer substrings. */ 2374 buffer substrings. */
2368 2375
2369Lisp_Object 2376Lisp_Object
2370make_buffer_string_both (int start, int start_byte, int end, int end_byte, int props) 2377make_buffer_string_both (EMACS_INT start, EMACS_INT start_byte,
2378 EMACS_INT end, EMACS_INT end_byte, int props)
2371{ 2379{
2372 Lisp_Object result, tem, tem1; 2380 Lisp_Object result, tem, tem1;
2373 2381
@@ -2400,7 +2408,7 @@ make_buffer_string_both (int start, int start_byte, int end, int end_byte, int p
2400 in the current buffer, if necessary. */ 2408 in the current buffer, if necessary. */
2401 2409
2402static void 2410static void
2403update_buffer_properties (int start, int end) 2411update_buffer_properties (EMACS_INT start, EMACS_INT end)
2404{ 2412{
2405 /* If this buffer has some access functions, 2413 /* If this buffer has some access functions,
2406 call them, specifying the range of the buffer being accessed. */ 2414 call them, specifying the range of the buffer being accessed. */
@@ -2439,7 +2447,7 @@ into the result string; if you don't want the text properties,
2439use `buffer-substring-no-properties' instead. */) 2447use `buffer-substring-no-properties' instead. */)
2440 (Lisp_Object start, Lisp_Object end) 2448 (Lisp_Object start, Lisp_Object end)
2441{ 2449{
2442 register int b, e; 2450 register EMACS_INT b, e;
2443 2451
2444 validate_region (&start, &end); 2452 validate_region (&start, &end);
2445 b = XINT (start); 2453 b = XINT (start);
@@ -2455,7 +2463,7 @@ The two arguments START and END are character positions;
2455they can be in either order. */) 2463they can be in either order. */)
2456 (Lisp_Object start, Lisp_Object end) 2464 (Lisp_Object start, Lisp_Object end)
2457{ 2465{
2458 register int b, e; 2466 register EMACS_INT b, e;
2459 2467
2460 validate_region (&start, &end); 2468 validate_region (&start, &end);
2461 b = XINT (start); 2469 b = XINT (start);
@@ -2481,7 +2489,7 @@ Arguments START and END are character positions specifying the substring.
2481They default to the values of (point-min) and (point-max) in BUFFER. */) 2489They default to the values of (point-min) and (point-max) in BUFFER. */)
2482 (Lisp_Object buffer, Lisp_Object start, Lisp_Object end) 2490 (Lisp_Object buffer, Lisp_Object start, Lisp_Object end)
2483{ 2491{
2484 register int b, e, temp; 2492 register EMACS_INT b, e, temp;
2485 register struct buffer *bp, *obuf; 2493 register struct buffer *bp, *obuf;
2486 Lisp_Object buf; 2494 Lisp_Object buf;
2487 2495
@@ -2534,13 +2542,13 @@ The value of `case-fold-search' in the current buffer
2534determines whether case is significant or ignored. */) 2542determines whether case is significant or ignored. */)
2535 (Lisp_Object buffer1, Lisp_Object start1, Lisp_Object end1, Lisp_Object buffer2, Lisp_Object start2, Lisp_Object end2) 2543 (Lisp_Object buffer1, Lisp_Object start1, Lisp_Object end1, Lisp_Object buffer2, Lisp_Object start2, Lisp_Object end2)
2536{ 2544{
2537 register int begp1, endp1, begp2, endp2, temp; 2545 register EMACS_INT begp1, endp1, begp2, endp2, temp;
2538 register struct buffer *bp1, *bp2; 2546 register struct buffer *bp1, *bp2;
2539 register Lisp_Object trt 2547 register Lisp_Object trt
2540 = (!NILP (current_buffer->case_fold_search) 2548 = (!NILP (current_buffer->case_fold_search)
2541 ? current_buffer->case_canon_table : Qnil); 2549 ? current_buffer->case_canon_table : Qnil);
2542 int chars = 0; 2550 EMACS_INT chars = 0;
2543 int i1, i2, i1_byte, i2_byte; 2551 EMACS_INT i1, i2, i1_byte, i2_byte;
2544 2552
2545 /* Find the first buffer and its substring. */ 2553 /* Find the first buffer and its substring. */
2546 2554
@@ -2701,12 +2709,12 @@ and don't mark the buffer as really changed.
2701Both characters must have the same length of multi-byte form. */) 2709Both characters must have the same length of multi-byte form. */)
2702 (Lisp_Object start, Lisp_Object end, Lisp_Object fromchar, Lisp_Object tochar, Lisp_Object noundo) 2710 (Lisp_Object start, Lisp_Object end, Lisp_Object fromchar, Lisp_Object tochar, Lisp_Object noundo)
2703{ 2711{
2704 register int pos, pos_byte, stop, i, len, end_byte; 2712 register EMACS_INT pos, pos_byte, stop, i, len, end_byte;
2705 /* Keep track of the first change in the buffer: 2713 /* Keep track of the first change in the buffer:
2706 if 0 we haven't found it yet. 2714 if 0 we haven't found it yet.
2707 if < 0 we've found it and we've run the before-change-function. 2715 if < 0 we've found it and we've run the before-change-function.
2708 if > 0 we've actually performed it and the value is its position. */ 2716 if > 0 we've actually performed it and the value is its position. */
2709 int changed = 0; 2717 EMACS_INT changed = 0;
2710 unsigned char fromstr[MAX_MULTIBYTE_LENGTH], tostr[MAX_MULTIBYTE_LENGTH]; 2718 unsigned char fromstr[MAX_MULTIBYTE_LENGTH], tostr[MAX_MULTIBYTE_LENGTH];
2711 unsigned char *p; 2719 unsigned char *p;
2712 int count = SPECPDL_INDEX (); 2720 int count = SPECPDL_INDEX ();
@@ -2715,7 +2723,7 @@ Both characters must have the same length of multi-byte form. */)
2715#define COMBINING_AFTER 2 2723#define COMBINING_AFTER 2
2716#define COMBINING_BOTH (COMBINING_BEFORE | COMBINING_AFTER) 2724#define COMBINING_BOTH (COMBINING_BEFORE | COMBINING_AFTER)
2717 int maybe_byte_combining = COMBINING_NO; 2725 int maybe_byte_combining = COMBINING_NO;
2718 int last_changed = 0; 2726 EMACS_INT last_changed = 0;
2719 int multibyte_p = !NILP (current_buffer->enable_multibyte_characters); 2727 int multibyte_p = !NILP (current_buffer->enable_multibyte_characters);
2720 2728
2721 restart: 2729 restart:
@@ -2772,7 +2780,7 @@ Both characters must have the same length of multi-byte form. */)
2772 stop = min (stop, GPT_BYTE); 2780 stop = min (stop, GPT_BYTE);
2773 while (1) 2781 while (1)
2774 { 2782 {
2775 int pos_byte_next = pos_byte; 2783 EMACS_INT pos_byte_next = pos_byte;
2776 2784
2777 if (pos_byte >= stop) 2785 if (pos_byte >= stop)
2778 { 2786 {
@@ -2875,7 +2883,8 @@ Both characters must have the same length of multi-byte form. */)
2875} 2883}
2876 2884
2877 2885
2878static Lisp_Object check_translation (int, int, int, Lisp_Object); 2886static Lisp_Object check_translation (EMACS_INT, EMACS_INT, EMACS_INT,
2887 Lisp_Object);
2879 2888
2880/* Helper function for Ftranslate_region_internal. 2889/* Helper function for Ftranslate_region_internal.
2881 2890
@@ -2884,7 +2893,8 @@ static Lisp_Object check_translation (int, int, int, Lisp_Object);
2884 element is found, return it. Otherwise return Qnil. */ 2893 element is found, return it. Otherwise return Qnil. */
2885 2894
2886static Lisp_Object 2895static Lisp_Object
2887check_translation (int pos, int pos_byte, int end, Lisp_Object val) 2896check_translation (EMACS_INT pos, EMACS_INT pos_byte, EMACS_INT end,
2897 Lisp_Object val)
2888{ 2898{
2889 int buf_size = 16, buf_used = 0; 2899 int buf_size = 16, buf_used = 0;
2890 int *buf = alloca (sizeof (int) * buf_size); 2900 int *buf = alloca (sizeof (int) * buf_size);
@@ -2892,7 +2902,7 @@ check_translation (int pos, int pos_byte, int end, Lisp_Object val)
2892 for (; CONSP (val); val = XCDR (val)) 2902 for (; CONSP (val); val = XCDR (val))
2893 { 2903 {
2894 Lisp_Object elt; 2904 Lisp_Object elt;
2895 int len, i; 2905 EMACS_INT len, i;
2896 2906
2897 elt = XCAR (val); 2907 elt = XCAR (val);
2898 if (! CONSP (elt)) 2908 if (! CONSP (elt))
@@ -2908,7 +2918,7 @@ check_translation (int pos, int pos_byte, int end, Lisp_Object val)
2908 if (buf_used <= i) 2918 if (buf_used <= i)
2909 { 2919 {
2910 unsigned char *p = BYTE_POS_ADDR (pos_byte); 2920 unsigned char *p = BYTE_POS_ADDR (pos_byte);
2911 int len; 2921 int len1;
2912 2922
2913 if (buf_used == buf_size) 2923 if (buf_used == buf_size)
2914 { 2924 {
@@ -2919,8 +2929,8 @@ check_translation (int pos, int pos_byte, int end, Lisp_Object val)
2919 memcpy (newbuf, buf, sizeof (int) * buf_used); 2929 memcpy (newbuf, buf, sizeof (int) * buf_used);
2920 buf = newbuf; 2930 buf = newbuf;
2921 } 2931 }
2922 buf[buf_used++] = STRING_CHAR_AND_LENGTH (p, len); 2932 buf[buf_used++] = STRING_CHAR_AND_LENGTH (p, len1);
2923 pos_byte += len; 2933 pos_byte += len1;
2924 } 2934 }
2925 if (XINT (AREF (elt, i)) != buf[i]) 2935 if (XINT (AREF (elt, i)) != buf[i])
2926 break; 2936 break;
@@ -2945,8 +2955,8 @@ It returns the number of characters changed. */)
2945 register unsigned char *tt; /* Trans table. */ 2955 register unsigned char *tt; /* Trans table. */
2946 register int nc; /* New character. */ 2956 register int nc; /* New character. */
2947 int cnt; /* Number of changes made. */ 2957 int cnt; /* Number of changes made. */
2948 int size; /* Size of translate table. */ 2958 EMACS_INT size; /* Size of translate table. */
2949 int pos, pos_byte, end_pos; 2959 EMACS_INT pos, pos_byte, end_pos;
2950 int multibyte = !NILP (current_buffer->enable_multibyte_characters); 2960 int multibyte = !NILP (current_buffer->enable_multibyte_characters);
2951 int string_multibyte; 2961 int string_multibyte;
2952 Lisp_Object val; 2962 Lisp_Object val;
@@ -3016,7 +3026,7 @@ It returns the number of characters changed. */)
3016 } 3026 }
3017 else 3027 else
3018 { 3028 {
3019 int c; 3029 EMACS_INT c;
3020 3030
3021 nc = oc; 3031 nc = oc;
3022 val = CHAR_TABLE_REF (table, oc); 3032 val = CHAR_TABLE_REF (table, oc);
@@ -3229,7 +3239,7 @@ save_restriction_restore (Lisp_Object data)
3229 /* The restriction has changed from the saved one, so restore 3239 /* The restriction has changed from the saved one, so restore
3230 the saved restriction. */ 3240 the saved restriction. */
3231 { 3241 {
3232 int pt = BUF_PT (buf); 3242 EMACS_INT pt = BUF_PT (buf);
3233 3243
3234 SET_BUF_BEGV_BOTH (buf, beg->charpos, beg->bytepos); 3244 SET_BUF_BEGV_BOTH (buf, beg->charpos, beg->bytepos);
3235 SET_BUF_ZV_BOTH (buf, end->charpos, end->bytepos); 3245 SET_BUF_ZV_BOTH (buf, end->charpos, end->bytepos);
@@ -3508,7 +3518,7 @@ usage: (format STRING &rest OBJECTS) */)
3508 (int nargs, register Lisp_Object *args) 3518 (int nargs, register Lisp_Object *args)
3509{ 3519{
3510 register int n; /* The number of the next arg to substitute */ 3520 register int n; /* The number of the next arg to substitute */
3511 register int total; /* An estimate of the final length */ 3521 register EMACS_INT total; /* An estimate of the final length */
3512 char *buf, *p; 3522 char *buf, *p;
3513 register unsigned char *format, *end, *format_start; 3523 register unsigned char *format, *end, *format_start;
3514 int nchars; 3524 int nchars;
@@ -3517,7 +3527,7 @@ usage: (format STRING &rest OBJECTS) */)
3517 int multibyte = 0; 3527 int multibyte = 0;
3518 /* When we make a multibyte string, we must pay attention to the 3528 /* When we make a multibyte string, we must pay attention to the
3519 byte combining problem, i.e., a byte may be combined with a 3529 byte combining problem, i.e., a byte may be combined with a
3520 multibyte charcter of the previous string. This flag tells if we 3530 multibyte character of the previous string. This flag tells if we
3521 must consider such a situation or not. */ 3531 must consider such a situation or not. */
3522 int maybe_combine_byte; 3532 int maybe_combine_byte;
3523 unsigned char *this_format; 3533 unsigned char *this_format;
@@ -3602,8 +3612,8 @@ usage: (format STRING &rest OBJECTS) */)
3602 while (format != end) 3612 while (format != end)
3603 if (*format++ == '%') 3613 if (*format++ == '%')
3604 { 3614 {
3605 int thissize = 0; 3615 EMACS_INT thissize = 0;
3606 int actual_width = 0; 3616 EMACS_INT actual_width = 0;
3607 unsigned char *this_format_start = format - 1; 3617 unsigned char *this_format_start = format - 1;
3608 int field_width = 0; 3618 int field_width = 0;
3609 3619
@@ -3845,8 +3855,8 @@ usage: (format STRING &rest OBJECTS) */)
3845 /* handle case (precision[n] >= 0) */ 3855 /* handle case (precision[n] >= 0) */
3846 3856
3847 int width, padding; 3857 int width, padding;
3848 int nbytes, start, end; 3858 EMACS_INT nbytes, start, end;
3849 int nchars_string; 3859 EMACS_INT nchars_string;
3850 3860
3851 /* lisp_string_width ignores a precision of 0, but GNU 3861 /* lisp_string_width ignores a precision of 0, but GNU
3852 libc functions print 0 characters when the precision 3862 libc functions print 0 characters when the precision
@@ -3857,7 +3867,8 @@ usage: (format STRING &rest OBJECTS) */)
3857 if (precision[n] == 0) 3867 if (precision[n] == 0)
3858 width = nchars_string = nbytes = 0; 3868 width = nchars_string = nbytes = 0;
3859 else if (precision[n] > 0) 3869 else if (precision[n] > 0)
3860 width = lisp_string_width (args[n], precision[n], &nchars_string, &nbytes); 3870 width = lisp_string_width (args[n], precision[n],
3871 &nchars_string, &nbytes);
3861 else 3872 else
3862 { /* no precision spec given for this argument */ 3873 { /* no precision spec given for this argument */
3863 width = lisp_string_width (args[n], -1, NULL, NULL); 3874 width = lisp_string_width (args[n], -1, NULL, NULL);
@@ -4016,7 +4027,8 @@ usage: (format STRING &rest OBJECTS) */)
4016 4027
4017 if (CONSP (props)) 4028 if (CONSP (props))
4018 { 4029 {
4019 int bytepos = 0, position = 0, translated = 0, argn = 1; 4030 EMACS_INT bytepos = 0, position = 0, translated = 0;
4031 int argn = 1;
4020 Lisp_Object list; 4032 Lisp_Object list;
4021 4033
4022 /* Adjust the bounds of each text property 4034 /* Adjust the bounds of each text property
@@ -4034,7 +4046,7 @@ usage: (format STRING &rest OBJECTS) */)
4034 for (list = props; CONSP (list); list = XCDR (list)) 4046 for (list = props; CONSP (list); list = XCDR (list))
4035 { 4047 {
4036 Lisp_Object item; 4048 Lisp_Object item;
4037 int pos; 4049 EMACS_INT pos;
4038 4050
4039 item = XCAR (list); 4051 item = XCAR (list);
4040 4052
@@ -4170,11 +4182,12 @@ Case is ignored if `case-fold-search' is non-nil in the current buffer. */)
4170 It's the caller's job to ensure that START1 <= END1 <= START2 <= END2. */ 4182 It's the caller's job to ensure that START1 <= END1 <= START2 <= END2. */
4171 4183
4172static void 4184static void
4173transpose_markers (int start1, int end1, int start2, int end2, 4185transpose_markers (EMACS_INT start1, EMACS_INT end1,
4174 int start1_byte, int end1_byte, 4186 EMACS_INT start2, EMACS_INT end2,
4175 int start2_byte, int end2_byte) 4187 EMACS_INT start1_byte, EMACS_INT end1_byte,
4188 EMACS_INT start2_byte, EMACS_INT end2_byte)
4176{ 4189{
4177 register int amt1, amt1_byte, amt2, amt2_byte, diff, diff_byte, mpos; 4190 register EMACS_INT amt1, amt1_byte, amt2, amt2_byte, diff, diff_byte, mpos;
4178 register struct Lisp_Marker *marker; 4191 register struct Lisp_Marker *marker;
4179 4192
4180 /* Update point as if it were a marker. */ 4193 /* Update point as if it were a marker. */
@@ -4271,7 +4284,7 @@ Transposing beyond buffer boundaries is an error. */)
4271 /* Swap the regions if they're reversed. */ 4284 /* Swap the regions if they're reversed. */
4272 if (start2 < end1) 4285 if (start2 < end1)
4273 { 4286 {
4274 register int glumph = start1; 4287 register EMACS_INT glumph = start1;
4275 start1 = start2; 4288 start1 = start2;
4276 start2 = glumph; 4289 start2 = glumph;
4277 glumph = end1; 4290 glumph = end1;