]> git.wh0rd.org Git - nano.git/commitdiff
Fixed null_at to ACTUALLY DO SOMETHING with its arg. Again, this was causing nasty...
authorChris Allegretta <chrisa@asty.org>
Mon, 22 Oct 2001 23:32:58 +0000 (23:32 +0000)
committerChris Allegretta <chrisa@asty.org>
Mon, 22 Oct 2001 23:32:58 +0000 (23:32 +0000)
git-svn-id: svn://svn.savannah.gnu.org/nano/branches/nano_1_0_branch/nano@867 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
cut.c
nano.c
proto.h

index dbdf7a16a7b3d074da14874f1c5c28fa239d17d1..861c624f625cde20db4bbd123636fdb8d9cac8d6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
 CVS code -
+- General
+       - Fixed null_at to ACTUALLY DO SOMETHING with its arg.  Again,
+         this was causing nasty errors if the call to nrealloc moved
+         where the data was located.
 - po/de.po:
        - Updated German translation (Karl Eichwalder).
 
diff --git a/cut.c b/cut.c
index 2dd8697a7a02a2bf737bd9065cba2424f283af6d..7d1fd9921a280d729e66421d700ced328f49ddd5 100644 (file)
--- a/cut.c
+++ b/cut.c
@@ -96,7 +96,7 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot,
     free(top->data);
     top->data = tmpstr;
 
-    null_at(bot->data, bot_x);
+    null_at(&bot->data, bot_x);
     next = bot->next;
 
     /* We explicitly don't decrement totlines here because we don't snarf
@@ -399,7 +399,7 @@ int do_uncut_text(void)
            tmp->data = nmalloc(strlen(&current->data[current_x]) + 1);
            strcpy(tmp->data, &current->data[current_x]);
            splice_node(current, tmp, current->next);
-           null_at(current->data, current_x);
+           null_at(&current->data, current_x);
            current = current->next;
            current_x = 0;
            placewewant = 0;
diff --git a/nano.c b/nano.c
index 1802cff5b8572f48f39d905169a7431604d6e248..3132f509f36e2e32e5e91ac07fe67d95ea4b7f6d 100644 (file)
--- a/nano.c
+++ b/nano.c
@@ -346,10 +346,12 @@ void align(char **strp)
 }
 
 /* Null a string at a certain index and align it */
-void null_at(char *data, int index)
+void null_at(char **data, int index)
 {
-    data[index] = 0;
-    align(&data);
+
+    /* Ahh!  Damn dereferencing */
+    (*data)[index] = 0;
+    align(data);
 }
 
 void usage(void)
@@ -828,7 +830,7 @@ void do_wrap(filestruct * inptr, char input_char)
            down = 1;
        }
 
-       null_at(inptr->data, current_x);
+       null_at(&inptr->data, current_x);
 
        if (ISSET(MARK_ISSET) && (mark_beginbuf == inptr)) {
            mark_beginbuf = temp;
@@ -884,7 +886,7 @@ void do_wrap(filestruct * inptr, char input_char)
                && (current_x == current_word_start)) {
                current_x = current_word_start;
 
-               null_at(inptr->data, current_word_start);
+               null_at(&inptr->data, current_word_start);
            } else {
 
                while (isspace((int) inptr->data[i])) {
diff --git a/proto.h b/proto.h
index aa0a53bc947df5f386576375950c06625cf19b3e..9827115de319f7f69454bebdd3ca4429a88c4240 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -131,7 +131,7 @@ void die(char *msg, ...);
 void new_file(void);
 void new_magicline(void);
 void splice_node(filestruct *begin, filestruct *newnode, filestruct *end);
-void null_at(char *data, int index);
+void null_at(char **data, int index);
 void page_up_center(void);
 void blank_edit(void);
 void search_init_globals(void);