Changed _POSIX_VERSION checks in regex code to HAVE_REGEX_H, added check for regex.h in configure.in

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@208 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
Chris Allegretta 2000-09-06 13:39:17 +00:00
parent d746d90cc3
commit 805c26d1a6
11 changed files with 107 additions and 87 deletions

View File

@ -1,4 +1,7 @@
CVS code - CVS code -
- General
- Changed _POSIX_VERSION checks in regex code to HAVE_REGEX_H,
added check for regex.h in configure.in.
- cut.c: - cut.c:
do_cut_text() do_cut_text()
- Don't immediately abort if we're on filebot and the marker is - Don't immediately abort if we're on filebot and the marker is

View File

@ -154,6 +154,9 @@
/* Define if you have the <nl_types.h> header file. */ /* Define if you have the <nl_types.h> header file. */
#undef HAVE_NL_TYPES_H #undef HAVE_NL_TYPES_H
/* Define if you have the <regex.h> header file. */
#undef HAVE_REGEX_H
/* Define if you have the <string.h> header file. */ /* Define if you have the <string.h> header file. */
#undef HAVE_STRING_H #undef HAVE_STRING_H

2
configure vendored
View File

@ -1225,7 +1225,7 @@ EOF
fi fi
for ac_hdr in fcntl.h unistd.h malloc.h termios.h termio.h limits.h getopt.h for ac_hdr in fcntl.h unistd.h malloc.h termios.h termio.h limits.h getopt.h regex.h
do do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6

View File

