nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] definition of filestruct with ENABLE_MULTIBUFFER


From: David Benbennick
Subject: Re: [Nano-devel] definition of filestruct with ENABLE_MULTIBUFFER
Date: Wed, 13 Mar 2002 11:54:39 -0500 (EST)

Below is a patch to allow ENABLE_MULTIBUFFER and NANO_SMALL together.  The
change is in global.c.

Also included is a slight fix to the get_next_filename() function of
files.c, now allowing it to return name.INT_MAX.

Furthermore, I plug a tiny memory leak in nano.c (sort of silly, since it
is in die_save_file()), and remove two redundant prototypes from proto.h.



On Mon, 11 Mar 2002, David Lawrence Ramsey wrote:    <snip>
> In response to your previous question, about whether
> ENABLE_MULTIBUFFER and NANO_SMALL should be allowed at the
> same time, the only problem with doing so is the lack of
> toggles in NANO_SMALL; if one wants to insert a file into a
> separate buffer one moment and the current buffer the next,
> there's no way for one to do that in NANO_SMALL, since the
> Meta-F toggle is disabled.

Of course, if you want to read a file to the current buffer, you can
always: insert the file, cut it, close it, and uncut in the original
buffer.

So, I was just checking the previous paragraph, and in fact that doesn't
work, and causes a seg fault.  I guess the cut buffer was freed when I
closed the current file buffer!  I will try to fix that now.



diff -u nano/files.c nano-working/files.c
--- nano/files.c        Wed Mar  6 10:32:17 2002
+++ nano-working/files.c        Wed Mar 13 05:59:50 2002
@@ -340,7 +340,7 @@
     while(1) {
 
        if (stat(buf, &fs) == -1)
-           break;
+           return buf;
        if (i == INT_MAX)
            break;
 
diff -u nano/global.c nano-working/global.c
--- nano/global.c       Sun Mar  3 17:36:36 2002
+++ nano-working/global.c       Wed Mar 13 10:21:23 2002
@@ -265,6 +265,9 @@
        "", *nano_enter_msg = "", *nano_cancel_msg = 
        "", *nano_unjustify_msg = "", *nano_append_msg =
        ""; 
+#ifdef ENABLE_MULTIBUFFER
+    char *nano_openprev_msg = "", *nano_opennext_msg = "";
+#endif
 
 #ifndef NANO_SMALL
     char *nano_tofiles_msg = "", *nano_gotodir_msg = "", *nano_case_msg =
@@ -274,9 +277,6 @@
 #ifdef HAVE_REGEX_H
     char *nano_regexp_msg = "", *nano_bracket_msg = "";
 #endif
-#ifdef ENABLE_MULTIBUFFER
-    char *nano_openprev_msg = "", *nano_opennext_msg = "";
-#endif
 
     nano_help_msg = _("Invoke the help menu");
     nano_writeout_msg = _("Write the current file to disk");
@@ -735,7 +735,7 @@
     filestruct * current_open_file;
 #endif
 
-#ifdef ENABLE_MULTIBUFFER
+#ifndef DISABLE_OPERATINGDIR
     if (operating_dir != NULL)
        free(operating_dir);
     if (full_operating_dir != NULL)
diff -u nano/nano.c nano-working/nano.c
--- nano/nano.c Sat Mar  9 15:05:26 2002
+++ nano-working/nano.c Wed Mar 13 05:59:00 2002
@@ -180,6 +180,7 @@
        if (strcmp(ret, ""))
            i = write_file(ret, 1, 0, 0);
        name = ret;
+        free(buf);
     }
 
     if (i != -1)
diff -u nano/proto.h nano-working/proto.h
--- nano/proto.h        Sat Mar  9 20:22:21 2002
+++ nano-working/proto.h        Wed Mar 13 06:00:20 2002
@@ -172,7 +172,7 @@
 void nano_small_msg(void);
 void nano_disable_msg(void);
 void do_early_abort(void);
-void *nmalloc(size_t howmuch);
+/* void *nmalloc(size_t howmuch); */
 void *nrealloc(void *ptr, size_t howmuch);
 void die(char *msg, ...);
 void die_save_file(char *die_filename);
@@ -213,7 +213,7 @@
 
 int do_page_up(void), do_page_down(void);
 int do_cursorpos(int constant), do_cursorpos_void(void), do_spell(void);
-int do_up(void), do_down (void), do_right(void), do_left (void);
+/* int do_up(void), do_down (void), do_right(void), do_left (void); */
 int do_home(void), do_end(void), total_refresh(void), do_mark(void);
 int do_delete(void), do_backspace(void), do_tab(void), do_justify(void);
 int do_first_line(void), do_last_line(void);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]