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

Added selection write to file and append codes, main changes to files.c stuff,...

Added selection write to file and append codes, main changes to files.c stuff, new shortcut list for inserting files, new args to do_writeout and write_file


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@672 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 232 additions and 127 deletions
+232 -127
......@@ -31,6 +31,10 @@ Cvs code -
value. This allows the value to vary with the screen size yet
still be correct. New static value wrap_at to minimize code
inpact. Updated man page and info file.
- Allow file appending. New shortcut list nano_insertfile_list (since
insert and write routines can't share shortcut lists anymore),
new args to do_writeout and write_file called append, and of source
code changes to those functions.
- configure.in:
- New option, --enable-nanorc, which allows people to have a .nanorc
initialization file and set options normally used on the command
......@@ -43,6 +47,9 @@ Cvs code -
cut_marked_segment()
- Add bizarre copy of bot node, else *BSD goes ballistic (fixes
BUG #60).
- Added 'destructive' argument. Allows the selected text to be
added to the cutbuffer without changing the contents of the
file. This allows writing selection to separate files.
- faq.html:
- Brought the FAQ up to date, many little changes (Jordi).
- files.c:
......@@ -51,6 +58,10 @@ Cvs code -
- Added the "Goto Directory" code (Rocco)
- Don't shift the size of the file is it's less than 1K. Fixed
files less than 1K being displayed as 0B (Rocco).
do_writeout()
- New code to allow writing selected text to a separate file.
When this is done, the current filename is not changed, the
modification state is preserved, etc.
- global.c:
- Updated some of the lists for the "Goto Directory" code (Rocco)
- move.c:
......
......@@ -2676,7 +2676,7 @@ else
int main() {
/* Ultrix mips cc rejects this. */
typedef int charset[2]; const charset x;
typedef int charset[2]; const charset x = {0,0};
/* SunOS 4.1.1 cc rejects this. */
char const *const *ccp;
char **p;
......@@ -2751,7 +2751,7 @@ for ac_kw in inline __inline__ __inline; do
#include "confdefs.h"
int main() {
} $ac_kw foo() {
} int $ac_kw foo() {
; return 0; }
EOF
if { (eval echo configure:2758: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
......@@ -2857,7 +2857,7 @@ else
#include "confdefs.h"
#include <alloca.h>
int main() {
char *p = alloca(2 * sizeof(int));
void *p = alloca(2 * sizeof(int));
; return 0; }
EOF
if { (eval echo configure:2864: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
......@@ -3210,12 +3210,15 @@ else
#include <sys/types.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
/* This mess was copied from the GNU getpagesize.h. */
#ifndef HAVE_GETPAGESIZE
# ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
/* Assume that all systems that can run configure have sys/param.h. */
# ifndef HAVE_SYS_PARAM_H
......@@ -3270,7 +3273,7 @@ main()
/*
* First, make a file with some known garbage in it.
*/
data = malloc(pagesize);
data = (char*)malloc(pagesize);
if (!data)
exit(1);
for (i = 0; i < pagesize; ++i)
......@@ -3291,7 +3294,7 @@ main()
fd = open("conftestmmap", O_RDWR);
if (fd < 0)
exit(1);
data2 = malloc(2 * pagesize);
data2 = (char*)malloc(2 * pagesize);
if (!data2)
exit(1);
data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1);
......@@ -3309,7 +3312,7 @@ main()
*/
for (i = 0; i < pagesize; ++i)
*(data2 + i) = *(data2 + i) + 1;
data3 = malloc(pagesize);
data3 = (char*)malloc(pagesize);
if (!data3)
exit(1);
if (read(fd, data3, pagesize) != pagesize)
......@@ -3323,7 +3326,7 @@ main()
}
EOF
if { (eval echo configure:3327: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
if { (eval echo configure:3330: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_mmap_fixed_mapped=yes
else
......@@ -3351,17 +3354,17 @@ unistd.h sys/param.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:3355: checking for $ac_hdr" >&5
echo "configure:3358: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3360 "configure"
#line 3363 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:3365: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:3368: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
......@@ -3391,12 +3394,12 @@ done
strdup __argz_count __argz_stringify __argz_next
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:3395: checking for $ac_func" >&5
echo "configure:3398: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3400 "configure"
#line 3403 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
......@@ -3419,7 +3422,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:3423: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:3426: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
......@@ -3448,12 +3451,12 @@ done
for ac_func in stpcpy
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:3452: checking for $ac_func" >&5
echo "configure:3455: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3457 "configure"
#line 3460 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
......@@ -3476,7 +3479,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:3480: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:3483: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
......@@ -3510,19 +3513,19 @@ EOF
if test $ac_cv_header_locale_h = yes; then
echo $ac_n "checking for LC_MESSAGES""... $ac_c" 1>&6
echo "configure:3514: checking for LC_MESSAGES" >&5
echo "configure:3517: checking for LC_MESSAGES" >&5
if eval "test \"`echo '$''{'am_cv_val_LC_MESSAGES'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3519 "configure"
#line 3522 "configure"
#include "confdefs.h"
#include <locale.h>
int main() {
return LC_MESSAGES
; return 0; }
EOF
if { (eval echo configure:3526: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:3529: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
am_cv_val_LC_MESSAGES=yes
else
......@@ -3543,7 +3546,7 @@ EOF
fi
fi
echo $ac_n "checking whether NLS is requested""... $ac_c" 1>&6
echo "configure:3547: checking whether NLS is requested" >&5
echo "configure:3550: checking whether NLS is requested" >&5
# Check whether --enable-nls or --disable-nls was given.
if test "${enable_nls+set}" = set; then
enableval="$enable_nls"
......@@ -3563,7 +3566,7 @@ fi
EOF
echo $ac_n "checking whether included gettext is requested""... $ac_c" 1>&6
echo "configure:3567: checking whether included gettext is requested" >&5
echo "configure:3570: checking whether included gettext is requested" >&5
# Check whether --with-included-gettext or --without-included-gettext was given.
if test "${with_included_gettext+set}" = set; then
withval="$with_included_gettext"
......@@ -3582,17 +3585,17 @@ fi
ac_safe=`echo "libintl.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for libintl.h""... $ac_c" 1>&6
echo "configure:3586: checking for libintl.h" >&5
echo "configure:3589: checking for libintl.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3591 "configure"
#line 3594 "configure"
#include "confdefs.h"
#include <libintl.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:3596: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:3599: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
......@@ -3609,19 +3612,19 @@ fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
echo $ac_n "checking for gettext in libc""... $ac_c" 1>&6
echo "configure:3613: checking for gettext in libc" >&5
echo "configure:3616: checking for gettext in libc" >&5
if eval "test \"`echo '$''{'gt_cv_func_gettext_libc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3618 "configure"
#line 3621 "configure"
#include "confdefs.h"
#include <libintl.h>
int main() {
return (int) gettext ("")
; return 0; }
EOF
if { (eval echo configure:3625: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:3628: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
gt_cv_func_gettext_libc=yes
else
......@@ -3637,7 +3640,7 @@ echo "$ac_t""$gt_cv_func_gettext_libc" 1>&6
if test "$gt_cv_func_gettext_libc" != "yes"; then
echo $ac_n "checking for bindtextdomain in -lintl""... $ac_c" 1>&6
echo "configure:3641: checking for bindtextdomain in -lintl" >&5
echo "configure:3644: checking for bindtextdomain in -lintl" >&5
ac_lib_var=`echo intl'_'bindtextdomain | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
......@@ -3645,7 +3648,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lintl $LIBS"
cat > conftest.$ac_ext <<EOF
#line 3649 "configure"
#line 3652 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
......@@ -3656,7 +3659,7 @@ int main() {
bindtextdomain()
; return 0; }
EOF
if { (eval echo configure:3660: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:3663: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
......@@ -3672,12 +3675,12 @@ fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
echo $ac_n "checking for gettext in libintl""... $ac_c" 1>&6
echo "configure:3676: checking for gettext in libintl" >&5
echo "configure:3679: checking for gettext in libintl" >&5
if eval "test \"`echo '$''{'gt_cv_func_gettext_libintl'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
echo $ac_n "checking for gettext in -lintl""... $ac_c" 1>&6
echo "configure:3681: checking for gettext in -lintl" >&5
echo "configure:3684: checking for gettext in -lintl" >&5
ac_lib_var=`echo intl'_'gettext | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
......@@ -3685,7 +3688,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lintl $LIBS"
cat > conftest.$ac_ext <<EOF
#line 3689 "configure"
#line 3692 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
......@@ -3696,7 +3699,7 @@ int main() {
gettext()
; return 0; }
EOF
if { (eval echo configure:3700: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:3703: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
......@@ -3735,7 +3738,7 @@ EOF
# Extract the first word of "msgfmt", so it can be a program name with args.
set dummy msgfmt; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:3739: checking for $ac_word" >&5
echo "configure:3742: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -3769,12 +3772,12 @@ fi
for ac_func in dcgettext
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:3773: checking for $ac_func" >&5
echo "configure:3776: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3778 "configure"
#line 3781 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
......@@ -3797,7 +3800,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:3801: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:3804: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
......@@ -3824,7 +3827,7 @@ done
# Extract the first word of "gmsgfmt", so it can be a program name with args.
set dummy gmsgfmt; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:3828: checking for $ac_word" >&5
echo "configure:3831: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -3860,7 +3863,7 @@ fi
# Extract the first word of "xgettext", so it can be a program name with args.
set dummy xgettext; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:3864: checking for $ac_word" >&5
echo "configure:3867: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -3892,7 +3895,7 @@ else
fi
cat > conftest.$ac_ext <<EOF
#line 3896 "configure"
#line 3899 "configure"
#include "confdefs.h"
int main() {
......@@ -3900,7 +3903,7 @@ extern int _nl_msg_cat_cntr;
return _nl_msg_cat_cntr
; return 0; }
EOF
if { (eval echo configure:3904: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:3907: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
CATOBJEXT=.gmo
DATADIRNAME=share
......@@ -3923,7 +3926,7 @@ fi
if test "$CATOBJEXT" = "NONE"; then
echo $ac_n "checking whether catgets can be used""... $ac_c" 1>&6
echo "configure:3927: checking whether catgets can be used" >&5
echo "configure:3930: checking whether catgets can be used" >&5
# Check whether --with-catgets or --without-catgets was given.
if test "${with_catgets+set}" = set; then
withval="$with_catgets"
......@@ -3936,7 +3939,7 @@ fi
if test "$nls_cv_use_catgets" = "yes"; then
echo $ac_n "checking for main in -li""... $ac_c" 1>&6
echo "configure:3940: checking for main in -li" >&5
echo "configure:3943: checking for main in -li" >&5
ac_lib_var=`echo i'_'main | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
......@@ -3944,14 +3947,14 @@ else
ac_save_LIBS="$LIBS"
LIBS="-li $LIBS"
cat > conftest.$ac_ext <<EOF
#line 3948 "configure"
#line 3951 "configure"
#include "confdefs.h"
int main() {
main()
; return 0; }
EOF
if { (eval echo configure:3955: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:3958: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
......@@ -3979,12 +3982,12 @@ else
fi
echo $ac_n "checking for catgets""... $ac_c" 1>&6
echo "configure:3983: checking for catgets" >&5
echo "configure:3986: checking for catgets" >&5
if eval "test \"`echo '$''{'ac_cv_func_catgets'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3988 "configure"
#line 3991 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char catgets(); below. */
......@@ -4007,7 +4010,7 @@ catgets();
; return 0; }
EOF
if { (eval echo configure:4011: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:4014: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_catgets=yes"
else
......@@ -4029,7 +4032,7 @@ EOF
# Extract the first word of "gencat", so it can be a program name with args.
set dummy gencat; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:4033: checking for $ac_word" >&5
echo "configure:4036: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_GENCAT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -4065,7 +4068,7 @@ fi
# Extract the first word of "gmsgfmt", so it can be a program name with args.
set dummy gmsgfmt; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:4069: checking for $ac_word" >&5
echo "configure:4072: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -4102,7 +4105,7 @@ fi
# Extract the first word of "msgfmt", so it can be a program name with args.
set dummy msgfmt; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:4106: checking for $ac_word" >&5
echo "configure:4109: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -4137,7 +4140,7 @@ fi
# Extract the first word of "xgettext", so it can be a program name with args.
set dummy xgettext; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:4141: checking for $ac_word" >&5
echo "configure:4144: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -4195,7 +4198,7 @@ fi
# Extract the first word of "msgfmt", so it can be a program name with args.
set dummy msgfmt; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:4199: checking for $ac_word" >&5
echo "configure:4202: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -4229,7 +4232,7 @@ fi
# Extract the first word of "gmsgfmt", so it can be a program name with args.
set dummy gmsgfmt; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:4233: checking for $ac_word" >&5
echo "configure:4236: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -4265,7 +4268,7 @@ fi
# Extract the first word of "xgettext", so it can be a program name with args.
set dummy xgettext; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:4269: checking for $ac_word" >&5
echo "configure:4272: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -4358,7 +4361,7 @@ fi
LINGUAS=
else
echo $ac_n "checking for catalogs to be installed""... $ac_c" 1>&6
echo "configure:4362: checking for catalogs to be installed" >&5
echo "configure:4365: checking for catalogs to be installed" >&5
NEW_LINGUAS=
for lang in ${LINGUAS=$ALL_LINGUAS}; do
case "$ALL_LINGUAS" in
......@@ -4386,17 +4389,17 @@ echo "configure:4362: checking for catalogs to be installed" >&5
if test "$CATOBJEXT" = ".cat"; then
ac_safe=`echo "linux/version.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for linux/version.h""... $ac_c" 1>&6
echo "configure:4390: checking for linux/version.h" >&5
echo "configure:4393: checking for linux/version.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 4395 "configure"
#line 4398 "configure"
#include "confdefs.h"
#include <linux/version.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:4400: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:4403: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
......
......@@ -58,8 +58,12 @@ void add_to_cutbuffer(filestruct * inptr)
}
#ifndef NANO_SMALL
/* Cut a marked segment instead of a whole line. Only called from do_cut_text().
destructive is whether to actually modify the file structure, if not then
just copy the buffer into cutbuffer and don't pull it from the file */
void cut_marked_segment(filestruct * top, int top_x, filestruct * bot,
int bot_x)
int bot_x, int destructive)
{
filestruct *tmp, *next, *botcopy;
char *tmpstr;
......@@ -74,12 +78,22 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot,
/* Chop off the end of the first line */
tmpstr = charalloc(top_x + 1);
strncpy(tmpstr, top->data, top_x);
free(top->data);
top->data = tmpstr;
if (destructive) {
free(top->data);
top->data = tmpstr;
}
do {
next = tmp->next;
add_to_cutbuffer(tmp);
if (destructive)
add_to_cutbuffer(tmp);
else {
filestruct *tmpcopy = NULL;
tmpcopy = copy_node(tmp);
add_to_cutbuffer(tmpcopy);
}
totlines--;
totsize--; /* newline (add_to_cutbuffer doesn't count newlines) */
tmp = next;
......@@ -89,48 +103,54 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot,
dump_buffer(cutbuffer);
if (next == NULL)
return;
/* Now, paste bot[bot_x] into top[top_x] */
tmpstr = charalloc(strlen(top->data) + strlen(&bot->data[bot_x]));
strncpy(tmpstr, top->data, top_x);
strcpy(&tmpstr[top_x], &bot->data[bot_x]);
free(top->data);
top->data = tmpstr;
null_at(bot->data, bot_x);
next = bot->next;
/* Now, paste bot[bot_x] into top[top_x] */
if (destructive) {
/* We explicitly don't decrement totlines here because we don't snarf
* up a newline when we're grabbing the last line of the mark. For
* the same reason, we don't do an extra totsize decrement. */
tmpstr = charalloc(strlen(top->data) + strlen(&bot->data[bot_x]));
strncpy(tmpstr, top->data, top_x);
strcpy(&tmpstr[top_x], &bot->data[bot_x]);
free(top->data);
top->data = tmpstr;
/* We explicitly don't decrement totlines here because we don't snarf
* up a newline when we're grabbing the last line of the mark. For
* the same reason, we don't do an extra totsize decrement. */
}
/* I honestly do not know why this is needed. After many hours of
using gdb on an OpenBSD box, I can honestly say something is
screwed somewhere. Not doing this causes update_line to annihilate
the last line copied into the cutbuffer when the mark is set ?!?!? */
using gdb on an OpenBSD box, I can honestly say something is
screwed somewhere. Not doing this causes update_line to annihilate
the last line copied into the cutbuffer when the mark is set ?!?!? */
botcopy = copy_node(bot);
null_at(botcopy->data, bot_x);
next = botcopy->next;
add_to_cutbuffer(botcopy);
free(bot);
top->next = next;
if (next != NULL)
next->prev = top;
dump_buffer(cutbuffer);
renumber(top);
current = top;
current_x = top_x;
/* If we're hitting the end of the buffer, we should clean that up. */
if (bot == filebot) {
if (next != NULL) {
filebot = next;
} else {
filebot = top;
if (destructive) {
free(bot);
top->next = next;
if (next != NULL)
next->prev = top;
dump_buffer(cutbuffer);
renumber(top);
current = top;
current_x = top_x;
/* If we're hitting the end of the buffer, we should clean that up. */
if (bot == filebot) {
if (next != NULL) {
filebot = next;
} else {
filebot = top;
}
}
if (top->lineno < edittop->lineno)
edit_update(top, CENTER);
}
if (top->lineno < edittop->lineno)
edit_update(top, CENTER);
}
#endif
......@@ -203,10 +223,10 @@ int do_cut_text(void)
align(&current->data);
} else if (current->lineno < mark_beginbuf->lineno)
cut_marked_segment(current, current_x, mark_beginbuf,
mark_beginx);
mark_beginx, 1);
else
cut_marked_segment(mark_beginbuf, mark_beginx, current,
current_x);
current_x, 1);
placewewant = xplustabs();
UNSET(MARK_ISSET);
......
......@@ -261,11 +261,11 @@ int do_insertfile(void)
wrap_reset();
#ifndef DISABLE_MOUSE
currshortcut = writefile_list;
currslen = WRITEFILE_LIST_LEN;
currshortcut = insertfile_list;
currslen = INSERTFILE_LIST_LEN;
#endif
i = statusq(1, writefile_list, WRITEFILE_LIST_LEN, "",
i = statusq(1, insertfile_list, INSERTFILE_LIST_LEN, "",
_("File to insert [from ./] "));
if (i != -1) {
......@@ -284,8 +284,8 @@ int do_insertfile(void)
char *tmp = do_browse_from(realname);
#ifndef DISABLE_MOUSE
currshortcut = writefile_list;
currslen = WRITEFILE_LIST_LEN;
currshortcut = insertfile_list;
currslen = INSERTFILE_LIST_LEN;
#endif
#ifdef DISABLE_TABCOMP
......@@ -331,8 +331,11 @@ int do_insertfile(void)
*
* tmp means we are writing a tmp file in a secure fashion. We use
* it when spell checking or dumping the file on an error.
*
* append means, not surprisingly, whether we are appending instead
* of overwriting.
*/
int write_file(char *name, int tmp)
int write_file(char *name, int tmp, int append)
{
long size, lineswritten = 0;
static char *buf = NULL;
......@@ -377,7 +380,9 @@ int write_file(char *name, int tmp)
else if (ISSET(FOLLOW_SYMLINKS) || !S_ISLNK(lst.st_mode) || tmp) {
/* Use O_EXCL if tmp == 1. This is now copied from joe, because
wiggy says so *shrug*. */
if (tmp)
if (append)
fd = open(realname, O_WRONLY | O_APPEND, (S_IRUSR|S_IWUSR));
else if (tmp)
fd = open(realname, O_WRONLY | O_CREAT | O_EXCL, (S_IRUSR|S_IWUSR));
else
fd = open(realname, O_WRONLY | O_CREAT | O_TRUNC, (S_IRUSR|S_IWUSR));
......@@ -386,7 +391,7 @@ int write_file(char *name, int tmp)
if (fd == -1) {
if (!tmp && ISSET(TEMP_OPT)) {
UNSET(TEMP_OPT);
return do_writeout(filename, 1);
return do_writeout(filename, 1, 0);
}
statusbar(_("Could not open file for writing: %s"),
strerror(errno));
......@@ -402,7 +407,7 @@ int write_file(char *name, int tmp)
if ((fd = mkstemp(buf)) == -1) {
if (ISSET(TEMP_OPT)) {
UNSET(TEMP_OPT);
return do_writeout(filename, 1);
return do_writeout(filename, 1, 0);
}
statusbar(_("Could not open file for writing: %s"),
strerror(errno));
......@@ -506,7 +511,7 @@ int write_file(char *name, int tmp)
return 1;
}
int do_writeout(char *path, int exiting)
int do_writeout(char *path, int exiting, int append)
{
int i = 0;
......@@ -523,7 +528,7 @@ int do_writeout(char *path, int exiting)
if ((exiting) && (ISSET(TEMP_OPT))) {
if (filename[0]) {
i = write_file(answer, 0);
i = write_file(answer, 0, 0);
display_main_list();
return i;
} else {
......@@ -536,8 +541,12 @@ int do_writeout(char *path, int exiting)
}
while (1) {
i = statusq(1, writefile_list, WRITEFILE_LIST_LEN, answer,
_("File Name to write"));
if (ISSET(MARK_ISSET) && !exiting)
i = statusq(1, writefile_list, WRITEFILE_LIST_LEN, answer,
_("%s Selection to File"), append ? _("Append") : _("Write"));
else
i = statusq(1, writefile_list, WRITEFILE_LIST_LEN, answer,
_("File Name to %s"), append ? _("Append") : _("Write"));
if (i != -1) {
......@@ -551,12 +560,14 @@ int do_writeout(char *path, int exiting)
currslen = WRITEFILE_LIST_LEN;
#endif
if (tmp != NULL)
if (tmp != NULL) {
answer = mallocstrcpy(answer, tmp);
else
return do_writeout(answer, exiting);
}
} else
return do_writeout(answer, exiting, append);
} else
#endif
if (i == NANO_APPEND_KEY)
return(do_writeout(answer, exiting, 1 - append));
#ifdef DEBUG
fprintf(stderr, _("filename is %s"), answer);
......@@ -570,7 +581,7 @@ int do_writeout(char *path, int exiting)
return -1;
}
#endif
if (strcmp(answer, filename)) {
if (!append && strcmp(answer, filename)) {
struct stat st;
if (!stat(answer, &st)) {
i = do_yesno(0, 0, _("File exists, OVERWRITE ?"));
......@@ -579,8 +590,48 @@ int do_writeout(char *path, int exiting)
continue;
}
}
i = write_file(answer, 0);
#ifndef NANO_SMALL
/* Here's where we allow the selected text to be written to
a separate file. */
if (ISSET(MARK_ISSET) && !exiting) {
char *backup = NULL;
filestruct *fileagebak = fileage;
filestruct *filebotbak = filebot;
filestruct *cutback = cutbuffer;
int oldmod = 0;
/* Okay, since write_file changes the filename, back it up */
backup = mallocstrcpy(backup, filename);
if (ISSET(MODIFIED))
oldmod = 1;
/* Now, non-destructively add the marked text to the
cutbuffer, and write the file out using the cutbuffer ;) */
if (current->lineno < mark_beginbuf->lineno)
cut_marked_segment(current, current_x, mark_beginbuf,
mark_beginx, 0);
else
cut_marked_segment(mark_beginbuf, mark_beginx, current,
current_x, 0);
fileage = cutbuffer;
for (filebot = cutbuffer; filebot->next != NULL;
filebot = filebot->next)
;
i = write_file(answer, 0, append);
/* Now restore everything */
backup = mallocstrcpy(filename, backup);
fileage = fileagebak;
filebot = filebotbak;
cutbuffer = cutback;
if (oldmod)
set_modified();
} else
#endif
i = write_file(answer, 0, append);
display_main_list();
return i;
} else {
......@@ -593,7 +644,7 @@ int do_writeout(char *path, int exiting)
int do_writeout_void(void)
{
return do_writeout(filename, 0);
return do_writeout(filename, 0, 0);
}
#ifndef DISABLE_TABCOMP
......
......@@ -82,6 +82,7 @@ shortcut replace_list_2[REPLACE_LIST_LEN]; /* 2nd half of replace dialog */
shortcut goto_list[GOTO_LIST_LEN];
shortcut gotodir_list[GOTODIR_LIST_LEN];
shortcut writefile_list[WRITEFILE_LIST_LEN];
shortcut insertfile_list[INSERTFILE_LIST_LEN];
shortcut help_list[HELP_LIST_LEN];
shortcut spell_list[SPELL_LIST_LEN];
#ifndef DISABLE_BROWSER
......@@ -192,7 +193,8 @@ void shortcut_init(int unjustify)
"", *nano_mark_msg = "", *nano_delete_msg =
"", *nano_backspace_msg = "", *nano_tab_msg =
"", *nano_enter_msg = "", *nano_case_msg =
"", *nano_cancel_msg = "", *nano_unjustify_msg = "";
"", *nano_cancel_msg = "", *nano_unjustify_msg =
"", *nano_append_msg = "";
#ifndef NANO_SMALL
char *nano_tofiles_msg = "";
......@@ -233,6 +235,7 @@ void shortcut_init(int unjustify)
nano_tofiles_msg = _("Go to file browser");
nano_gotodir_msg = _("Goto Directory");
nano_cancel_msg = _("Cancel the current function");
nano_append_msg = _("Append to the current file");
#endif
sc_init_one(&main_list[0], NANO_HELP_KEY, _("Get Help"),
......@@ -428,9 +431,20 @@ void shortcut_init(int unjustify)
nano_tofiles_msg, 0, 0, 0, NOVIEW, 0);
#endif
sc_init_one(&writefile_list[WRITEFILE_LIST_LEN - 2], NANO_APPEND_KEY, _("Append"),
nano_append_msg, 0, 0, 0, NOVIEW, 0);
sc_init_one(&writefile_list[WRITEFILE_LIST_LEN - 1], NANO_CANCEL_KEY, _("Cancel"),
nano_cancel_msg, 0, 0, 0, VIEW, 0);
#ifndef DISABLE_BROWSER
sc_init_one(&insertfile_list[0], NANO_TOFILES_KEY, _("To Files"),
nano_tofiles_msg, 0, 0, 0, NOVIEW, 0);
#endif
sc_init_one(&insertfile_list[INSERTFILE_LIST_LEN - 1], NANO_CANCEL_KEY, _("Cancel"),
nano_cancel_msg, 0, 0, 0, VIEW, 0);
sc_init_one(&spell_list[0], NANO_CANCEL_KEY, _("Cancel"),
nano_cancel_msg, 0, 0, 0, VIEW, 0);
......
......@@ -1524,7 +1524,7 @@ int do_exit(void)
#endif
if (i == 1) {
if (do_writeout(filename, 1) > 0)
if (do_writeout(filename, 1, 0) > 0)
finish(0);
} else if (i == 0)
finish(0);
......
......@@ -239,6 +239,7 @@ know what you're doing */
#define NANO_ENTER_KEY NANO_CONTROL_M
#define NANO_FROMSEARCHTOGOTO_KEY NANO_CONTROL_T
#define NANO_TOFILES_KEY NANO_CONTROL_T
#define NANO_APPEND_KEY NANO_CONTROL_A
#define TOGGLE_CONST_KEY NANO_ALT_C
#define TOGGLE_AUTOINDENT_KEY NANO_ALT_I
......@@ -261,10 +262,12 @@ know what you're doing */
#define SPELL_LIST_LEN 1
#ifndef DISABLE_BROWSER
#define WRITEFILE_LIST_LEN 2
#define WRITEFILE_LIST_LEN 3
#define INSERTFILE_LIST_LEN 2
#define BROWSER_LIST_LEN 4
#else
#define WRITEFILE_LIST_LEN 1
#define WRITEFILE_LIST_LEN 3
#define IMSERTFILE_LIST_LEN 1
#endif
#ifdef HAVE_REGEX_H
......
......@@ -53,8 +53,9 @@ extern filestruct *cutbuffer, *mark_beginbuf;
extern shortcut *shortcut_list;
extern shortcut main_list[MAIN_LIST_LEN], whereis_list[WHEREIS_LIST_LEN];
extern shortcut replace_list[REPLACE_LIST_LEN], goto_list[GOTO_LIST_LEN];
extern shortcut writefile_list[WRITEFILE_LIST_LEN], help_list[HELP_LIST_LEN];
extern shortcut writefile_list[WRITEFILE_LIST_LEN], insertfile_list[INSERTFILE_LIST_LEN];
extern shortcut spell_list[SPELL_LIST_LEN], replace_list_2[REPLACE_LIST_LEN];
extern shortcut help_list[HELP_LIST_LEN];
#ifndef DISABLE_BROWSER
extern shortcut browser_list[BROWSER_LIST_LEN], gotodir_list[GOTODIR_LIST_LEN];
#endif
......@@ -80,13 +81,13 @@ int do_yesno(int all, int leavecursor, char *msg, ...);
int actual_x(filestruct * fileptr, int xplus);
int strlenpt(char *buf);
int statusq(int allowtabs, shortcut s[], int slen, char *def, char *msg, ...);
int write_file(char *name, int tmpfile);
int write_file(char *name, int tmpfile, int append);
int do_cut_text(void);
int do_uncut_text(void);
int no_help(void);
int renumber_all(void);
int open_file(char *filename, int insert, int quiet);
int do_writeout(char *path, int exiting);
int do_writeout(char *path, int exiting, int append);
int do_gotoline(long defline);
int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx,
int wholewords, int *i);
......@@ -147,6 +148,8 @@ void nano_disabled_msg(void);
void window_init(void);
void do_mouse(void);
void print_view_warning(void);
void cut_marked_segment(filestruct * top, int top_x, filestruct * bot,
int bot_x, int destructive);
#ifdef ENABLE_NANORC
void do_rcfile(void);
......
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