Commit d845193a authored by Chris Allegretta's avatar Chris Allegretta
Browse files

DLR's cumulative patch, one minor configure.ac tweak

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1484 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
parent 53c3b47b
Showing with 109 additions and 59 deletions
+109 -59
CVS code - CVS code -
- General: - General:
- Translation updates (see po/ChangeLog for details). - Translation updates (see po/ChangeLog for details).
- Work around broken regexec() on some systems that segfaults
when passed an empty string. New function regexec_safe().
(David Benbennick)
- Fix various bugs with search string history logging: don't
print a broken error message and freeze if ~/.nano_history is
unreadable, actually show an error message in save_history()
if ~/.nano_history is unwritable, and prevent ~/.nano_history
from being completely overwritten by save_history() if it's
unreadable but writable. (David Benbennick)
- global.c:
shortcut_init()
- Simplify the #ifdef used to enable file insertion in view mode
if multibuffer support has been compiled in. (DLR)
- nano.c:
justify_format()
- If we shave spaces off the end of the line, make sure totsize
is properly updated. (DLR; much simplified by David
Benbennick)
- nano.h:
- Simplify #ifdefs relating to HAVE_STRCASECMP and
HAVE_STRNCASECMP. (David Benbennick)
- configure.ac:
- Enable autodetection of broken regexec(). (DLR) Re-added
regex.h check to ensure compile under Debian w/autoconf 1.6.
- TODO:
- Fix typo. (David Benbennick)
- faq.html:
- Update RPM links for nano 1.2.x. (DLR)
GNU nano 1.2.0 - 2003.02.19 GNU nano 1.2.0 - 2003.02.19
- General: - General:
...@@ -32,31 +60,32 @@ GNU nano 1.1.99pre3 - 2003.02.13 ...@@ -32,31 +60,32 @@ GNU nano 1.1.99pre3 - 2003.02.13
nano.c:global_init(), window_init(), and handle_sigwinch(). nano.c:global_init(), window_init(), and handle_sigwinch().
New macro MIN_EDITOR_COLS replaces MIN_FILL_LENGTH New macro MIN_EDITOR_COLS replaces MIN_FILL_LENGTH
(David Benbennick). (David Benbennick).
- Change ngettext macro to P_(), to avoid a clash with the reserved C - Change ngettext macro to P_(), to avoid a clash with the
__ identifier (Jordi). reserved C __ identifier (Jordi).
- Memory leak fixes for files.c:do_insertfile(),do_browser(), - Memory leak fixes for files.c:do_insertfile(),do_browser(),
nano.c:do_spell(), and search.c:do_replace() (David Benbennick). nano.c:do_spell(), and search.c:do_replace() (David
Benbennick).
- Remove do_preserve_msg, as using -p still gives Pico-style - Remove do_preserve_msg, as using -p still gives Pico-style
string behavior, so an annoying message every invocation is string behavior, so an annoying message every invocation is
probably unneeded (all cheer). probably unneeded (all cheer).
- Change resetpos function to be global (now called - Change resetpos function to be global (now called
resetstatuspos. Fixes annoying but small odd problem with resetstatuspos. Fixes annoying but small odd problem with
cursor placement when inserting a file. This needs to be done cursor placement when inserting a file. This needs to be done
better in 1.3 (originally by David Lawrence Ramsey). better in 1.3 (originally by David Lawrence Ramsey). Added
Added this issue to TODO. this issue to TODO.
- files.c: - files.c:
cwd_tab_completion() cwd_tab_completion()
- Memory leak fix (David Benbennick). - Memory leak fix (David Benbennick).
intput_tab() intput_tab()
- Fix assumption that matches is null terminated (David - Fix assumption that matches is null terminated (David
Benbennick). Benbennick).
load_history() load_history()
- Fix segfault on loading huge strings from history file - Fix segfault on loading huge strings from history file
(David Benbennick). (David Benbennick).
load_history(), save_history() load_history(), save_history()
- Changed to look at $HOME before getpwuid(geteuid()), see - Changed to look at $HOME before getpwuid(geteuid()), see
details in comment for rcfile.c:do_rcfile(). details in comment for rcfile.c:do_rcfile().
real_dir_from_tidle() real_dir_from_tilde()
- Change check for the running user's home dir to use - Change check for the running user's home dir to use
getpwuid(geteuid()) rather than a getpwent() loop getpwuid(geteuid()) rather than a getpwent() loop
(suggested by Jordi). (suggested by Jordi).
...@@ -69,7 +98,7 @@ GNU nano 1.1.99pre3 - 2003.02.13 ...@@ -69,7 +98,7 @@ GNU nano 1.1.99pre3 - 2003.02.13
nano.c:line_len(). (David Benbennick). nano.c:line_len(). (David Benbennick).
do_justify() do_justify()
- Add regfree() to quote regex (David Benbennick). - Add regfree() to quote regex (David Benbennick).
- Only copy previous indent if AUTOINDENT is set (David - Only copy previous indent if AUTOINDENT is set (David
Benbennick). Benbennick).
do_suspend() do_suspend()
- Fix untranslated message (David Benbennick). - Fix untranslated message (David Benbennick).
......
...@@ -19,7 +19,7 @@ For version 1.4: ...@@ -19,7 +19,7 @@ For version 1.4:
- UTF-8 support. - UTF-8 support.
- Support for Pico's paragraph searching ability. - Support for Pico's paragraph searching ability.
- Undo/Redo key? - Undo/Redo key?
- Remindable keys? - Rebindable keys?
- Keystroke to implement "Add next sequence as raw" like vi's ^V. - Keystroke to implement "Add next sequence as raw" like vi's ^V.
- Spell check selected text only. - Spell check selected text only.
- Make "To line" (^W^T) and "Read from Command" (^R^X) re-enter their - Make "To line" (^W^T) and "Read from Command" (^R^X) re-enter their
......
...@@ -38,12 +38,22 @@ AM_GNU_GETTEXT([external], [need-ngettext]) ...@@ -38,12 +38,22 @@ AM_GNU_GETTEXT([external], [need-ngettext])
dnl Checks for header files. dnl Checks for header files.
AC_HEADER_STDC AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h getopt.h libintl.h limits.h regex.h termio.h termios.h unistd.h) AC_CHECK_HEADERS(fcntl.h getopt.h libintl.h limits.h regex.h termio.h termios.h unistd.h)
AC_CHECK_HEADER(regex.h,
AC_MSG_CHECKING([for broken regexec])
AC_TRY_RUN([
#include <sys/types.h>
#include <regex.h>
int main() { regex_t reg; size_t n; regmatch_t r; regcomp(&reg, ".", 0); regexec(&reg, "", n, &r, 0); 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.])
)
)
dnl options dnl options
AC_ARG_ENABLE(debug, AC_ARG_ENABLE(debug,
[ --enable-debug Enable debugging (disabled by default)], [ --enable-debug Enable debugging (disabled by default)],
[if test x$enableval = xyes; then [if test x$enableval = xyes; then
AC_DEFINE(DEBUG, 1, [Define this to enable nano debug messages and assert warnings.]) AC_DEFINE(DEBUG, 1, [Define this to enable nano debug messages and assert warnings.])
debug_support=yes debug_support=yes
fi]) fi])
...@@ -125,7 +135,6 @@ AC_ARG_ENABLE(wrapping-as-root, ...@@ -125,7 +135,6 @@ AC_ARG_ENABLE(wrapping-as-root,
AC_DEFINE(DISABLE_ROOTWRAP, 1, [Define this to disable wrapping as root by default.]) AC_DEFINE(DISABLE_ROOTWRAP, 1, [Define this to disable wrapping as root by default.])
fi]) fi])
AC_ARG_ENABLE(color, AC_ARG_ENABLE(color,
[ --enable-color Enable color and syntax highlighting], [ --enable-color Enable color and syntax highlighting],
[if test x$enableval = xyes; then [if test x$enableval = xyes; then
......
...@@ -93,8 +93,8 @@ ...@@ -93,8 +93,8 @@
<h2><a name="2.2"></a>2.2. RedHat and derivatives (.rpm) packages.</h2> <h2><a name="2.2"></a>2.2. RedHat and derivatives (.rpm) packages.</h2>
<blockquote> <blockquote>
<ul> <ul>
<li><a href="http://www.nano-editor.org/dist/v1.0/RPMS/">http://www.nano-editor.org/dist/v1.0/RPMS/</a></li> <li><a href="http://www.nano-editor.org/dist/v1.2/RPMS/">http://www.nano-editor.org/dist/v1.2/RPMS/</a></li>
<li><a href="http://www.ewtoo.org/~astyanax/nano/dist/v1.0/RPMS/">http://www.ewtoo.org/~astyanax/nano/dist/v1.0/RPMS/</a></li> <li><a href="http://www.ewtoo.org/~astyanax/nano/dist/v1.2/RPMS/">http://www.ewtoo.org/~astyanax/nano/dist/v1.2/RPMS/</a></li>
</ul> </ul>
<p>Additionally, check out the RedHat contribs section at:</p> <p>Additionally, check out the RedHat contribs section at:</p>
<ul> <ul>
...@@ -233,6 +233,7 @@ ...@@ -233,6 +233,7 @@
<h2><a name="8"></a>8. ChangeLog</h2> <h2><a name="8"></a>8. ChangeLog</h2>
<blockquote> <blockquote>
<p> <p>
2003/02/23 - Updated RPM links for nano 1.2.x. (DLR).<br>
2003/01/16 - Split section 4.5 into 4.5a and 4.5b for search string behavior. Added --enable-all docs.<br> 2003/01/16 - Split section 4.5 into 4.5a and 4.5b for search string behavior. Added --enable-all docs.<br>
2002/12/28 - More misc. fixes (David Benbennick, DLR).<br> 2002/12/28 - More misc. fixes (David Benbennick, DLR).<br>
2002/10/25 - Misc. fixes and link updates (DLR).<br> 2002/10/25 - Misc. fixes and link updates (DLR).<br>
......
...@@ -1898,8 +1898,8 @@ char *real_dir_from_tilde(const char *buf) ...@@ -1898,8 +1898,8 @@ char *real_dir_from_tilde(const char *buf)
for (i = 1; buf[i] != '/' && buf[i] != '\0'; i++) for (i = 1; buf[i] != '/' && buf[i] != '\0'; i++)
; ;
/* Determine home directory using getpwent(), don't rely on /* Determine home directory using getpwuid() or getpwent(),
$HOME */ don't rely on $HOME */
if (i == 1) if (i == 1)
userdata = getpwuid(geteuid()); userdata = getpwuid(geteuid());
else { else {
...@@ -2892,8 +2892,11 @@ void load_history(void) ...@@ -2892,8 +2892,11 @@ void load_history(void)
if (homenv != NULL || userage != NULL) { if (homenv != NULL || userage != NULL) {
hist = fopen(nanohist, "r"); hist = fopen(nanohist, "r");
if (!hist) { if (!hist) {
if (errno != ENOENT) if (errno != ENOENT) {
/* Don't save history when we quit. */
UNSET(HISTORYLOG);
rcfile_error(_("Unable to open ~/.nano_history file, %s"), strerror(errno)); rcfile_error(_("Unable to open ~/.nano_history file, %s"), strerror(errno));
}
free(nanohist); free(nanohist);
} else { } else {
buf = charalloc(1024); buf = charalloc(1024);
......
...@@ -439,16 +439,15 @@ void shortcut_init(int unjustify) ...@@ -439,16 +439,15 @@ void shortcut_init(int unjustify)
IFHELP(nano_justify_msg, 0), NANO_JUSTIFY_FKEY, 0, IFHELP(nano_justify_msg, 0), NANO_JUSTIFY_FKEY, 0,
NOVIEW, do_justify); NOVIEW, do_justify);
/* this is so we can view multiple files */
sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"),
IFHELP(nano_insert_msg, 0), NANO_INSERTFILE_FKEY, 0,
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
/* this is so we can view multiple files */ VIEW
sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"),
IFHELP(nano_insert_msg, 0),
NANO_INSERTFILE_FKEY, 0, VIEW, do_insertfile_void);
#else #else
sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"), NOVIEW
IFHELP(nano_insert_msg, 0),
NANO_INSERTFILE_FKEY, 0, NOVIEW, do_insertfile_void);
#endif #endif
, do_insertfile_void);
sc_init_one(&main_list, NANO_WHEREIS_KEY, _("Where Is"), sc_init_one(&main_list, NANO_WHEREIS_KEY, _("Where Is"),
IFHELP(nano_whereis_msg, 0), IFHELP(nano_whereis_msg, 0),
......
...@@ -66,18 +66,6 @@ static sigjmp_buf jmpbuf; /* Used to return to mainloop after SIGWINCH */ ...@@ -66,18 +66,6 @@ static sigjmp_buf jmpbuf; /* Used to return to mainloop after SIGWINCH */
/* What we do when we're all set to exit */ /* What we do when we're all set to exit */
RETSIGTYPE finish(int sigage) RETSIGTYPE finish(int sigage)
{ {
#ifndef NANO_SMALL
#ifdef ENABLE_NANORC
/* do here so errors about ./nano_history
don't confuse user */
if (!ISSET(NO_RCFILE) && ISSET(HISTORYLOG))
save_history();
#endif
free_history(&search_history);
free_history(&replace_history);
#endif
keypad(edit, TRUE); keypad(edit, TRUE);
keypad(bottomwin, TRUE); keypad(bottomwin, TRUE);
...@@ -93,6 +81,11 @@ RETSIGTYPE finish(int sigage) ...@@ -93,6 +81,11 @@ RETSIGTYPE finish(int sigage)
/* Restore the old term settings */ /* Restore the old term settings */
tcsetattr(0, TCSANOW, &oldterm); tcsetattr(0, TCSANOW, &oldterm);
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
if (!ISSET(NO_RCFILE) && ISSET(HISTORYLOG))
save_history();
#endif
#ifdef DEBUG #ifdef DEBUG
thanks_for_all_the_fish(); thanks_for_all_the_fish();
#endif #endif
...@@ -2042,7 +2035,7 @@ int justify_format(int changes_allowed, filestruct *line, size_t skip) ...@@ -2042,7 +2035,7 @@ int justify_format(int changes_allowed, filestruct *line, size_t skip)
/* These four asserts are assumptions about the input data. */ /* These four asserts are assumptions about the input data. */
assert(line != NULL); assert(line != NULL);
assert(line->data != NULL); assert(line->data != NULL);
assert(skip <= strlen(line->data)); assert(skip < strlen(line->data));
assert(line->data[skip] != ' ' && line->data[skip] != '\t'); assert(line->data[skip] != ' ' && line->data[skip] != '\t');
back = line->data + skip; back = line->data + skip;
...@@ -2091,14 +2084,14 @@ int justify_format(int changes_allowed, filestruct *line, size_t skip) ...@@ -2091,14 +2084,14 @@ int justify_format(int changes_allowed, filestruct *line, size_t skip)
} }
back--; back--;
assert(*back == '\0'); assert(*back == '\0' && *front == '\0');
/* This assert merely documents a fact about the loop above. */ /* This assert merely documents a fact about the loop above. */
assert(changes_allowed != 0 || back == front); assert(changes_allowed != 0 || back == front);
/* Now back is the new end of line->data. */ /* Now back is the new end of line->data. */
if (back != front) { if (back != front) {
totsize += back - line->data - strlen(line->data); totsize -= front - back;
null_at(&line->data, back - line->data); null_at(&line->data, back - line->data);
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (mark_beginbuf == line && back - line->data < mark_beginx) if (mark_beginbuf == line && back - line->data < mark_beginx)
...@@ -3317,6 +3310,14 @@ int main(int argc, char *argv[]) ...@@ -3317,6 +3310,14 @@ int main(int argc, char *argv[])
#endif #endif
#endif /* ENABLE_NANORC */ #endif /* ENABLE_NANORC */
#ifndef NANO_SMALL
history_init();
#ifdef ENABLE_NANORC
if (!ISSET(NO_RCFILE) && ISSET(HISTORYLOG))
load_history();
#endif
#endif
#ifndef DISABLE_OPERATINGDIR #ifndef DISABLE_OPERATINGDIR
/* Set up the operating directory. This entails chdir()ing there, /* Set up the operating directory. This entails chdir()ing there,
so that file reads and writes will be based there. */ so that file reads and writes will be based there. */
...@@ -3396,17 +3397,6 @@ int main(int argc, char *argv[]) ...@@ -3396,17 +3397,6 @@ int main(int argc, char *argv[])
keypad(bottomwin, TRUE); keypad(bottomwin, TRUE);
} }
#ifndef NANO_SMALL
history_init();
#ifdef ENABLE_NANORC
if (!ISSET(NO_RCFILE) && ISSET(HISTORYLOG))
load_history();
#endif
#endif
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, _("Main: bottom win\n")); fprintf(stderr, _("Main: bottom win\n"));
#endif #endif
......
...@@ -35,6 +35,9 @@ ...@@ -35,6 +35,9 @@
/* Define charalloc as a macro rather than duplicating code */ /* Define charalloc as a macro rather than duplicating code */
#define charalloc(howmuch) (char *)nmalloc((howmuch) * sizeof(char)) #define charalloc(howmuch) (char *)nmalloc((howmuch) * sizeof(char))
#define charealloc(ptr, howmuch) (char *)nrealloc(ptr, (howmuch) * sizeof(char)) #define charealloc(ptr, howmuch) (char *)nrealloc(ptr, (howmuch) * sizeof(char))
#ifdef BROKEN_REGEXEC
#define regexec(preg, string, nmatch, pmatch, eflags) regexec_safe(preg, string, nmatch, pmatch, eflags)
#endif
#ifndef NANO_SMALL #ifndef NANO_SMALL
/* For the backup file copy ... */ /* For the backup file copy ... */
...@@ -76,13 +79,12 @@ ...@@ -76,13 +79,12 @@
# endif # endif
#endif #endif
#if !defined(HAVE_STRCASECMP) || !defined(HAVE_STRNCASECMP) #ifndef HAVE_STRCASECMP
# ifndef HAVE_STRCASECMP #define strcasecmp strcmp
# define strcasecmp strcmp #endif
# endif
# ifndef HAVE_STRNCASECMP #ifndef HAVE_STRNCASECMP
# define strncasecmp strncmp #define strncasecmp strncmp
# endif
#endif #endif
/* HP-UX 10 & 11 do not seem to support KEY_HOME and KEY_END */ /* HP-UX 10 & 11 do not seem to support KEY_HOME and KEY_END */
......
...@@ -391,6 +391,10 @@ void save_history(void); ...@@ -391,6 +391,10 @@ void save_history(void);
#endif #endif
/* Public functions in utils.c */ /* Public functions in utils.c */
#ifdef BROKEN_REGEXEC
int regexec_safe(const regex_t *preg, const char *string, size_t nmatch,
regmatch_t pmatch[], int eflags);
#endif
int is_cntrl_char(int c); int is_cntrl_char(int c);
int num_of_digits(int n); int num_of_digits(int n);
void align(char **strp); void align(char **strp);
......
...@@ -676,6 +676,7 @@ void do_rcfile(void) ...@@ -676,6 +676,7 @@ void do_rcfile(void)
fclose(rcstream); fclose(rcstream);
} }
} }
lineno = 0;
free(nanorc); free(nanorc);
#ifdef ENABLE_COLOR #ifdef ENABLE_COLOR
......
...@@ -30,6 +30,18 @@ ...@@ -30,6 +30,18 @@
#include "proto.h" #include "proto.h"
#include "nano.h" #include "nano.h"
#ifdef BROKEN_REGEXEC
#undef regexec
int regexec_safe(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;
}
#define regexec(preg, string, nmatch, pmatch, eflags) regexec_safe(preg, string, nmatch, pmatch, eflags)
#endif
int is_cntrl_char(int c) int is_cntrl_char(int c)
{ {
return (-128 <= c && c < -96) || (0 <= c && c < 32) || return (-128 <= c && c < -96) || (0 <= c && c < 32) ||
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment