From b5a7bbf4f339cdd939a14b994a2bf02e9b64e26c Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Mon, 5 Jun 2006 15:41:23 +0000 Subject: [PATCH] remove the workaround for glibc 2.2.3's broken regexec(), and replace it with a FAQ entry explaining the problem, since it could break anything using extended regular expressions, and glibc 2.2.3 is old git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3624 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ configure.ac | 19 ------------------- doc/faq.html | 31 ++++++++++++++++++------------- src/nano.h | 6 ------ src/proto.h | 4 ---- src/utils.c | 15 +-------------- 6 files changed, 24 insertions(+), 56 deletions(-) diff --git a/ChangeLog b/ChangeLog index 84021914..148c5884 100644 --- a/ChangeLog +++ b/ChangeLog @@ -138,6 +138,11 @@ CVS code - - Replace usage of the bool curses_ended with the isendwin() function, and remove curses_ended. Changes to do_suspend(). (DLR) + - Remove the workaround for glibc 2.2.3's broken regexec(), and + replace it with a FAQ entry explaining the problem, since it + could break anything using extended regular expressions, and + glibc 2.2.3 is old. Changes to configure.ac, faq.html, + nano.h, and proto.h; removal of safe_regexec(). (DLR) - browser.c: do_browser() - Reference NANO_GOTODIR_(ALT|F)?KEY instead of diff --git a/configure.ac b/configure.ac index d2799a43..ce21a5b3 100644 --- a/configure.ac +++ b/configure.ac @@ -50,25 +50,6 @@ dnl Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS(fcntl.h getopt.h libintl.h limits.h regex.h termios.h wchar.h wctype.h) -AC_CHECK_HEADER(regex.h, - AC_MSG_CHECKING([for broken regexec from glibc 2.2.3]) - AC_TRY_RUN([ -#include -#include -int main(void) -{ - regex_t reg; - size_t n = 1; - regmatch_t r; - regcomp(®, "\\<", 0); - regexec(®, "", n, &r, 0); - regfree(®); - return 0; -}], - AC_MSG_RESULT(no), - AC_MSG_RESULT(yes) - AC_DEFINE(BROKEN_REGEXEC, 1, [Define this if your regexec() function segfaults when passed an empty string under certain conditions, as the one from glibc 2.2.3 does.]), - AC_MSG_RESULT([cross-compiling; assuming no]))) dnl Checks for options. diff --git a/doc/faq.html b/doc/faq.html index 43131820..5c41764d 100644 --- a/doc/faq.html +++ b/doc/faq.html @@ -38,12 +38,13 @@ 4.5. How do I type the F13-F16 keys shown in the help browser? My keyboard only has F1-F12!
4.6. Nano crashes when I type <insert keystroke here>!
4.7. Nano crashes when I resize my window. How can I fix that?
- 4.8. [version 1.1.12 and earlier] Why does nano show ^\ in the shortcut list instead of ^J?
- 4.9a. [version 1.1.12 and earlier] When I type in a search string, the string I last searched for is already in front of my cursor! What happened?!
- 4.9b. [version 1.1.99pre1 and later] Hey, the search string behavior has reverted, it's now like Pico, what happened to the consistency?
- 4.10. How do I make nano my default editor (in Pine, mutt, etc.)?
- 4.11. I've compiled nano with color support, but I don't see any color when I run it!
- 4.12. How do I select text for the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?

+ 4.8. [version 1.3.12 and later] I'm using glibc 2.2.3, and nano crashes when I use color support or do regular expression searches. How can I fix that?
+ 4.9. [version 1.1.12 and earlier] Why does nano show ^\ in the shortcut list instead of ^J?
+ 4.10a. [version 1.1.12 and earlier] When I type in a search string, the string I last searched for is already in front of my cursor! What happened?!
+ 4.10b. [version 1.1.99pre1 and later] Hey, the search string behavior has reverted, it's now like Pico, what happened to the consistency?
+ 4.11. How do I make nano my default editor (in Pine, mutt, etc.)?
+ 4.12. I've compiled nano with color support, but I don't see any color when I run it!
+ 4.13. How do I select text for the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?

5. Internationalization

5.1. There's no translation for my language!
5.2. I don't like the translation for <x> in my language. How can I fix it?
@@ -189,13 +190,15 @@

If you aren't trying some bizarre keystroke combination with some bizarre $TERM entry, chances are you have found a bug. You are welcome to submit it to the nano-devel list or to nano@nano-editor.org.

4.7. Nano crashes when I resize my window. How can I fix that?

Older versions of nano had this problem, please upgrade to a newer version (at least 0.9.9 would be great, 0.9.12 is recommended).

-

4.8. [version 1.1.12 and earlier] Why does nano show ^\ in the shortcut list instead of ^J?

+

4.8. [version 1.3.12 and later] I'm using glibc 2.2.3, and nano crashes when I use color support or do regular expression searches. How can I fix that?

+

It's a bug in glibc 2.2.3. You should upgrade to at least glibc 2.2.4.

+

4.9. [version 1.1.12 and earlier] Why does nano show ^\ in the shortcut list instead of ^J?

The help (^G) and justify (^J) function were among the last to be written. To show the improvements that nano had over Pico (go to line # and replace), ^_ and ^\ were put on the shortcut list. Later, ^G came back in place of ^_ as it proved to be very valuable for new Unix users. If you use the -p option to nano (or hit Meta-P) you will get the same shortcuts at the bottom as Pico.

-

4.9a. [version 1.1.12 and earlier] When I type in a search string, the string I last searched for is already in front of my cursor! What happened?!

+

4.10a. [version 1.1.12 and earlier] When I type in a search string, the string I last searched for is already in front of my cursor! What happened?!

In nano version 0.9.20, the default is to have a completely consistent user interface across all user input functions. This means that regardless of whether you're being asked for a filename to insert or write, or a string to search for, the previous value is already inserted before the cursor. If you prefer the old behavior, use the Pico emulation mode (-p or --pico) or just hit Meta-P while in nano (see the ^G help text for more details).

-

4.9b. [version 1.1.99pre1 and later] Hey, the search string behavior has reverted, it's now like Pico, what happened to the consistency?

+

4.10b. [version 1.1.99pre1 and later] Hey, the search string behavior has reverted, it's now like Pico, what happened to the consistency?

It was decided that consistency was nice, but people are used to Pico's inconsistent behavior. Also, in version 1.1.99pre1, search and replace history was introduced. If you wish to edit your previous search/replace entry (or any previous entry), you can do so by hitting the up arrow to cycle through your history. This method allows the best of both worlds: You don't need to erase the previous string if you want to enter a new one, but you can with one keystroke recall previous entries for editing. Therefore there is now no "Pico mode", nano is and has always been a Pico clone, and clones by default should be compatible.

-

4.10. How do I make nano my default editor (in Pine, mutt, etc.)?

+

4.11. How do I make nano my default editor (in Pine, mutt, etc.)?

You need to make nano your $EDITOR. If you want this to be saved, you should put a line like this in your .bashrc if you use bash (or .zshrc if you believe in zsh):

export EDITOR=/usr/local/bin/nano

or, if you use tcsh, put this in your .cshrc file:

@@ -208,9 +211,9 @@

If you're a mutt user, you should see an effect immediately the next time you log in. No further configuration is needed. However, if you want to let people know you use nano to compose your email messages, you can put a line like this in your .muttrc:

my_hdr X-Composer: nano x.y.z

Again, replace x.y.z with the version of nano you use.

-

4.11. I've compiled nano with color support, but I don't see any color when I run it!

+

4.12. I've compiled nano with color support, but I don't see any color when I run it!

If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Some example configurations are in the nanorc.sample that comes with the nano source or your nano package. See Section 3.9.

-

4.12. How do I select text for or paste text from the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?

+

4.13. How do I select text for or paste text from the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?

Try holding down the Shift key and selecting or pasting the text as you normally would.


5. Internationalization

@@ -253,7 +256,9 @@

Re-read Section 7.4 and you should know the answer.

8. ChangeLog

-

2006/06/04 - Add minor punctuation, wording, and typo fixes. (DLR)
+

+2006/06/05 - Add a new section 4.8, and move all section 4 entries after it down one number, to explain how to deal with glibc 2.2.3's crashes involving extended regular expressions. (DLR)
+2006/06/04 - Add minor punctuation, wording, and typo fixes. (DLR)
2006/05/27 - Update section 3.8 to mention the new "Unicode Input" prompt, and how Unicode input only works when Unicode support is enabled. (DLR)
2006/05/12 - Remove section 4.4, and move all section 4 entries after it up one number, since it no longer applies. Meta-] and Meta-[ are no longer used to indent and unindent marked text, since they require that the bracket matching key change to Ctrl-], which is used as the telnet escape key (found by Chris). Also, make the link to the nano CVS page a bit more readable. (DLR)
2006/05/08 - Add a new section 4.5, and move all section 4 entries after it down one number, to explain a problem that can occur when holding down keys to generate Meta sequences. Also add a few more capitalization and wording fixes. (Benno Schulenberg, minor tweaks by DLR)
diff --git a/src/nano.h b/src/nano.h index 18c9032c..26d6c4ac 100644 --- a/src/nano.h +++ b/src/nano.h @@ -52,12 +52,6 @@ #define charmove(dest, src, n) memmove(dest, src, (n) * sizeof(char)) #define charset(dest, src, n) memset(dest, src, (n) * sizeof(char)) -/* Other macros. */ -#ifdef BROKEN_REGEXEC -#undef regexec -#define regexec(preg, string, nmatch, pmatch, eflags) safe_regexec(preg, string, nmatch, pmatch, eflags) -#endif - /* Set a default value for PATH_MAX if there isn't one. */ #ifndef PATH_MAX #define PATH_MAX 4096 diff --git a/src/proto.h b/src/proto.h index c9e85794..c6d5e29a 100644 --- a/src/proto.h +++ b/src/proto.h @@ -677,10 +677,6 @@ ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream); #endif #endif #ifdef HAVE_REGEX_H -#ifdef BROKEN_REGEXEC -int safe_regexec(const regex_t *preg, const char *string, size_t nmatch, - regmatch_t pmatch[], int eflags); -#endif bool regexp_bol_or_eol(const regex_t *preg, const char *string); #endif #ifndef DISABLE_SPELLER diff --git a/src/utils.c b/src/utils.c index 10a4baba..0758d1ac 100644 --- a/src/utils.c +++ b/src/utils.c @@ -242,19 +242,6 @@ ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream) #endif /* !NANO_TINY && ENABLE_NANORC */ #ifdef HAVE_REGEX_H -#ifdef BROKEN_REGEXEC -/* glibc 2.2.3 brain damage: Work around a potential segfault in - * regexec(). */ -int safe_regexec(const regex_t *preg, const char *string, size_t nmatch, - regmatch_t pmatch[], int eflags) -{ - if (string != NULL && *string != '\0') - return regexec(preg, string, nmatch, pmatch, eflags); - - return REG_NOMATCH; -} -#endif - /* Do the compiled regex in preg and the regex in string match the * beginning or end of a line? */ bool regexp_bol_or_eol(const regex_t *preg, const char *string) @@ -263,7 +250,7 @@ bool regexp_bol_or_eol(const regex_t *preg, const char *string) regexec(preg, string, 0, NULL, REG_NOTBOL | REG_NOTEOL) == REG_NOMATCH); } -#endif /* HAVE_REGEX_H */ +#endif #ifndef DISABLE_SPELLER /* Is the word starting at position pos in buf a whole word? */ -- 2.39.5