Mercurial > hg > xemacs-beta
comparison src/line-number.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 | 308d34e9f07d |
children | bd4d2c8ef9cc |
comparison
equal
deleted
inserted
replaced
5580:a0e81357194e | 5581:56144c8593a8 |
---|---|
109 LINE_NUMBER_BEGV (b) = Qzero; | 109 LINE_NUMBER_BEGV (b) = Qzero; |
110 else | 110 else |
111 /* Calculating the line number of BUF_BEGV here is a bad idea, | 111 /* Calculating the line number of BUF_BEGV here is a bad idea, |
112 because there is absolutely no reason to do it before the next | 112 because there is absolutely no reason to do it before the next |
113 redisplay. We simply mark it as dirty instead. */ | 113 redisplay. We simply mark it as dirty instead. */ |
114 LINE_NUMBER_BEGV (b) = make_int (-1); | 114 LINE_NUMBER_BEGV (b) = make_fixnum (-1); |
115 } | 115 } |
116 | 116 |
117 /* Invalidate the line number cache positions that lie after POS. */ | 117 /* Invalidate the line number cache positions that lie after POS. */ |
118 static void | 118 static void |
119 invalidate_line_number_cache (struct buffer *b, Charbpos pos) | 119 invalidate_line_number_cache (struct buffer *b, Charbpos pos) |
197 (i.e. BUF_BEGV, and cached positions). The return position will be | 197 (i.e. BUF_BEGV, and cached positions). The return position will be |
198 either closer than BEG, or BEG. The line of this known position | 198 either closer than BEG, or BEG. The line of this known position |
199 will be stored in LINE. | 199 will be stored in LINE. |
200 | 200 |
201 *LINE should be initialized to the line number of BEG (normally, | 201 *LINE should be initialized to the line number of BEG (normally, |
202 BEG will be BUF_BEGV, and *LINE will be XINT (LINE_NUMBER_BEGV). | 202 BEG will be BUF_BEGV, and *LINE will be XFIXNUM (LINE_NUMBER_BEGV). |
203 This will initialize the cache, if necessary. */ | 203 This will initialize the cache, if necessary. */ |
204 static void | 204 static void |
205 get_nearest_line_number (struct buffer *b, Charbpos *beg, Charbpos pos, | 205 get_nearest_line_number (struct buffer *b, Charbpos *beg, Charbpos pos, |
206 EMACS_INT *line) | 206 EMACS_INT *line) |
207 { | 207 { |
221 howfar = -howfar; | 221 howfar = -howfar; |
222 if (howfar < length) | 222 if (howfar < length) |
223 { | 223 { |
224 length = howfar; | 224 length = howfar; |
225 *beg = newpos; | 225 *beg = newpos; |
226 *line = XINT (XCDR (ring[i])); | 226 *line = XFIXNUM (XCDR (ring[i])); |
227 } | 227 } |
228 } | 228 } |
229 } | 229 } |
230 | 230 |
231 /* Add a (POS . LINE) pair to the ring, and rotate it. */ | 231 /* Add a (POS . LINE) pair to the ring, and rotate it. */ |
242 /* Rotate the ring... */ | 242 /* Rotate the ring... */ |
243 for (; i > 0; i--) | 243 for (; i > 0; i--) |
244 ring[i] = ring[i - 1]; | 244 ring[i] = ring[i - 1]; |
245 | 245 |
246 /* ...and update it. */ | 246 /* ...and update it. */ |
247 ring[0] = Fcons (Fset_marker (Fmake_marker (), make_int (pos), | 247 ring[0] = Fcons (Fset_marker (Fmake_marker (), make_fixnum (pos), |
248 wrap_buffer (b)), | 248 wrap_buffer (b)), |
249 make_int (line)); | 249 make_fixnum (line)); |
250 } | 250 } |
251 | 251 |
252 /* Calculate the line number in buffer B at position POS. If CACHEP | 252 /* Calculate the line number in buffer B at position POS. If CACHEP |
253 is non-zero, initialize and facilitate the line-number cache. The | 253 is non-zero, initialize and facilitate the line-number cache. The |
254 line number of the first line is 0. If narrowing is in effect, | 254 line number of the first line is 0. If narrowing is in effect, |
278 if (cachep) | 278 if (cachep) |
279 { | 279 { |
280 if (NILP (b->text->line_number_cache)) | 280 if (NILP (b->text->line_number_cache)) |
281 allocate_line_number_cache (b); | 281 allocate_line_number_cache (b); |
282 /* If we don't know the line number of BUF_BEGV, calculate it now. */ | 282 /* If we don't know the line number of BUF_BEGV, calculate it now. */ |
283 if (XINT (LINE_NUMBER_BEGV (b)) == -1) | 283 if (XFIXNUM (LINE_NUMBER_BEGV (b)) == -1) |
284 { | 284 { |
285 LINE_NUMBER_BEGV (b) = Qzero; | 285 LINE_NUMBER_BEGV (b) = Qzero; |
286 /* #### This has a side-effect of changing the cache. */ | 286 /* #### This has a side-effect of changing the cache. */ |
287 LINE_NUMBER_BEGV (b) = | 287 LINE_NUMBER_BEGV (b) = |
288 make_int (buffer_line_number (b, BUF_BEGV (b), 1)); | 288 make_fixnum (buffer_line_number (b, BUF_BEGV (b), 1)); |
289 } | 289 } |
290 cached_lines = XINT (LINE_NUMBER_BEGV (b)); | 290 cached_lines = XFIXNUM (LINE_NUMBER_BEGV (b)); |
291 get_nearest_line_number (b, &beg, pos, &cached_lines); | 291 get_nearest_line_number (b, &beg, pos, &cached_lines); |
292 } | 292 } |
293 | 293 |
294 scan_buffer (b, '\n', beg, pos, pos > beg ? EMACS_INT_MAX : -EMACS_INT_MAX, | 294 scan_buffer (b, '\n', beg, pos, pos > beg ? MOST_POSITIVE_FIXNUM : -MOST_POSITIVE_FIXNUM, |
295 &shortage, 0); | 295 &shortage, 0); |
296 | 296 |
297 line = EMACS_INT_MAX - shortage; | 297 line = MOST_POSITIVE_FIXNUM - shortage; |
298 if (beg > pos) | 298 if (beg > pos) |
299 line = -line; | 299 line = -line; |
300 line += cached_lines; | 300 line += cached_lines; |
301 | 301 |
302 if (cachep) | 302 if (cachep) |
304 /* If too far, update the cache. */ | 304 /* If too far, update the cache. */ |
305 if ((pos > beg ? pos - beg : beg - pos) > LINE_NUMBER_FAR) | 305 if ((pos > beg ? pos - beg : beg - pos) > LINE_NUMBER_FAR) |
306 add_position_to_cache (b, pos, line); | 306 add_position_to_cache (b, pos, line); |
307 /* Account for narrowing. If cache is not used, this is | 307 /* Account for narrowing. If cache is not used, this is |
308 unnecessary, because we counted from BUF_BEGV anyway. */ | 308 unnecessary, because we counted from BUF_BEGV anyway. */ |
309 line -= XINT (LINE_NUMBER_BEGV (b)); | 309 line -= XFIXNUM (LINE_NUMBER_BEGV (b)); |
310 } | 310 } |
311 | 311 |
312 return line; | 312 return line; |
313 } | 313 } |