static void Hit_Return(void);
#if ENABLE_FEATURE_VI_SEARCH
-static char *char_search(char *, const char *, int, int); // search for pattern starting at p
+static char *char_search(char *, const char *, int); // search for pattern starting at p
#endif
#if ENABLE_FEATURE_VI_COLON
static char *get_one_address(char *, int *); // get colon addr, if present
p = q;
if (*p == '/')
p++;
- q = char_search(dot, pat, FORWARD, FULL);
+ q = char_search(dot, pat, (FORWARD << 1) | FULL);
if (q != NULL) {
*addr = count_lines(text, q);
}
char *ls = q; // orig line start
char *found;
vc4:
- found = char_search(q, F, FORWARD, LIMITED); // search cur line only for "find"
+ found = char_search(q, F, (FORWARD << 1) | LIMITED); // search cur line only for "find"
if (found) {
uintptr_t bias;
// we found the "find" pattern - delete it
# if ENABLE_FEATURE_VI_REGEX_SEARCH
// search for pattern starting at p
-static char *char_search(char *p, const char *pat, int dir, int range)
+static char *char_search(char *p, const char *pat, int dir_and_range)
{
struct re_pattern_buffer preg;
const char *err;
char *q;
int i;
int size;
+ int range;
re_syntax_options = RE_SYNTAX_POSIX_EXTENDED;
if (ignorecase)
return p;
}
+ range = (dir_and_range & 1);
q = end - 1; // if FULL
if (range == LIMITED)
q = next_line(p);
- if (dir == BACK) {
+ if (dir_and_range < 0) { // BACK?
q = text;
if (range == LIMITED)
q = prev_line(p);
regfree(&preg);
if (i < 0)
return NULL;
- if (dir == FORWARD)
+ if (dir_and_range > 0) // FORWARD?
p = p + i;
else
p = p - i;
# define mycmp strncmp
# endif
-static char *char_search(char *p, const char *pat, int dir, int range)
+static char *char_search(char *p, const char *pat, int dir_and_range)
{
char *start, *stop;
int len;
+ int range;
len = strlen(pat);
- if (dir == FORWARD) {
+ range = (dir_and_range & 1);
+ if (dir_and_range > 0) { //FORWARD?
stop = end - 1; // assume range is p..end-1
if (range == LIMITED)
stop = next_line(p); // range is to next line
return start;
}
}
- } else if (dir == BACK) {
+ } else { //BACK
stop = text; // assume range is text..p
if (range == LIMITED)
stop = prev_line(p); // range is to prev line
p = dot - 1;
}
dc4:
- q = char_search(p, last_search_pattern + 1, dir, FULL);
+ q = char_search(p, last_search_pattern + 1, (dir << 1) | FULL);
if (q != NULL) {
dot = q; // good search, update "dot"
msg = NULL;
if (dir == BACK) {
p = end - 1;
}
- q = char_search(p, last_search_pattern + 1, dir, FULL);
+ q = char_search(p, last_search_pattern + 1, (dir << 1) | FULL);
if (q != NULL) { // found something
dot = q; // found new pattern- goto it
msg = "search hit BOTTOM, continuing at TOP";
} while (--cmdcnt > 0);
break;
case '{': // {- move backward paragraph
- q = char_search(dot, "\n\n", BACK, FULL);
+ q = char_search(dot, "\n\n", (BACK << 1) | FULL);
if (q != NULL) { // found blank line
dot = next_line(q); // move to next blank line
}
break;
case '}': // }- move forward paragraph
- q = char_search(dot, "\n\n", FORWARD, FULL);
+ q = char_search(dot, "\n\n", (FORWARD << 1) | FULL);
if (q != NULL) { // found blank line
dot = next_line(q); // move to next blank line
}