Compare commits

...

49 Commits

Author SHA1 Message Date
Chris Allegretta
4ceb30cfe7 GNU nano 1.1.8 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1163 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-30 16:56:53 +00:00
Chris Allegretta
ec8c1bc79d Fix the formatting of the spec a leetle
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1162 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-30 16:52:42 +00:00
Chris Allegretta
06d62372dc - Added new nano.spec file from Brett <brett@bad-sports.com>, added because maintaining the spec file is getting to be a large
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1161 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-30 16:51:38 +00:00
Chris Allegretta
78f0fc61ff rcfile fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1160 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-29 19:41:57 +00:00
Chris Allegretta
77777d4c0d Add David Benbennick's changes to open_pipe() and move it to nano.c, and add his nperror function
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1159 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-29 16:31:29 +00:00
Chris Allegretta
9b4055c4da Bah, don't fix what isn't broken
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1158 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-29 16:00:59 +00:00
Chris Allegretta
6ca01b1cd8 - nano.c: - Move the termios things in main() up to signal_init(), where they should probably be anyway
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1157 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-29 15:38:17 +00:00
Chris Allegretta
8e207bf03f - nano.c: - Move the termios things in main() up to signal_init(), where they should probably be anyway
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1156 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-29 15:31:54 +00:00
Chris Allegretta
f3a07b2d7e - winio.c:do_cursorpos() - Make col numbering start from 1 (suggested by Andrew Ho)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1155 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-29 15:15:38 +00:00
Chris Allegretta
e373909037 - files.c:do_insertfile() - Handle cancel from ExtCmd properly (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1154 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-29 15:06:05 +00:00
Jordi Mallach
465a0ffa15 Danish updates.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1153 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-29 00:46:05 +00:00
Chris Allegretta
2598c66d81 DLR's patch
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1152 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-28 01:59:34 +00:00
Jordi Mallach
7afc6d9468 Italian updates (Marco Colombo).
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1151 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-27 16:34:46 +00:00
Chris Allegretta
d1c2c1ca76 - search.c:do_gotoline() - Set placewewant if we actually move to a different line
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1150 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-26 17:58:42 +00:00
Chris Allegretta
f6cba64376 David's fixes for read_file and the assert stuff for renumber
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1147 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-26 13:05:54 +00:00
Chris Allegretta
bb88ece93c Rocco's mods to open_pipe
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1145 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-25 13:40:39 +00:00
Chris Allegretta
f21f3fcc1e - nano.c:do_int_speller() - Fix zombie processes and spelling buffer issues (Rocco Corsi)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1143 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-25 03:26:27 +00:00
Jordi Mallach
9c20ab0d5e Indonesian translation updates.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1142 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-25 01:13:59 +00:00
Chris Allegretta
373bc2fa48 General - Added separate regex variable (color_regex and colormatches) so that color syntax and regex search/replace can coexist
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1141 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-24 23:20:32 +00:00
Chris Allegretta
3533a348fc General - Added separate regex variable (color_regex and colormatches) so that color syntax and regex search/replace can coexist
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1140 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-24 23:19:32 +00:00
Chris Allegretta
b23d14460e Redo open_pipe with just pipes and no FIFOs
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1138 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-21 23:39:56 +00:00
Chris Allegretta
cf1d812ccb - nano.c:do_justify() - More fixes for indented justify (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1137 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-21 19:53:36 +00:00
Chris Allegretta
52c5a6ea48 External command code and fix for BUG #70
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1136 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-21 05:07:28 +00:00
Jordi Mallach
7fa082dc90 French translation updates (Jean-Philippe Guérard).
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1133 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-17 00:35:41 +00:00
Chris Allegretta
dce44abec7 winio.c:do_credits() - Add Thomas Dickey
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1131 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-16 01:03:41 +00:00
Jordi Mallach
b83e61aea0 Polish translation updates (Wojciech Kotwica).
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1130 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-15 15:15:13 +00:00
Jordi Mallach
286ee1faff Fix date.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1129 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-14 11:01:21 +00:00
Jordi Mallach
057c3c4aba Russian and Ukrainian translation updates (Sergey A. Ribalchenko).
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1128 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-14 11:00:56 +00:00
Jordi Mallach
6e6a7ac493 Iberian translations update.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1127 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-12 17:23:07 +00:00
Jordi Mallach
5477e1028a Galician translatin updates (Jacobo Tarrio).
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1126 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-12 16:15:50 +00:00
Jordi Mallach
558b5d8774 French translation updates (Jean-Philippe Guérard).
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1125 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-11 13:23:33 +00:00
Chris Allegretta
45329a127a Rocco's fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1124 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-10 01:22:21 +00:00
Chris Allegretta
d1ec7b0287 Allow flags with args to be translatable
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1123 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-09 20:05:26 +00:00
Chris Allegretta
b479c89594 - nano.c:help_init() - Various fixes and string changes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1122 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-09 20:03:10 +00:00
Chris Allegretta
1f8394d4bc Add newlines to gotodir help text
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1121 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-09 19:58:18 +00:00
Jordi Mallach
f7277b8176 Header fixes.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1120 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-09 19:42:08 +00:00
Chris Allegretta
3fc5d5722c - nano.c:usage() - Rewritten to encompass systems with and without GETOPT_LONG. New function print1opt does most of the dirty work, stops duplication of effort and eases translator's jobs. Also breaks all the current translations ;-)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1119 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-09 18:51:58 +00:00
Jordi Mallach
4e803aa59b Catalan, Indonesian and Spanish translation updates.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1118 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-09 18:05:53 +00:00
Chris Allegretta
97e6fe6331 - nano.c:usage() - Add -N to short format (no GETOPT_LONG) strings (noticed by Jordi)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1117 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-09 17:38:47 +00:00
Jordi Mallach
4951c66adc German & Swedish translation updates.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1116 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-07 14:12:53 +00:00
Chris Allegretta
5902f9672d - nano.c:help_init() - Capitalize Meta altkeys
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1115 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-07 12:40:39 +00:00
Chris Allegretta
e8e10347a9 - rcfile.c:parse_rcfile() - Don't use i for both for loop and atoi(), fixes lots of potential crashes, 1st reported by Jean-Philippe Gue'rard
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1114 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-07 00:47:22 +00:00
Chris Allegretta
1596d38698 - rcfile.c:parse_rcfile() - Don't use i for both for loop and atoi(), fixes lots of potential crashes, 1st reported by Jean-Philippe Gue'rard
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1113 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-07 00:46:17 +00:00
Jordi Mallach
79dcc475a7 Groar. Kill it this time.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1112 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-06 16:17:49 +00:00
Chris Allegretta
564535a6f7 - files.c:check_writable_directory() - Stat full_path, not path (Steven Kneizys)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1111 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-06 15:32:17 +00:00
Chris Allegretta
40ecbad296 NANO_SMALL issues
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1110 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-06 15:27:44 +00:00
Jordi Mallach
ee91f71a66 shitstamp
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1109 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-06 10:58:52 +00:00
Chris Allegretta
bef1297c6d Type misalignments and mem leaks in renumber_all, do_justify and do_spell (Rocco & Steven Kneizys)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1108 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-06 03:30:40 +00:00
Chris Allegretta
26d59eae5f Back to CVS
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1107 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2002-03-05 23:49:14 +00:00
38 changed files with 9850 additions and 8131 deletions

View File

@@ -17,4 +17,5 @@ mkinstalldirs
nano
nano.info
stamp-h
stamp-h.in
stamp-h1

1
BUGS
View File

@@ -131,6 +131,7 @@
Trevor Cordes) (68) [FIXED].
- Home and End control keys (^A, ^E) do not always work in filename
prompt (bug found by Ian Turner) (69) [1.0 series only] [FIXED].
- Trying to insert a file of 0 bytes will hang nano (70) [FIXED].
** Open BUGS **
$Id$

View File

@@ -1,3 +1,100 @@
GNU nano 1.1.8 - 03/30/2002
- General
- Type misalignments and mem leaks in renumber_all, do_justify
and do_spell (Rocco & Steven Kneizys).
- New "External Command" code, originally by Dwayne Rightler,
various fixes and changes by Chris, Rocco and David Benbennick.
New function nano.c:open_pipe() and signal handler cancel_fork(),
changes to do_insertfile(), new list extcmd_list, cmd is
^X after ^R.
- Added separate regex variable (color_regex and colormatches)
so that color syntax and regex search/replace can coexist.
- Added new nano.spec file from Brett <brett@bad-sports.com>,
added because maintaining the spec file is getting to be a large
hassle ;)
- files.c:
check_writable_directory()
- Stat full_path, not path (Steven Kneizys).
open_pipe()
- I18nize the pipe error (DLR).
do_insertfile()
- Handle cancel from ExtCmd properly (David Benbennick).
read_file()
- Abort if we read a file of 0 lines (num_lines == 0), fixes BUG #70.
- Reverse tests to stop segfault on editing a new file of 0
lines (David Benbennick)
- Change input var to one char instead of array (David Benbennick).
- Move NO_CONVERT check up so chars get read in properly (DLR).
- nano.c:
do_justify()
- More fixes for indented justify (David Benbennick).
do_int_speller()
- Fix zombie processes and spelling buffer issues (Rocco Corsi).
help_init()
- Capitalize Meta altkeys.
- Various fixes and string changes.
main()
- Put NANO_SMALL defines around toggle pointer (noticed by Jordi);
usage()
- Rewritten to encompass systems with and without GETOPT_LONG.
New function print1opt does most of the dirty work, stops
duplication of effort and eases translator's jobs. Also
breaks all the current translations ;-)
- proto.h:
- Missing externs (Rocco).
- rcfile.c:
do_rcfile()
- Reset lineno between system and local .nanorc file.
- Fix errno->strerror(errno) mismatch.
parse_rcfile()
- Don't use i for both for loop and atoi(), fixes lots of
potential crashes, 1st reported by Jean-Philippe Guérard.
rcfile_error()
- Don't print out the file name if we haven't opened the file
yet (lineno == 0).
- search.c:
search_init()
- Fix a missing free (Rocco).
do_gotoline()
- Set placewewant if we actually move to a different line.
- utils.c:
stristr()
- Defined regardless of NANO_SMALL (noticed by Jordi).
nperror()
- New wrapper for perror (David Benbennick).
- winio.c:
do_credits()
- Add Thomas Dickey.
do_cursorpos()
- Make col numbering start from 1 (suggested by Andrew Ho).
update_line(), xpt()
- Add check for 127 (DLR).
- po/sv.po:
- Swedish translation updates (Christian Rose).
- po/de.po:
- German translation updates (Michael Piefel).
- po/id.po:
- Indonesian translation updates (Tedi Heriyanto).
- po/it.po:
- Serious typo.
- po/ca.po, po/es.po:
- Catalan and Spanish translation updates (Jordi).
- Typo (DLR).
- po/fr.po:
- French translation updates (Jean-Philippe Guérard).
- po/gl.po:
- Galician translation updates (Jacobo Tarrio).
- po/uk.po, po/ru.po:
- Russian and Ukrainian translation updates (Sergey A. Ribalchenko).
- po/pl.po:
- Polish translation updates (Wojciech Kotwica).
- po/fr.po:
- French translation updates (Jean-Philippe Guérard).
- po/it.po:
- Italian translation updates (Marco Colombo).
- po/da.po:
- Danish translation updates (Keld Simonsen).
GNU nano 1.1.7 - 03/05/2002
- General
- malloc->calloc, etc cleanups (DLR).

