aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrea Corallo2020-03-29 12:31:24 +0100
committerAndrea Corallo2020-03-29 12:31:24 +0100
commit00ee320a620704ae12a1e2104c2d08bf8bbdf0c9 (patch)
tree498c59219b572c89e10f9521b54c98896cb52ca9 /src
parent530faee2752c7b316fa21f2ac4d1266d3e7a38e6 (diff)
parent76b3bd8cbb9a0a01941d9c1766c054960e4bfd97 (diff)
downloademacs-00ee320a620704ae12a1e2104c2d08bf8bbdf0c9.tar.gz
emacs-00ee320a620704ae12a1e2104c2d08bf8bbdf0c9.zip
Merge remote-tracking branch 'savannah/master' into HEAD
Diffstat (limited to 'src')
-rw-r--r--src/bignum.h2
-rw-r--r--src/buffer.c32
-rw-r--r--src/buffer.h2
-rw-r--r--src/character.c6
-rw-r--r--src/cmds.c15
-rw-r--r--src/coding.c42
-rw-r--r--src/composite.c17
-rw-r--r--src/data.c77
-rw-r--r--src/editfns.c121
-rw-r--r--src/emacs-module.c9
-rw-r--r--src/fileio.c2
-rw-r--r--src/filelock.c24
-rw-r--r--src/fns.c18
-rw-r--r--src/font.c16
-rw-r--r--src/fringe.c6
-rw-r--r--src/lisp.h32
-rw-r--r--src/module-env-28.h3
-rw-r--r--src/process.c12
-rw-r--r--src/process.h2
-rw-r--r--src/search.c3
-rw-r--r--src/textprop.c15
-rw-r--r--src/window.c5
-rw-r--r--src/xdisp.c20
23 files changed, 216 insertions, 265 deletions
diff --git a/src/bignum.h b/src/bignum.h
index 0c2541a9dc7..ad9021f15fd 100644
--- a/src/bignum.h
+++ b/src/bignum.h
@@ -55,7 +55,7 @@ extern void emacs_mpz_mul_2exp (mpz_t, mpz_t const, EMACS_INT)
55 ARG_NONNULL ((1, 2)); 55 ARG_NONNULL ((1, 2));
56extern void emacs_mpz_pow_ui (mpz_t, mpz_t const, unsigned long) 56extern void emacs_mpz_pow_ui (mpz_t, mpz_t const, unsigned long)
57 ARG_NONNULL ((1, 2)); 57 ARG_NONNULL ((1, 2));
58extern double mpz_get_d_rounded (mpz_t const); 58extern double mpz_get_d_rounded (mpz_t const) ATTRIBUTE_CONST;
59 59
60INLINE_HEADER_BEGIN 60INLINE_HEADER_BEGIN
61 61
diff --git a/src/buffer.c b/src/buffer.c
index cc7d4e4817c..70598a7a22a 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -131,6 +131,23 @@ CHECK_OVERLAY (Lisp_Object x)
131 CHECK_TYPE (OVERLAYP (x), Qoverlayp, x); 131 CHECK_TYPE (OVERLAYP (x), Qoverlayp, x);
132} 132}
133 133
134/* Convert the position POS to an EMACS_INT that fits in a fixnum.
135 Yield POS's value if POS is already a fixnum, POS's marker position
136 if POS is a marker, and MOST_NEGATIVE_FIXNUM or
137 MOST_POSITIVE_FIXNUM if POS is a negative or positive bignum.
138 Signal an error if POS is not of the proper form. */
139
140EMACS_INT
141fix_position (Lisp_Object pos)
142{
143 if (FIXNUMP (pos))
144 return XFIXNUM (pos);
145 if (MARKERP (pos))
146 return marker_position (pos);
147 CHECK_TYPE (BIGNUMP (pos), Qinteger_or_marker_p, pos);
148 return !NILP (Fnatnump (pos)) ? MOST_POSITIVE_FIXNUM : MOST_NEGATIVE_FIXNUM;
149}
150
134/* These setters are used only in this file, so they can be private. 151/* These setters are used only in this file, so they can be private.
135 The public setters are inline functions defined in buffer.h. */ 152 The public setters are inline functions defined in buffer.h. */
136static void 153static void
@@ -2257,19 +2274,20 @@ so the buffer is truly empty after this. */)
2257} 2274}
2258 2275
2259void 2276void
2260validate_region (register Lisp_Object *b, register Lisp_Object *e) 2277validate_region (Lisp_Object *b, Lisp_Object *e)
2261{ 2278{
2262 CHECK_FIXNUM_COERCE_MARKER (*b); 2279 EMACS_INT beg = fix_position (*b), end = fix_position (*e);
2263 CHECK_FIXNUM_COERCE_MARKER (*e);
2264 2280
2265 if (XFIXNUM (*b) > XFIXNUM (*e)) 2281 if (end < beg)
2266 { 2282 {
2267 Lisp_Object tem; 2283 EMACS_INT tem = beg; beg = end; end = tem;
2268 tem = *b; *b = *e; *e = tem;
2269 } 2284 }
2270 2285
2271 if (! (BEGV <= XFIXNUM (*b) && XFIXNUM (*e) <= ZV)) 2286 if (! (BEGV <= beg && end <= ZV))
2272 args_out_of_range_3 (Fcurrent_buffer (), *b, *e); 2287 args_out_of_range_3 (Fcurrent_buffer (), *b, *e);
2288
2289 *b = make_fixnum (beg);
2290 *e = make_fixnum (end);
2273} 2291}
2274 2292
2275/* Advance BYTE_POS up to a character boundary 2293/* Advance BYTE_POS up to a character boundary
diff --git a/src/buffer.h b/src/buffer.h
index fd05fdd37de..31f497ea40a 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1150,6 +1150,8 @@ extern Lisp_Object interval_insert_behind_hooks;
1150extern Lisp_Object interval_insert_in_front_hooks; 1150extern Lisp_Object interval_insert_in_front_hooks;
1151 1151
1152 1152
1153extern EMACS_INT fix_position (Lisp_Object);
1154#define CHECK_FIXNUM_COERCE_MARKER(x) ((x) = make_fixnum (fix_position (x)))
1153extern void delete_all_overlays (struct buffer *); 1155extern void delete_all_overlays (struct buffer *);
1154extern void reset_buffer (struct buffer *); 1156extern void reset_buffer (struct buffer *);
1155extern void compact_buffer (struct buffer *); 1157extern void compact_buffer (struct buffer *);
diff --git a/src/character.c b/src/character.c
index 5d419a2e836..d71cb3f145c 100644
--- a/src/character.c
+++ b/src/character.c
@@ -931,10 +931,10 @@ character is not ASCII nor 8-bit character, an error is signaled. */)
931 } 931 }
932 else 932 else
933 { 933 {
934 CHECK_FIXNUM_COERCE_MARKER (position); 934 EMACS_INT fixed_pos = fix_position (position);
935 if (XFIXNUM (position) < BEGV || XFIXNUM (position) >= ZV) 935 if (! (BEGV <= fixed_pos && fixed_pos < ZV))
936 args_out_of_range_3 (position, make_fixnum (BEGV), make_fixnum (ZV)); 936 args_out_of_range_3 (position, make_fixnum (BEGV), make_fixnum (ZV));
937 pos = XFIXNAT (position); 937 pos = fixed_pos;
938 p = CHAR_POS_ADDR (pos); 938 p = CHAR_POS_ADDR (pos);
939 } 939 }
940 if (NILP (BVAR (current_buffer, enable_multibyte_characters))) 940 if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
diff --git a/src/cmds.c b/src/cmds.c
index 5d7a45e65f6..c342cd88bd8 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -31,15 +31,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
31 31
32static int internal_self_insert (int, EMACS_INT); 32static int internal_self_insert (int, EMACS_INT);
33 33
34DEFUN ("forward-point", Fforward_point, Sforward_point, 1, 1, 0,
35 doc: /* Return buffer position N characters after (before if N negative) point. */)
36 (Lisp_Object n)
37{
38 CHECK_FIXNUM (n);
39
40 return make_fixnum (PT + XFIXNUM (n));
41}
42
43/* Add N to point; or subtract N if FORWARD is false. N defaults to 1. 34/* Add N to point; or subtract N if FORWARD is false. N defaults to 1.
44 Validate the new location. Return nil. */ 35 Validate the new location. Return nil. */
45static Lisp_Object 36static Lisp_Object
@@ -460,7 +451,10 @@ internal_self_insert (int c, EMACS_INT n)
460 string = concat2 (string, tem); 451 string = concat2 (string, tem);
461 } 452 }
462 453
463 replace_range (PT, PT + chars_to_delete, string, 1, 1, 1, 0); 454 ptrdiff_t to;
455 if (INT_ADD_WRAPV (PT, chars_to_delete, &to))
456 to = PTRDIFF_MAX;
457 replace_range (PT, to, string, 1, 1, 1, 0);
464 Fforward_char (make_fixnum (n)); 458 Fforward_char (make_fixnum (n));
465 } 459 }
466 else if (n > 1) 460 else if (n > 1)
@@ -526,7 +520,6 @@ syms_of_cmds (void)
526This is run after inserting the character. */); 520This is run after inserting the character. */);
527 Vpost_self_insert_hook = Qnil; 521 Vpost_self_insert_hook = Qnil;
528 522
529 defsubr (&Sforward_point);
530 defsubr (&Sforward_char); 523 defsubr (&Sforward_char);
531 defsubr (&Sbackward_char); 524 defsubr (&Sbackward_char);
532 defsubr (&Sforward_line); 525 defsubr (&Sforward_line);
diff --git a/src/coding.c b/src/coding.c
index 8b54281c0bf..0bea2a0c2bc 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -9023,23 +9023,23 @@ DEFUN ("find-coding-systems-region-internal",
9023 } 9023 }
9024 else 9024 else
9025 { 9025 {
9026 CHECK_FIXNUM_COERCE_MARKER (start); 9026 EMACS_INT s = fix_position (start);
9027 CHECK_FIXNUM_COERCE_MARKER (end); 9027 EMACS_INT e = fix_position (end);
9028 if (XFIXNUM (start) < BEG || XFIXNUM (end) > Z || XFIXNUM (start) > XFIXNUM (end)) 9028 if (! (BEG <= s && s <= e && e <= Z))
9029 args_out_of_range (start, end); 9029 args_out_of_range (start, end);
9030 if (NILP (BVAR (current_buffer, enable_multibyte_characters))) 9030 if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
9031 return Qt; 9031 return Qt;
9032 start_byte = CHAR_TO_BYTE (XFIXNUM (start)); 9032 start_byte = CHAR_TO_BYTE (s);
9033 end_byte = CHAR_TO_BYTE (XFIXNUM (end)); 9033 end_byte = CHAR_TO_BYTE (e);
9034 if (XFIXNUM (end) - XFIXNUM (start) == end_byte - start_byte) 9034 if (e - s == end_byte - start_byte)
9035 return Qt; 9035 return Qt;
9036 9036
9037 if (XFIXNUM (start) < GPT && XFIXNUM (end) > GPT) 9037 if (s < GPT && GPT < e)
9038 { 9038 {
9039 if ((GPT - XFIXNUM (start)) < (XFIXNUM (end) - GPT)) 9039 if (GPT - s < e - GPT)
9040 move_gap_both (XFIXNUM (start), start_byte); 9040 move_gap_both (s, start_byte);
9041 else 9041 else
9042 move_gap_both (XFIXNUM (end), end_byte); 9042 move_gap_both (e, end_byte);
9043 } 9043 }
9044 } 9044 }
9045 9045
@@ -9277,25 +9277,25 @@ is nil. */)
9277 } 9277 }
9278 else 9278 else
9279 { 9279 {
9280 CHECK_FIXNUM_COERCE_MARKER (start); 9280 EMACS_INT s = fix_position (start);
9281 CHECK_FIXNUM_COERCE_MARKER (end); 9281 EMACS_INT e = fix_position (end);
9282 if (XFIXNUM (start) < BEG || XFIXNUM (end) > Z || XFIXNUM (start) > XFIXNUM (end)) 9282 if (! (BEG <= s && s <= e && e <= Z))
9283 args_out_of_range (start, end); 9283 args_out_of_range (start, end);
9284 if (NILP (BVAR (current_buffer, enable_multibyte_characters))) 9284 if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
9285 return Qnil; 9285 return Qnil;
9286 start_byte = CHAR_TO_BYTE (XFIXNUM (start)); 9286 start_byte = CHAR_TO_BYTE (s);
9287 end_byte = CHAR_TO_BYTE (XFIXNUM (end)); 9287 end_byte = CHAR_TO_BYTE (e);
9288 if (XFIXNUM (end) - XFIXNUM (start) == end_byte - start_byte) 9288 if (e - s == end_byte - start_byte)
9289 return Qnil; 9289 return Qnil;
9290 9290
9291 if (XFIXNUM (start) < GPT && XFIXNUM (end) > GPT) 9291 if (s < GPT && GPT < e)
9292 { 9292 {
9293 if ((GPT - XFIXNUM (start)) < (XFIXNUM (end) - GPT)) 9293 if (GPT - s < e - GPT)
9294 move_gap_both (XFIXNUM (start), start_byte); 9294 move_gap_both (s, start_byte);
9295 else 9295 else
9296 move_gap_both (XFIXNUM (end), end_byte); 9296 move_gap_both (e, end_byte);
9297 } 9297 }
9298 pos = XFIXNUM (start); 9298 pos = s;
9299 } 9299 }
9300 9300
9301 list = Qnil; 9301 list = Qnil;
diff --git a/src/composite.c b/src/composite.c
index 84de334ce0d..a00a4541f5e 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -1839,27 +1839,24 @@ See `find-composition' for more details. */)
1839 ptrdiff_t start, end, from, to; 1839 ptrdiff_t start, end, from, to;
1840 int id; 1840 int id;
1841 1841
1842 CHECK_FIXNUM_COERCE_MARKER (pos); 1842 EMACS_INT fixed_pos = fix_position (pos);
1843 if (!NILP (limit)) 1843 if (!NILP (limit))
1844 { 1844 to = clip_to_bounds (PTRDIFF_MIN, fix_position (limit), ZV);
1845 CHECK_FIXNUM_COERCE_MARKER (limit);
1846 to = min (XFIXNUM (limit), ZV);
1847 }
1848 else 1845 else
1849 to = -1; 1846 to = -1;
1850 1847
1851 if (!NILP (string)) 1848 if (!NILP (string))
1852 { 1849 {
1853 CHECK_STRING (string); 1850 CHECK_STRING (string);
1854 if (XFIXNUM (pos) < 0 || XFIXNUM (pos) > SCHARS (string)) 1851 if (! (0 <= fixed_pos && fixed_pos <= SCHARS (string)))
1855 args_out_of_range (string, pos); 1852 args_out_of_range (string, pos);
1856 } 1853 }
1857 else 1854 else
1858 { 1855 {
1859 if (XFIXNUM (pos) < BEGV || XFIXNUM (pos) > ZV) 1856 if (! (BEGV <= fixed_pos && fixed_pos <= ZV))
1860 args_out_of_range (Fcurrent_buffer (), pos); 1857 args_out_of_range (Fcurrent_buffer (), pos);
1861 } 1858 }
1862 from = XFIXNUM (pos); 1859 from = fixed_pos;
1863 1860
1864 if (!find_composition (from, to, &start, &end, &prop, string)) 1861 if (!find_composition (from, to, &start, &end, &prop, string))
1865 { 1862 {
@@ -1870,12 +1867,12 @@ See `find-composition' for more details. */)
1870 return list3 (make_fixnum (start), make_fixnum (end), gstring); 1867 return list3 (make_fixnum (start), make_fixnum (end), gstring);
1871 return Qnil; 1868 return Qnil;
1872 } 1869 }
1873 if ((end <= XFIXNUM (pos) || start > XFIXNUM (pos))) 1870 if (! (start <= fixed_pos && fixed_pos < end))
1874 { 1871 {
1875 ptrdiff_t s, e; 1872 ptrdiff_t s, e;
1876 1873
1877 if (find_automatic_composition (from, to, &s, &e, &gstring, string) 1874 if (find_automatic_composition (from, to, &s, &e, &gstring, string)
1878 && (e <= XFIXNUM (pos) ? e > end : s < start)) 1875 && (e <= fixed_pos ? e > end : s < start))
1879 return list3 (make_fixnum (s), make_fixnum (e), gstring); 1876 return list3 (make_fixnum (s), make_fixnum (e), gstring);
1880 } 1877 }
1881 if (!composition_valid_p (start, end, prop)) 1878 if (!composition_valid_p (start, end, prop))
diff --git a/src/data.c b/src/data.c
index 2820f647981..b53b8409b59 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2368,6 +2368,24 @@ bool-vector. IDX starts at 0. */)
2368 2368
2369/* Arithmetic functions */ 2369/* Arithmetic functions */
2370 2370
2371static Lisp_Object
2372check_integer_coerce_marker (Lisp_Object x)
2373{
2374 if (MARKERP (x))
2375 return make_fixnum (marker_position (x));
2376 CHECK_TYPE (INTEGERP (x), Qinteger_or_marker_p, x);
2377 return x;
2378}
2379
2380static Lisp_Object
2381check_number_coerce_marker (Lisp_Object x)
2382{
2383 if (MARKERP (x))
2384 return make_fixnum (marker_position (x));
2385 CHECK_TYPE (NUMBERP (x), Qnumber_or_marker_p, x);
2386 return x;
2387}
2388
2371Lisp_Object 2389Lisp_Object
2372arithcompare (Lisp_Object num1, Lisp_Object num2, 2390arithcompare (Lisp_Object num1, Lisp_Object num2,
2373 enum Arith_Comparison comparison) 2391 enum Arith_Comparison comparison)
@@ -2376,8 +2394,8 @@ arithcompare (Lisp_Object num1, Lisp_Object num2,
2376 bool lt, eq = true, gt; 2394 bool lt, eq = true, gt;
2377 bool test; 2395 bool test;
2378 2396
2379 CHECK_NUMBER_COERCE_MARKER (num1); 2397 num1 = check_number_coerce_marker (num1);
2380 CHECK_NUMBER_COERCE_MARKER (num2); 2398 num2 = check_number_coerce_marker (num2);
2381 2399
2382 /* If the comparison is mostly done by comparing two doubles, 2400 /* If the comparison is mostly done by comparing two doubles,
2383 set LT, EQ, and GT to the <, ==, > results of that comparison, 2401 set LT, EQ, and GT to the <, ==, > results of that comparison,
@@ -2779,9 +2797,7 @@ floatop_arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args,
2779 argnum++; 2797 argnum++;
2780 if (argnum == nargs) 2798 if (argnum == nargs)
2781 return make_float (accum); 2799 return make_float (accum);
2782 Lisp_Object val = args[argnum]; 2800 next = XFLOATINT (check_number_coerce_marker (args[argnum]));
2783 CHECK_NUMBER_COERCE_MARKER (val);
2784 next = XFLOATINT (val);
2785 } 2801 }
2786} 2802}
2787 2803
@@ -2843,8 +2859,7 @@ bignum_arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args,
2843 argnum++; 2859 argnum++;
2844 if (argnum == nargs) 2860 if (argnum == nargs)
2845 return make_integer_mpz (); 2861 return make_integer_mpz ();
2846 val = args[argnum]; 2862 val = check_number_coerce_marker (args[argnum]);
2847 CHECK_NUMBER_COERCE_MARKER (val);
2848 if (FLOATP (val)) 2863 if (FLOATP (val))
2849 return float_arith_driver (code, nargs, args, argnum, 2864 return float_arith_driver (code, nargs, args, argnum,
2850 mpz_get_d_rounded (*accum), val); 2865 mpz_get_d_rounded (*accum), val);
@@ -2873,8 +2888,7 @@ arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args,
2873 argnum++; 2888 argnum++;
2874 if (argnum == nargs) 2889 if (argnum == nargs)
2875 return make_int (accum); 2890 return make_int (accum);
2876 val = args[argnum]; 2891 val = check_number_coerce_marker (args[argnum]);
2877 CHECK_NUMBER_COERCE_MARKER (val);
2878 2892
2879 /* Set NEXT to the next value if it fits, else exit the loop. */ 2893 /* Set NEXT to the next value if it fits, else exit the loop. */
2880 intmax_t next; 2894 intmax_t next;
@@ -2921,8 +2935,7 @@ usage: (+ &rest NUMBERS-OR-MARKERS) */)
2921{ 2935{
2922 if (nargs == 0) 2936 if (nargs == 0)
2923 return make_fixnum (0); 2937 return make_fixnum (0);
2924 Lisp_Object a = args[0]; 2938 Lisp_Object a = check_number_coerce_marker (args[0]);
2925 CHECK_NUMBER_COERCE_MARKER (a);
2926 return nargs == 1 ? a : arith_driver (Aadd, nargs, args, a); 2939 return nargs == 1 ? a : arith_driver (Aadd, nargs, args, a);
2927} 2940}
2928 2941
@@ -2935,8 +2948,7 @@ usage: (- &optional NUMBER-OR-MARKER &rest MORE-NUMBERS-OR-MARKERS) */)
2935{ 2948{
2936 if (nargs == 0) 2949 if (nargs == 0)
2937 return make_fixnum (0); 2950 return make_fixnum (0);
2938 Lisp_Object a = args[0]; 2951 Lisp_Object a = check_number_coerce_marker (args[0]);
2939 CHECK_NUMBER_COERCE_MARKER (a);
2940 if (nargs == 1) 2952 if (nargs == 1)
2941 { 2953 {
2942 if (FIXNUMP (a)) 2954 if (FIXNUMP (a))
@@ -2956,8 +2968,7 @@ usage: (* &rest NUMBERS-OR-MARKERS) */)
2956{ 2968{
2957 if (nargs == 0) 2969 if (nargs == 0)
2958 return make_fixnum (1); 2970 return make_fixnum (1);
2959 Lisp_Object a = args[0]; 2971 Lisp_Object a = check_number_coerce_marker (args[0]);
2960 CHECK_NUMBER_COERCE_MARKER (a);
2961 return nargs == 1 ? a : arith_driver (Amult, nargs, args, a); 2972 return nargs == 1 ? a : arith_driver (Amult, nargs, args, a);
2962} 2973}
2963 2974
@@ -2969,8 +2980,7 @@ The arguments must be numbers or markers.
2969usage: (/ NUMBER &rest DIVISORS) */) 2980usage: (/ NUMBER &rest DIVISORS) */)
2970 (ptrdiff_t nargs, Lisp_Object *args) 2981 (ptrdiff_t nargs, Lisp_Object *args)
2971{ 2982{
2972 Lisp_Object a = args[0]; 2983 Lisp_Object a = check_number_coerce_marker (args[0]);
2973 CHECK_NUMBER_COERCE_MARKER (a);
2974 if (nargs == 1) 2984 if (nargs == 1)
2975 { 2985 {
2976 if (FIXNUMP (a)) 2986 if (FIXNUMP (a))
@@ -3052,10 +3062,10 @@ integer_remainder (Lisp_Object num, Lisp_Object den, bool modulo)
3052DEFUN ("%", Frem, Srem, 2, 2, 0, 3062DEFUN ("%", Frem, Srem, 2, 2, 0,
3053 doc: /* Return remainder of X divided by Y. 3063 doc: /* Return remainder of X divided by Y.
3054Both must be integers or markers. */) 3064Both must be integers or markers. */)
3055 (register Lisp_Object x, Lisp_Object y) 3065 (Lisp_Object x, Lisp_Object y)
3056{ 3066{
3057 CHECK_INTEGER_COERCE_MARKER (x); 3067 x = check_integer_coerce_marker (x);
3058 CHECK_INTEGER_COERCE_MARKER (y); 3068 y = check_integer_coerce_marker (y);
3059 return integer_remainder (x, y, false); 3069 return integer_remainder (x, y, false);
3060} 3070}
3061 3071
@@ -3065,8 +3075,8 @@ The result falls between zero (inclusive) and Y (exclusive).
3065Both X and Y must be numbers or markers. */) 3075Both X and Y must be numbers or markers. */)
3066 (Lisp_Object x, Lisp_Object y) 3076 (Lisp_Object x, Lisp_Object y)
3067{ 3077{
3068 CHECK_NUMBER_COERCE_MARKER (x); 3078 x = check_number_coerce_marker (x);
3069 CHECK_NUMBER_COERCE_MARKER (y); 3079 y = check_number_coerce_marker (y);
3070 if (FLOATP (x) || FLOATP (y)) 3080 if (FLOATP (x) || FLOATP (y))
3071 return fmod_float (x, y); 3081 return fmod_float (x, y);
3072 return integer_remainder (x, y, true); 3082 return integer_remainder (x, y, true);
@@ -3076,12 +3086,10 @@ static Lisp_Object
3076minmax_driver (ptrdiff_t nargs, Lisp_Object *args, 3086minmax_driver (ptrdiff_t nargs, Lisp_Object *args,
3077 enum Arith_Comparison comparison) 3087 enum Arith_Comparison comparison)
3078{ 3088{
3079 Lisp_Object accum = args[0]; 3089 Lisp_Object accum = check_number_coerce_marker (args[0]);
3080 CHECK_NUMBER_COERCE_MARKER (accum);
3081 for (ptrdiff_t argnum = 1; argnum < nargs; argnum++) 3090 for (ptrdiff_t argnum = 1; argnum < nargs; argnum++)
3082 { 3091 {
3083 Lisp_Object val = args[argnum]; 3092 Lisp_Object val = check_number_coerce_marker (args[argnum]);
3084 CHECK_NUMBER_COERCE_MARKER (val);
3085 if (!NILP (arithcompare (val, accum, comparison))) 3093 if (!NILP (arithcompare (val, accum, comparison)))
3086 accum = val; 3094 accum = val;
3087 else if (FLOATP (val) && isnan (XFLOAT_DATA (val))) 3095 else if (FLOATP (val) && isnan (XFLOAT_DATA (val)))
@@ -3116,8 +3124,7 @@ usage: (logand &rest INTS-OR-MARKERS) */)
3116{ 3124{
3117 if (nargs == 0) 3125 if (nargs == 0)
3118 return make_fixnum (-1); 3126 return make_fixnum (-1);
3119 Lisp_Object a = args[0]; 3127 Lisp_Object a = check_integer_coerce_marker (args[0]);
3120 CHECK_INTEGER_COERCE_MARKER (a);
3121 return nargs == 1 ? a : arith_driver (Alogand, nargs, args, a); 3128 return nargs == 1 ? a : arith_driver (Alogand, nargs, args, a);
3122} 3129}
3123 3130
@@ -3129,8 +3136,7 @@ usage: (logior &rest INTS-OR-MARKERS) */)
3129{ 3136{
3130 if (nargs == 0) 3137 if (nargs == 0)
3131 return make_fixnum (0); 3138 return make_fixnum (0);
3132 Lisp_Object a = args[0]; 3139 Lisp_Object a = check_integer_coerce_marker (args[0]);
3133 CHECK_INTEGER_COERCE_MARKER (a);
3134 return nargs == 1 ? a : arith_driver (Alogior, nargs, args, a); 3140 return nargs == 1 ? a : arith_driver (Alogior, nargs, args, a);
3135} 3141}
3136 3142
@@ -3142,8 +3148,7 @@ usage: (logxor &rest INTS-OR-MARKERS) */)
3142{ 3148{
3143 if (nargs == 0) 3149 if (nargs == 0)
3144 return make_fixnum (0); 3150 return make_fixnum (0);
3145 Lisp_Object a = args[0]; 3151 Lisp_Object a = check_integer_coerce_marker (args[0]);
3146 CHECK_INTEGER_COERCE_MARKER (a);
3147 return nargs == 1 ? a : arith_driver (Alogxor, nargs, args, a); 3152 return nargs == 1 ? a : arith_driver (Alogxor, nargs, args, a);
3148} 3153}
3149 3154
@@ -3262,9 +3267,9 @@ expt_integer (Lisp_Object x, Lisp_Object y)
3262DEFUN ("1+", Fadd1, Sadd1, 1, 1, 0, 3267DEFUN ("1+", Fadd1, Sadd1, 1, 1, 0,
3263 doc: /* Return NUMBER plus one. NUMBER may be a number or a marker. 3268 doc: /* Return NUMBER plus one. NUMBER may be a number or a marker.
3264Markers are converted to integers. */) 3269Markers are converted to integers. */)
3265 (register Lisp_Object number) 3270 (Lisp_Object number)
3266{ 3271{
3267 CHECK_NUMBER_COERCE_MARKER (number); 3272 number = check_number_coerce_marker (number);
3268 3273
3269 if (FIXNUMP (number)) 3274 if (FIXNUMP (number))
3270 return make_int (XFIXNUM (number) + 1); 3275 return make_int (XFIXNUM (number) + 1);
@@ -3277,9 +3282,9 @@ Markers are converted to integers. */)
3277DEFUN ("1-", Fsub1, Ssub1, 1, 1, 0, 3282DEFUN ("1-", Fsub1, Ssub1, 1, 1, 0,
3278 doc: /* Return NUMBER minus one. NUMBER may be a number or a marker. 3283 doc: /* Return NUMBER minus one. NUMBER may be a number or a marker.
3279Markers are converted to integers. */) 3284Markers are converted to integers. */)
3280 (register Lisp_Object number) 3285 (Lisp_Object number)
3281{ 3286{
3282 CHECK_NUMBER_COERCE_MARKER (number); 3287 number = check_number_coerce_marker (number);
3283 3288
3284 if (FIXNUMP (number)) 3289 if (FIXNUMP (number))
3285 return make_int (XFIXNUM (number) - 1); 3290 return make_int (XFIXNUM (number) - 1);
diff --git a/src/editfns.c b/src/editfns.c
index eb15566fb48..90520d0dced 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -725,18 +725,23 @@ boundaries, bind `inhibit-field-text-motion' to t.
725This function does not move point. */) 725This function does not move point. */)
726 (Lisp_Object n) 726 (Lisp_Object n)
727{ 727{
728 ptrdiff_t charpos, bytepos; 728 ptrdiff_t charpos, bytepos, count;
729 729
730 if (NILP (n)) 730 if (NILP (n))
731 XSETFASTINT (n, 1); 731 count = 0;
732 else if (FIXNUMP (n))
733 count = clip_to_bounds (-BUF_BYTES_MAX, XFIXNUM (n) - 1, BUF_BYTES_MAX);
732 else 734 else
733 CHECK_FIXNUM (n); 735 {
736 CHECK_INTEGER (n);
737 count = NILP (Fnatnump (n)) ? -BUF_BYTES_MAX : BUF_BYTES_MAX;
738 }
734 739
735 scan_newline_from_point (XFIXNUM (n) - 1, &charpos, &bytepos); 740 scan_newline_from_point (count, &charpos, &bytepos);
736 741
737 /* Return END constrained to the current input field. */ 742 /* Return END constrained to the current input field. */
738 return Fconstrain_to_field (make_fixnum (charpos), make_fixnum (PT), 743 return Fconstrain_to_field (make_fixnum (charpos), make_fixnum (PT),
739 XFIXNUM (n) != 1 ? Qt : Qnil, 744 count != 0 ? Qt : Qnil,
740 Qt, Qnil); 745 Qt, Qnil);
741} 746}
742 747
@@ -763,11 +768,14 @@ This function does not move point. */)
763 ptrdiff_t orig = PT; 768 ptrdiff_t orig = PT;
764 769
765 if (NILP (n)) 770 if (NILP (n))
766 XSETFASTINT (n, 1); 771 clipped_n = 1;
772 else if (FIXNUMP (n))
773 clipped_n = clip_to_bounds (-BUF_BYTES_MAX, XFIXNUM (n), BUF_BYTES_MAX);
767 else 774 else
768 CHECK_FIXNUM (n); 775 {
769 776 CHECK_INTEGER (n);
770 clipped_n = clip_to_bounds (PTRDIFF_MIN + 1, XFIXNUM (n), PTRDIFF_MAX); 777 clipped_n = NILP (Fnatnump (n)) ? -BUF_BYTES_MAX : BUF_BYTES_MAX;
778 }
771 end_pos = find_before_next_newline (orig, 0, clipped_n - (clipped_n <= 0), 779 end_pos = find_before_next_newline (orig, 0, clipped_n - (clipped_n <= 0),
772 NULL); 780 NULL);
773 781
@@ -940,10 +948,10 @@ DEFUN ("position-bytes", Fposition_bytes, Sposition_bytes, 1, 1, 0,
940If POSITION is out of range, the value is nil. */) 948If POSITION is out of range, the value is nil. */)
941 (Lisp_Object position) 949 (Lisp_Object position)
942{ 950{
943 CHECK_FIXNUM_COERCE_MARKER (position); 951 EMACS_INT pos = fix_position (position);
944 if (XFIXNUM (position) < BEG || XFIXNUM (position) > Z) 952 if (! (BEG <= pos && pos <= Z))
945 return Qnil; 953 return Qnil;
946 return make_fixnum (CHAR_TO_BYTE (XFIXNUM (position))); 954 return make_fixnum (CHAR_TO_BYTE (pos));
947} 955}
948 956
949DEFUN ("byte-to-position", Fbyte_to_position, Sbyte_to_position, 1, 1, 0, 957DEFUN ("byte-to-position", Fbyte_to_position, Sbyte_to_position, 1, 1, 0,
@@ -1060,11 +1068,11 @@ If POS is out of range, the value is nil. */)
1060 } 1068 }
1061 else 1069 else
1062 { 1070 {
1063 CHECK_FIXNUM_COERCE_MARKER (pos); 1071 EMACS_INT p = fix_position (pos);
1064 if (XFIXNUM (pos) < BEGV || XFIXNUM (pos) >= ZV) 1072 if (! (BEGV <= p && p < ZV))
1065 return Qnil; 1073 return Qnil;
1066 1074
1067 pos_byte = CHAR_TO_BYTE (XFIXNUM (pos)); 1075 pos_byte = CHAR_TO_BYTE (p);
1068 } 1076 }
1069 1077
1070 return make_fixnum (FETCH_CHAR (pos_byte)); 1078 return make_fixnum (FETCH_CHAR (pos_byte));
@@ -1094,12 +1102,12 @@ If POS is out of range, the value is nil. */)
1094 } 1102 }
1095 else 1103 else
1096 { 1104 {
1097 CHECK_FIXNUM_COERCE_MARKER (pos); 1105 EMACS_INT p = fix_position (pos);
1098 1106
1099 if (XFIXNUM (pos) <= BEGV || XFIXNUM (pos) > ZV) 1107 if (! (BEGV < p && p <= ZV))
1100 return Qnil; 1108 return Qnil;
1101 1109
1102 pos_byte = CHAR_TO_BYTE (XFIXNUM (pos)); 1110 pos_byte = CHAR_TO_BYTE (p);
1103 } 1111 }
1104 1112
1105 if (!NILP (BVAR (current_buffer, enable_multibyte_characters))) 1113 if (!NILP (BVAR (current_buffer, enable_multibyte_characters)))
@@ -1718,21 +1726,8 @@ using `string-make-multibyte' or `string-make-unibyte', which see. */)
1718 if (!BUFFER_LIVE_P (bp)) 1726 if (!BUFFER_LIVE_P (bp))
1719 error ("Selecting deleted buffer"); 1727 error ("Selecting deleted buffer");
1720 1728
1721 if (NILP (start)) 1729 b = !NILP (start) ? fix_position (start) : BUF_BEGV (bp);
1722 b = BUF_BEGV (bp); 1730 e = !NILP (end) ? fix_position (end) : BUF_ZV (bp);
1723 else
1724 {
1725 CHECK_FIXNUM_COERCE_MARKER (start);
1726 b = XFIXNUM (start);
1727 }
1728 if (NILP (end))
1729 e = BUF_ZV (bp);
1730 else
1731 {
1732 CHECK_FIXNUM_COERCE_MARKER (end);
1733 e = XFIXNUM (end);
1734 }
1735
1736 if (b > e) 1731 if (b > e)
1737 temp = b, b = e, e = temp; 1732 temp = b, b = e, e = temp;
1738 1733
@@ -1786,21 +1781,8 @@ determines whether case is significant or ignored. */)
1786 error ("Selecting deleted buffer"); 1781 error ("Selecting deleted buffer");
1787 } 1782 }
1788 1783
1789 if (NILP (start1)) 1784 begp1 = !NILP (start1) ? fix_position (start1) : BUF_BEGV (bp1);
1790 begp1 = BUF_BEGV (bp1); 1785 endp1 = !NILP (end1) ? fix_position (end1) : BUF_ZV (bp1);
1791 else
1792 {
1793 CHECK_FIXNUM_COERCE_MARKER (start1);
1794 begp1 = XFIXNUM (start1);
1795 }
1796 if (NILP (end1))
1797 endp1 = BUF_ZV (bp1);
1798 else
1799 {
1800 CHECK_FIXNUM_COERCE_MARKER (end1);
1801 endp1 = XFIXNUM (end1);
1802 }
1803
1804 if (begp1 > endp1) 1786 if (begp1 > endp1)
1805 temp = begp1, begp1 = endp1, endp1 = temp; 1787 temp = begp1, begp1 = endp1, endp1 = temp;
1806 1788
@@ -1824,21 +1806,8 @@ determines whether case is significant or ignored. */)
1824 error ("Selecting deleted buffer"); 1806 error ("Selecting deleted buffer");
1825 } 1807 }
1826 1808
1827 if (NILP (start2)) 1809 begp2 = !NILP (start2) ? fix_position (start2) : BUF_BEGV (bp2);
1828 begp2 = BUF_BEGV (bp2); 1810 endp2 = !NILP (end2) ? fix_position (end2) : BUF_ZV (bp2);
1829 else
1830 {
1831 CHECK_FIXNUM_COERCE_MARKER (start2);
1832 begp2 = XFIXNUM (start2);
1833 }
1834 if (NILP (end2))
1835 endp2 = BUF_ZV (bp2);
1836 else
1837 {
1838 CHECK_FIXNUM_COERCE_MARKER (end2);
1839 endp2 = XFIXNUM (end2);
1840 }
1841
1842 if (begp2 > endp2) 1811 if (begp2 > endp2)
1843 temp = begp2, begp2 = endp2, endp2 = temp; 1812 temp = begp2, begp2 = endp2, endp2 = temp;
1844 1813
@@ -2692,29 +2661,27 @@ See also `save-restriction'.
2692When calling from Lisp, pass two arguments START and END: 2661When calling from Lisp, pass two arguments START and END:
2693positions (integers or markers) bounding the text that should 2662positions (integers or markers) bounding the text that should
2694remain visible. */) 2663remain visible. */)
2695 (register Lisp_Object start, Lisp_Object end) 2664 (Lisp_Object start, Lisp_Object end)
2696{ 2665{
2697 CHECK_FIXNUM_COERCE_MARKER (start); 2666 EMACS_INT s = fix_position (start), e = fix_position (end);
2698 CHECK_FIXNUM_COERCE_MARKER (end);
2699 2667
2700 if (XFIXNUM (start) > XFIXNUM (end)) 2668 if (e < s)
2701 { 2669 {
2702 Lisp_Object tem; 2670 EMACS_INT tem = s; s = e; e = tem;
2703 tem = start; start = end; end = tem;
2704 } 2671 }
2705 2672
2706 if (!(BEG <= XFIXNUM (start) && XFIXNUM (start) <= XFIXNUM (end) && XFIXNUM (end) <= Z)) 2673 if (!(BEG <= s && s <= e && e <= Z))
2707 args_out_of_range (start, end); 2674 args_out_of_range (start, end);
2708 2675
2709 if (BEGV != XFIXNAT (start) || ZV != XFIXNAT (end)) 2676 if (BEGV != s || ZV != e)
2710 current_buffer->clip_changed = 1; 2677 current_buffer->clip_changed = 1;
2711 2678
2712 SET_BUF_BEGV (current_buffer, XFIXNAT (start)); 2679 SET_BUF_BEGV (current_buffer, s);
2713 SET_BUF_ZV (current_buffer, XFIXNAT (end)); 2680 SET_BUF_ZV (current_buffer, e);
2714 if (PT < XFIXNAT (start)) 2681 if (PT < s)
2715 SET_PT (XFIXNAT (start)); 2682 SET_PT (s);
2716 if (PT > XFIXNAT (end)) 2683 if (e < PT)
2717 SET_PT (XFIXNAT (end)); 2684 SET_PT (e);
2718 /* Changing the buffer bounds invalidates any recorded current column. */ 2685 /* Changing the buffer bounds invalidates any recorded current column. */
2719 invalidate_current_column (); 2686 invalidate_current_column ();
2720 return Qnil; 2687 return Qnil;
diff --git a/src/emacs-module.c b/src/emacs-module.c
index 60f16418efa..cdcbe061b53 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -88,6 +88,7 @@ To add a new module function, proceed as follows:
88#include "dynlib.h" 88#include "dynlib.h"
89#include "coding.h" 89#include "coding.h"
90#include "keyboard.h" 90#include "keyboard.h"
91#include "process.h"
91#include "syssignal.h" 92#include "syssignal.h"
92#include "sysstdio.h" 93#include "sysstdio.h"
93#include "thread.h" 94#include "thread.h"
@@ -977,6 +978,13 @@ module_make_big_integer (emacs_env *env, int sign,
977 return lisp_to_value (env, make_integer_mpz ()); 978 return lisp_to_value (env, make_integer_mpz ());
978} 979}
979 980
981static int
982module_open_channel (emacs_env *env, emacs_value pipe_process)
983{
984 MODULE_FUNCTION_BEGIN (-1);
985 return open_channel_for_module (value_to_lisp (pipe_process));
986}
987
980 988
981/* Subroutines. */ 989/* Subroutines. */
982 990
@@ -1391,6 +1399,7 @@ initialize_environment (emacs_env *env, struct emacs_env_private *priv)
1391 env->make_big_integer = module_make_big_integer; 1399 env->make_big_integer = module_make_big_integer;
1392 env->get_function_finalizer = module_get_function_finalizer; 1400 env->get_function_finalizer = module_get_function_finalizer;
1393 env->set_function_finalizer = module_set_function_finalizer; 1401 env->set_function_finalizer = module_set_function_finalizer;
1402 env->open_channel = module_open_channel;
1394 Vmodule_environments = Fcons (make_mint_ptr (env), Vmodule_environments); 1403 Vmodule_environments = Fcons (make_mint_ptr (env), Vmodule_environments);
1395 return env; 1404 return env;
1396} 1405}
diff --git a/src/fileio.c b/src/fileio.c
index ffe79559a3f..978a373d39b 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -96,7 +96,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
96#include <acl.h> 96#include <acl.h>
97#include <allocator.h> 97#include <allocator.h>
98#include <careadlinkat.h> 98#include <careadlinkat.h>
99#include <dosname.h> 99#include <filename.h>
100#include <fsusage.h> 100#include <fsusage.h>
101#include <stat-time.h> 101#include <stat-time.h>
102#include <tempname.h> 102#include <tempname.h>
diff --git a/src/filelock.c b/src/filelock.c
index 2b734ee00d5..ee46e0e3e00 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -661,7 +661,7 @@ void
661lock_file (Lisp_Object fn) 661lock_file (Lisp_Object fn)
662{ 662{
663 Lisp_Object orig_fn, encoded_fn; 663 Lisp_Object orig_fn, encoded_fn;
664 char *lfname; 664 char *lfname = NULL;
665 lock_info_type lock_info; 665 lock_info_type lock_info;
666 USE_SAFE_ALLOCA; 666 USE_SAFE_ALLOCA;
667 667
@@ -686,21 +686,15 @@ lock_file (Lisp_Object fn)
686 686
687 /* See if this file is visited and has changed on disk since it was 687 /* See if this file is visited and has changed on disk since it was
688 visited. */ 688 visited. */
689 { 689 Lisp_Object subject_buf = get_truename_buffer (orig_fn);
690 register Lisp_Object subject_buf; 690 if (!NILP (subject_buf)
691 691 && NILP (Fverify_visited_file_modtime (subject_buf))
692 subject_buf = get_truename_buffer (orig_fn); 692 && !NILP (Ffile_exists_p (fn))
693 693 && !(lfname && current_lock_owner (NULL, lfname) == -2))
694 if (!NILP (subject_buf) 694 call1 (intern ("userlock--ask-user-about-supersession-threat"), fn);
695 && NILP (Fverify_visited_file_modtime (subject_buf))
696 && !NILP (Ffile_exists_p (fn))
697 && (!create_lockfiles || current_lock_owner (NULL, lfname) != -2))
698 call1 (intern ("userlock--ask-user-about-supersession-threat"), fn);
699
700 }
701 695
702 /* Don't do locking if the user has opted out. */ 696 /* Don't do locking if the user has opted out. */
703 if (create_lockfiles) 697 if (lfname)
704 { 698 {
705 /* Try to lock the lock. FIXME: This ignores errors when 699 /* Try to lock the lock. FIXME: This ignores errors when
706 lock_if_free returns a positive errno value. */ 700 lock_if_free returns a positive errno value. */
@@ -860,7 +854,7 @@ syms_of_filelock (void)
860The name of the (per-buffer) lockfile is constructed by prepending a 854The name of the (per-buffer) lockfile is constructed by prepending a
861'.#' to the name of the file being locked. See also `lock-buffer' and 855'.#' to the name of the file being locked. See also `lock-buffer' and
862Info node `(emacs)Interlocking'. */); 856Info node `(emacs)Interlocking'. */);
863 create_lockfiles = 1; 857 create_lockfiles = true;
864 858
865 defsubr (&Sunlock_buffer); 859 defsubr (&Sunlock_buffer);
866 defsubr (&Slock_buffer); 860 defsubr (&Slock_buffer);
diff --git a/src/fns.c b/src/fns.c
index 80012fa9d28..138082e07c8 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -5187,22 +5187,8 @@ extract_data_from_object (Lisp_Object spec,
5187 struct buffer *bp = XBUFFER (object); 5187 struct buffer *bp = XBUFFER (object);
5188 set_buffer_internal (bp); 5188 set_buffer_internal (bp);
5189 5189
5190 if (NILP (start)) 5190 b = !NILP (start) ? fix_position (start) : BEGV;
5191 b = BEGV; 5191 e = !NILP (end) ? fix_position (end) : ZV;
5192 else
5193 {
5194 CHECK_FIXNUM_COERCE_MARKER (start);
5195 b = XFIXNUM (start);
5196 }
5197
5198 if (NILP (end))
5199 e = ZV;
5200 else
5201 {
5202 CHECK_FIXNUM_COERCE_MARKER (end);
5203 e = XFIXNUM (end);
5204 }
5205
5206 if (b > e) 5192 if (b > e)
5207 { 5193 {
5208 EMACS_INT temp = b; 5194 EMACS_INT temp = b;
diff --git a/src/font.c b/src/font.c
index 2a456300619..0c9e752e089 100644
--- a/src/font.c
+++ b/src/font.c
@@ -4606,10 +4606,10 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
4606 Lisp_Object window; 4606 Lisp_Object window;
4607 struct window *w; 4607 struct window *w;
4608 4608
4609 CHECK_FIXNUM_COERCE_MARKER (position); 4609 EMACS_INT fixed_pos = fix_position (position);
4610 if (! (BEGV <= XFIXNUM (position) && XFIXNUM (position) < ZV)) 4610 if (! (BEGV <= fixed_pos && fixed_pos < ZV))
4611 args_out_of_range_3 (position, make_fixnum (BEGV), make_fixnum (ZV)); 4611 args_out_of_range_3 (position, make_fixnum (BEGV), make_fixnum (ZV));
4612 pos = XFIXNUM (position); 4612 pos = fixed_pos;
4613 pos_byte = CHAR_TO_BYTE (pos); 4613 pos_byte = CHAR_TO_BYTE (pos);
4614 if (NILP (ch)) 4614 if (NILP (ch))
4615 c = FETCH_CHAR (pos_byte); 4615 c = FETCH_CHAR (pos_byte);
@@ -5013,24 +5013,26 @@ character at index specified by POSITION. */)
5013 (Lisp_Object position, Lisp_Object window, Lisp_Object string) 5013 (Lisp_Object position, Lisp_Object window, Lisp_Object string)
5014{ 5014{
5015 struct window *w = decode_live_window (window); 5015 struct window *w = decode_live_window (window);
5016 EMACS_INT pos;
5016 5017
5017 if (NILP (string)) 5018 if (NILP (string))
5018 { 5019 {
5019 if (XBUFFER (w->contents) != current_buffer) 5020 if (XBUFFER (w->contents) != current_buffer)
5020 error ("Specified window is not displaying the current buffer"); 5021 error ("Specified window is not displaying the current buffer");
5021 CHECK_FIXNUM_COERCE_MARKER (position); 5022 pos = fix_position (position);
5022 if (! (BEGV <= XFIXNUM (position) && XFIXNUM (position) < ZV)) 5023 if (! (BEGV <= pos && pos < ZV))
5023 args_out_of_range_3 (position, make_fixnum (BEGV), make_fixnum (ZV)); 5024 args_out_of_range_3 (position, make_fixnum (BEGV), make_fixnum (ZV));
5024 } 5025 }
5025 else 5026 else
5026 { 5027 {
5027 CHECK_FIXNUM (position); 5028 CHECK_FIXNUM (position);
5028 CHECK_STRING (string); 5029 CHECK_STRING (string);
5029 if (! (0 <= XFIXNUM (position) && XFIXNUM (position) < SCHARS (string))) 5030 pos = XFIXNUM (position);
5031 if (! (0 <= pos && pos < SCHARS (string)))
5030 args_out_of_range (string, position); 5032 args_out_of_range (string, position);
5031 } 5033 }
5032 5034
5033 return font_at (-1, XFIXNUM (position), NULL, w, string); 5035 return font_at (-1, pos, NULL, w, string);
5034} 5036}
5035 5037
5036#if 0 5038#if 0
diff --git a/src/fringe.c b/src/fringe.c
index 2a46e3c34f2..d8d80bb3fe9 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -1675,10 +1675,10 @@ Return nil if POS is not visible in WINDOW. */)
1675 1675
1676 if (!NILP (pos)) 1676 if (!NILP (pos))
1677 { 1677 {
1678 CHECK_FIXNUM_COERCE_MARKER (pos); 1678 EMACS_INT p = fix_position (pos);
1679 if (! (BEGV <= XFIXNUM (pos) && XFIXNUM (pos) <= ZV)) 1679 if (! (BEGV <= p && p <= ZV))
1680 args_out_of_range (window, pos); 1680 args_out_of_range (window, pos);
1681 textpos = XFIXNUM (pos); 1681 textpos = p;
1682 } 1682 }
1683 else if (w == XWINDOW (selected_window)) 1683 else if (w == XWINDOW (selected_window))
1684 textpos = PT; 1684 textpos = PT;
diff --git a/src/lisp.h b/src/lisp.h
index f86b4880f35..2f719b1f03e 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -585,7 +585,7 @@ INLINE void set_sub_char_table_contents (Lisp_Object, ptrdiff_t,
585 Lisp_Object); 585 Lisp_Object);
586 586
587/* Defined in bignum.c. */ 587/* Defined in bignum.c. */
588extern double bignum_to_double (Lisp_Object); 588extern double bignum_to_double (Lisp_Object) ATTRIBUTE_CONST;
589extern Lisp_Object make_bigint (intmax_t); 589extern Lisp_Object make_bigint (intmax_t);
590extern Lisp_Object make_biguint (uintmax_t); 590extern Lisp_Object make_biguint (uintmax_t);
591 591
@@ -3023,14 +3023,6 @@ CHECK_FIXNAT (Lisp_Object x)
3023 CHECK_RANGED_INTEGER (x, 0, TYPE_MAXIMUM (type)); \ 3023 CHECK_RANGED_INTEGER (x, 0, TYPE_MAXIMUM (type)); \
3024 } while (false) 3024 } while (false)
3025 3025
3026#define CHECK_FIXNUM_COERCE_MARKER(x) \
3027 do { \
3028 if (MARKERP ((x))) \
3029 XSETFASTINT (x, marker_position (x)); \
3030 else \
3031 CHECK_TYPE (FIXNUMP (x), Qinteger_or_marker_p, x); \
3032 } while (false)
3033
3034INLINE double 3026INLINE double
3035XFLOATINT (Lisp_Object n) 3027XFLOATINT (Lisp_Object n)
3036{ 3028{
@@ -3050,22 +3042,6 @@ CHECK_INTEGER (Lisp_Object x)
3050{ 3042{
3051 CHECK_TYPE (INTEGERP (x), Qnumberp, x); 3043 CHECK_TYPE (INTEGERP (x), Qnumberp, x);
3052} 3044}
3053
3054#define CHECK_NUMBER_COERCE_MARKER(x) \
3055 do { \
3056 if (MARKERP (x)) \
3057 XSETFASTINT (x, marker_position (x)); \
3058 else \
3059 CHECK_TYPE (NUMBERP (x), Qnumber_or_marker_p, x); \
3060 } while (false)
3061
3062#define CHECK_INTEGER_COERCE_MARKER(x) \
3063 do { \
3064 if (MARKERP (x)) \
3065 XSETFASTINT (x, marker_position (x)); \
3066 else \
3067 CHECK_TYPE (INTEGERP (x), Qnumber_or_marker_p, x); \
3068 } while (false)
3069 3045
3070 3046
3071/* If we're not dumping using the legacy dumper and we might be using 3047/* If we're not dumping using the legacy dumper and we might be using
@@ -3519,9 +3495,9 @@ set_sub_char_table_contents (Lisp_Object table, ptrdiff_t idx, Lisp_Object val)
3519 3495
3520/* Defined in bignum.c. This part of bignum.c's API does not require 3496/* Defined in bignum.c. This part of bignum.c's API does not require
3521 the caller to access bignum internals; see bignum.h for that. */ 3497 the caller to access bignum internals; see bignum.h for that. */
3522extern intmax_t bignum_to_intmax (Lisp_Object); 3498extern intmax_t bignum_to_intmax (Lisp_Object) ATTRIBUTE_CONST;
3523extern uintmax_t bignum_to_uintmax (Lisp_Object); 3499extern uintmax_t bignum_to_uintmax (Lisp_Object) ATTRIBUTE_CONST;
3524extern ptrdiff_t bignum_bufsize (Lisp_Object, int); 3500extern ptrdiff_t bignum_bufsize (Lisp_Object, int) ATTRIBUTE_CONST;
3525extern ptrdiff_t bignum_to_c_string (char *, ptrdiff_t, Lisp_Object, int); 3501extern ptrdiff_t bignum_to_c_string (char *, ptrdiff_t, Lisp_Object, int);
3526extern Lisp_Object bignum_to_string (Lisp_Object, int); 3502extern Lisp_Object bignum_to_string (Lisp_Object, int);
3527extern Lisp_Object make_bignum_str (char const *, int); 3503extern Lisp_Object make_bignum_str (char const *, int);
diff --git a/src/module-env-28.h b/src/module-env-28.h
index a2479a8f744..5d884c148c4 100644
--- a/src/module-env-28.h
+++ b/src/module-env-28.h
@@ -9,3 +9,6 @@
9 void (*set_function_finalizer) (emacs_env *env, emacs_value arg, 9 void (*set_function_finalizer) (emacs_env *env, emacs_value arg,
10 void (*fin) (void *) EMACS_NOEXCEPT) 10 void (*fin) (void *) EMACS_NOEXCEPT)
11 EMACS_ATTRIBUTE_NONNULL (1); 11 EMACS_ATTRIBUTE_NONNULL (1);
12
13 int (*open_channel) (emacs_env *env, emacs_value pipe_process)
14 EMACS_ATTRIBUTE_NONNULL (1);
diff --git a/src/process.c b/src/process.c
index e4e5e57aeee..07881d6c5d3 100644
--- a/src/process.c
+++ b/src/process.c
@@ -8200,6 +8200,17 @@ restore_nofile_limit (void)
8200#endif 8200#endif
8201} 8201}
8202 8202
8203int
8204open_channel_for_module (Lisp_Object process)
8205{
8206 CHECK_PROCESS (process);
8207 CHECK_TYPE (PIPECONN_P (process), Qpipe_process_p, process);
8208 int fd = dup (XPROCESS (process)->open_fd[SUBPROCESS_STDOUT]);
8209 if (fd == -1)
8210 report_file_error ("Cannot duplicate file descriptor", Qnil);
8211 return fd;
8212}
8213
8203 8214
8204/* This is not called "init_process" because that is the name of a 8215/* This is not called "init_process" because that is the name of a
8205 Mach system call, so it would cause problems on Darwin systems. */ 8216 Mach system call, so it would cause problems on Darwin systems. */
@@ -8446,6 +8457,7 @@ amounts of data in one go. */);
8446 DEFSYM (Qinterrupt_process_functions, "interrupt-process-functions"); 8457 DEFSYM (Qinterrupt_process_functions, "interrupt-process-functions");
8447 8458
8448 DEFSYM (Qnull, "null"); 8459 DEFSYM (Qnull, "null");
8460 DEFSYM (Qpipe_process_p, "pipe-process-p");
8449 8461
8450 defsubr (&Sprocessp); 8462 defsubr (&Sprocessp);
8451 defsubr (&Sget_process); 8463 defsubr (&Sget_process);
diff --git a/src/process.h b/src/process.h
index 7884efc5494..a783a31cb86 100644
--- a/src/process.h
+++ b/src/process.h
@@ -300,6 +300,8 @@ extern Lisp_Object remove_slash_colon (Lisp_Object);
300extern void update_processes_for_thread_death (Lisp_Object); 300extern void update_processes_for_thread_death (Lisp_Object);
301extern void dissociate_controlling_tty (void); 301extern void dissociate_controlling_tty (void);
302 302
303extern int open_channel_for_module (Lisp_Object);
304
303INLINE_HEADER_END 305INLINE_HEADER_END
304 306
305#endif /* EMACS_PROCESS_H */ 307#endif /* EMACS_PROCESS_H */
diff --git a/src/search.c b/src/search.c
index 818bb4af246..7389fbef0ee 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1028,8 +1028,7 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror,
1028 } 1028 }
1029 else 1029 else
1030 { 1030 {
1031 CHECK_FIXNUM_COERCE_MARKER (bound); 1031 lim = fix_position (bound);
1032 lim = XFIXNUM (bound);
1033 if (n > 0 ? lim < PT : lim > PT) 1032 if (n > 0 ? lim < PT : lim > PT)
1034 error ("Invalid search bound (wrong side of point)"); 1033 error ("Invalid search bound (wrong side of point)");
1035 if (lim > ZV) 1034 if (lim > ZV)
diff --git a/src/textprop.c b/src/textprop.c
index ee048336ac0..960dba3f8dc 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -131,6 +131,7 @@ validate_interval_range (Lisp_Object object, Lisp_Object *begin,
131{ 131{
132 INTERVAL i; 132 INTERVAL i;
133 ptrdiff_t searchpos; 133 ptrdiff_t searchpos;
134 Lisp_Object begin0 = *begin, end0 = *end;
134 135
135 CHECK_STRING_OR_BUFFER (object); 136 CHECK_STRING_OR_BUFFER (object);
136 CHECK_FIXNUM_COERCE_MARKER (*begin); 137 CHECK_FIXNUM_COERCE_MARKER (*begin);
@@ -155,7 +156,7 @@ validate_interval_range (Lisp_Object object, Lisp_Object *begin,
155 156
156 if (!(BUF_BEGV (b) <= XFIXNUM (*begin) && XFIXNUM (*begin) <= XFIXNUM (*end) 157 if (!(BUF_BEGV (b) <= XFIXNUM (*begin) && XFIXNUM (*begin) <= XFIXNUM (*end)
157 && XFIXNUM (*end) <= BUF_ZV (b))) 158 && XFIXNUM (*end) <= BUF_ZV (b)))
158 args_out_of_range (*begin, *end); 159 args_out_of_range (begin0, end0);
159 i = buffer_intervals (b); 160 i = buffer_intervals (b);
160 161
161 /* If there's no text, there are no properties. */ 162 /* If there's no text, there are no properties. */
@@ -170,7 +171,7 @@ validate_interval_range (Lisp_Object object, Lisp_Object *begin,
170 171
171 if (! (0 <= XFIXNUM (*begin) && XFIXNUM (*begin) <= XFIXNUM (*end) 172 if (! (0 <= XFIXNUM (*begin) && XFIXNUM (*begin) <= XFIXNUM (*end)
172 && XFIXNUM (*end) <= len)) 173 && XFIXNUM (*end) <= len))
173 args_out_of_range (*begin, *end); 174 args_out_of_range (begin0, end0);
174 i = string_intervals (object); 175 i = string_intervals (object);
175 176
176 if (len == 0) 177 if (len == 0)
@@ -611,7 +612,7 @@ get_char_property_and_overlay (Lisp_Object position, register Lisp_Object prop,
611{ 612{
612 struct window *w = 0; 613 struct window *w = 0;
613 614
614 CHECK_FIXNUM_COERCE_MARKER (position); 615 EMACS_INT pos = fix_position (position);
615 616
616 if (NILP (object)) 617 if (NILP (object))
617 XSETBUFFER (object, current_buffer); 618 XSETBUFFER (object, current_buffer);
@@ -628,14 +629,14 @@ get_char_property_and_overlay (Lisp_Object position, register Lisp_Object prop,
628 Lisp_Object *overlay_vec; 629 Lisp_Object *overlay_vec;
629 struct buffer *obuf = current_buffer; 630 struct buffer *obuf = current_buffer;
630 631
631 if (XFIXNUM (position) < BUF_BEGV (XBUFFER (object)) 632 if (! (BUF_BEGV (XBUFFER (object)) <= pos
632 || XFIXNUM (position) > BUF_ZV (XBUFFER (object))) 633 && pos <= BUF_ZV (XBUFFER (object))))
633 xsignal1 (Qargs_out_of_range, position); 634 xsignal1 (Qargs_out_of_range, position);
634 635
635 set_buffer_temp (XBUFFER (object)); 636 set_buffer_temp (XBUFFER (object));
636 637
637 USE_SAFE_ALLOCA; 638 USE_SAFE_ALLOCA;
638 GET_OVERLAYS_AT (XFIXNUM (position), overlay_vec, noverlays, NULL, false); 639 GET_OVERLAYS_AT (pos, overlay_vec, noverlays, NULL, false);
639 noverlays = sort_overlays (overlay_vec, noverlays, w); 640 noverlays = sort_overlays (overlay_vec, noverlays, w);
640 641
641 set_buffer_temp (obuf); 642 set_buffer_temp (obuf);
@@ -662,7 +663,7 @@ get_char_property_and_overlay (Lisp_Object position, register Lisp_Object prop,
662 663
663 /* Not a buffer, or no appropriate overlay, so fall through to the 664 /* Not a buffer, or no appropriate overlay, so fall through to the
664 simpler case. */ 665 simpler case. */
665 return Fget_text_property (position, prop, object); 666 return Fget_text_property (make_fixnum (pos), prop, object);
666} 667}
667 668
668DEFUN ("get-char-property", Fget_char_property, Sget_char_property, 2, 3, 0, 669DEFUN ("get-char-property", Fget_char_property, Sget_char_property, 2, 3, 0,
diff --git a/src/window.c b/src/window.c
index 8cdad27b664..075fd4e550c 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1895,10 +1895,7 @@ POS, ROWH is the visible height of that row, and VPOS is the row number
1895 if (EQ (pos, Qt)) 1895 if (EQ (pos, Qt))
1896 posint = -1; 1896 posint = -1;
1897 else if (!NILP (pos)) 1897 else if (!NILP (pos))
1898 { 1898 posint = fix_position (pos);
1899 CHECK_FIXNUM_COERCE_MARKER (pos);
1900 posint = XFIXNUM (pos);
1901 }
1902 else if (w == XWINDOW (selected_window)) 1899 else if (w == XWINDOW (selected_window))
1903 posint = PT; 1900 posint = PT;
1904 else 1901 else
diff --git a/src/xdisp.c b/src/xdisp.c
index 04fc8aa3c45..61c798c59e8 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -815,11 +815,6 @@ static struct props it_props[] =
815 {0, 0, NULL} 815 {0, 0, NULL}
816}; 816};
817 817
818/* Value is the position described by X. If X is a marker, value is
819 the marker_position of X. Otherwise, value is X. */
820
821#define COERCE_MARKER(X) (MARKERP ((X)) ? Fmarker_position (X) : (X))
822
823/* Enumeration returned by some move_it_.* functions internally. */ 818/* Enumeration returned by some move_it_.* functions internally. */
824 819
825enum move_it_result 820enum move_it_result
@@ -10418,10 +10413,7 @@ include the height of both, if present, in the return value. */)
10418 start = pos; 10413 start = pos;
10419 } 10414 }
10420 else 10415 else
10421 { 10416 start = clip_to_bounds (BEGV, fix_position (from), ZV);
10422 CHECK_FIXNUM_COERCE_MARKER (from);
10423 start = min (max (XFIXNUM (from), BEGV), ZV);
10424 }
10425 10417
10426 if (NILP (to)) 10418 if (NILP (to))
10427 end = ZV; 10419 end = ZV;
@@ -10435,10 +10427,7 @@ include the height of both, if present, in the return value. */)
10435 end = pos; 10427 end = pos;
10436 } 10428 }
10437 else 10429 else
10438 { 10430 end = clip_to_bounds (start, fix_position (to), ZV);
10439 CHECK_FIXNUM_COERCE_MARKER (to);
10440 end = max (start, min (XFIXNUM (to), ZV));
10441 }
10442 10431
10443 if (!NILP (x_limit) && RANGED_FIXNUMP (0, x_limit, INT_MAX)) 10432 if (!NILP (x_limit) && RANGED_FIXNUMP (0, x_limit, INT_MAX))
10444 max_x = XFIXNUM (x_limit); 10433 max_x = XFIXNUM (x_limit);
@@ -14944,7 +14933,7 @@ overlay_arrows_changed_p (bool set_redisplay)
14944 val = find_symbol_value (var); 14933 val = find_symbol_value (var);
14945 if (!MARKERP (val)) 14934 if (!MARKERP (val))
14946 continue; 14935 continue;
14947 if (! EQ (COERCE_MARKER (val), 14936 if (! EQ (Fmarker_position (val),
14948 /* FIXME: Don't we have a problem, using such a global 14937 /* FIXME: Don't we have a problem, using such a global
14949 * "last-position" if the variable is buffer-local? */ 14938 * "last-position" if the variable is buffer-local? */
14950 Fget (var, Qlast_arrow_position)) 14939 Fget (var, Qlast_arrow_position))
@@ -14987,8 +14976,7 @@ update_overlay_arrows (int up_to_date)
14987 Lisp_Object val = find_symbol_value (var); 14976 Lisp_Object val = find_symbol_value (var);
14988 if (!MARKERP (val)) 14977 if (!MARKERP (val))
14989 continue; 14978 continue;
14990 Fput (var, Qlast_arrow_position, 14979 Fput (var, Qlast_arrow_position, Fmarker_position (val));
14991 COERCE_MARKER (val));
14992 Fput (var, Qlast_arrow_string, 14980 Fput (var, Qlast_arrow_string,
14993 overlay_arrow_string_or_property (var)); 14981 overlay_arrow_string_or_property (var));
14994 } 14982 }