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
This commit is contained in:
Chris Allegretta 2003-03-11 03:50:40 +00:00
parent 53c3b47bf9
commit d845193a1d
11 changed files with 109 additions and 59 deletions

View File

@ -1,6 +1,34 @@
CVS code -
- General:
- 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
- General:
@ -32,18 +60,19 @@ GNU nano 1.1.99pre3 - 2003.02.13
nano.c:global_init(), window_init(), and handle_sigwinch().
New macro MIN_EDITOR_COLS replaces MIN_FILL_LENGTH
(David Benbennick).
- Change ngettext macro to P_(), to avoid a clash with the reserved C
__ identifier (Jordi).
- Change ngettext macro to P_(), to avoid a clash with the
reserved C __ identifier (Jordi).
- 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
string behavior, so an annoying message every invocation is
probably unneeded (all cheer).
- Change resetpos function to be global (now called
resetstatuspos. Fixes annoying but small odd problem with
cursor placement when inserting a file. This needs to be done
better in 1.3 (originally by David Lawrence Ramsey).
Added this issue to TODO.
better in 1.3 (originally by David Lawrence Ramsey). Added
this issue to TODO.
- files.c:
cwd_tab_completion()
- Memory leak fix (David Benbennick).
@ -56,7 +85,7 @@ GNU nano 1.1.99pre3 - 2003.02.13
load_history(), save_history()
- Changed to look at $HOME before getpwuid(geteuid()), see
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
getpwuid(geteuid()) rather than a getpwent() loop
(suggested by Jordi).

2
TODO
View File

@ -19,7 +19,7 @@ For version 1.4:
- UTF-8 support.
- Support for Pico's paragraph searching ability.
- Undo/Redo key?
- Remindable keys?
- Rebindable keys?
- Keystroke to implement "Add next sequence as raw" like vi's ^V.
- Spell check selected text only.
- Make "To line" (^W^T) and "Read from Command" (^R^X) re-enter their

View File

@ -38,6 +38,16 @@ AM_GNU_GETTEXT([external], [need-ngettext])
dnl Checks for header files.
AC_HEADER_STDC
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
AC_ARG_ENABLE(debug,
@ -125,7 +135,6 @@ AC_ARG_ENABLE(wrapping-as-root,
AC_DEFINE(DISABLE_ROOTWRAP, 1, [Define this to disable wrapping as root by default.])
fi])
AC_ARG_ENABLE(color,
[ --enable-color Enable color and syntax highlighting],
[if test x$enableval = xyes; then

View File

@ -93,8 +93,8 @@
<h2><a name="2.2"></a>2.2. RedHat and derivatives (.rpm) packages.</h2>
<blockquote>
<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.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.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.2/RPMS/">http://www.ewtoo.org/~astyanax/nano/dist/v1.2/RPMS/</a></li>
</ul>
<p>Additionally, check out the RedHat contribs section at:</p>
<ul>
@ -233,6 +233,7 @@
<h2><a name="8"></a>8. ChangeLog</h2>
<blockquote>
<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>
2002/12/28 - More misc. fixes (David Benbennick, DLR).<br>
2002/10/25 - Misc. fixes and link updates (DLR).<br>

View File

@ -1898,8 +1898,8 @@ char *real_dir_from_tilde(const char *buf)
for (i = 1; buf[i] != '/' && buf[i] != '\0'; i++)
;
/* Determine home directory using getpwent(), don't rely on
$HOME */
/* Determine home directory using getpwuid() or getpwent(),
don't rely on $HOME */
if (i == 1)
userdata = getpwuid(geteuid());
else {
@ -2892,8 +2892,11 @@ void load_history(void)
if (homenv != NULL || userage != NULL) {
hist = fopen(nanohist, "r");
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));
}
free(nanohist);
} else {
buf = charalloc(1024);

View File

@ -439,16 +439,15 @@ void shortcut_init(int unjustify)
IFHELP(nano_justify_msg, 0), NANO_JUSTIFY_FKEY, 0,
NOVIEW, do_justify);
#ifdef ENABLE_MULTIBUFFER
/* 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, VIEW, do_insertfile_void);
IFHELP(nano_insert_msg, 0), NANO_INSERTFILE_FKEY, 0,
#ifdef ENABLE_MULTIBUFFER
VIEW
#else
sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"),
IFHELP(nano_insert_msg, 0),
NANO_INSERTFILE_FKEY, 0, NOVIEW, do_insertfile_void);
NOVIEW
#endif
, do_insertfile_void);
sc_init_one(&main_list, NANO_WHEREIS_KEY, _("Where Is"),
IFHELP(nano_whereis_msg, 0),

42
nano.c
View File

@ -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 */
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(bottomwin, TRUE);
@ -93,6 +81,11 @@ RETSIGTYPE finish(int sigage)
/* Restore the old term settings */
tcsetattr(0, TCSANOW, &oldterm);
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
if (!ISSET(NO_RCFILE) && ISSET(HISTORYLOG))
save_history();
#endif
#ifdef DEBUG
thanks_for_all_the_fish();
#endif
@ -2042,7 +2035,7 @@ int justify_format(int changes_allowed, filestruct *line, size_t skip)
/* These four asserts are assumptions about the input data. */
assert(line != NULL);
assert(line->data != NULL);
assert(skip <= strlen(line->data));
assert(skip < strlen(line->data));
assert(line->data[skip] != ' ' && line->data[skip] != '\t');
back = line->data + skip;
@ -2091,14 +2084,14 @@ int justify_format(int changes_allowed, filestruct *line, size_t skip)
}
back--;
assert(*back == '\0');
assert(*back == '\0' && *front == '\0');
/* This assert merely documents a fact about the loop above. */
assert(changes_allowed != 0 || back == front);
/* Now back is the new end of line->data. */
if (back != front) {
totsize += back - line->data - strlen(line->data);
totsize -= front - back;
null_at(&line->data, back - line->data);
#ifndef NANO_SMALL
if (mark_beginbuf == line && back - line->data < mark_beginx)
@ -3317,6 +3310,14 @@ int main(int argc, char *argv[])
#endif
#endif /* ENABLE_NANORC */
#ifndef NANO_SMALL
history_init();
#ifdef ENABLE_NANORC
if (!ISSET(NO_RCFILE) && ISSET(HISTORYLOG))
load_history();
#endif
#endif
#ifndef DISABLE_OPERATINGDIR
/* Set up the operating directory. This entails chdir()ing there,
so that file reads and writes will be based there. */
@ -3396,17 +3397,6 @@ int main(int argc, char *argv[])
keypad(bottomwin, TRUE);
}
#ifndef NANO_SMALL
history_init();
#ifdef ENABLE_NANORC
if (!ISSET(NO_RCFILE) && ISSET(HISTORYLOG))
load_history();
#endif
#endif
#ifdef DEBUG
fprintf(stderr, _("Main: bottom win\n"));
#endif

