summaryrefslogtreecommitdiff
path: root/src/search.c
diff options
context:
space:
mode:
authorDmitry Antipov <dmantipov@yandex.ru>2013-03-08 13:34:35 +0400
committerDmitry Antipov <dmantipov@yandex.ru>2013-03-08 13:34:35 +0400
commitb5426561089d39f18b42bed9dbfcb531f43ed562 (patch)
treeea345a9966321890c6abc989182429a5f76de121 /src/search.c
parentc3e2de4c1a98a45557008700c3e0a654ecdbe447 (diff)
downloademacs-b5426561089d39f18b42bed9dbfcb531f43ed562.tar.gz
* search.c (find_newline): Accept start and end byte positions
as arguments and allow -1 if not known. (find_newline_no_quit): Likewise for start position. * lisp.h (find_newline, find_newline_no_quit): Adjust prototype. * bidi.c (bidi_find_paragraph_start): Pass byte position to find_newline_no_quit, thus eliminating CHAR_TO_BYTE. * editfns.c (Fconstrain_to_field): Break long line. Adjust call to find_newline. * indent.c (vmotion): Adjust calls to find_newline_no_quit. Use DEC_BOTH to start next search from the previous buffer position, where appropriate. * xdisp.c (back_to_previous_line_start, forward_to_next_line_start) (get_visually_first_element, move_it_vertically_backward): Likewise. Obtain byte position from the display iterator, where appropriate.
Diffstat (limited to 'src/search.c')
-rw-r--r--src/search.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/search.c b/src/search.c
index 090965ead3b..8bcf556eeeb 100644
--- a/src/search.c
+++ b/src/search.c
@@ -621,7 +621,7 @@ newline_cache_on_off (struct buffer *buf)
}
-/* Search for COUNT newlines between START and END.
+/* Search for COUNT newlines between START/START_BYTE and END/END_BYTE.
If COUNT is positive, search forwards; END must be >= START.
If COUNT is negative, search backwards for the -COUNTth instance;
@@ -645,11 +645,11 @@ newline_cache_on_off (struct buffer *buf)
except when inside redisplay. */
ptrdiff_t
-find_newline (ptrdiff_t start, ptrdiff_t end, ptrdiff_t count,
- ptrdiff_t *shortage, ptrdiff_t *bytepos, bool allow_quit)
+find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
+ ptrdiff_t end_byte, ptrdiff_t count, ptrdiff_t *shortage,
+ ptrdiff_t *bytepos, bool allow_quit)
{
struct region_cache *newline_cache;
- ptrdiff_t start_byte = -1, end_byte = -1;
int direction;
if (count > 0)
@@ -706,7 +706,7 @@ find_newline (ptrdiff_t start, ptrdiff_t end, ptrdiff_t count,
next_change is the position of the next known region. */
ceiling_byte = min (CHAR_TO_BYTE (next_change) - 1, ceiling_byte);
}
- else
+ else if (start_byte == -1)
start_byte = CHAR_TO_BYTE (start);
/* The dumb loop can only scan text stored in contiguous
@@ -783,7 +783,7 @@ find_newline (ptrdiff_t start, ptrdiff_t end, ptrdiff_t count,
next_change is the position of the next known region. */
ceiling_byte = max (CHAR_TO_BYTE (next_change), ceiling_byte);
}
- else
+ else if (start_byte == -1)
start_byte = CHAR_TO_BYTE (start);
/* Stop scanning before the gap. */
@@ -944,9 +944,10 @@ scan_newline (ptrdiff_t start, ptrdiff_t start_byte,
/* Like find_newline, but doesn't allow QUITting and doesn't return
SHORTAGE. */
ptrdiff_t
-find_newline_no_quit (ptrdiff_t from, ptrdiff_t cnt, ptrdiff_t *bytepos)
+find_newline_no_quit (ptrdiff_t from, ptrdiff_t frombyte,
+ ptrdiff_t cnt, ptrdiff_t *bytepos)
{
- return find_newline (from, 0, cnt, NULL, bytepos, 0);
+ return find_newline (from, frombyte, 0, -1, cnt, NULL, bytepos, 0);
}
/* Like find_newline, but returns position before the newline, not
@@ -958,7 +959,7 @@ find_before_next_newline (ptrdiff_t from, ptrdiff_t to,
ptrdiff_t cnt, ptrdiff_t *bytepos)
{
ptrdiff_t shortage;
- ptrdiff_t pos = find_newline (from, to, cnt, &shortage, bytepos, 1);
+ ptrdiff_t pos = find_newline (from, -1, to, -1, cnt, &shortage, bytepos, 1);
if (shortage == 0)
{