diff options
| author | Juanma Barranquero | 2014-04-25 18:11:07 +0200 |
|---|---|---|
| committer | Juanma Barranquero | 2014-04-25 18:11:07 +0200 |
| commit | dff4a9f6a4e9e42de6177e29faa7e3524b47e6d4 (patch) | |
| tree | 60924b65da522416f928b436f8525f5bc8bfc3d7 /src | |
| parent | 8de17fac97652d77bffd24e41b0097c863bd752b (diff) | |
| parent | 844465d6cac7c243e37e446067b1a2e06be293da (diff) | |
| download | emacs-dff4a9f6a4e9e42de6177e29faa7e3524b47e6d4.tar.gz emacs-dff4a9f6a4e9e42de6177e29faa7e3524b47e6d4.zip | |
Merge from emacs-24; up to 2014-04-25T10:35:01Z!michael.albinus@gmx.de
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/search.c | 56 |
2 files changed, 43 insertions, 19 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 654b9425770..9d4fd2d6d37 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2014-04-25 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * search.c (Fnewline_cache_check): Don't try to count newlines | ||
| 4 | outside the buffer's restriction, as find_newline doesn't support | ||
| 5 | that. | ||
| 6 | |||
| 1 | 2014-04-24 Stefan Monnier <monnier@iro.umontreal.ca> | 7 | 2014-04-24 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 8 | ||
| 3 | * window.c (Fset_window_configuration): Deactivate the mark before | 9 | * window.c (Fset_window_configuration): Deactivate the mark before |
diff --git a/src/search.c b/src/search.c index ee449213ace..dc4820d8588 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -3199,7 +3199,7 @@ the first based on the cache, the second based on actually scanning | |||
| 3199 | the buffer. If the buffer doesn't have a cache, the value is nil. */) | 3199 | the buffer. If the buffer doesn't have a cache, the value is nil. */) |
| 3200 | (Lisp_Object buffer) | 3200 | (Lisp_Object buffer) |
| 3201 | { | 3201 | { |
| 3202 | struct buffer *buf; | 3202 | struct buffer *buf, *old = NULL; |
| 3203 | ptrdiff_t shortage, nl_count_cache, nl_count_buf; | 3203 | ptrdiff_t shortage, nl_count_cache, nl_count_buf; |
| 3204 | Lisp_Object cache_newlines, buf_newlines, val; | 3204 | Lisp_Object cache_newlines, buf_newlines, val; |
| 3205 | ptrdiff_t from, found, i; | 3205 | ptrdiff_t from, found, i; |
| @@ -3210,6 +3210,7 @@ the buffer. If the buffer doesn't have a cache, the value is nil. */) | |||
| 3210 | { | 3210 | { |
| 3211 | CHECK_BUFFER (buffer); | 3211 | CHECK_BUFFER (buffer); |
| 3212 | buf = XBUFFER (buffer); | 3212 | buf = XBUFFER (buffer); |
| 3213 | old = current_buffer; | ||
| 3213 | } | 3214 | } |
| 3214 | if (buf->base_buffer) | 3215 | if (buf->base_buffer) |
| 3215 | buf = buf->base_buffer; | 3216 | buf = buf->base_buffer; |
| @@ -3219,46 +3220,63 @@ the buffer. If the buffer doesn't have a cache, the value is nil. */) | |||
| 3219 | || buf->newline_cache == NULL) | 3220 | || buf->newline_cache == NULL) |
| 3220 | return Qnil; | 3221 | return Qnil; |
| 3221 | 3222 | ||
| 3223 | /* find_newline can only work on the current buffer. */ | ||
| 3224 | if (old != NULL) | ||
| 3225 | set_buffer_internal_1 (buf); | ||
| 3226 | |||
| 3222 | /* How many newlines are there according to the cache? */ | 3227 | /* How many newlines are there according to the cache? */ |
| 3223 | find_newline (BUF_BEG (buf), BUF_BEG_BYTE (buf), | 3228 | find_newline (BEGV, BEGV_BYTE, ZV, ZV_BYTE, |
| 3224 | BUF_Z (buf), BUF_Z_BYTE (buf), | ||
| 3225 | TYPE_MAXIMUM (ptrdiff_t), &shortage, NULL, true); | 3229 | TYPE_MAXIMUM (ptrdiff_t), &shortage, NULL, true); |
| 3226 | nl_count_cache = TYPE_MAXIMUM (ptrdiff_t) - shortage; | 3230 | nl_count_cache = TYPE_MAXIMUM (ptrdiff_t) - shortage; |
| 3227 | 3231 | ||
| 3228 | /* Create vector and populate it. */ | 3232 | /* Create vector and populate it. */ |
| 3229 | cache_newlines = make_uninit_vector (nl_count_cache); | 3233 | cache_newlines = make_uninit_vector (nl_count_cache); |
| 3230 | for (from = BUF_BEG( buf), found = from, i = 0; | 3234 | |
| 3231 | from < BUF_Z (buf); | 3235 | if (nl_count_cache) |
| 3232 | from = found, i++) | ||
| 3233 | { | 3236 | { |
| 3234 | ptrdiff_t from_byte = CHAR_TO_BYTE (from); | 3237 | for (from = BEGV, found = from, i = 0; from < ZV; from = found, i++) |
| 3238 | { | ||
| 3239 | ptrdiff_t from_byte = CHAR_TO_BYTE (from); | ||
| 3235 | 3240 | ||
| 3236 | found = find_newline (from, from_byte, 0, -1, 1, &shortage, NULL, true); | 3241 | found = find_newline (from, from_byte, 0, -1, 1, &shortage, |
| 3237 | if (shortage == 0) | 3242 | NULL, true); |
| 3238 | ASET (cache_newlines, i, make_number (found - 1)); | 3243 | if (shortage != 0 || i >= nl_count_cache) |
| 3244 | break; | ||
| 3245 | ASET (cache_newlines, i, make_number (found - 1)); | ||
| 3246 | } | ||
| 3247 | /* Fill the rest of slots with an invalid position. */ | ||
| 3248 | for ( ; i < nl_count_cache; i++) | ||
| 3249 | ASET (cache_newlines, i, make_number (-1)); | ||
| 3239 | } | 3250 | } |
| 3240 | 3251 | ||
| 3241 | /* Now do the same, but without using the cache. */ | 3252 | /* Now do the same, but without using the cache. */ |
| 3242 | find_newline1 (BUF_BEG (buf), BUF_BEG_BYTE (buf), | 3253 | find_newline1 (BEGV, BEGV_BYTE, ZV, ZV_BYTE, |
| 3243 | BUF_Z (buf), BUF_Z_BYTE (buf), | ||
| 3244 | TYPE_MAXIMUM (ptrdiff_t), &shortage, NULL, true); | 3254 | TYPE_MAXIMUM (ptrdiff_t), &shortage, NULL, true); |
| 3245 | nl_count_buf = TYPE_MAXIMUM (ptrdiff_t) - shortage; | 3255 | nl_count_buf = TYPE_MAXIMUM (ptrdiff_t) - shortage; |
| 3246 | buf_newlines = make_uninit_vector (nl_count_buf); | 3256 | buf_newlines = make_uninit_vector (nl_count_buf); |
| 3247 | for (from = BUF_BEG( buf), found = from, i = 0; | 3257 | if (nl_count_buf) |
| 3248 | from < BUF_Z (buf); | ||
| 3249 | from = found, i++) | ||
| 3250 | { | 3258 | { |
| 3251 | ptrdiff_t from_byte = CHAR_TO_BYTE (from); | 3259 | for (from = BEGV, found = from, i = 0; from < ZV; from = found, i++) |
| 3260 | { | ||
| 3261 | ptrdiff_t from_byte = CHAR_TO_BYTE (from); | ||
| 3252 | 3262 | ||
| 3253 | found = find_newline1 (from, from_byte, 0, -1, 1, &shortage, NULL, true); | 3263 | found = find_newline1 (from, from_byte, 0, -1, 1, &shortage, |
| 3254 | if (shortage == 0) | 3264 | NULL, true); |
| 3255 | ASET (buf_newlines, i, make_number (found - 1)); | 3265 | if (shortage != 0 || i >= nl_count_buf) |
| 3266 | break; | ||
| 3267 | ASET (buf_newlines, i, make_number (found - 1)); | ||
| 3268 | } | ||
| 3269 | for ( ; i < nl_count_buf; i++) | ||
| 3270 | ASET (buf_newlines, i, make_number (-1)); | ||
| 3256 | } | 3271 | } |
| 3257 | 3272 | ||
| 3258 | /* Construct the value and return it. */ | 3273 | /* Construct the value and return it. */ |
| 3259 | val = make_uninit_vector (2); | 3274 | val = make_uninit_vector (2); |
| 3260 | ASET (val, 0, cache_newlines); | 3275 | ASET (val, 0, cache_newlines); |
| 3261 | ASET (val, 1, buf_newlines); | 3276 | ASET (val, 1, buf_newlines); |
| 3277 | |||
| 3278 | if (old != NULL) | ||
| 3279 | set_buffer_internal_1 (old); | ||
| 3262 | return val; | 3280 | return val; |
| 3263 | } | 3281 | } |
| 3264 | 3282 | ||