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 -
- General
- Changed _POSIX_VERSION checks in regex code to HAVE_REGEX_H,
added check for regex.h in configure.in.
- cut.c:
do_cut_text()
- 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. */
#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. */
#undef HAVE_STRING_H

2
configure vendored
View File

@ -1225,7 +1225,7 @@ EOF
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
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
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.
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
AC_ARG_ENABLE(tiny,

View File

@ -82,9 +82,11 @@ toggle toggles[TOGGLE_LEN];
/* Regular expressions */
#ifdef HAVE_REGEX_H
regex_t search_regexp; /* Global to store compiled search regexp */
regmatch_t regmatches[10]; /* Match positions for parenthetical
subexpressions, max of 10 */
#endif
/* Initialize a struct *without* our lovely braces =( */
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_mouse_msg = _("Mouse support");
toggle_cuttoend_msg = _("Cut to end");
#ifdef HAVE_REGEX_H
toggle_regexp_msg = _("Regular expressions");
#endif
toggle_wrap_msg = _("Auto wrap");
toggle_init_one(&toggles[0], TOGGLE_CONST_KEY, toggle_const_msg,
@ -141,9 +145,11 @@ void toggle_init(void)
USE_MOUSE);
toggle_init_one(&toggles[7], TOGGLE_CUTTOEND_KEY, toggle_cuttoend_msg,
CUT_TO_END);
#ifdef HAVE_REGEX_H
toggle_init_one(&toggles[8], TOGGLE_REGEXP_KEY, toggle_regexp_msg,
USE_REGEXP);
#endif
#endif
}
void shortcut_init(void)

6
nano.c
View File

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

4
nano.h
View File

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

View File

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

View File

@ -22,7 +22,11 @@
/* Externs */
#include <sys/stat.h>
#ifdef HAVE_REGEX_H
#include <regex.h>
#endif
#include "nano.h"
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 writefile_list[WRITEFILE_LIST_LEN], help_list[HELP_LIST_LEN];
extern shortcut spell_list[SPELL_LIST_LEN];
#ifdef HAVE_REGEX_H
extern int use_regexp, regexp_compiled;
extern regex_t search_regexp;
extern regmatch_t regmatches[10];
#endif
extern toggle toggles[TOGGLE_LEN];
/* Programs we want available */

View File

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

View File

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