[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs qe.h qe.c
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs qe.h qe.c |
Date: |
Sun, 16 Aug 2015 17:52:14 +0000 |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 15/08/16 17:52:14
Modified files:
. : qe.h qe.c
Log message:
search: some fixes
- fix case matching cycling with C-c and A-c in incremental search
- use smartcase for search-forward and search-backward
- display status for search-forward and search-backward failures
- eb_search returns -1 upon abort
- make eb_search and search_abort_func private;
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.195&r2=1.196
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.198&r2=1.199
Patches:
Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.195
retrieving revision 1.196
diff -u -b -r1.195 -r1.196
--- qe.h 16 Aug 2015 17:40:41 -0000 1.195
+++ qe.h 16 Aug 2015 17:52:13 -0000 1.196
@@ -1947,11 +1947,6 @@
void do_load_file_from_path(EditState *s, const char *filename, int bflags);
void do_set_visited_file_name(EditState *s, const char *filename,
const char *renamefile);
-int eb_search(EditBuffer *b, int offset, int dir, int flags,
- const unsigned int *buf, int size,
- CSSAbortFunc *abort_func, void *abort_opaque,
- int *found_start, int *found_end);
-int search_abort_func(void *opaque);
void do_doctor(EditState *s);
void do_delete_other_windows(EditState *s);
void do_describe_key_briefly(EditState *s);
Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.198
retrieving revision 1.199
diff -u -b -r1.198 -r1.199
--- qe.c 16 Aug 2015 17:40:40 -0000 1.198
+++ qe.c 16 Aug 2015 17:52:14 -0000 1.199
@@ -6460,7 +6460,7 @@
#define SEARCH_FLAG_UNIHEX 0x0020
/* XXX: OPTIMIZE ! */
-int eb_search(EditBuffer *b, int start_offset, int dir, int flags,
+static int eb_search(EditBuffer *b, int start_offset, int dir, int flags,
const unsigned int *buf, int len,
CSSAbortFunc *abort_func, void *abort_opaque,
int *found_offset, int *found_end)
@@ -6474,6 +6474,18 @@
*found_offset = -1;
*found_end = -1;
+ /* analyze buffer if smart case */
+ if (flags & SEARCH_FLAG_SMARTCASE) {
+ int upper_count = 0;
+ int lower_count = 0;
+ for (pos = 0; pos < len; pos++) {
+ lower_count += qe_islower(buf[pos]);
+ upper_count += qe_isupper(buf[pos]);
+ }
+ if (lower_count > 0 && upper_count == 0)
+ flags |= SEARCH_FLAG_IGNORECASE;
+ }
+
if (flags & SEARCH_FLAG_HEX) {
/* handle buffer as single bytes */
/* XXX: should handle ucs2 and ucs4 as words */
@@ -6486,10 +6498,10 @@
if (offset >= total_size)
return 0;
- if ((offset & 0xfffff) == 0) {
- /* check for search abort every meg */
+ if ((offset & 0x1ffff) == 0) {
+ /* check for search abort every 128k */
if (abort_func && abort_func(abort_opaque))
- return 0;
+ return -1;
}
pos = 0;
@@ -6512,18 +6524,6 @@
}
}
- /* analyze buffer if smart case */
- if (flags & SEARCH_FLAG_SMARTCASE) {
- int upper_count = 0;
- int lower_count = 0;
- for (pos = 0; pos < len; pos++) {
- lower_count += qe_islower(buf[pos]);
- upper_count += qe_isupper(buf[pos]);
- }
- if (lower_count > 0 && upper_count == 0)
- flags |= SEARCH_FLAG_IGNORECASE;
- }
-
for (;; (void)(dir >= 0 && eb_nextc(b, offset, &offset))) {
if (dir < 0) {
if (offset == 0)
@@ -6536,7 +6536,7 @@
if ((offset & 0x1ffff) == 0) {
/* check for search abort every 128k */
if (abort_func && abort_func(abort_opaque))
- return 0;
+ return -1;
}
if (flags & SEARCH_FLAG_WORD) {
@@ -6585,7 +6585,7 @@
static unsigned int last_search_u32[SEARCH_LENGTH];
static int last_search_u32_len = 0;
-int search_abort_func(__unused__ void *opaque)
+static int search_abort_func(__unused__ void *opaque)
{
return is_user_input_pending();
}
@@ -6698,7 +6698,7 @@
} else {
if (eb_search(s->b, search_offset, is->dir, flags,
buf, len, search_abort_func, NULL,
- &is->found_offset, &is->found_end)) {
+ &is->found_offset, &is->found_end) > 0) {
s->region_style = QE_STYLE_SEARCH_MATCH;
if (is->dir > 0) {
s->b->mark = is->found_offset;
@@ -6881,6 +6881,7 @@
} else {
is->search_flags |= SEARCH_FLAG_IGNORECASE;
}
+ is->search_flags &= ~SEARCH_FLAG_SMARTCASE;
break;
case KEY_CTRL('l'):
do_center_cursor(s);
@@ -6931,9 +6932,9 @@
is->pos = 0;
if (s->hex_mode) {
if (s->unihex_mode)
- flags = SEARCH_FLAG_UNIHEX;
+ flags |= SEARCH_FLAG_UNIHEX;
else
- flags = SEARCH_FLAG_HEX;
+ flags |= SEARCH_FLAG_HEX;
}
is->search_flags = flags;
@@ -7035,9 +7036,9 @@
is->replace_str, is->search_flags);
for (;;) {
- if (!eb_search(s->b, is->found_offset, 1, is->search_flags,
+ if (eb_search(s->b, is->found_offset, 1, is->search_flags,
is->search_u32, is->search_u32_len,
- NULL, NULL, &is->found_offset, &is->found_end)) {
+ NULL, NULL, &is->found_offset, &is->found_end) <= 0) {
query_replace_abort(is);
return;
}
@@ -7199,20 +7200,22 @@
unsigned int search_u32[SEARCH_LENGTH];
int search_u32_len;
int found_offset, found_end;
- int flags = 0;
+ int flags = SEARCH_FLAG_SMARTCASE;
if (s->hex_mode) {
if (s->unihex_mode)
- flags = SEARCH_FLAG_UNIHEX;
+ flags |= SEARCH_FLAG_UNIHEX;
else
- flags = SEARCH_FLAG_HEX;
+ flags |= SEARCH_FLAG_HEX;
}
search_u32_len = search_to_u32(search_u32, countof(search_u32),
search_str, flags);
if (eb_search(s->b, s->offset, dir, flags, search_u32, search_u32_len,
- NULL, NULL, &found_offset, &found_end)) {
+ NULL, NULL, &found_offset, &found_end) > 0) {
s->offset = (dir < 0) ? found_offset : found_end;
do_center_cursor_maybe(s);
+ } else {
+ put_status(s, "Search failed: \"%s\"", search_str);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs qe.h qe.c,
Charlie Gordon <=