16
nano.h
View File

@ -35,6 +35,9 @@
/* Define charalloc as a macro rather than duplicating code */
#define charalloc(howmuch) (char *)nmalloc((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
/* For the backup file copy ... */
@ -76,13 +79,12 @@
# endif
#endif
#if !defined(HAVE_STRCASECMP) || !defined(HAVE_STRNCASECMP)
# ifndef HAVE_STRCASECMP
# define strcasecmp strcmp
# endif
# ifndef HAVE_STRNCASECMP
# define strncasecmp strncmp
# endif
#ifndef HAVE_STRCASECMP
#define strcasecmp strcmp
#endif
#ifndef HAVE_STRNCASECMP
#define strncasecmp strncmp
#endif
/* HP-UX 10 & 11 do not seem to support KEY_HOME and KEY_END */

View File

@ -391,6 +391,10 @@ void save_history(void);
#endif
/* 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 num_of_digits(int n);
void align(char **strp);

View File

@ -676,6 +676,7 @@ void do_rcfile(void)
fclose(rcstream);
}
}
lineno = 0;
free(nanorc);
#ifdef ENABLE_COLOR

12
utils.c
View File

@ -30,6 +30,18 @@
#include "proto.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)
{
return (-128 <= c && c < -96) || (0 <= c && c < 32) ||