assume regex.h support is always available
Now that we pull in the gnulib regex module, we can assume it exists.master
parent
63cae0c199
commit
3deec4352b
|
@ -9,6 +9,7 @@ modules="
|
||||||
getline
|
getline
|
||||||
isblank
|
isblank
|
||||||
iswblank
|
iswblank
|
||||||
|
regex
|
||||||
strcase
|
strcase
|
||||||
strcasestr-simple
|
strcasestr-simple
|
||||||
strnlen
|
strnlen
|
||||||
|
|
10
configure.ac
10
configure.ac
|
@ -54,7 +54,7 @@ AC_DEFINE_DIR([PKGDATADIR], [pkgdatadir], [Where data are placed to.])
|
||||||
|
|
||||||
dnl Checks for header files.
|
dnl Checks for header files.
|
||||||
|
|
||||||
AC_CHECK_HEADERS(getopt.h libintl.h limits.h regex.h sys/param.h wchar.h wctype.h stdarg.h)
|
AC_CHECK_HEADERS(getopt.h libintl.h limits.h sys/param.h wchar.h wctype.h stdarg.h)
|
||||||
|
|
||||||
dnl Checks for options.
|
dnl Checks for options.
|
||||||
|
|
||||||
|
@ -76,17 +76,9 @@ if test "x$enable_nanorc" = xno; then
|
||||||
fi
|
fi
|
||||||
if test "x$enable_color" = xno; then
|
if test "x$enable_color" = xno; then
|
||||||
AC_DEFINE(DISABLE_COLOR, 1, [Define this to disable syntax highlighting.])
|
AC_DEFINE(DISABLE_COLOR, 1, [Define this to disable syntax highlighting.])
|
||||||
else
|
|
||||||
if test x$ac_cv_header_regex_h != xyes; then
|
|
||||||
AC_MSG_ERROR([
|
|
||||||
*** The header file regex.h was not found. If you wish to have
|
|
||||||
*** color support, this header file is required. Please either
|
|
||||||
*** install C libraries that include the regex.h file, or call
|
|
||||||
*** the configure script with --disable-color.])
|
|
||||||
else
|
else
|
||||||
color_support=yes
|
color_support=yes
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(comment,
|
AC_ARG_ENABLE(comment,
|
||||||
AS_HELP_STRING([--disable-comment], [Disable comment/uncomment functions]))
|
AS_HELP_STRING([--disable-comment], [Disable comment/uncomment functions]))
|
||||||
|
|
13
src/global.c
13
src/global.c
|
@ -124,17 +124,12 @@ char *brackets = NULL;
|
||||||
* can end sentences. */
|
* can end sentences. */
|
||||||
char *quotestr = NULL;
|
char *quotestr = NULL;
|
||||||
/* The quoting string. The default value is set in main(). */
|
/* The quoting string. The default value is set in main(). */
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
regex_t quotereg;
|
regex_t quotereg;
|
||||||
/* The compiled regular expression from the quoting string. */
|
/* The compiled regular expression from the quoting string. */
|
||||||
int quoterc;
|
int quoterc;
|
||||||
/* Whether it was compiled successfully. */
|
/* Whether it was compiled successfully. */
|
||||||
char *quoteerr = NULL;
|
char *quoteerr = NULL;
|
||||||
/* The error message, if it didn't. */
|
/* The error message, if it didn't. */
|
||||||
#else
|
|
||||||
size_t quotelen;
|
|
||||||
/* The length of the quoting string in bytes. */
|
|
||||||
#endif
|
|
||||||
#endif /* !DISABLE_JUSTIFY */
|
#endif /* !DISABLE_JUSTIFY */
|
||||||
|
|
||||||
char *word_chars = NULL;
|
char *word_chars = NULL;
|
||||||
|
@ -212,13 +207,11 @@ poshiststruct *position_history = NULL;
|
||||||
/* The cursor position history list. */
|
/* The cursor position history list. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
regex_t search_regexp;
|
regex_t search_regexp;
|
||||||
/* The compiled regular expression to use in searches. */
|
/* The compiled regular expression to use in searches. */
|
||||||
regmatch_t regmatches[10];
|
regmatch_t regmatches[10];
|
||||||
/* The match positions for parenthetical subexpressions, 10
|
/* The match positions for parenthetical subexpressions, 10
|
||||||
* maximum, used in regular expression searches. */
|
* maximum, used in regular expression searches. */
|
||||||
#endif
|
|
||||||
|
|
||||||
int hilite_attribute = A_REVERSE;
|
int hilite_attribute = A_REVERSE;
|
||||||
/* The curses attribute we use to highlight something. */
|
/* The curses attribute we use to highlight something. */
|
||||||
|
@ -605,10 +598,8 @@ void shortcut_init(void)
|
||||||
N_("Toggle the case sensitivity of the search");
|
N_("Toggle the case sensitivity of the search");
|
||||||
const char *nano_reverse_msg =
|
const char *nano_reverse_msg =
|
||||||
N_("Reverse the direction of the search");
|
N_("Reverse the direction of the search");
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
const char *nano_regexp_msg =
|
const char *nano_regexp_msg =
|
||||||
N_("Toggle the use of regular expressions");
|
N_("Toggle the use of regular expressions");
|
||||||
#endif
|
|
||||||
#ifndef DISABLE_HISTORIES
|
#ifndef DISABLE_HISTORIES
|
||||||
const char *nano_prev_history_msg =
|
const char *nano_prev_history_msg =
|
||||||
N_("Recall the previous search/replace string");
|
N_("Recall the previous search/replace string");
|
||||||
|
@ -765,10 +756,8 @@ void shortcut_init(void)
|
||||||
|
|
||||||
add_to_funcs(case_sens_void, MWHEREIS|MREPLACE,
|
add_to_funcs(case_sens_void, MWHEREIS|MREPLACE,
|
||||||
N_("Case Sens"), IFSCHELP(nano_case_msg), TOGETHER, VIEW);
|
N_("Case Sens"), IFSCHELP(nano_case_msg), TOGETHER, VIEW);
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
add_to_funcs(regexp_void, MWHEREIS|MREPLACE,
|
add_to_funcs(regexp_void, MWHEREIS|MREPLACE,
|
||||||
N_("Regexp"), IFSCHELP(nano_regexp_msg), TOGETHER, VIEW);
|
N_("Regexp"), IFSCHELP(nano_regexp_msg), TOGETHER, VIEW);
|
||||||
#endif
|
|
||||||
add_to_funcs(backwards_void, MWHEREIS|MREPLACE,
|
add_to_funcs(backwards_void, MWHEREIS|MREPLACE,
|
||||||
N_("Backwards"), IFSCHELP(nano_reverse_msg), TOGETHER, VIEW);
|
N_("Backwards"), IFSCHELP(nano_reverse_msg), TOGETHER, VIEW);
|
||||||
|
|
||||||
|
@ -1697,11 +1686,9 @@ void thanks_for_all_the_fish(void)
|
||||||
free(word_chars);
|
free(word_chars);
|
||||||
#ifndef DISABLE_JUSTIFY
|
#ifndef DISABLE_JUSTIFY
|
||||||
free(quotestr);
|
free(quotestr);
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
regfree("ereg);
|
regfree("ereg);
|
||||||
free(quoteerr);
|
free(quoteerr);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
free(backup_dir);
|
free(backup_dir);
|
||||||
#endif
|
#endif
|
||||||
|
|
12
src/nano.c
12
src/nano.c
|
@ -2421,14 +2421,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* If quotestr wasn't specified, set its default value. */
|
/* If quotestr wasn't specified, set its default value. */
|
||||||
if (quotestr == NULL)
|
if (quotestr == NULL)
|
||||||
quotestr = mallocstrcpy(NULL,
|
quotestr = mallocstrcpy(NULL, "^([ \t]*[#:>|}])+");
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
"^([ \t]*[#:>|}])+"
|
|
||||||
#else
|
|
||||||
"> "
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
quoterc = regcomp("ereg, quotestr, NANO_REG_EXTENDED);
|
quoterc = regcomp("ereg, quotestr, NANO_REG_EXTENDED);
|
||||||
|
|
||||||
if (quoterc == 0) {
|
if (quoterc == 0) {
|
||||||
|
@ -2441,9 +2434,6 @@ int main(int argc, char **argv)
|
||||||
quoteerr = charalloc(size);
|
quoteerr = charalloc(size);
|
||||||
regerror(quoterc, "ereg, quoteerr, size);
|
regerror(quoterc, "ereg, quoteerr, size);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
quotelen = strlen(quotestr);
|
|
||||||
#endif /* !HAVE_REGEX_H */
|
|
||||||
#endif /* !DISABLE_JUSTIFY */
|
#endif /* !DISABLE_JUSTIFY */
|
||||||
|
|
||||||
#ifndef DISABLE_SPELLER
|
#ifndef DISABLE_SPELLER
|
||||||
|
|
|
@ -116,9 +116,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#endif
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
12
src/proto.h
12
src/proto.h
|
@ -100,13 +100,9 @@ extern const char *unjust_tag;
|
||||||
extern char *punct;
|
extern char *punct;
|
||||||
extern char *brackets;
|
extern char *brackets;
|
||||||
extern char *quotestr;
|
extern char *quotestr;
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
extern regex_t quotereg;
|
extern regex_t quotereg;
|
||||||
extern int quoterc;
|
extern int quoterc;
|
||||||
extern char *quoteerr;
|
extern char *quoteerr;
|
||||||
#else
|
|
||||||
extern size_t quotelen;
|
|
||||||
#endif
|
|
||||||
#endif /* !DISABLE_JUSTIFY */
|
#endif /* !DISABLE_JUSTIFY */
|
||||||
|
|
||||||
extern char *word_chars;
|
extern char *word_chars;
|
||||||
|
@ -154,10 +150,8 @@ extern filestruct *replacebot;
|
||||||
extern poshiststruct *position_history;
|
extern poshiststruct *position_history;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
extern regex_t search_regexp;
|
extern regex_t search_regexp;
|
||||||
extern regmatch_t regmatches[10];
|
extern regmatch_t regmatches[10];
|
||||||
#endif
|
|
||||||
|
|
||||||
extern int hilite_attribute;
|
extern int hilite_attribute;
|
||||||
#ifndef DISABLE_COLOR
|
#ifndef DISABLE_COLOR
|
||||||
|
@ -513,10 +507,8 @@ void do_rcfiles(void);
|
||||||
#endif /* !DISABLE_NANORC */
|
#endif /* !DISABLE_NANORC */
|
||||||
|
|
||||||
/* All functions in search.c. */
|
/* All functions in search.c. */
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
bool regexp_init(const char *regexp);
|
bool regexp_init(const char *regexp);
|
||||||
void regexp_cleanup(void);
|
void regexp_cleanup(void);
|
||||||
#endif
|
|
||||||
void not_found_msg(const char *str);
|
void not_found_msg(const char *str);
|
||||||
void search_replace_abort(void);
|
void search_replace_abort(void);
|
||||||
int search_init(bool replacing, bool use_answer);
|
int search_init(bool replacing, bool use_answer);
|
||||||
|
@ -529,9 +521,7 @@ void do_findnext(void);
|
||||||
#endif
|
#endif
|
||||||
void do_research(void);
|
void do_research(void);
|
||||||
void go_looking(void);
|
void go_looking(void);
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
int replace_regexp(char *string, bool create);
|
int replace_regexp(char *string, bool create);
|
||||||
#endif
|
|
||||||
char *replace_line(const char *needle);
|
char *replace_line(const char *needle);
|
||||||
ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||||
const filestruct *real_current, size_t *real_current_x);
|
const filestruct *real_current, size_t *real_current_x);
|
||||||
|
@ -646,9 +636,7 @@ void snuggly_fit(char **str);
|
||||||
void null_at(char **data, size_t index);
|
void null_at(char **data, size_t index);
|
||||||
void unsunder(char *str, size_t true_len);
|
void unsunder(char *str, size_t true_len);
|
||||||
void sunder(char *str);
|
void sunder(char *str);
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
const char *fixbounds(const char *r);
|
const char *fixbounds(const char *r);
|
||||||
#endif
|
|
||||||
#ifndef DISABLE_SPELLER
|
#ifndef DISABLE_SPELLER
|
||||||
bool is_separate_word(size_t position, size_t length, const char *buf);
|
bool is_separate_word(size_t position, size_t length, const char *buf);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -79,9 +79,7 @@ static const rcoption rcopts[] = {
|
||||||
#endif
|
#endif
|
||||||
{"rebinddelete", REBIND_DELETE},
|
{"rebinddelete", REBIND_DELETE},
|
||||||
{"rebindkeypad", REBIND_KEYPAD},
|
{"rebindkeypad", REBIND_KEYPAD},
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
{"regexp", USE_REGEXP},
|
{"regexp", USE_REGEXP},
|
||||||
#endif
|
|
||||||
#ifndef DISABLE_SPELLER
|
#ifndef DISABLE_SPELLER
|
||||||
{"speller", 0},
|
{"speller", 0},
|
||||||
#endif
|
#endif
|
||||||
|
|
34
src/search.c
34
src/search.c
|
@ -35,7 +35,6 @@ static bool came_full_circle = FALSE;
|
||||||
static bool history_changed = FALSE;
|
static bool history_changed = FALSE;
|
||||||
/* Have any of the history lists changed? */
|
/* Have any of the history lists changed? */
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
static bool regexp_compiled = FALSE;
|
static bool regexp_compiled = FALSE;
|
||||||
/* Have we compiled any regular expressions? */
|
/* Have we compiled any regular expressions? */
|
||||||
|
|
||||||
|
@ -72,7 +71,6 @@ void regexp_cleanup(void)
|
||||||
regfree(&search_regexp);
|
regfree(&search_regexp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Indicate on the statusbar that the string at str was not found by the
|
/* Indicate on the statusbar that the string at str was not found by the
|
||||||
* last search. */
|
* last search. */
|
||||||
|
@ -102,9 +100,7 @@ void search_replace_abort(void)
|
||||||
if (openfile->mark_set)
|
if (openfile->mark_set)
|
||||||
refresh_needed = TRUE;
|
refresh_needed = TRUE;
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
regexp_cleanup();
|
regexp_cleanup();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set up the system variables for a search or replace. If use_answer
|
/* Set up the system variables for a search or replace. If use_answer
|
||||||
|
@ -156,10 +152,7 @@ int search_init(bool replacing, bool use_answer)
|
||||||
edit_refresh, "%s%s%s%s%s%s", _("Search"),
|
edit_refresh, "%s%s%s%s%s%s", _("Search"),
|
||||||
/* TRANSLATORS: The next three modify the search prompt. */
|
/* TRANSLATORS: The next three modify the search prompt. */
|
||||||
ISSET(CASE_SENSITIVE) ? _(" [Case Sensitive]") : "",
|
ISSET(CASE_SENSITIVE) ? _(" [Case Sensitive]") : "",
|
||||||
#ifdef HAVE_REGEX_H
|
ISSET(USE_REGEXP) ? _(" [Regexp]") : "",
|
||||||
ISSET(USE_REGEXP) ? _(" [Regexp]") :
|
|
||||||
#endif
|
|
||||||
"",
|
|
||||||
ISSET(BACKWARDS_SEARCH) ? _(" [Backwards]") : "", replacing ?
|
ISSET(BACKWARDS_SEARCH) ? _(" [Backwards]") : "", replacing ?
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
/* TRANSLATORS: The next two modify the search prompt. */
|
/* TRANSLATORS: The next two modify the search prompt. */
|
||||||
|
@ -189,11 +182,9 @@ int search_init(bool replacing, bool use_answer)
|
||||||
update_history(&search_history, answer);
|
update_history(&search_history, answer);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
if (ISSET(USE_REGEXP) && !regexp_init(last_search))
|
if (ISSET(USE_REGEXP) && !regexp_init(last_search))
|
||||||
return -1;
|
return -1;
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
return 0; /* We have a valid string or regex. */
|
return 0; /* We have a valid string or regex. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,15 +198,11 @@ int search_init(bool replacing, bool use_answer)
|
||||||
TOGGLE(BACKWARDS_SEARCH);
|
TOGGLE(BACKWARDS_SEARCH);
|
||||||
backupstring = mallocstrcpy(backupstring, answer);
|
backupstring = mallocstrcpy(backupstring, answer);
|
||||||
return 1;
|
return 1;
|
||||||
} else
|
} else if (func == regexp_void) {
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
if (func == regexp_void) {
|
|
||||||
TOGGLE(USE_REGEXP);
|
TOGGLE(USE_REGEXP);
|
||||||
backupstring = mallocstrcpy(backupstring, answer);
|
backupstring = mallocstrcpy(backupstring, answer);
|
||||||
return 1;
|
return 1;
|
||||||
} else
|
} else if (func == do_replace || func == flip_replace_void) {
|
||||||
#endif
|
|
||||||
if (func == do_replace || func == flip_replace_void) {
|
|
||||||
backupstring = mallocstrcpy(backupstring, answer);
|
backupstring = mallocstrcpy(backupstring, answer);
|
||||||
return -2; /* Call the opposite search function. */
|
return -2; /* Call the opposite search function. */
|
||||||
} else if (func == do_gotolinecolumn_void) {
|
} else if (func == do_gotolinecolumn_void) {
|
||||||
|
@ -297,11 +284,9 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found != NULL) {
|
if (found != NULL) {
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
/* When doing a regex search, compute the length of the match. */
|
/* When doing a regex search, compute the length of the match. */
|
||||||
if (ISSET(USE_REGEXP))
|
if (ISSET(USE_REGEXP))
|
||||||
found_len = regmatches[0].rm_eo - regmatches[0].rm_so;
|
found_len = regmatches[0].rm_eo - regmatches[0].rm_so;
|
||||||
#endif
|
|
||||||
#ifndef DISABLE_SPELLER
|
#ifndef DISABLE_SPELLER
|
||||||
/* When we're spell checking, a match should be a separate word;
|
/* When we're spell checking, a match should be a separate word;
|
||||||
* if it's not, continue looking in the rest of the line. */
|
* if it's not, continue looking in the rest of the line. */
|
||||||
|
@ -438,10 +423,8 @@ void do_research(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
if (ISSET(USE_REGEXP) && !regexp_init(last_search))
|
if (ISSET(USE_REGEXP) && !regexp_init(last_search))
|
||||||
return;
|
return;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Use the search-menu key bindings, to allow cancelling. */
|
/* Use the search-menu key bindings, to allow cancelling. */
|
||||||
currmenu = MWHEREIS;
|
currmenu = MWHEREIS;
|
||||||
|
@ -479,7 +462,6 @@ void go_looking(void)
|
||||||
search_replace_abort();
|
search_replace_abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
/* Calculate the size of the replacement text, taking possible
|
/* Calculate the size of the replacement text, taking possible
|
||||||
* subexpressions \1 to \9 into account. Return the replacement
|
* subexpressions \1 to \9 into account. Return the replacement
|
||||||
* text in the passed string only when create is TRUE. */
|
* text in the passed string only when create is TRUE. */
|
||||||
|
@ -522,7 +504,6 @@ int replace_regexp(char *string, bool create)
|
||||||
|
|
||||||
return replacement_size;
|
return replacement_size;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_REGEX_H */
|
|
||||||
|
|
||||||
/* Return a copy of the current line with one needle replaced. */
|
/* Return a copy of the current line with one needle replaced. */
|
||||||
char *replace_line(const char *needle)
|
char *replace_line(const char *needle)
|
||||||
|
@ -532,17 +513,13 @@ char *replace_line(const char *needle)
|
||||||
size_t new_line_size = strlen(openfile->current->data) + 1;
|
size_t new_line_size = strlen(openfile->current->data) + 1;
|
||||||
|
|
||||||
/* First adjust the size of the new line for the change. */
|
/* First adjust the size of the new line for the change. */
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
if (ISSET(USE_REGEXP)) {
|
if (ISSET(USE_REGEXP)) {
|
||||||
match_len = regmatches[0].rm_eo - regmatches[0].rm_so;
|
match_len = regmatches[0].rm_eo - regmatches[0].rm_so;
|
||||||
new_line_size += replace_regexp(NULL, FALSE) - match_len;
|
new_line_size += replace_regexp(NULL, FALSE) - match_len;
|
||||||
} else {
|
} else {
|
||||||
#endif
|
|
||||||
match_len = strlen(needle);
|
match_len = strlen(needle);
|
||||||
new_line_size += strlen(answer) - match_len;
|
new_line_size += strlen(answer) - match_len;
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Create the buffer. */
|
/* Create the buffer. */
|
||||||
copy = charalloc(new_line_size);
|
copy = charalloc(new_line_size);
|
||||||
|
@ -551,11 +528,9 @@ char *replace_line(const char *needle)
|
||||||
strncpy(copy, openfile->current->data, openfile->current_x);
|
strncpy(copy, openfile->current->data, openfile->current_x);
|
||||||
|
|
||||||
/* Add the replacement text. */
|
/* Add the replacement text. */
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
if (ISSET(USE_REGEXP))
|
if (ISSET(USE_REGEXP))
|
||||||
replace_regexp(copy + openfile->current_x, TRUE);
|
replace_regexp(copy + openfile->current_x, TRUE);
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
strcpy(copy + openfile->current_x, answer);
|
strcpy(copy + openfile->current_x, answer);
|
||||||
|
|
||||||
assert(openfile->current_x + match_len <= strlen(openfile->current->data));
|
assert(openfile->current_x + match_len <= strlen(openfile->current->data));
|
||||||
|
@ -706,11 +681,10 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
/* Don't find the same zero-length or BOL match again. */
|
/* Don't find the same zero-length or BOL match again. */
|
||||||
if (match_len == 0 || (*needle == '^' && ISSET(USE_REGEXP)))
|
if (match_len == 0 || (*needle == '^' && ISSET(USE_REGEXP)))
|
||||||
skipone = TRUE;
|
skipone = TRUE;
|
||||||
#endif
|
|
||||||
/* When moving forward, put the cursor just after the replacement
|
/* When moving forward, put the cursor just after the replacement
|
||||||
* text, so that searching will continue there. */
|
* text, so that searching will continue there. */
|
||||||
if (!ISSET(BACKWARDS_SEARCH))
|
if (!ISSET(BACKWARDS_SEARCH))
|
||||||
|
|
16
src/text.c
16
src/text.c
|
@ -1864,13 +1864,9 @@ void justify_format(filestruct *paragraph, size_t skip)
|
||||||
|
|
||||||
/* The "quote part" of a line is the largest initial substring matching
|
/* The "quote part" of a line is the largest initial substring matching
|
||||||
* the quote string. This function returns the length of the quote part
|
* the quote string. This function returns the length of the quote part
|
||||||
* of the given line.
|
* of the given line. */
|
||||||
*
|
|
||||||
* Note that if !HAVE_REGEX_H then we match concatenated copies of
|
|
||||||
* quotestr. */
|
|
||||||
size_t quote_length(const char *line)
|
size_t quote_length(const char *line)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
regmatch_t matches;
|
regmatch_t matches;
|
||||||
int rc = regexec("ereg, line, 1, &matches, 0);
|
int rc = regexec("ereg, line, 1, &matches, 0);
|
||||||
|
|
||||||
|
@ -1879,14 +1875,6 @@ size_t quote_length(const char *line)
|
||||||
/* matches.rm_so should be 0, since the quote string should start
|
/* matches.rm_so should be 0, since the quote string should start
|
||||||
* with the caret ^. */
|
* with the caret ^. */
|
||||||
return matches.rm_eo;
|
return matches.rm_eo;
|
||||||
#else /* !HAVE_REGEX_H */
|
|
||||||
size_t qdepth = 0;
|
|
||||||
|
|
||||||
/* Compute quote depth level. */
|
|
||||||
while (strncmp(line + qdepth, quotestr, quotelen) == 0)
|
|
||||||
qdepth += quotelen;
|
|
||||||
return qdepth;
|
|
||||||
#endif /* !HAVE_REGEX_H */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* a_line and b_line are lines of text. The quotation part of a_line is
|
/* a_line and b_line are lines of text. The quotation part of a_line is
|
||||||
|
@ -2088,12 +2076,10 @@ bool find_paragraph(size_t *const quote, size_t *const par)
|
||||||
filestruct *current_save;
|
filestruct *current_save;
|
||||||
/* The line at the beginning of the paragraph we search for. */
|
/* The line at the beginning of the paragraph we search for. */
|
||||||
|
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
if (quoterc != 0) {
|
if (quoterc != 0) {
|
||||||
statusline(ALERT, _("Bad quote string %s: %s"), quotestr, quoteerr);
|
statusline(ALERT, _("Bad quote string %s: %s"), quotestr, quoteerr);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
assert(openfile->current != NULL);
|
assert(openfile->current != NULL);
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,6 @@ void sunder(char *str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
/* Fix the regex if we're on platforms which require an adjustment
|
/* Fix the regex if we're on platforms which require an adjustment
|
||||||
* from GNU-style to BSD-style word boundaries. */
|
* from GNU-style to BSD-style word boundaries. */
|
||||||
const char *fixbounds(const char *r)
|
const char *fixbounds(const char *r)
|
||||||
|
@ -206,7 +205,6 @@ const char *fixbounds(const char *r)
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_REGEX_H */
|
|
||||||
|
|
||||||
#ifndef DISABLE_SPELLER
|
#ifndef DISABLE_SPELLER
|
||||||
/* Is the word starting at the given position in buf and of the given length
|
/* Is the word starting at the given position in buf and of the given length
|
||||||
|
@ -236,7 +234,6 @@ bool is_separate_word(size_t position, size_t length, const char *buf)
|
||||||
const char *strstrwrapper(const char *haystack, const char *needle,
|
const char *strstrwrapper(const char *haystack, const char *needle,
|
||||||
const char *start)
|
const char *start)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
if (ISSET(USE_REGEXP)) {
|
if (ISSET(USE_REGEXP)) {
|
||||||
if (ISSET(BACKWARDS_SEARCH)) {
|
if (ISSET(BACKWARDS_SEARCH)) {
|
||||||
size_t last_find, ceiling, far_end;
|
size_t last_find, ceiling, far_end;
|
||||||
|
@ -289,7 +286,6 @@ const char *strstrwrapper(const char *haystack, const char *needle,
|
||||||
else
|
else
|
||||||
return haystack + regmatches[0].rm_so;
|
return haystack + regmatches[0].rm_so;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_REGEX_H */
|
|
||||||
if (ISSET(CASE_SENSITIVE)) {
|
if (ISSET(CASE_SENSITIVE)) {
|
||||||
if (ISSET(BACKWARDS_SEARCH))
|
if (ISSET(BACKWARDS_SEARCH))
|
||||||
return revstrstr(haystack, needle, start);
|
return revstrstr(haystack, needle, start);
|
||||||
|
|
Loading…
Reference in New Issue