View File

@@ -25,7 +25,7 @@ MAKEINFO = makeinfo --no-split
EXTRA_DIST = ABOUT-NLS AUTHORS BUGS COPYING ChangeLog INSTALL NEWS \
README THANKS TODO install-sh missing mkinstalldirs \
nano.1 nano.1.html faq.html nanorc.sample
nano.1 nano.1.html faq.html nanorc.sample nano.spec
SUBDIRS = po intl m4

10
NEWS
View File

@@ -1,3 +1,13 @@
03/30/2002 - GNU nano 1.1.8 is released. New features include an
"Insert Output of External Command", ^R^X, and a .spec
file is now included in the distribution. There are
cleanups in the usage code, fixes for regex parsing,
the file browser, the NO_CONVERT auto-detect, indented
justification, the internal spell checker, and a serious
bug where reading a file of 0 lines would hang nano.
Also, the "show position" code now shows the starting
column as 1 instead of 0. Have fun!
03/05/2002 - GNU nano 1.1.7 "lets change everything and see what breaks"
is released. New features include new flags
-N,--noconvert to stop any file format conversion and

View File

@@ -3,7 +3,7 @@ dnl Process this file with autoconf to produce a configure script.
AC_INIT
AC_CONFIG_SRCDIR([nano.c])
AC_PREREQ(2.52)
AM_INIT_AUTOMAKE(nano, 1.1.7)
AM_INIT_AUTOMAKE(nano, 1.1.8)
AM_CONFIG_HEADER(config.h:config.h.in)
AM_ACLOCAL_INCLUDE(m4)
ALL_LINGUAS="es de fr it id fi hu ca cs gl uk ru sv nn nl da pl nb"
@@ -309,5 +309,5 @@ fi
dnl i18n stuff - pretty incomplete for now
NANO_AM_GNU_GETTEXT
AC_CONFIG_FILES([Makefile intl/Makefile m4/Makefile po/Makefile.in])
AC_CONFIG_FILES([Makefile intl/Makefile m4/Makefile po/Makefile.in nano.spec])
AC_OUTPUT

4
cut.c
View File

@@ -382,6 +382,10 @@ int do_uncut_text(void)
totsize += strlen(cutbuffer->data);
if (strlen(cutbuffer->data) == 0)
totlines++;
/* If we've uncut a line, make sure there's a magicline after
it */
if (current->next == NULL)
new_magicline();
placewewant = xplustabs();
update_cursor();

View File

