comparison src/search.c @ 5581:56144c8593a8

Mechanically change INT to FIXNUM in our sources. src/ChangeLog addition: 2011-10-09 Aidan Kehoe <kehoea@parhasard.net> [...] Mechanically change INT (where it refers to non-bignum Lisp integers) to FIXNUM in our sources. Done for the following functions, enums, and macros: Lisp_Type_Int_Even, Lisp_Type_Int_Odd, INT_GCBITS, INT_VALBITS, make_int(), INTP(), XINT(), CHECK_INT(), XREALINT(), INT_PLUS(), INT_MINUS(), EMACS_INT_MAX (to MOST_POSITIVE_FIXNUM), EMACS_INT_MIN (to MOST_NEGATIVE_FIXNUM), NUMBER_FITS_IN_AN_EMACS_INT() to NUMBER_FITS_IN_A_FIXNUM(), XFLOATINT, XCHAR_OR_INT, INT_OR_FLOAT. The EMACS_INT typedef was not changed, it does not describe non-bignum Lisp integers. Script that did the change available in http://mid.gmane.org/20067.17650.181273.12014@parhasard.net . modules/ChangeLog addition: 2011-10-09 Aidan Kehoe <kehoea@parhasard.net> [...] Mechanically change INT to FIXNUM, where the usage describes non-bignum Lisp integers. See the src/ChangeLog entry for more details. man/ChangeLog addition: 2011-10-09 Aidan Kehoe <kehoea@parhasard.net> * internals/internals.texi (How Lisp Objects Are Represented in C): * internals/internals.texi (Integers and Characters): Mechanically change INT to FIXNUM, where the usage describes non-bignum Lisp integers.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 09 Oct 2011 09:51:57 +0100
parents dab422055bab
children d026b665014f
comparison
equal deleted inserted replaced
5580:a0e81357194e 5581:56144c8593a8
436 s = 0; 436 s = 0;
437 else 437 else
438 { 438 {
439 Charcount len = string_char_length (string); 439 Charcount len = string_char_length (string);
440 440
441 CHECK_INT (start); 441 CHECK_FIXNUM (start);
442 s = XINT (start); 442 s = XFIXNUM (start);
443 if (s < 0 && -s <= len) 443 if (s < 0 && -s <= len)
444 s = len + s; 444 s = len + s;
445 else if (0 > s || s > len) 445 else if (0 > s || s > len)
446 args_out_of_range (string, start); 446 args_out_of_range (string, start);
447 } 447 }
474 if (val == -2) 474 if (val == -2)
475 matcher_overflow (); 475 matcher_overflow ();
476 if (val < 0) return Qnil; 476 if (val < 0) return Qnil;
477 last_thing_searched = Qt; 477 last_thing_searched = Qt;
478 fixup_search_regs_for_string (string); 478 fixup_search_regs_for_string (string);
479 return make_int (string_index_byte_to_char (string, val)); 479 return make_fixnum (string_index_byte_to_char (string, val));
480 } 480 }
481 481
482 DEFUN ("string-match", Fstring_match, 2, 4, 0, /* 482 DEFUN ("string-match", Fstring_match, 2, 4, 0, /*
483 Return index of start of first match for REGEXP in STRING, or nil. 483 Return index of start of first match for REGEXP in STRING, or nil.
484 If third arg START is non-nil, start search at that index in STRING. 484 If third arg START is non-nil, start search at that index in STRING.
893 893
894 if (NILP (lim)) 894 if (NILP (lim))
895 limit = forwardp ? BUF_ZV (buf) : BUF_BEGV (buf); 895 limit = forwardp ? BUF_ZV (buf) : BUF_BEGV (buf);
896 else 896 else
897 { 897 {
898 CHECK_INT_COERCE_MARKER (lim); 898 CHECK_FIXNUM_COERCE_MARKER (lim);
899 limit = XINT (lim); 899 limit = XFIXNUM (lim);
900 900
901 /* In any case, don't allow scan outside bounds of buffer. */ 901 /* In any case, don't allow scan outside bounds of buffer. */
902 if (limit > BUF_ZV (buf)) limit = BUF_ZV (buf); 902 if (limit > BUF_ZV (buf)) limit = BUF_ZV (buf);
903 if (limit < BUF_BEGV (buf)) limit = BUF_BEGV (buf); 903 if (limit < BUF_BEGV (buf)) limit = BUF_BEGV (buf);
904 } 904 }
951 { 951 {
952 fastmap[c] = 1; 952 fastmap[c] = 1;
953 c++; 953 c++;
954 } 954 }
955 if (c <= cend) 955 if (c <= cend)
956 Fput_range_table (make_int (c), make_int (cend), Qt, 956 Fput_range_table (make_fixnum (c), make_fixnum (cend), Qt,
957 Vskip_chars_range_table); 957 Vskip_chars_range_table);
958 INC_IBYTEPTR (p); 958 INC_IBYTEPTR (p);
959 } 959 }
960 else 960 else
961 { 961 {
962 if (c < 0400) 962 if (c < 0400)
963 fastmap[c] = 1; 963 fastmap[c] = 1;
964 else 964 else
965 Fput_range_table (make_int (c), make_int (c), Qt, 965 Fput_range_table (make_fixnum (c), make_fixnum (c), Qt,
966 Vskip_chars_range_table); 966 Vskip_chars_range_table);
967 } 967 }
968 } 968 }
969 } 969 }
970 970
1031 { 1031 {
1032 while (pos < limit) 1032 while (pos < limit)
1033 { 1033 {
1034 Ichar ch = BYTE_BUF_FETCH_CHAR (buf, pos_byte); 1034 Ichar ch = BYTE_BUF_FETCH_CHAR (buf, pos_byte);
1035 if ((ch < 0400) ? fastmap[ch] : 1035 if ((ch < 0400) ? fastmap[ch] :
1036 (NILP (Fget_range_table (make_int (ch), 1036 (NILP (Fget_range_table (make_fixnum (ch),
1037 Vskip_chars_range_table, 1037 Vskip_chars_range_table,
1038 Qnil)) 1038 Qnil))
1039 == negate)) 1039 == negate))
1040 { 1040 {
1041 pos++; 1041 pos++;
1053 Ichar ch; 1053 Ichar ch;
1054 1054
1055 DEC_BYTEBPOS (buf, prev_pos_byte); 1055 DEC_BYTEBPOS (buf, prev_pos_byte);
1056 ch = BYTE_BUF_FETCH_CHAR (buf, prev_pos_byte); 1056 ch = BYTE_BUF_FETCH_CHAR (buf, prev_pos_byte);
1057 if ((ch < 0400) ? fastmap[ch] : 1057 if ((ch < 0400) ? fastmap[ch] :
1058 (NILP (Fget_range_table (make_int (ch), 1058 (NILP (Fget_range_table (make_fixnum (ch),
1059 Vskip_chars_range_table, 1059 Vskip_chars_range_table,
1060 Qnil)) 1060 Qnil))
1061 == negate)) 1061 == negate))
1062 { 1062 {
1063 pos--; 1063 pos--;
1068 } 1068 }
1069 } 1069 }
1070 } 1070 }
1071 QUIT; 1071 QUIT;
1072 BOTH_BUF_SET_PT (buf, pos, pos_byte); 1072 BOTH_BUF_SET_PT (buf, pos, pos_byte);
1073 return make_int (BUF_PT (buf) - start_point); 1073 return make_fixnum (BUF_PT (buf) - start_point);
1074 } 1074 }
1075 } 1075 }
1076 1076
1077 DEFUN ("skip-chars-forward", Fskip_chars_forward, 1, 3, 0, /* 1077 DEFUN ("skip-chars-forward", Fskip_chars_forward, 1, 3, 0, /*
1078 Move point forward, stopping before a char not in STRING, or at pos LIMIT. 1078 Move point forward, stopping before a char not in STRING, or at pos LIMIT.
1143 EMACS_INT n = direction; 1143 EMACS_INT n = direction;
1144 struct buffer *buf; 1144 struct buffer *buf;
1145 1145
1146 if (!NILP (count)) 1146 if (!NILP (count))
1147 { 1147 {
1148 CHECK_INT (count); 1148 CHECK_FIXNUM (count);
1149 n *= XINT (count); 1149 n *= XFIXNUM (count);
1150 } 1150 }
1151 1151
1152 buf = decode_buffer (buffer, 0); 1152 buf = decode_buffer (buffer, 0);
1153 CHECK_STRING (string); 1153 CHECK_STRING (string);
1154 if (NILP (limit)) 1154 if (NILP (limit))
1155 lim = n > 0 ? BUF_ZV (buf) : BUF_BEGV (buf); 1155 lim = n > 0 ? BUF_ZV (buf) : BUF_BEGV (buf);
1156 else 1156 else
1157 { 1157 {
1158 CHECK_INT_COERCE_MARKER (limit); 1158 CHECK_FIXNUM_COERCE_MARKER (limit);
1159 lim = XINT (limit); 1159 lim = XFIXNUM (limit);
1160 if (n > 0 ? lim < BUF_PT (buf) : lim > BUF_PT (buf)) 1160 if (n > 0 ? lim < BUF_PT (buf) : lim > BUF_PT (buf))
1161 invalid_argument ("Invalid search limit (wrong side of point)", 1161 invalid_argument ("Invalid search limit (wrong side of point)",
1162 Qunbound); 1162 Qunbound);
1163 if (lim > BUF_ZV (buf)) 1163 if (lim > BUF_ZV (buf))
1164 lim = BUF_ZV (buf); 1164 lim = BUF_ZV (buf);
1199 if (np < BUF_BEGV (buf) || np > BUF_ZV (buf)) 1199 if (np < BUF_BEGV (buf) || np > BUF_ZV (buf))
1200 ABORT (); 1200 ABORT ();
1201 1201
1202 BUF_SET_PT (buf, np); 1202 BUF_SET_PT (buf, np);
1203 1203
1204 return make_int (np); 1204 return make_fixnum (np);
1205 } 1205 }
1206 1206
1207 static int 1207 static int
1208 trivial_regexp_p (Lisp_Object regexp) 1208 trivial_regexp_p (Lisp_Object regexp)
1209 { 1209 {
2672 { 2672 {
2673 buf = decode_buffer (strbuffer, 0); 2673 buf = decode_buffer (strbuffer, 0);
2674 } 2674 }
2675 else if (!NILP (strbuffer)) 2675 else if (!NILP (strbuffer))
2676 { 2676 {
2677 CHECK_INT (strbuffer); 2677 CHECK_FIXNUM (strbuffer);
2678 sub = XINT (strbuffer); 2678 sub = XFIXNUM (strbuffer);
2679 if (sub < 0 || sub >= (int) search_regs.num_regs) 2679 if (sub < 0 || sub >= (int) search_regs.num_regs)
2680 invalid_argument ("match data register invalid", strbuffer); 2680 invalid_argument ("match data register invalid", strbuffer);
2681 if (search_regs.start[sub] < 0) 2681 if (search_regs.start[sub] < 0)
2682 invalid_argument ("match data register not set", strbuffer); 2682 invalid_argument ("match data register not set", strbuffer);
2683 buf = current_buffer; 2683 buf = current_buffer;
2713 if (NILP (string)) 2713 if (NILP (string))
2714 { 2714 {
2715 if (search_regs.start[sub] < BUF_BEGV (buf) 2715 if (search_regs.start[sub] < BUF_BEGV (buf)
2716 || search_regs.start[sub] > search_regs.end[sub] 2716 || search_regs.start[sub] > search_regs.end[sub]
2717 || search_regs.end[sub] > BUF_ZV (buf)) 2717 || search_regs.end[sub] > BUF_ZV (buf))
2718 args_out_of_range (make_int (search_regs.start[sub]), 2718 args_out_of_range (make_fixnum (search_regs.start[sub]),
2719 make_int (search_regs.end[sub])); 2719 make_fixnum (search_regs.end[sub]));
2720 } 2720 }
2721 else 2721 else
2722 { 2722 {
2723 if (search_regs.start[0] < 0 2723 if (search_regs.start[0] < 0
2724 || search_regs.start[0] > search_regs.end[0] 2724 || search_regs.start[0] > search_regs.end[0]
2725 || search_regs.end[0] > string_char_length (string)) 2725 || search_regs.end[0] > string_char_length (string))
2726 args_out_of_range (make_int (search_regs.start[0]), 2726 args_out_of_range (make_fixnum (search_regs.start[0]),
2727 make_int (search_regs.end[0])); 2727 make_fixnum (search_regs.end[0]));
2728 } 2728 }
2729 2729
2730 if (NILP (fixedcase)) 2730 if (NILP (fixedcase))
2731 { 2731 {
2732 /* Decide how to casify by examining the matched text. */ 2732 /* Decide how to casify by examining the matched text. */
2797 if (!NILP (string)) 2797 if (!NILP (string))
2798 { 2798 {
2799 Lisp_Object before, after; 2799 Lisp_Object before, after;
2800 2800
2801 speccount = specpdl_depth (); 2801 speccount = specpdl_depth ();
2802 before = Fsubseq (string, Qzero, make_int (search_regs.start[sub])); 2802 before = Fsubseq (string, Qzero, make_fixnum (search_regs.start[sub]));
2803 after = Fsubseq (string, make_int (search_regs.end[sub]), Qnil); 2803 after = Fsubseq (string, make_fixnum (search_regs.end[sub]), Qnil);
2804 2804
2805 /* Do case substitution into REPLACEMENT if desired. */ 2805 /* Do case substitution into REPLACEMENT if desired. */
2806 if (NILP (literal)) 2806 if (NILP (literal))
2807 { 2807 {
2808 Charcount stlen = string_char_length (replacement); 2808 Charcount stlen = string_char_length (replacement);
2885 { 2885 {
2886 Lisp_Object literal_text = Qnil; 2886 Lisp_Object literal_text = Qnil;
2887 Lisp_Object substring = Qnil; 2887 Lisp_Object substring = Qnil;
2888 if (literal_end != literal_start) 2888 if (literal_end != literal_start)
2889 literal_text = Fsubseq (replacement, 2889 literal_text = Fsubseq (replacement,
2890 make_int (literal_start), 2890 make_fixnum (literal_start),
2891 make_int (literal_end)); 2891 make_fixnum (literal_end));
2892 if (substart >= 0 && subend != substart) 2892 if (substart >= 0 && subend != substart)
2893 substring = Fsubseq (string, make_int (substart), 2893 substring = Fsubseq (string, make_fixnum (substart),
2894 make_int (subend)); 2894 make_fixnum (subend));
2895 if (!NILP (literal_text) || !NILP (substring)) 2895 if (!NILP (literal_text) || !NILP (substring))
2896 accum = concat3 (accum, literal_text, substring); 2896 accum = concat3 (accum, literal_text, substring);
2897 literal_start = strpos + 1; 2897 literal_start = strpos + 1;
2898 } 2898 }
2899 } 2899 }
2900 2900
2901 if (strpos != literal_start) 2901 if (strpos != literal_start)
2902 /* some literal text at end to be inserted */ 2902 /* some literal text at end to be inserted */
2903 replacement = concat2 (accum, Fsubseq (replacement, 2903 replacement = concat2 (accum, Fsubseq (replacement,
2904 make_int (literal_start), 2904 make_fixnum (literal_start),
2905 make_int (strpos))); 2905 make_fixnum (strpos)));
2906 else 2906 else
2907 replacement = accum; 2907 replacement = accum;
2908 } 2908 }
2909 2909
2910 /* replacement can be nil. */ 2910 /* replacement can be nil. */
2998 */ 2998 */
2999 c = string_ichar (replacement, ++strpos); 2999 c = string_ichar (replacement, ++strpos);
3000 if (c == '&') 3000 if (c == '&')
3001 Finsert_buffer_substring 3001 Finsert_buffer_substring
3002 (buffer, 3002 (buffer,
3003 make_int (search_regs.start[0] + offset), 3003 make_fixnum (search_regs.start[0] + offset),
3004 make_int (search_regs.end[0] + offset)); 3004 make_fixnum (search_regs.end[0] + offset));
3005 /* #### This logic is totally broken, 3005 /* #### This logic is totally broken,
3006 since we can have backrefs like "\99", right? */ 3006 since we can have backrefs like "\99", right? */
3007 else if (c >= '1' && c <= '9' && 3007 else if (c >= '1' && c <= '9' &&
3008 c <= search_regs.num_regs + '0') 3008 c <= search_regs.num_regs + '0')
3009 { 3009 {
3010 if (search_regs.start[c - '0'] >= 1) 3010 if (search_regs.start[c - '0'] >= 1)
3011 Finsert_buffer_substring 3011 Finsert_buffer_substring
3012 (buffer, 3012 (buffer,
3013 make_int (search_regs.start[c - '0'] + offset), 3013 make_fixnum (search_regs.start[c - '0'] + offset),
3014 make_int (search_regs.end[c - '0'] + offset)); 3014 make_fixnum (search_regs.end[c - '0'] + offset));
3015 } 3015 }
3016 else if (c == 'U' || c == 'u' || c == 'L' || c == 'l' || 3016 else if (c == 'U' || c == 'u' || c == 'L' || c == 'l' ||
3017 c == 'E') 3017 c == 'E')
3018 { 3018 {
3019 /* Keep track of all case changes requested, but don't 3019 /* Keep track of all case changes requested, but don't
3043 inslen = BUF_PT (buf) - (search_regs.start[sub]); 3043 inslen = BUF_PT (buf) - (search_regs.start[sub]);
3044 buffer_delete_range (buf, search_regs.start[sub] + inslen, 3044 buffer_delete_range (buf, search_regs.start[sub] + inslen,
3045 search_regs.end[sub] + inslen, 0); 3045 search_regs.end[sub] + inslen, 0);
3046 3046
3047 if (case_action == all_caps) 3047 if (case_action == all_caps)
3048 Fupcase_region (make_int (BUF_PT (buf) - inslen), 3048 Fupcase_region (make_fixnum (BUF_PT (buf) - inslen),
3049 make_int (BUF_PT (buf)), buffer); 3049 make_fixnum (BUF_PT (buf)), buffer);
3050 else if (case_action == cap_initial) 3050 else if (case_action == cap_initial)
3051 Fupcase_initials_region (make_int (BUF_PT (buf) - inslen), 3051 Fupcase_initials_region (make_fixnum (BUF_PT (buf) - inslen),
3052 make_int (BUF_PT (buf)), buffer); 3052 make_fixnum (BUF_PT (buf)), buffer);
3053 3053
3054 /* Now go through and make all the case changes that were requested 3054 /* Now go through and make all the case changes that were requested
3055 in the replacement string. */ 3055 in the replacement string. */
3056 if (ul_pos_dynarr) 3056 if (ul_pos_dynarr)
3057 { 3057 {
3099 static Lisp_Object 3099 static Lisp_Object
3100 match_limit (Lisp_Object num, int beginningp) 3100 match_limit (Lisp_Object num, int beginningp)
3101 { 3101 {
3102 int n; 3102 int n;
3103 3103
3104 CHECK_INT (num); 3104 CHECK_FIXNUM (num);
3105 n = XINT (num); 3105 n = XFIXNUM (num);
3106 if (n < 0 || n >= search_regs.num_regs) 3106 if (n < 0 || n >= search_regs.num_regs)
3107 args_out_of_range (num, make_int (search_regs.num_regs)); 3107 args_out_of_range (num, make_fixnum (search_regs.num_regs));
3108 if (search_regs.num_regs == 0 || 3108 if (search_regs.num_regs == 0 ||
3109 search_regs.start[n] < 0) 3109 search_regs.start[n] < 0)
3110 return Qnil; 3110 return Qnil;
3111 return make_int (beginningp ? search_regs.start[n] : search_regs.end[n]); 3111 return make_fixnum (beginningp ? search_regs.start[n] : search_regs.end[n]);
3112 } 3112 }
3113 3113
3114 DEFUN ("match-beginning", Fmatch_beginning, 1, 1, 0, /* 3114 DEFUN ("match-beginning", Fmatch_beginning, 1, 1, 0, /*
3115 Return position of start of text matched by last regexp search. 3115 Return position of start of text matched by last regexp search.
3116 NUM, specifies which parenthesized expression in the last regexp. 3116 NUM, specifies which parenthesized expression in the last regexp.
3165 if (start >= 0) 3165 if (start >= 0)
3166 { 3166 {
3167 if (EQ (last_thing_searched, Qt) 3167 if (EQ (last_thing_searched, Qt)
3168 || !NILP (integers)) 3168 || !NILP (integers))
3169 { 3169 {
3170 data[2 * i] = make_int (start); 3170 data[2 * i] = make_fixnum (start);
3171 data[2 * i + 1] = make_int (search_regs.end[i]); 3171 data[2 * i + 1] = make_fixnum (search_regs.end[i]);
3172 } 3172 }
3173 else if (BUFFERP (last_thing_searched)) 3173 else if (BUFFERP (last_thing_searched))
3174 { 3174 {
3175 data[2 * i] = Fmake_marker (); 3175 data[2 * i] = Fmake_marker ();
3176 Fset_marker (data[2 * i], 3176 Fset_marker (data[2 * i],
3177 make_int (start), 3177 make_fixnum (start),
3178 last_thing_searched); 3178 last_thing_searched);
3179 data[2 * i + 1] = Fmake_marker (); 3179 data[2 * i + 1] = Fmake_marker ();
3180 Fset_marker (data[2 * i + 1], 3180 Fset_marker (data[2 * i + 1],
3181 make_int (search_regs.end[i]), 3181 make_fixnum (search_regs.end[i]),
3182 last_thing_searched); 3182 last_thing_searched);
3183 } 3183 }
3184 else 3184 else
3185 /* last_thing_searched must always be Qt, a buffer, or Qnil. */ 3185 /* last_thing_searched must always be Qt, a buffer, or Qnil. */
3186 ABORT (); 3186 ABORT ();
3234 /* Unless we find a marker with a buffer in LIST, assume that this 3234 /* Unless we find a marker with a buffer in LIST, assume that this
3235 match data came from a string. */ 3235 match data came from a string. */
3236 last_thing_searched = Qt; 3236 last_thing_searched = Qt;
3237 3237
3238 /* Allocate registers if they don't already exist. */ 3238 /* Allocate registers if they don't already exist. */
3239 length = XINT (Flength (list)) / 2; 3239 length = XFIXNUM (Flength (list)) / 2;
3240 num_regs = search_regs.num_regs; 3240 num_regs = search_regs.num_regs;
3241 3241
3242 if (length > num_regs) 3242 if (length > num_regs)
3243 { 3243 {
3244 if (search_regs.num_regs == 0) 3244 if (search_regs.num_regs == 0)
3271 marker = Qzero; 3271 marker = Qzero;
3272 else 3272 else
3273 last_thing_searched = wrap_buffer (XMARKER (marker)->buffer); 3273 last_thing_searched = wrap_buffer (XMARKER (marker)->buffer);
3274 } 3274 }
3275 3275
3276 CHECK_INT_COERCE_MARKER (marker); 3276 CHECK_FIXNUM_COERCE_MARKER (marker);
3277 search_regs.start[i] = XINT (marker); 3277 search_regs.start[i] = XFIXNUM (marker);
3278 list = Fcdr (list); 3278 list = Fcdr (list);
3279 3279
3280 marker = Fcar (list); 3280 marker = Fcar (list);
3281 if (MARKERP (marker) && XMARKER (marker)->buffer == 0) 3281 if (MARKERP (marker) && XMARKER (marker)->buffer == 0)
3282 marker = Qzero; 3282 marker = Qzero;
3283 3283
3284 CHECK_INT_COERCE_MARKER (marker); 3284 CHECK_FIXNUM_COERCE_MARKER (marker);
3285 search_regs.end[i] = XINT (marker); 3285 search_regs.end[i] = XFIXNUM (marker);
3286 } 3286 }
3287 list = Fcdr (list); 3287 list = Fcdr (list);
3288 } 3288 }
3289 3289
3290 return Qnil; 3290 return Qnil;