@ -11,7 +11,7 @@ AC_ISC_POSIX
dnl Checks for header files. dnl Checks for header files.
AC_HEADER_STDC AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h unistd.h malloc.h termios.h termio.h limits.h getopt.h) AC_CHECK_HEADERS(fcntl.h unistd.h malloc.h termios.h termio.h limits.h getopt.h regex.h)
dnl options dnl options
AC_ARG_ENABLE(tiny, AC_ARG_ENABLE(tiny,

View File

@ -82,9 +82,11 @@ toggle toggles[TOGGLE_LEN];
/* Regular expressions */ /* Regular expressions */
#ifdef HAVE_REGEX_H
regex_t search_regexp; /* Global to store compiled search regexp */ regex_t search_regexp; /* Global to store compiled search regexp */
regmatch_t regmatches[10]; /* Match positions for parenthetical regmatch_t regmatches[10]; /* Match positions for parenthetical
subexpressions, max of 10 */ subexpressions, max of 10 */
#endif
/* Initialize a struct *without* our lovely braces =( */ /* Initialize a struct *without* our lovely braces =( */
void sc_init_one(shortcut * s, int key, char *desc, char *help, int alt, void sc_init_one(shortcut * s, int key, char *desc, char *help, int alt,
@ -122,7 +124,9 @@ void toggle_init(void)
toggle_picomode_msg = _("Pico messages"); toggle_picomode_msg = _("Pico messages");
toggle_mouse_msg = _("Mouse support"); toggle_mouse_msg = _("Mouse support");
toggle_cuttoend_msg = _("Cut to end"); toggle_cuttoend_msg = _("Cut to end");
#ifdef HAVE_REGEX_H
toggle_regexp_msg = _("Regular expressions"); toggle_regexp_msg = _("Regular expressions");
#endif
toggle_wrap_msg = _("Auto wrap"); toggle_wrap_msg = _("Auto wrap");
toggle_init_one(&toggles[0], TOGGLE_CONST_KEY, toggle_const_msg, toggle_init_one(&toggles[0], TOGGLE_CONST_KEY, toggle_const_msg,
@ -141,9 +145,11 @@ void toggle_init(void)
USE_MOUSE); USE_MOUSE);
toggle_init_one(&toggles[7], TOGGLE_CUTTOEND_KEY, toggle_cuttoend_msg, toggle_init_one(&toggles[7], TOGGLE_CUTTOEND_KEY, toggle_cuttoend_msg,
CUT_TO_END); CUT_TO_END);
#ifdef HAVE_REGEX_H
toggle_init_one(&toggles[8], TOGGLE_REGEXP_KEY, toggle_regexp_msg, toggle_init_one(&toggles[8], TOGGLE_REGEXP_KEY, toggle_regexp_msg,
USE_REGEXP); USE_REGEXP);
#endif #endif
#endif
} }
void shortcut_init(void) void shortcut_init(void)

6
nano.c
View File

@ -319,7 +319,7 @@ void usage(void)
printf(_("Option Long option Meaning\n")); printf(_("Option Long option Meaning\n"));
printf(_ printf(_
(" -T --tabsize=[num] Set width of a tab to num\n")); (" -T --tabsize=[num] Set width of a tab to num\n"));
#ifdef _POSIX_VERSION #ifdef HAVE_REGEX_H
printf(_ printf(_
(" -R --regexp Use regular expressions for search\n")); (" -R --regexp Use regular expressions for search\n"));
#endif #endif
@ -1681,7 +1681,7 @@ int main(int argc, char *argv[])
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
int option_index = 0; int option_index = 0;
struct option long_options[] = { struct option long_options[] = {
#ifdef _POSIX_VERSION #ifdef HAVE_REGEX_H
{"regexp", 0, 0, 'R'}, {"regexp", 0, 0, 'R'},
#endif #endif
{"version", 0, 0, 'V'}, {"version", 0, 0, 'V'},
@ -1729,7 +1729,7 @@ int main(int argc, char *argv[])
finish(1); finish(1);
} }
break; break;
#ifdef _POSIX_VERSION #ifdef HAVE_REGEX_H
case 'R': case 'R':
SET(USE_REGEXP); SET(USE_REGEXP);
break; break;

4
nano.h
View File

@ -245,10 +245,10 @@ know what you're doing */
#define HELP_LIST_LEN 3 #define HELP_LIST_LEN 3
#define SPELL_LIST_LEN 3 #define SPELL_LIST_LEN 3
#ifndef SMALL_NANO #ifndef HAVE_REGEX_H
#define TOGGLE_LEN 9 #define TOGGLE_LEN 9
#else #else
#define TOGGLE_LEN 6 #define TOGGLE_LEN 8
#endif #endif
#define VIEW 1 #define VIEW 1

View File

@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-09-04 13:13-0400\n" "POT-Creation-Date: 2000-09-06 09:44-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -107,284 +107,284 @@ msgstr ""
msgid "File exists, OVERWRITE ?" msgid "File exists, OVERWRITE ?"
msgstr "" msgstr ""
#: global.c:118 #: global.c:120
msgid "Constant cursor position" msgid "Constant cursor position"
msgstr "" msgstr ""
#: global.c:119 #: global.c:121
msgid "Auto indent" msgid "Auto indent"
msgstr "" msgstr ""
#: global.c:120 #: global.c:122
msgid "Suspend" msgid "Suspend"
msgstr "" msgstr ""
#: global.c:121 #: global.c:123
msgid "Help mode" msgid "Help mode"
msgstr "" msgstr ""
#: global.c:122 #: global.c:124
msgid "Pico messages" msgid "Pico messages"
msgstr "" msgstr ""
#: global.c:123 #: global.c:125
msgid "Mouse support" msgid "Mouse support"
msgstr "" msgstr ""
#: global.c:124 #: global.c:126
msgid "Cut to end" msgid "Cut to end"
msgstr "" msgstr ""
#: global.c:125 #: global.c:128
msgid "Regular expressions" msgid "Regular expressions"
msgstr "" msgstr ""
#: global.c:126 #: global.c:130
msgid "Auto wrap" msgid "Auto wrap"
msgstr "" msgstr ""
#: global.c:166 #: global.c:172
msgid "Invoke the help menu" msgid "Invoke the help menu"
msgstr "" msgstr ""
#: global.c:167 #: global.c:173
msgid "Write the current file to disk" msgid "Write the current file to disk"
msgstr "" msgstr ""
#: global.c:168 #: global.c:174
msgid "Exit from nano" msgid "Exit from nano"
msgstr "" msgstr ""
#: global.c:169 #: global.c:175
msgid "Goto a specific line number" msgid "Goto a specific line number"
msgstr "" msgstr ""
#: global.c:170 #: global.c:176
msgid "Justify the current paragraph" msgid "Justify the current paragraph"
msgstr "" msgstr ""
#: global.c:171 #: global.c:177
msgid "Replace text within the editor" msgid "Replace text within the editor"
msgstr "" msgstr ""
#: global.c:172 #: global.c:178
msgid "Insert another file into the current one" msgid "Insert another file into the current one"
msgstr "" msgstr ""
#: global.c:173 #: global.c:179
msgid "Search for text within the editor" msgid "Search for text within the editor"
msgstr "" msgstr ""
#: global.c:174 #: global.c:180
msgid "Move to the previous screen" msgid "Move to the previous screen"
msgstr "" msgstr ""
#: global.c:175 #: global.c:181
msgid "Move to the next screen" msgid "Move to the next screen"
msgstr "" msgstr ""
#: global.c:176 #: global.c:182
msgid "Cut the current line and store it in the cutbuffer" msgid "Cut the current line and store it in the cutbuffer"
msgstr "" msgstr ""
#: global.c:177 #: global.c:183
msgid "Uncut from the cutbuffer into the current line" msgid "Uncut from the cutbuffer into the current line"
msgstr "" msgstr ""
#: global.c:178 #: global.c:184
msgid "Show the posititon of the cursor" msgid "Show the posititon of the cursor"
msgstr "" msgstr ""
#: global.c:179 #: global.c:185
msgid "Invoke the spell checker (if available)" msgid "Invoke the spell checker (if available)"
msgstr "" msgstr ""
#: global.c:180 #: global.c:186
msgid "Move up one line" msgid "Move up one line"
msgstr "" msgstr ""
#: global.c:181 #: global.c:187
msgid "Move down one line" msgid "Move down one line"
msgstr "" msgstr ""
#: global.c:182 #: global.c:188
msgid "Move forward one character" msgid "Move forward one character"
msgstr "" msgstr ""
#: global.c:183 #: global.c:189
msgid "Move back one character" msgid "Move back one character"
msgstr "" msgstr ""
#: global.c:184 #: global.c:190
msgid "Move to the beginning of the current line" msgid "Move to the beginning of the current line"
msgstr "" msgstr ""
#: global.c:185 #: global.c:191
msgid "Move to the end of the current line" msgid "Move to the end of the current line"
msgstr "" msgstr ""
#: global.c:186 #: global.c:192
msgid "Go to the first line of the file" msgid "Go to the first line of the file"
msgstr "" msgstr ""
#: global.c:187 #: global.c:193
msgid "Go to the last line of the file" msgid "Go to the last line of the file"
msgstr "" msgstr ""
#: global.c:188 #: global.c:194
msgid "Refresh (redraw) the current screen" msgid "Refresh (redraw) the current screen"
msgstr "" msgstr ""
#: global.c:189 #: global.c:195
msgid "Mark text at the current cursor location" msgid "Mark text at the current cursor location"
msgstr "" msgstr ""
#: global.c:190 #: global.c:196
msgid "Delete the character under the cursor" msgid "Delete the character under the cursor"
msgstr "" msgstr ""
#: global.c:192 #: global.c:198
msgid "Delete the character to the left of the cursor" msgid "Delete the character to the left of the cursor"
msgstr "" msgstr ""
#: global.c:193 #: global.c:199
msgid "Insert a tab character" msgid "Insert a tab character"
msgstr "" msgstr ""
#: global.c:194 #: global.c:200
msgid "Insert a carriage return at the cursor position" msgid "Insert a carriage return at the cursor position"
msgstr "" msgstr ""
#: global.c:196 #: global.c:202
msgid "Make the current search or replace case (in)sensitive" msgid "Make the current search or replace case (in)sensitive"
msgstr "" msgstr ""
#: global.c:197 #: global.c:203
msgid "Cancel the current function" msgid "Cancel the current function"
msgstr "" msgstr ""
#: global.c:201 global.c:311 global.c:383 #: global.c:207 global.c:317 global.c:389
msgid "Get Help" msgid "Get Help"
msgstr "" msgstr ""
#: global.c:204 global.c:212 #: global.c:210 global.c:218
msgid "WriteOut" msgid "WriteOut"
msgstr "" msgstr ""
#: global.c:208 global.c:372 #: global.c:214 global.c:378
msgid "Exit" msgid "Exit"
msgstr "" msgstr ""
#: global.c:216 global.c:307 global.c:328 global.c:347 #: global.c:222 global.c:313 global.c:334 global.c:353
msgid "Goto Line" msgid "Goto Line"
msgstr "" msgstr ""
#: global.c:221 global.c:299 #: global.c:227 global.c:305
msgid "Justify" msgid "Justify"
msgstr "" msgstr ""
#: global.c:224 global.c:295 global.c:325 #: global.c:230 global.c:301 global.c:331
msgid "Replace" msgid "Replace"
msgstr "" msgstr ""
#: global.c:228 #: global.c:234
msgid "Read File" msgid "Read File"
msgstr "" msgstr ""
#: global.c:232 #: global.c:238
msgid "Where Is" msgid "Where Is"
msgstr "" msgstr ""
#: global.c:236 global.c:364 #: global.c:242 global.c:370
msgid "Prev Page" msgid "Prev Page"
msgstr "" msgstr ""
#: global.c:240 global.c:368 #: global.c:246 global.c:374
msgid "Next Page" msgid "Next Page"
msgstr "" msgstr ""
#: global.c:244 #: global.c:250
msgid "Cut Text" msgid "Cut Text"
msgstr "" msgstr ""
#: global.c:247 #: global.c:253
msgid "UnCut Txt" msgid "UnCut Txt"
msgstr "" msgstr ""
#: global.c:251 #: global.c:257
msgid "Cur Pos" msgid "Cur Pos"
msgstr "" msgstr ""
#: global.c:255 #: global.c:261
msgid "To Spell" msgid "To Spell"
msgstr "" msgstr ""
#: global.c:259 #: global.c:265
msgid "Up" msgid "Up"
msgstr "" msgstr ""
#: global.c:262 #: global.c:268
msgid "Down" msgid "Down"
msgstr "" msgstr ""
#: global.c:265 #: global.c:271
msgid "Forward" msgid "Forward"
msgstr "" msgstr ""
#: global.c:268 #: global.c:274
msgid "Back" msgid "Back"
msgstr "" msgstr ""
#: global.c:271 #: global.c:277
msgid "Home" msgid "Home"
msgstr "" msgstr ""
#: global.c:274 #: global.c:280
msgid "End" msgid "End"
msgstr "" msgstr ""
#: global.c:277 #: global.c:283
msgid "Refresh" msgid "Refresh"
msgstr "" msgstr ""
#: global.c:280 #: global.c:286
msgid "Mark Text" msgid "Mark Text"
msgstr "" msgstr ""
#: global.c:283 #: global.c:289
msgid "Delete" msgid "Delete"
msgstr "" msgstr ""
#: global.c:287 #: global.c:293
msgid "Backspace" msgid "Backspace"
msgstr "" msgstr ""
#: global.c:291 #: global.c:297
msgid "Tab" msgid "Tab"
msgstr "" msgstr ""
#: global.c:302 #: global.c:308
msgid "Enter" msgid "Enter"
msgstr "" msgstr ""
#: global.c:315 global.c:335 global.c:354 #: global.c:321 global.c:341 global.c:360
msgid "First Line" msgid "First Line"
msgstr "" msgstr ""
#: global.c:318 global.c:338 global.c:357 #: global.c:324 global.c:344 global.c:363
msgid "Last Line" msgid "Last Line"
msgstr "" msgstr ""
#: global.c:321 global.c:341 #: global.c:327 global.c:347
msgid "Case Sens" msgid "Case Sens"
msgstr "" msgstr ""
#: global.c:331 global.c:350 global.c:360 global.c:376 global.c:380 #: global.c:337 global.c:356 global.c:366 global.c:382 global.c:386
#: global.c:386 winio.c:999 #: global.c:392 winio.c:999
msgid "Cancel" msgid "Cancel"
msgstr "" msgstr ""
#: global.c:344 #: global.c:350
msgid "No Replace" msgid "No Replace"
msgstr "" msgstr ""

View File

@ -22,7 +22,11 @@
/* Externs */ /* Externs */
#include <sys/stat.h> #include <sys/stat.h>
#ifdef HAVE_REGEX_H
#include <regex.h> #include <regex.h>
#endif
#include "nano.h" #include "nano.h"
extern int center_x, center_y, editwinrows; extern int center_x, center_y, editwinrows;
@ -44,9 +48,13 @@ extern shortcut main_list[MAIN_LIST_LEN], whereis_list[WHEREIS_LIST_LEN];
extern shortcut replace_list[REPLACE_LIST_LEN], goto_list[GOTO_LIST_LEN]; extern shortcut replace_list[REPLACE_LIST_LEN], goto_list[GOTO_LIST_LEN];
extern shortcut writefile_list[WRITEFILE_LIST_LEN], help_list[HELP_LIST_LEN]; extern shortcut writefile_list[WRITEFILE_LIST_LEN], help_list[HELP_LIST_LEN];
extern shortcut spell_list[SPELL_LIST_LEN]; extern shortcut spell_list[SPELL_LIST_LEN];
#ifdef HAVE_REGEX_H
extern int use_regexp, regexp_compiled; extern int use_regexp, regexp_compiled;
extern regex_t search_regexp; extern regex_t search_regexp;
extern regmatch_t regmatches[10]; extern regmatch_t regmatches[10];
#endif
extern toggle toggles[TOGGLE_LEN]; extern toggle toggles[TOGGLE_LEN];
/* Programs we want available */ /* Programs we want available */

View File

@ -39,7 +39,7 @@ static char last_replace[132]; /* Last replacement string */
/* Regular expression helper functions */ /* Regular expression helper functions */
#ifdef _POSIX_VERSION #ifdef HAVE_REGEX_H
void regexp_init(const char *regexp) void regexp_init(const char *regexp)
{ {
regcomp(&search_regexp, regexp, ISSET(CASE_SENSITIVE) ? 0 : REG_ICASE); regcomp(&search_regexp, regexp, ISSET(CASE_SENSITIVE) ? 0 : REG_ICASE);
@ -95,13 +95,13 @@ int search_init(int replacing)
return -1; return -1;
} else if (i == -2) { /* Same string */ } else if (i == -2) { /* Same string */
strncpy(answer, last_search, 132); strncpy(answer, last_search, 132);
#ifdef _POSIX_VERSION #ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP)) if (ISSET(USE_REGEXP))
regexp_init(answer); regexp_init(answer);
#endif #endif
} else if (i == 0) { /* They entered something new */ } else if (i == 0) { /* They entered something new */
strncpy(last_search, answer, 132); strncpy(last_search, answer, 132);
#ifdef _POSIX_VERSION #ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP)) if (ISSET(USE_REGEXP))
regexp_init(answer); regexp_init(answer);
#endif #endif
@ -203,7 +203,7 @@ void search_abort(void)
if (ISSET(MARK_ISSET)) if (ISSET(MARK_ISSET))
edit_refresh_clearok(); edit_refresh_clearok();
#ifdef _POSIX_VERSION #ifdef HAVE_REGEX_H
if (ISSET(REGEXP_COMPILED)) if (ISSET(REGEXP_COMPILED))
regexp_cleanup(); regexp_cleanup();
#endif #endif
@ -252,7 +252,7 @@ void replace_abort(void)
search_abort(); search_abort();
} }
#ifdef _POSIX_VERSION #ifdef HAVE_REGEX_H
int replace_regexp(char *string, int create_flag) int replace_regexp(char *string, int create_flag)
{ {
/* split personality here - if create_flag is null, just calculate /* split personality here - if create_flag is null, just calculate
@ -322,7 +322,7 @@ char *replace_line()
int search_match_count; int search_match_count;
/* Calculate size of new line */ /* Calculate size of new line */
#ifdef _POSIX_VERSION #ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP)) { if (ISSET(USE_REGEXP)) {
search_match_count = regmatches[0].rm_eo - search_match_count = regmatches[0].rm_eo -
regmatches[0].rm_so; regmatches[0].rm_so;
@ -350,7 +350,7 @@ char *replace_line()
/* Replacement Text */ /* Replacement Text */
if (!ISSET(USE_REGEXP)) if (!ISSET(USE_REGEXP))
strcat(copy, last_replace); strcat(copy, last_replace);
#ifdef _POSIX_VERSION #ifdef HAVE_REGEX_H
else else
(void)replace_regexp(copy + current_x, 1); (void)replace_regexp(copy + current_x, 1);
#endif #endif

View File

@ -82,7 +82,7 @@ char *strcasestr(char *haystack, char *needle)
char *strstrwrapper(char *haystack, char *needle) char *strstrwrapper(char *haystack, char *needle)
{ {
#ifdef _POSIX_VERSION #ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP)) { if (ISSET(USE_REGEXP)) {
int result=regexec(&search_regexp, haystack, 10, regmatches, 0); int result=regexec(&search_regexp, haystack, 10, regmatches, 0);
if (!result) if (!result)