commit 2ab03f6896005b8ce99ac4804f94174726d501b7
parent e42df73644c82c657323d47a299f06cf44fdac39
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Thu, 17 Oct 2002 02:19:31 +0000
miscellaneous bug fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1303 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
16 files changed, 115 insertions(+), 125 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -8,6 +8,43 @@ CVS code -
complicated for a feature freeze.
- Disable VSTOP keystroke. Stops people accidentally locking up
nano (suggested by David Benbennick).
+ - Pluralize messages with ngettext() where needed. (David
+ Benbennick)
+ - Update nano.1 and nano.1.html to show that nano now does an
+ emergency save on receiving SIGHUP or SIGTERM. (DLR)
+ - Don't include "nowrap" in the long options if
+ DISABLE_WRAPPING is defined. (DLR)
+- files.c:
+ read_file()
+ - Minor efficiency fixes, some of which fit in with the change
+ to ngettext() usage mentioned above. (David Benbennick)
+ do_browser()
+ - Make sure the value of path is mallocstrcpy()ed into retval
+ and not just assigned to it, to avoid memory corruption
+ problems. (DLR)
+- nano.c:
+ justify_format()
+ - Make sure the double space maintained after sentence-ending
+ punctuation is done when that punctuation is immediately
+ followed by a bracket-type character, so justifying e.g.
+ sentences in parentheses works properly. (David Benbennick)
+ handle_hup()
+ - Renamed handle_hupterm() to show that it now handles SIGTERM
+ as well as SIGHUP. (DLR)
+ signal_init()
+ - Do an emergency save on receiving either SIGHUP or SIGTERM,
+ not just SIGHUP. (David Benbennick)
+ main()
+ - Fix a problem where control key commands were printed
+ literally instead of interpreted after a failed search of a
+ one-line file. (David Benbennick)
+- proto.h:
+ handle_hup()
+ - Renamed handle_hupterm(); see above for why. (DLR)
+- winio.c:
+ edit_add()
+ - Fix a potential infinite loop occurring with certain
+ zero-length regexes. (David Benbennick)
GNU nano 1.1.11 - 10/01/2002
- General:
diff --git a/color.c b/color.c
@@ -33,13 +33,6 @@
#ifdef ENABLE_COLOR
-#ifdef ENABLE_NLS
-#include <libintl.h>
-#define _(string) gettext(string)
-#else
-#define _(string) (string)
-#endif
-
/* For each syntax list entry, we go through the list of colors and
* assign color pairs. */
void set_colorpairs(void)
diff --git a/configure.ac b/configure.ac
@@ -15,7 +15,7 @@ AC_SYS_LARGEFILE
dnl Checks for header files.
AC_HEADER_STDC
-AC_CHECK_HEADERS(fcntl.h unistd.h termios.h termio.h limits.h getopt.h regex.h)
+AC_CHECK_HEADERS(fcntl.h getopt.h libintl.h limits.h termio.h termios.h regex.h unistd.h)
dnl options
AC_ARG_ENABLE(debug,
diff --git a/cut.c b/cut.c
@@ -28,13 +28,6 @@
#include "proto.h"
#include "nano.h"
-#ifdef ENABLE_NLS
-#include <libintl.h>
-#define _(string) gettext(string)
-#else
-#define _(string) (string)
-#endif
-
static int marked_cut; /* Is the cutbuffer from a mark? */
static filestruct *cutbottom = NULL; /* Pointer to end of cutbuffer */
diff --git a/files.c b/files.c
@@ -38,13 +38,6 @@
#include "proto.h"
#include "nano.h"
-#ifdef ENABLE_NLS
-#include <libintl.h>
-#define _(string) gettext(string)
-#else
-#define _(string) (string)
-#endif
-
#ifndef NANO_SMALL
static int fileformat = 0; /* 0 = *nix, 1 = DOS, 2 = Mac */
#endif
@@ -287,44 +280,38 @@ int read_file(FILE *f, const char *filename, int quiet)
#endif
/* Did we even GET a file if we don't already have one? */
- if (totsize == 0 || fileptr == NULL) {
+ if (totsize == 0 || fileptr == NULL)
new_file();
- statusbar(_("Read %d lines"), num_lines);
- return 1;
- }
/* Did we try to insert a file of 0 bytes? */
- if (num_lines == 0)
- {
- statusbar(_("Read %d lines"), 0);
- return 1;
- }
-
- if (current != NULL) {
- fileptr->next = current;
- current->prev = fileptr;
- renumber(current);
- current_x = 0;
- placewewant = 0;
- } else if (fileptr->next == NULL) {
- filebot = fileptr;
- new_magicline();
- totsize--;
-
- /* Update the edit buffer; note that if using multibuffers, a
- quiet load will update the current open_files entry, while a
- noisy load will add a new open_files entry */
- load_file(quiet);
+ if (num_lines != 0) {
+ if (current != NULL) {
+ fileptr->next = current;
+ current->prev = fileptr;
+ renumber(current);
+ current_x = 0;
+ placewewant = 0;
+ } else if (fileptr->next == NULL) {
+ filebot = fileptr;
+ new_magicline();
+ totsize--;
+ load_file(quiet);
+ }
}
#ifndef NANO_SMALL
if (fileformat == 2)
- statusbar(_("Read %d lines (Converted from Mac format)"), num_lines);
+ statusbar(ngettext("Read %d line (Converted from Mac format)",
+ "Read %d lines (Converted from Mac format)",
+ num_lines), num_lines);
else if (fileformat == 1)
- statusbar(_("Read %d lines (Converted from DOS format)"), num_lines);
+ statusbar(ngettext("Read %d line (Converted from DOS format)",
+ "Read %d lines (Converted from DOS format)",
+ num_lines), num_lines);
else
#endif
- statusbar(_("Read %d lines"), num_lines);
+ statusbar(ngettext("Read %d line", "Read %d lines", num_lines),
+ num_lines);
totlines += num_lines;
@@ -1659,7 +1646,8 @@ int write_file(const char *name, int tmp, int append, int nonamechange)
/* Update originalfilestat to reference the file as it is now. */
stat(filename, &originalfilestat);
#endif
- statusbar(_("Wrote %d lines"), lineswritten);
+ statusbar(ngettext("Wrote %d line", "Wrote %d lines", lineswritten),
+ lineswritten);
UNSET(MODIFIED);
titlebar(NULL);
}
@@ -2655,7 +2643,7 @@ char *do_browser(const char *inpath)
free(foo);
return do_browser(path);
} else {
- retval = path;
+ retval = mallocstrcpy(retval, path);
abort = 1;
}
break;
diff --git a/global.c b/global.c
@@ -27,13 +27,6 @@
#include "proto.h"
#include "nano.h"
-#ifdef ENABLE_NLS
-#include <libintl.h>
-#define _(string) gettext(string)
-#else
-#define _(string) (string)
-#endif
-
/*
* Global variables
*/
diff --git a/move.c b/move.c
@@ -28,13 +28,6 @@
#include "proto.h"
#include "nano.h"
-#ifdef ENABLE_NLS
-#include <libintl.h>
-#define _(string) gettext(string)
-#else
-#define _(string) (string)
-#endif
-
int do_home(void)
{
UNSET(KEEP_CUTBUFFER);
diff --git a/nano.1 b/nano.1
@@ -135,10 +135,10 @@ Enable suspend ability.
Ignored, for compatibility with Pico.
.SH NOTES
\fBnano\fP will try to dump the buffer into an emergency file in some
-cases. Mainly, this will happen if \fBnano\fP receives a SIGHUP or runs
-out of memory, when it will write the buffer into a file named
-"nano.save" if the buffer didn't have a name already, or will add a
-".save" suffix to the current filename. If an emergency file with that
+cases. Mainly, this will happen if \fBnano\fP receives a SIGHUP or
+SIGTERM or runs out of memory, when it will write the buffer into a file
+named "nano.save" if the buffer didn't have a name already, or will add
+a ".save" suffix to the current filename. If an emergency file with that
name already exists in the current directory, ".save" and a number (e.g.
".save.1") will be suffixed to the current filename in order to make it
unique. In multibuffer mode, \fBnano\fP will write all the open buffers
diff --git a/nano.1.html b/nano.1.html
@@ -3,7 +3,7 @@ Content-type: text/html
<HTML><HEAD><TITLE>Manpage of NANO</TITLE>
</HEAD><BODY>
<H1>NANO</H1>
-Section: User Commands (1)<BR>Updated: July 30, 2002<BR><A HREF="#index">Index</A>
+Section: User Commands (1)<BR>Updated: October 13, 2002<BR><A HREF="#index">Index</A>
<A HREF="http://localhost/cgi-bin/man/man2html">Return to Main Contents</A><HR>
@@ -180,10 +180,10 @@ Ignored, for compatibility with Pico.
<H2>NOTES</H2>
<B>nano</B> will try to dump the buffer into an emergency file in some
-cases. Mainly, this will happen if <B>nano</B> receives a SIGHUP or runs
-out of memory, when it will write the buffer into a file named
-"nano.save" if the buffer didn't have a name already, or will add a
-".save" suffix to the current filename. If an emergency file with that
+cases. Mainly, this will happen if <B>nano</B> receives a SIGHUP or
+SIGTERM or runs out of memory, when it will write the buffer into a file
+named "nano.save" if the buffer didn't have a name already, or will add
+a ".save" suffix to the current filename. If an emergency file with that
name already exists in the current directory, ".save" and a number (e.g.
".save.1") will be suffixed to the current filename in order to make it
unique. In multibuffer mode, <B>nano</B> will write all the open buffers
@@ -235,6 +235,6 @@ used by others).
This document was created by
<A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
-Time: 21:12:05 GMT, July 30, 2002
+Time: 16:04:40 GMT, October 13, 2002
</BODY>
</HTML>
diff --git a/nano.c b/nano.c
@@ -42,13 +42,6 @@
#include "proto.h"
#include "nano.h"
-#ifdef ENABLE_NLS
-#include <libintl.h>
-#define _(string) gettext(string)
-#else
-#define _(string) (string)
-#endif
-
#ifdef HAVE_TERMIOS_H
#include <termios.h>
#endif
@@ -1973,16 +1966,34 @@ int justify_format(int changes_allowed, filestruct *line, size_t skip)
back = line->data + skip;
front = back;
for (; *front; front++) {
+ int remove_space = 0;
+ /* Do we want to remove this space? */
+
if (*front == '\t') {
if (!changes_allowed)
return 1;
*front = ' ';
}
/* these tests are safe since line->data + skip is not a space */
- if (*front == ' ' && *(front - 1) == ' ' && *(front - 2) != '.' &&
- *(front - 2) != '!' && *(front - 2) != '?') {
+ if (*front == ' ' && *(front-1) == ' ') {
+ const char *brackets = _("'\")}]>");
+ const char *punct = _(".?!");
+ const char *bob = front - 2;
+
+ remove_space = 1;
+ for (bob = front - 2; bob >= line->data + skip; bob--) {
+ if (strchr(punct, *bob) != NULL) {
+ remove_space = 0;
+ break;
+ }
+ if (strchr(brackets, *bob) == NULL)
+ break;
+ }
+ }
+
+ if (remove_space) {
/* Now *front is a space we want to remove. We do that by
- * simply failing to assign it to *back */
+ * simply failing to assign it to *back. */
if (!changes_allowed)
return 1;
#ifndef NANO_SMALL
@@ -2630,9 +2641,10 @@ void signal_init(void)
act.sa_handler = SIG_IGN;
sigaction(SIGINT, &act, NULL);
- /* Trap SIGHUP cuz we want to write the file out. */
- act.sa_handler = handle_hup;
+ /* Trap SIGHUP and SIGTERM cuz we want to write the file out. */
+ act.sa_handler = handle_hupterm;
sigaction(SIGHUP, &act, NULL);
+ sigaction(SIGTERM, &act, NULL);
#ifndef NANO_SMALL
act.sa_handler = handle_sigwinch;
@@ -2677,10 +2689,10 @@ void signal_init(void)
#endif
}
-/* Handler for SIGHUP */
-RETSIGTYPE handle_hup(int signal)
+/* Handler for SIGHUP and SIGTERM */
+RETSIGTYPE handle_hupterm(int signal)
{
- die(_("Received SIGHUP"));
+ die(_("Received SIGHUP or SIGTERM"));
}
/* What do we do when we catch the suspend signal */
@@ -2933,7 +2945,9 @@ int main(int argc, char *argv[])
#endif
{"tempfile", 0, 0, 't'},
{"view", 0, 0, 'v'},
+#ifndef DISABLE_WRAPPING
{"nowrap", 0, 0, 'w'},
+#endif
{"nohelp", 0, 0, 'x'},
{"suspend", 0, 0, 'z'},
#ifndef NANO_SMALL
@@ -3256,7 +3270,7 @@ int main(int argc, char *argv[])
while (1) {
-#ifndef DISABLE_MOUSE
+#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE) || !defined(DISABLE_HELP)
currshortcut = main_list;
#endif
diff --git a/nano.h b/nano.h
@@ -46,8 +46,14 @@
#include <curses.h>
#endif /* CURSES_H */
-#ifdef HAVE_LIBINTL_H
-#include <libintl.h>
+#ifdef ENABLE_NLS
+# ifdef HAVE_LIBINTL_H
+# include <libintl.h>
+# endif
+# define _(string) gettext(string)
+#else
+# define _(string) (string)
+# define ngettext(singular, plural, number) number == 1 ? singular : plural
#endif
#include <sys/types.h>
diff --git a/proto.h b/proto.h
@@ -290,7 +290,7 @@ int break_line(const char *line, int goal, int force);
int do_justify(void);
int do_exit(void);
void signal_init(void);
-RETSIGTYPE handle_hup(int signal);
+RETSIGTYPE handle_hupterm(int signal);
RETSIGTYPE do_suspend(int signal);
RETSIGTYPE do_cont(int signal);
#ifndef NANO_SMALL
diff --git a/rcfile.c b/rcfile.c
@@ -37,13 +37,6 @@
#ifdef ENABLE_NANORC
-#ifdef ENABLE_NLS
-#include <libintl.h>
-#define _(string) gettext(string)
-#else
-#define _(string) (string)
-#endif
-
const static rcoption rcopts[] = {
#ifndef NANO_SMALL
{"autoindent", AUTOINDENT},
diff --git a/search.c b/search.c
@@ -30,13 +30,6 @@
#include "proto.h"
#include "nano.h"
-#ifdef ENABLE_NLS
-#include <libintl.h>
-#define _(string) gettext(string)
-#else
-#define _(string) (string)
-#endif
-
/* Regular expression helper functions */
#ifdef HAVE_REGEX_H
diff --git a/utils.c b/utils.c
@@ -30,13 +30,6 @@
#include "proto.h"
#include "nano.h"
-#ifdef ENABLE_NLS
-#include <libintl.h>
-#define _(string) gettext(string)
-#else
-#define _(string) (string)
-#endif
-
int is_cntrl_char(int c)
{
if (iscntrl(c) || ((c & 127) != 127 && iscntrl(c & 127)))
diff --git a/winio.c b/winio.c
@@ -30,13 +30,6 @@
#include "proto.h"
#include "nano.h"
-#ifdef ENABLE_NLS
-#include <libintl.h>
-#define _(string) gettext(string)
-#else
-#define _(string) (string)
-#endif
-
static int statblank = 0; /* Number of keystrokes left after
we call statusbar(), before we
actually blank the statusbar */
@@ -655,9 +648,10 @@ void edit_add(const filestruct *fileptr, int yval, int start
/* Translate the match to the beginning of the line. */
startmatch.rm_so += k;
startmatch.rm_eo += k;
- if (startmatch.rm_so == startmatch.rm_eo)
+ if (startmatch.rm_so == startmatch.rm_eo) {
+ startmatch.rm_eo++;
statusbar(_("Refusing 0 length regex match"));
- else if (startmatch.rm_so < start + COLS &&
+ } else if (startmatch.rm_so < start + COLS &&
startmatch.rm_eo > start) {
x_start = startmatch.rm_so - start;
if (x_start < 0)