@@ -203,7 +203,7 @@ nano was developed).</font></blockquote>
of nano?</font></h2>
<blockquote><font color="#330000">The current version of nano *should*
be 1.1.7.&nbsp; Of course you should always check the nano homepage to
be 1.1.8.&nbsp; Of course you should always check the nano homepage to
see what the latest and greatest version is.</font></blockquote>
<h2>
@@ -394,7 +394,7 @@ try:
3.7. Tell me more about this multibuffer stuff!</font></h2>
<blockquote><font color="#330000"> To use multiple file buffers, you must
be using nano 1.1.7 or newer, and you must have configured nano with
be using nano 1.1.8 or newer, and you must have configured nano with
<b>--enable-multibuffer</b> or <b>--enable-extra</b> (use nano -V to check).
Then when you want to enable inserting a file into its own buffer instead of
into the current file, just hit <b>Meta-F</b>, then insert the file as normal
@@ -414,7 +414,7 @@ buffer is open.
<blockquote><font color="#330000"> It's not hard at all! But, your version
of nano must have beem compiled with <b>--enable-nanorc</b>, and again must
be version 1.1.7 or newer (use nano -V to check your version and compiled
be version 1.1.8 or newer (use nano -V to check your version and compiled
features). Then simply copy the <b>nanorc.sample</b>
that came with the nano source or your nano package (most likely in
/usr/doc/nano) to .nanorc in your home directory. If you didn't get one,

74
files.c
View File

@@ -26,6 +26,7 @@
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
@@ -109,11 +110,9 @@ int read_byte(int fd, char *filename, char *input)
index = 0;
size = read(fd, buf, BUFSIZ);
if (size == -1) {
clear();
refresh();
resetty();
endwin();
perror(filename);
size = index; /* note index==0 */
nperror(filename);
return -1;
}
if (!size)
return 0;
@@ -174,7 +173,7 @@ int read_file(int fd, char *filename, int quiet)
{
long size;
int num_lines = 0;
char input[2]; /* buffer */
char input; /* current input character */
char *buf;
long i = 0, bufx = 128;
filestruct *fileptr = current, *tmp = NULL;
@@ -191,30 +190,31 @@ int read_file(int fd, char *filename, int quiet)
current = fileage;
line1ins = 1;
}
input[1] = 0;
/* Read the entire file into file struct */
while ((size = read_byte(fd, filename, input)) > 0) {
while ((size = read_byte(fd, filename, &input)) > 0) {
if (input[0] == '\n') {
#ifndef NANO_SMALL
if (!ISSET(NO_CONVERT) && input >= 0 && input <= 31
&& input != 127 && input != '\t' && input != '\r'
&& input != '\n')
/* If the file has binary chars in it, don't stupidly
assume it's a DOS or Mac formatted file! */
SET(NO_CONVERT);
#endif
if (input == '\n') {
fileptr = read_line(buf, fileptr, &line1ins);
num_lines++;
buf[0] = 0;
i = 0;
#ifndef NANO_SMALL
} else if (!ISSET(NO_CONVERT) && input[0] >= 0 && input[0] <= 31
&& input[0] != '\t' && input[0] != '\r'
&& input[0] != '\n')
/* If the file has binary chars in it, don't stupidly
assume it's a DOS or Mac formatted file! */
SET(NO_CONVERT);
/* If it's a Mac file (no LF just a CR), and file conversion
isn't disabled, handle it! */
else if (!ISSET(NO_CONVERT) && i > 0 && buf[i-1] == '\r') {
} else if (!ISSET(NO_CONVERT) && i > 0 && buf[i-1] == '\r') {
fileformat = 2;
fileptr = read_line(buf, fileptr, &line1ins);
num_lines++;
buf[0] = input[0];
buf[0] = input;
buf[1] = 0;
i = 1;
#endif
@@ -228,7 +228,7 @@ int read_file(int fd, char *filename, int quiet)
buf = nrealloc(buf, bufx + 128);
bufx += 128;
}
buf[i] = input[0];
buf[i] = input;
buf[i + 1] = 0;
i++;
}
@@ -241,13 +241,21 @@ int read_file(int fd, char *filename, int quiet)
num_lines++;
buf[0] = 0;
}
/* Did we even GET a file? */
/* Did we even GET a file if we don't already have one? */
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;
@@ -280,6 +288,7 @@ int read_file(int fd, char *filename, int quiet)
return 1;
}
/* Open the file (and decide if it exists) */
int open_file(char *filename, int insert, int quiet)
{
@@ -416,6 +425,19 @@ int do_insertfile(int loading_file)
}
#endif
#ifndef NANO_SMALL
if (i == NANO_EXTCMD_KEY) {
int ts;
ts = statusq(1, extcmd_list, "", _("Command to execute "));
if (ts == -1 || answer == NULL || !strcmp(answer,"")) {
statusbar(_("Cancelled"));
UNSET(KEEP_CUTBUFFER);
display_main_list();
return 0;
}
}
#endif
#ifdef ENABLE_MULTIBUFFER
if (loading_file) {
@@ -427,7 +449,15 @@ int do_insertfile(int loading_file)
}
#endif
i = open_file(realname, 1, loading_file);
#ifndef NANO_SMALL
if (i == NANO_EXTCMD_KEY) {
i = open_pipe(answer);
}
else
#endif /* NANO_SMALL */
{
i = open_file(realname, 1, loading_file);
}
#ifdef ENABLE_MULTIBUFFER
if (loading_file)
@@ -970,7 +1000,7 @@ char *check_writable_directory(const char *path) {
/* otherwise, stat() the full path to see if it's writable by the
user; set writable to 1 if it is, or 0 if it isn't */
stat(path, &fileinfo);
stat(full_path, &fileinfo);
if (fileinfo.st_mode & S_IWUSR)
writable = 1;
else

View File

@@ -99,6 +99,7 @@ shortcut *writefile_list = NULL;
shortcut *insertfile_list = NULL;
shortcut *help_list = NULL;
shortcut *spell_list = NULL;
shortcut *extcmd_list = NULL;
#ifndef DISABLE_BROWSER
shortcut *browser_list = NULL;
#endif
@@ -122,6 +123,11 @@ toggle *toggles = NULL;
regex_t search_regexp; /* Global to store compiled search regexp */
regmatch_t regmatches[10]; /* Match positions for parenthetical
subexpressions, max of 10 */
#ifdef ENABLE_COLOR
regex_t color_regexp; /* Global to store compiled search regexp */
regmatch_t colormatches[1]; /* Match positions for parenthetical */
#endif /* ENABLE_COLOR */
#endif
int length_of_list(shortcut *s)
@@ -268,7 +274,7 @@ void shortcut_init(int unjustify)
#ifndef NANO_SMALL
char *nano_tofiles_msg = "", *nano_gotodir_msg = "", *nano_case_msg =
"", *nano_reverse_msg = "";
"", *nano_reverse_msg = "", *nano_execute_msg = "";
char *nano_dos_msg = "", *nano_mac_msg = "";
#ifdef HAVE_REGEX_H
@@ -317,6 +323,7 @@ void shortcut_init(int unjustify)
nano_case_msg =
_("Make the current search or replace case (in)sensitive");
nano_tofiles_msg = _("Go to file browser");
nano_execute_msg = _("Execute external command");
nano_gotodir_msg = _("Goto Directory");
nano_cancel_msg = _("Cancel the current function");
nano_append_msg = _("Append to the current file");
@@ -638,6 +645,10 @@ void shortcut_init(int unjustify)
sc_init_one(&insertfile_list, NANO_TOFILES_KEY, _("To Files"),
nano_tofiles_msg, 0, 0, 0, NOVIEW, 0);
#endif
#ifndef NANO_SMALL
sc_init_one(&insertfile_list, NANO_EXTCMD_KEY, _("Execute Command"),
nano_execute_msg, 0, 0, 0, NOVIEW, 0);
#endif
sc_init_one(&spell_list, NANO_HELP_KEY,
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
@@ -645,6 +656,13 @@ void shortcut_init(int unjustify)
sc_init_one(&spell_list, NANO_CANCEL_KEY, _("Cancel"),
nano_cancel_msg, 0, 0, 0, VIEW, 0);
#ifndef NANO_SMALL
sc_init_one(&extcmd_list, NANO_HELP_KEY,
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
sc_init_one(&extcmd_list, NANO_CANCEL_KEY, _("Cancel"),
nano_cancel_msg, 0, 0, 0, VIEW, 0);
#endif
#ifndef DISABLE_BROWSER
@@ -735,7 +753,7 @@ void thanks_for_all_the_fish(void)
filestruct * current_open_file;
#endif
#ifdef ENABLE_MULTIBUFFER
#ifndef DISABLE_OPERATINGDIR
if (operating_dir != NULL)
free(operating_dir);
if (full_operating_dir != NULL)

391
nano.c
View File

@@ -367,8 +367,9 @@ int free_filestruct(filestruct * src)
int renumber_all(void)
{
filestruct *temp;
long i = 1;
int i = 1;
assert(fileage==NULL || fileage!=fileage->next);
for (temp = fileage; temp != NULL; temp = temp->next) {
temp->lineno = i++;
}
@@ -384,6 +385,7 @@ int renumber(filestruct * fileptr)
renumber_all();
return 0;
}
assert(fileptr==NULL || fileptr!=fileptr->next);
for (temp = fileptr; temp != NULL; temp = temp->next) {
if (temp->prev != NULL)
temp->lineno = temp->prev->lineno + 1;
@@ -412,149 +414,88 @@ void null_at(char **data, int index)
align(data);
}
/* Print one usage string to the screen, removes lots of duplicate
strings to translate and takes out the parts that shouldn't be
translatable (the flag names) */
void print1opt(char *shortflag, char *longflag, char *desc)
{
printf(" %s\t", shortflag);
if (strlen(shortflag) < 8)
printf("\t");
#ifdef HAVE_GETOPT_LONG
printf("%s\t", longflag);
if (strlen(longflag) < 8)
printf("\t\t");
else if (strlen(longflag) < 16)
printf("\t");
#endif
printf("%s\n", desc);
}
void usage(void)
{
#ifdef HAVE_GETOPT_LONG
printf(_("Usage: nano [GNU long option] [option] +LINE <file>\n\n"));
printf(_("Option Long option Meaning\n"));
#ifndef NANO_SMALL
printf
(_
(" -D --dos Write file in DOS format\n"));
#endif
#ifdef ENABLE_MULTIBUFFER
printf
(_
(" -F --multibuffer Enable multiple file buffers\n"));
#endif
printf(_
(" -K --keypad Use alternate keypad routines\n"));
#ifndef NANO_SMALL
printf
(_
(" -M --mac Write file in Mac format\n"));
printf
(_
(" -N --noconvert Don't convert files from DOS/Mac format\n"));
#endif
#ifndef DISABLE_JUSTIFY
printf
(_
(" -Q [str] --quotestr [str] Quoting string, default \"> \"\n"));
#endif
#ifndef NANO_SMALL
printf(_
(" -S --smooth Smooth scrolling\n"));
#endif
printf(_
(" -T [num] --tabsize=[num] Set width of a tab to num\n"));
printf
(_
(" -V --version Print version information and exit\n"));
printf(_
(" -c --const Constantly show cursor position\n"));
printf(_
(" -h --help Show this message\n"));
#ifndef NANO_SMALL
printf(_
(" -i --autoindent Automatically indent new lines\n"));
printf(_
(" -k --cut Let ^K cut from cursor to end of line\n"));
#endif
printf(_
(" -l --nofollow Don't follow symbolic links, overwrite\n"));
#ifndef DISABLE_MOUSE
#ifdef NCURSES_MOUSE_VERSION
printf(_(" -m --mouse Enable mouse\n"));
#endif
#endif
#ifndef DISABLE_OPERATINGDIR
printf(_
(" -o [dir] --operatingdir=[dir] Set operating directory\n"));
#endif
printf(_
(" -p --pico Emulate Pico as closely as possible\n"));
#ifndef DISABLE_WRAPJUSTIFY
printf
(_
(" -r [#cols] --fill=[#cols] Set fill cols to (wrap lines at) #cols\n"));
#endif
#ifndef DISABLE_SPELLER
printf(_
(" -s [prog] --speller=[prog] Enable alternate speller\n"));
#endif
printf(_
(" -t --tempfile Auto save on exit, don't prompt\n"));
printf(_
(" -v --view View (read only) mode\n"));
#ifndef DISABLE_WRAPPING
printf(_
(" -w --nowrap Don't wrap long lines\n"));
#endif
printf(_
(" -x --nohelp Don't show help window\n"));
printf(_
(" -z --suspend Enable suspend\n"));
printf(_
(" +LINE Start at line number LINE\n"));
#else
printf(_("Usage: nano [option] +LINE <file>\n\n"));
printf(_("Option Meaning\n"));
#endif /* HAVE_GETOPT_LONG */
#ifndef NANO_SMALL
printf(_(" -D Write file in DOS format\n"));
print1opt("-D", "--dos", _("Write file in DOS format"));
#endif
#ifdef ENABLE_MULTIBUFFER
printf(_(" -F Enable multiple file buffers\n"));
print1opt("-F", "--multibuffer", _("Enable multiple file buffers"));
#endif
printf(_(" -K Use alternate keypad routines\n"));
print1opt("-K", "--keypad", _("Use alternate keypad routines"));
#ifndef NANO_SMALL
printf(_(" -M Write file in Mac format\n"));
print1opt("-M", "--mac", _("Write file in Mac format"));
print1opt("-N", "--noconvert", _("Don't convert files from DOS/Mac format"));
#endif
#ifndef DISABLE_JUSTIFY
printf(_(" -Q [str] Quoting string, default \"> \"\n"));
print1opt(_("-Q [str]"), _("--quotestr [str]"), _("Quoting string, default \"> \""));
#endif
printf(_(" -R Use regular expressions for search\n"));
#ifndef NANO_SMALL
printf(_(" -S Smooth scrolling\n"));
print1opt("-S", "--smooth", _("Smooth scrolling"));
#endif
printf(_(" -T [num] Set width of a tab to num\n"));
printf(_(" -V Print version information and exit\n"));
printf(_(" -c Constantly show cursor position\n"));
printf(_(" -h Show this message\n"));
print1opt(_("-T [num]"), _("--tabsize=[num]"), _("Set width of a tab to num"));
print1opt("-V", "--version", _("Print version information and exit"));
print1opt("-c", "--const", _("Constantly show cursor position"));
print1opt("-h", "--help", _("Show this message"));
#ifndef NANO_SMALL
printf(_(" -i Automatically indent new lines\n"));
printf(_(" -k Let ^K cut from cursor to end of line\n"));
print1opt("-i", "--autoindent", _("Automatically indent new lines"));
print1opt("-k", "--cut", _("Let ^K cut from cursor to end of line"));
#endif
printf(_
(" -l Don't follow symbolic links, overwrite\n"));
print1opt("-l", "--nofollow", _("Don't follow symbolic links, overwrite"));
#ifndef DISABLE_MOUSE
#ifdef NCURSES_MOUSE_VERSION
printf(_(" -m Enable mouse\n"));
print1opt("-m", "--mouse", _("Enable mouse"));
#endif
#endif
#ifndef DISABLE_OPERATINGDIR
printf(_(" -o [dir] Set operating directory\n"));
print1opt(_("-o [dir]"), _("--operatingdir=[dir]"), _("Set operating directory"));
#endif
printf(_(" -p Emulate Pico as closely as possible\n"));
print1opt("-p", "--pico", _("Emulate Pico as closely as possible"));
#ifndef DISABLE_WRAPJUSTIFY
printf(_
(" -r [#cols] Set fill cols to (wrap lines at) #cols\n"));
print1opt(_("-r [#cols]"), _("--fill=[#cols]"), _("Set fill cols to (wrap lines at) #cols"));
#endif
#ifndef DISABLE_SPELLER
printf(_(" -s [prog] Enable alternate speller\n"));
print1opt(_("-s [prog]"), _("--speller=[prog]"), _("Enable alternate speller"));
#endif
printf(_(" -t Auto save on exit, don't prompt\n"));
printf(_(" -v View (read only) mode\n"));
print1opt("-t", "--tempfile", _("Auto save on exit, don't prompt"));
print1opt("-v", "--view", _("View (read only) mode"));
#ifndef DISABLE_WRAPPING
printf(_(" -w Don't wrap long lines\n"));
#endif
printf(_(" -x Don't show help window\n"));
printf(_(" -z Enable suspend\n"));
printf(_(" +LINE Start at line number LINE\n"));
print1opt("-w", "--nowrap", _("Don't wrap long lines"));
#endif
print1opt("-x", "--nohelp", _("Don't show help window"));
print1opt("-z", "--suspend", _("Enable suspend"));
print1opt(_("+LINE"), "", _("Start at line number LINE"));
exit(0);
}
@@ -1524,8 +1465,9 @@ int do_int_spell_fix(char *word)
}
/* restore the search/replace strings */
last_search = mallocstrcpy(last_search, save_search);
last_replace = mallocstrcpy(last_replace, save_replace);
free(last_search); last_search=save_search;
free(last_replace); last_replace=save_replace;
free(prevanswer);
/* restore where we were */
current = begin;
@@ -1547,11 +1489,10 @@ int do_int_spell_fix(char *word)
int do_int_speller(char *tempfile_name)
{
char *read_buff, *read_buff_ptr, *read_buff_word;
long pipe_buff_size;
size_t pipe_buff_size, read_buff_size, read_buff_read, bytesread;
int in_fd[2], tempfile_fd;
int spell_status;
pid_t pid_spell;
ssize_t bytesread;
/* Create a pipe to spell program */
@@ -1620,40 +1561,48 @@ int do_int_speller(char *tempfile_name)
return FALSE;
}
read_buff = charalloc(pipe_buff_size + 1);
/* Read-in the returned spelling errors */
/* Process the returned spelling errors */
read_buff_read = 0;
read_buff_size = pipe_buff_size + 1;
read_buff = read_buff_ptr = charalloc(read_buff_size);
while ((bytesread = read(in_fd[0], read_buff, pipe_buff_size)) > 0) {
while ((bytesread = read(in_fd[0], read_buff_ptr, pipe_buff_size)) > 0) {
read_buff[bytesread] = (char) NULL;
read_buff_word = read_buff_ptr = read_buff;
while (*read_buff_ptr != (char) NULL) {
/* Windows version may need to process additional char '\r' */
/* Possible problem here if last word not followed by '\n' */
if (*read_buff_ptr == '\n') {
*read_buff_ptr = (char) NULL;
if (!do_int_spell_fix(read_buff_word)) {
close(in_fd[0]);
free(read_buff);
replace_abort();
return TRUE;
}
read_buff_word = read_buff_ptr;
read_buff_word++;
}
read_buff_ptr++;
}
read_buff_read += bytesread;
read_buff_size += pipe_buff_size;
read_buff = read_buff_ptr = nrealloc(read_buff, read_buff_size);
read_buff_ptr += read_buff_read;
}
*read_buff_ptr = (char) NULL;
close(in_fd[0]);
/* Process the spelling errors */
read_buff_word = read_buff_ptr = read_buff;
while (*read_buff_ptr) {
if ((*read_buff_ptr == '\n') || (*read_buff_ptr == '\r')) {
*read_buff_ptr = (char) NULL;
if (read_buff_word != read_buff_ptr) {
if (!do_int_spell_fix(read_buff_word)) {
read_buff_word = read_buff_ptr;
break;
}
}
read_buff_word = read_buff_ptr + 1;
}
read_buff_ptr++;
}
/* special case where last word doesn't end with \n or \r */
if (read_buff_word != read_buff_ptr)
do_int_spell_fix(read_buff_word);
free(read_buff);
replace_abort();
@@ -1755,6 +1704,7 @@ int do_spell(void)
if (write_file(temp, 1, 0, 0) == -1) {
statusbar(_("Spell checking failed: unable to write temp file!"));
free(temp);
return 0;
}
@@ -1777,11 +1727,117 @@ int do_spell(void)
else
statusbar(_("Spell checking failed"));
free(temp);
return spell_res;
#endif
}
#ifndef NANO_SMALL
static int pid; /* this is the PID of the newly forked process below.
* It must be global since the signal handler needs it.
*/
RETSIGTYPE cancel_fork(int signal) {
if (kill(pid, SIGKILL)==-1) nperror("kill");
}
int open_pipe(char *command)
{
int fd[2];
struct sigaction oldaction, newaction;
/* original and temporary handlers for SIGINT */
#ifdef _POSIX_VDISABLE
struct termios term, newterm;
#endif /* _POSIX_VDISABLE */
int cancel_sigs = 0;
/* cancel_sigs==1 means that sigaction failed without changing the
* signal handlers. cancel_sigs==2 means the signal handler was
* changed, but the tcsetattr didn't succeed.
* I use this variable since it is important to put things back when
* we finish, even if we get errors.
*/
/* Make our pipes. */
if (pipe(fd) == -1) {
statusbar(_("Could not pipe"));
return 1;
}
/* Fork a child */
if ((pid = fork()) == 0) {
close(fd[0]);
dup2(fd[1], fileno(stdout));
dup2(fd[1], fileno(stderr));
/* If execl() returns at all, there was an error. */
execl("/bin/sh","sh","-c",command,0);
exit(0);
}
/* Else continue as parent */
close(fd[1]);
if (pid == -1) {
close(fd[0]);
statusbar(_("Could not fork"));
return 1;
}
/* before we start reading the forked command's output, we set
* things up so that ^C will cancel the new process.
*/
if (sigaction(SIGINT, NULL, &newaction)==-1) {
cancel_sigs = 1;
nperror("sigaction");
} else {
newaction.sa_handler = cancel_fork;
if (sigaction(SIGINT, &newaction, &oldaction)==-1) {
cancel_sigs = 1;
nperror("sigaction");
}
}
/* note that now oldaction is the previous SIGINT signal handler, to
be restored later */
/* if the platform supports disabling individual control characters */
#ifdef _POSIX_VDISABLE
if (!cancel_sigs && tcgetattr(0, &term) == -1) {
cancel_sigs = 2;
nperror("tcgetattr");
}
if (!cancel_sigs) {
newterm = term;
/* Grab oldterm's VINTR key :-) */
newterm.c_cc[VINTR] = oldterm.c_cc[VINTR];
if (tcsetattr(0, TCSANOW, &newterm) == -1) {
cancel_sigs = 2;
nperror("tcsetattr");
}
}
#endif /* _POSIX_VDISABLE */
read_file(fd[0],"stdin",0);
set_modified();
if (wait(NULL) == -1)
nperror("wait");
#ifdef _POSIX_VDISABLE
if (!cancel_sigs && tcsetattr(0, TCSANOW, &term) == -1)
nperror("tcsetattr");
#endif /* _POSIX_VDISABLE */
if (cancel_sigs!=1 && sigaction(SIGINT, &oldaction, NULL) == -1)
nperror("sigaction");
return 0;
}
#endif /* NANO_SMALL */
int do_exit(void)
{
int i;
@@ -2237,7 +2293,8 @@ int do_justify(void)
return 1;
#else
int slen = 0; /* length of combined lines on one line. */
int initial_y, kbinput = 0, totbak;
int initial_y, kbinput = 0;
long totbak;
filestruct *initial = NULL, *tmpjust = NULL, *cutbak, *tmptop, *tmpbot;
filestruct *samecheck = current;
int qdepth = 0;
@@ -2339,10 +2396,9 @@ int do_justify(void)
totsize += slen;
if ((strlenpt(current->data) > (fill))
&& !no_spaces(current->data)) {
&& !no_spaces(current->data + qdepth)) {
do {
int i = 0, j = 0;
int len2 = 0;
filestruct *tmpline = nmalloc(sizeof(filestruct));
@@ -2353,16 +2409,12 @@ int do_justify(void)
/* Note that we CAN break before the first word, since that is how
* pico does it. */
int last_space = -1; /* index of the last breakpoint */
int allowed_width;
i = qdepth * strlen(quotestr); /* the line starts with
indentation, so we must skip it! */
allowed_width = fill - i; /* how wide can our lines be? */
for(; i<slen; i++) {
for(i=qdepth; i<slen; i++) {
if (isspace((int) current->data[i])) last_space = i;
if (last_space!=-1 &&
strnlenpt(current->data,i) >= allowed_width) {
/* ARGH! We must look at the length of the first i+1 characters. */
strnlenpt(current->data,i+1) > fill) {
i = last_space;
break;
}
@@ -2375,15 +2427,15 @@ int do_justify(void)
current->data[i] = '\0';
len2 = strlen(current->data + i + 1);
tmpline->data = charalloc(len2 + 1 + qdepth);
slen -= i + 1 - qdepth; /* note i > qdepth */
tmpline->data = charalloc(slen + 1);
for (j = 0; j < qdepth; j += strlen(quotestr))
strcpy(&tmpline->data[j], quotestr);
/* Skip the white space in current. */
memcpy(&tmpline->data[j], current->data + i + 1, len2);
tmpline->data[len2 + qdepth] = '\0';
memcpy(&tmpline->data[qdepth], current->data + i + 1, slen-qdepth);
tmpline->data[slen] = '\0';
current->data = nrealloc(current->data, i + 1);
@@ -2394,10 +2446,9 @@ int do_justify(void)
current->next = tmpline;
current = tmpline;
slen -= i + 1;
current_y++;
} while ((strlenpt(current->data) > (fill))
&& !no_spaces(current->data));
&& !no_spaces(current->data + qdepth));
}
tmpbot = current;
@@ -2517,9 +2568,9 @@ void help_init(void)
"using a nanorc file, inserting a file will cause it to be "
"loaded into a separate buffer (use Meta-< and > to switch "
"between file buffers).\n\n If you need another blank "
"buffer, just press Enter at the prompt without typing in a "
"filename, or type in a nonexistent filename at the prompt "
"and press Enter.\n\n The following function keys are "
"buffer, do not enter any filename, or type in a "
"nonexistent filename at the prompt and press "
"Enter.\n\n The following function keys are "
"available in Insert File mode:\n\n");
else if (currshortcut == writefile_list)
ptr = _("Write File Help Text\n\n "
@@ -2549,7 +2600,7 @@ void help_init(void)
"Enter the name of the directory you would like to "
"browse to.\n\n If tab completion has not been disabled, "
"you can use the TAB key to (attempt to) automatically "
"complete the directory name. The following function "
"complete the directory name.\n\n The following function "
"keys are available in Browser GotoDir mode:\n\n");
#endif
else if (currshortcut == spell_list)
@@ -2561,6 +2612,14 @@ void help_init(void)
"instance of the given misspelled word in the "
"current file.\n\n The following other functions are "
"available in Spell Check mode:\n\n");
#ifndef NANO_SMALL
else if (currshortcut == extcmd_list)
ptr = _("External Command Help Text\n\n "
"This menu allows you to insert the output of a command "
"run by the shell into the current buffer (or a new "
"buffer in multibuffer mode).\n\n The following keys are "
"available in this mode:\n\n");
#endif
else /* Default to the main help list */
ptr = help_text_init;
@@ -2618,6 +2677,10 @@ void help_init(void)
sofar += snprintf(&buf[sofar], BUFSIZ - sofar,
(meta_shortcut ? "M-%c " : "(M-%c) "),
s->altval - 32);
else if (s->altval >= 'a')
sofar += snprintf(&buf[sofar], BUFSIZ - sofar,
(meta_shortcut ? "M-%c " : "(M-%c) "),
s->altval - 32);
else if (s->altval > 0)
sofar += snprintf(&buf[sofar], BUFSIZ - sofar,
(meta_shortcut ? "M-%c " : "(M-%c) "),
@@ -2771,7 +2834,9 @@ int main(int argc, char *argv[])
int modify_control_seq;
char *argv0;
shortcut *s;
#ifndef NANO_SMALL
toggle *t;
#endif
#ifdef _POSIX_VDISABLE
struct termios term;

1
nano.h
View File

@@ -289,6 +289,7 @@ know what you're doing */
#define NANO_OPENPREV_ALTKEY NANO_ALT_COMMA
#define NANO_OPENNEXT_ALTKEY NANO_ALT_PERIOD
#define NANO_BRACKET_KEY NANO_ALT_BRACKET
#define NANO_EXTCMD_KEY NANO_CONTROL_X
#define TOGGLE_CONST_KEY NANO_ALT_C
#define TOGGLE_AUTOINDENT_KEY NANO_ALT_I

45
nano.spec.in Normal file
View File

@@ -0,0 +1,45 @@
%define name @PACKAGE@
%define ver @VERSION@
%define rel 1
Summary : Pico editor clone with enhancements
Name : %{name}
Version : %{ver}
Release : %{rel}
Copyright : GPL
Group : Console/Editors
Packager : Chris Allegretta <chrisa@asty.org>
URL : http://www.nano-editor.org
Source : http://www.nano-editor.org/dist/v1.1/%{name}/%{name}-%{ver}.tar.gz
BuildRoot : /var/tmp/%{name}-buildroot
Requires : ncurses
%description
GNU nano is a small and friendly text editor. It aims to emulate the Pico
text editor while also offering a few enhancements.
%prep
%setup -q
%build
%configure --enable-extra
make RPM_OPT_FLAGS="$RPM_OPT_FLAGS"
%install
rm -rf "$RPM_BUILD_ROOT"
make DESTDIR="$RPM_BUILD_ROOT" install
%files
%defattr(-,root,root)
%doc AUTHORS BUGS COPYING ChangeLog INSTALL NEWS README THANKS TODO nanorc.sample
%{_bindir}/nano
%{_mandir}/*/*
%{_datadir}/locale/*/LC_MESSAGES/nano.mo
%{_infodir}/nano.info*
%changelog
* Sat Mar 30 2002 Chris Allegretta <chrisa@asty.org>
- Accepted into main distribution
- Added Packager and URL tage from original spec file.
* Tue Mar 06 2002 Brett Pemberton <generica@email.com>
- Initial spec-file

View File

@@ -8,7 +8,7 @@
@c Run `makeinfo' rather than `texinfo-format-buffer'.
@smallbook
@set EDITION 0.1
@set VERSION 1.1.7
@set VERSION 1.1.8
@set UPDATED 4 Jan 2002
@dircategory Editors
@@ -23,7 +23,7 @@
@titlepage
@title GNU @code{nano}
@subtitle a small and friendly text editor.
@subtitle version 1.1.7
@subtitle version 1.1.8
@author Chris Allegretta
@page

View File

@@ -1,3 +1,53 @@
2002-03-29 Jordi Mallach <jordi@sindominio.net>
* da.po: Updated translation by Keld Simonsen.
2002-03-27 Jordi Mallach <jordi@sindominio.net>
* it.po: Updated translation by Marco Colombo.
2002-03-25 Jordi Mallach <jordi@sindominio.net>
* id.po: Updated translation by Tedi Heriyanto.
2002-03-17 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard
2002-03-15 Jordi Mallach <jordi@sindominio.net>
* pl.po: Updated translation by Wojciech Kotwica.
2002-03-14 Jordi Mallach <jordi@sindominio.net>
* uk.po, ru.po: Updated translations by Sergey A.
Ribalchenko.
2002-03-12 Jordi Mallach <jordi@sindominio.net>
* ca.po: Updated to current CVS.
* es.po: Updated to current CVS.
* gl.po: Updated translation to current CVS by Jacobo Tarrio.
2002-03-12 Jordi Mallach <jordi@sindominio.net>
* gl.po: Updated translation by Jacobo Tarrio.
2002-03-11 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-03-09 Jordi Mallach <jordi@sindominio.net>
* id.po: Updated translation by Tedi Heriyanto.
* ca.po: Updated.
* es.po: Updated.
2002-03-07 Jordi Mallach <jordi@sindominio.net>
* sv.po: Updated translation by Christian Rose.
* de.po: Updated translation by Michael Piefel.
2002-03-05 Jordi Mallach <jordi@sindominio.net>
* pl.po: Updated translation by Wojciech Kotwica.
@@ -24,7 +74,7 @@
2002-02-07 Jordi Mallach <jordi@sindominio.net>
* uk.po, ru.po: Updated translations by Sergei A.
* uk.po, ru.po: Updated translations by Sergey A.
Ribalchenko.
2002-02-06 Jordi Mallach <jordi@sindominio.net>

1019
po/ca.po

File diff suppressed because it is too large Load Diff

893
po/cs.po

File diff suppressed because it is too large Load Diff

943
po/da.po

File diff suppressed because it is too large Load Diff

958
po/de.po

File diff suppressed because it is too large Load Diff

992
po/es.po

File diff suppressed because it is too large Load Diff

879
po/fi.po

File diff suppressed because it is too large Load Diff

950
po/fr.po

File diff suppressed because it is too large Load Diff

1019
po/gl.po

File diff suppressed because it is too large Load Diff

885
po/hu.po

File diff suppressed because it is too large Load Diff

1321
po/id.po

File diff suppressed because it is too large Load Diff

872
po/it.po

File diff suppressed because it is too large Load Diff

876
po/nb.po

File diff suppressed because it is too large Load Diff

878
po/nl.po

File diff suppressed because it is too large Load Diff

877
po/nn.po

File diff suppressed because it is too large Load Diff

942
po/pl.po

File diff suppressed because it is too large Load Diff

935
po/ru.po

File diff suppressed because it is too large Load Diff

939
po/sv.po

File diff suppressed because it is too large Load Diff

962
po/uk.po

File diff suppressed because it is too large Load Diff

14
proto.h
View File

@@ -40,7 +40,7 @@ extern int search_last_line;
extern int currslen;
#ifndef DISABLE_JUSTIFY
char *quotestr;
extern char *quotestr;
#endif
extern WINDOW *edit, *topwin, *bottomwin;
@@ -65,14 +65,14 @@ extern filestruct *open_files;
#endif
#ifdef ENABLE_COLOR
colortype *colorstrings;
extern colortype *colorstrings;
#endif
extern shortcut *shortcut_list;
extern shortcut *main_list, *whereis_list;
extern shortcut *replace_list, *goto_list;
extern shortcut *writefile_list, *insertfile_list;
extern shortcut *spell_list, *replace_list_2;
extern shortcut *spell_list, *replace_list_2, *extcmd_list;
extern shortcut *help_list;
#ifndef DISABLE_BROWSER
extern shortcut *browser_list, *gotodir_list;
@@ -83,6 +83,11 @@ extern shortcut *currshortcut;
extern int use_regexp, regexp_compiled;
extern regex_t search_regexp;
extern regmatch_t regmatches[10];
#ifdef ENABLE_COLOR
extern regex_t color_regexp;
extern regmatch_t colormatches[1];
#endif /* HJAVE_COLOR */
#endif
extern toggle *toggles;
@@ -111,6 +116,8 @@ int open_file(char *filename, int insert, int quiet);
int do_insertfile(int loading_file);
int length_of_list(shortcut *s);
int num_of_digits(int n);
int open_pipe(char *command);
int read_file(int fd, char *filename, int quiet);
#ifdef ENABLE_MULTIBUFFER
int add_open_file(int update);
@@ -166,6 +173,7 @@ void center_cursor(void);
void bottombars(shortcut *s);
void blank_statusbar_refresh(void);
void *nmalloc (size_t howmuch);
void nperror(const char *s);
void *mallocstrcpy(char *dest, char *src);
void wrap_reset(void);
void display_main_list(void);

View File

@@ -77,7 +77,9 @@ void rcfile_error(char *msg, ...)
va_list ap;
fprintf(stderr, "\n");
fprintf(stderr, _("Error in %s on line %d: "), nanorc, lineno);
if (lineno > 0)
fprintf(stderr, _("Error in %s on line %d: "), nanorc, lineno);
va_start(ap, msg);
vfprintf(stderr, msg, ap);
va_end(ap);
@@ -304,7 +306,7 @@ void parse_colors(FILE * rcstream, char *buf, char *ptr)
void parse_rcfile(FILE * rcstream)
{
char *buf, *ptr, *keyword, *option;
int set = 0, i;
int set = 0, i, j;
buf = charalloc(1024);
while (fgets(buf, 1023, rcstream) > 0) {
@@ -382,22 +384,22 @@ void parse_rcfile(FILE * rcstream)
if (!strcasecmp(rcopts[i].name, "fill")) {
#ifndef DISABLE_WRAPJUSTIFY
if ((i = atoi(option)) < MIN_FILL_LENGTH) {
if ((j = atoi(option)) < MIN_FILL_LENGTH) {
rcfile_error(_
("requested fill size %d too small"),
i);
j);
} else
fill = i;
fill = j;
#endif
} else
if (!strcasecmp(rcopts[i].name, "tabsize"))
{
if ((i = atoi(option)) <= 0) {
if ((j = atoi(option)) <= 0) {
rcfile_error(_
("requested tab size %d too small"),
i);
j);
} else {
tabsize = i;
tabsize = j;
}
#ifndef DISABLE_JUSTIFY
} else
@@ -464,12 +466,13 @@ void do_rcfile(void)
nanorc = charalloc(strlen(getenv("HOME")) + 10);
sprintf(nanorc, "%s/.nanorc", getenv("HOME"));
lineno = 0;
if (stat(nanorc, &fileinfo) == -1) {
/* Abort if the file doesn't exist and there's some other kind
of error stat()ing it */
if (errno != ENOENT)
rcfile_error(unable, errno);
rcfile_error(unable, strerror(errno));
return;
}

View File

@@ -145,6 +145,9 @@ int search_init(int replacing)
replacing ? _(" (to replace)") : "",
buf);
/* Release buf now that we don't need it anymore */
free(buf);
/* Cancel any search, or just return with no previous search */
if ((i == -1) || (i < 0 && !last_search[0])) {
statusbar(_("Search Cancelled"));
@@ -841,6 +844,7 @@ int do_gotoline(int line, int save_pos)
else
edit_update(current, CENTER);
placewewant = xplustabs();
goto_abort();
return 1;
}

15
utils.c
View File

@@ -21,6 +21,7 @@
#include "config.h"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
@@ -89,6 +90,7 @@ char *revstristr(char *haystack, char *needle, char *rev_start)
}
return 0;
}
#endif /* NANO_SMALL */
/* This is now mutt's version (called mutt_stristr) because it doesn't
use memory allocation to do a simple search (yuck). */
@@ -110,7 +112,6 @@ char *stristr(char *haystack, char *needle)
}
return NULL;
}
#endif /* NANO_SMALL */
char *strstrwrapper(char *haystack, char *needle, char *rev_start)
{
@@ -160,6 +161,18 @@ char *strstrwrapper(char *haystack, char *needle, char *rev_start)
#endif
}
/* This is a wrapper for the perror function. The wrapper takes care of
* ncurses, calls perror (which writes to STDERR), then refreshes the
* screen. Note that nperror causes the window to flicker once.
*/
void nperror(const char *s) {
/* leave ncurses mode, go to the terminal */
if (endwin() != ERR) {
perror(s); /* print the error */
total_refresh(); /* return to ncurses and repaint */
}
}
/* Thanks BG, many ppl have been asking for this... */
void *nmalloc(size_t howmuch)
{

73
winio.c
View File

@@ -84,7 +84,7 @@ int xpt(filestruct * fileptr, int index)
} else if (fileptr->data[i] & 0x80)
/* Make 8 bit chars only 1 column! */
;
else if (fileptr->data[i] < 32)
else if (fileptr->data[i] < 32 || fileptr->data[i] == 127)
tabs++;
}
@@ -798,32 +798,32 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
/* First, highlight all single-line regexes */
k = start;
regcomp(&search_regexp, tmpcolor->start, 0);
while (!regexec(&search_regexp, &fileptr->data[k], 1,
regmatches, 0)) {
regcomp(&color_regexp, tmpcolor->start, 0);
while (!regexec(&color_regexp, &fileptr->data[k], 1,
colormatches, 0)) {
if (regmatches[0].rm_eo - regmatches[0].rm_so < 1) {
if (colormatches[0].rm_eo - colormatches[0].rm_so < 1) {
statusbar("Refusing 0 length regex match");
break;
}
#ifdef DEBUG
fprintf(stderr, "Match! (%d chars) \"%s\"\n",
regmatches[0].rm_eo - regmatches[0].rm_so,
&fileptr->data[k + regmatches[0].rm_so]);
colormatches[0].rm_eo - colormatches[0].rm_so,
&fileptr->data[k + colormatches[0].rm_so]);
#endif
if (regmatches[0].rm_so < COLS - 1) {
if (colormatches[0].rm_so < COLS - 1) {
if (tmpcolor->bright)
wattron(edit, A_BOLD);
wattron(edit, COLOR_PAIR(tmpcolor->pairnum));
if (regmatches[0].rm_eo + k <= COLS)
if (colormatches[0].rm_eo + k <= COLS)
paintlen =
regmatches[0].rm_eo - regmatches[0].rm_so;
colormatches[0].rm_eo - colormatches[0].rm_so;
else
paintlen = COLS - k - regmatches[0].rm_so - 1;
paintlen = COLS - k - colormatches[0].rm_so - 1;
mvwaddnstr(edit, yval, regmatches[0].rm_so + k,
&fileptr->data[k + regmatches[0].rm_so],
mvwaddnstr(edit, yval, colormatches[0].rm_so + k,
&fileptr->data[k + colormatches[0].rm_so],
paintlen);
}
@@ -832,7 +832,7 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
wattroff(edit, A_BOLD);
wattroff(edit, COLOR_PAIR(tmpcolor->pairnum));
k += regmatches[0].rm_eo;
k += colormatches[0].rm_eo;
}
}
@@ -845,22 +845,22 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
s = fileptr;
while (s != NULL) {
regcomp(&search_regexp, tmpcolor->start, 0);
regcomp(&color_regexp, tmpcolor->start, 0);
if (!regexec
(&search_regexp, s->data, 1, regmatches, 0))
(&color_regexp, s->data, 1, colormatches, 0))
break;
s = s->prev;
}
if (s != NULL) {
/* We found a start, mark it */
smatch = regmatches[0].rm_so;
smatch = colormatches[0].rm_so;
e = s;
while (e != NULL && e != fileptr) {
regcomp(&search_regexp, tmpcolor->end, 0);
regcomp(&color_regexp, tmpcolor->end, 0);
if (!regexec
(&search_regexp, e->data, 1, regmatches, 0))
(&color_regexp, e->data, 1, colormatches, 0))
break;
e = e->next;
}
@@ -869,9 +869,9 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
continue; /* There's an end before us */
else { /* Keep looking for an end */
while (e != NULL) {
regcomp(&search_regexp, tmpcolor->end, 0);
regcomp(&color_regexp, tmpcolor->end, 0);
if (!regexec
(&search_regexp, e->data, 1, regmatches,
(&color_regexp, e->data, 1, colormatches,
0))
break;
e = e->next;
@@ -880,13 +880,13 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
if (e == NULL)
continue; /* There's no start before the end :) */
else { /* Okay, we found an end, mark it! */
ematch = regmatches[0].rm_eo;
ematch = colormatches[0].rm_eo;
while (e != NULL) {
regcomp(&search_regexp, tmpcolor->end, 0);
regcomp(&color_regexp, tmpcolor->end, 0);
if (!regexec
(&search_regexp, e->data, 1,
regmatches, 0))
(&color_regexp, e->data, 1,
colormatches, 0))
break;
e = e->next;
}
@@ -1140,8 +1140,11 @@ void update_line(filestruct * fileptr, int index)
virt_cur_x--;
if (i < mark_beginx)
virt_mark_beginx--;
} else if (realdata[i] == 127) {
/* Treat control characters as ^symbol (ASCII 1 - 31, 127) */
fileptr->data[pos++] = '^';
fileptr->data[pos++] = '?';
} else if (realdata[i] >= 1 && realdata[i] <= 31) {
/* Treat control characters as ^letter */
fileptr->data[pos++] = '^';
fileptr->data[pos++] = realdata[i] + 64;
} else {
@@ -1604,10 +1607,7 @@ int do_cursorpos(int constant)
if (old_totsize == -1)
old_totsize = totsize;
if (strlen(current->data) == 0)
colpct = 0;
else
colpct = 100 * xplustabs() / xpt(current, strlen(current->data));
colpct = 100 * (xplustabs() + 1) / (xpt(current, strlen(current->data)) + 1);
for (fileptr = fileage; fileptr != current && fileptr != NULL;
fileptr = fileptr->next)
@@ -1637,8 +1637,8 @@ int do_cursorpos(int constant)
if (!constant || (old_i != i || old_totsize != totsize)) {
statusbar(_
("line %d/%d (%.0f%%), col %ld/%ld (%.0f%%), char %ld/%ld (%.0f%%)"),
current->lineno, totlines, linepct, xplustabs(),
xpt(current, strlen(current->data)), colpct, i, j, bytepct);
current->lineno, totlines, linepct, xplustabs() + 1,
xpt(current, strlen(current->data)) + 1, colpct, i, j, bytepct);
}
old_i = i;
@@ -1871,7 +1871,7 @@ void do_replace_highlight(int highlight_flag, char *word)
}
#ifdef NANO_EXTRA
#define CREDIT_LEN 48
#define CREDIT_LEN 52
void do_credits(void)
{
int i, j = 0, k, place = 0, start_x;
@@ -1882,8 +1882,7 @@ void do_credits(void)
char *brought = _("Brought to you by:");
char *specialthx = _("Special thanks to:");
char *fsf = _("The Free Software Foundation");
char *ncurses =
_("Pavel Curtis, Zeyd Ben-Halim and Eric S. Raymond for ncurses");
char *ncurses = _("For ncurses:");
char *anyonelse = _("and anyone else we forgot...");
char *thankyou = _("Thank you for using nano!\n");
@@ -1923,6 +1922,10 @@ void do_credits(void)
fsf,
"Linus Torvalds",
ncurses,
"Thomas Dickey",
"Pavel Curtis",
"Zeyd Ben-Halim",
"Eric S. Raymond",
anyonelse,
thankyou,
"", "", "", "",