From: Benno Schulenberg Date: Sun, 22 Nov 2015 16:09:15 +0000 (+0000) Subject: Eliding an unneeded variable. X-Git-Tag: v2.5.0~51 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=81f3177a3348c7cfbd5198cedd508c99f5a8f582;p=nano.git Eliding an unneeded variable. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5432 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 065217bb..760a463f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ * src/text.c (add_undo): Delete a condition that will never occur -- this function is only ever called with PASTE when cutbuffer != NULL. * src/text.c: Rewrap, rewrite, rename, and reorder some things. + * src/text.c (do_undo, do_redo): Elide an unneeded variable. 2015-11-21 Benno Schulenberg * src/nano.c (main): Let the value of a --fill option on the diff --git a/src/text.c b/src/text.c index d8c21a55..f52071e7 100644 --- a/src/text.c +++ b/src/text.c @@ -478,8 +478,7 @@ void redo_cut(undo *u) void do_undo(void) { undo *u = openfile->current_undo; - filestruct *t = 0; - size_t len = 0; + filestruct *t = NULL; char *data, *undidmsg = NULL; if (!u) { @@ -502,8 +501,7 @@ void do_undo(void) switch (u->type) { case ADD: undidmsg = _("text add"); - len = strlen(f->data) - strlen(u->strdata) + 1; - data = charalloc(len); + data = charalloc(strlen(f->data) - strlen(u->strdata) + 1); strncpy(data, f->data, u->begin); strcpy(&data[u->begin], &f->data[u->begin + strlen(u->strdata)]); free(f->data); @@ -513,8 +511,7 @@ void do_undo(void) case BACK: case DEL: undidmsg = _("text delete"); - len = strlen(f->data) + strlen(u->strdata) + 1; - data = charalloc(len); + data = charalloc(strlen(f->data) + strlen(u->strdata) + 1); strncpy(data, f->data, u->begin); strcpy(&data[u->begin], u->strdata); strcpy(&data[u->begin + strlen(u->strdata)], &f->data[u->begin]); @@ -625,7 +622,6 @@ void do_undo(void) /* Redo the last thing(s) we undid. */ void do_redo(void) { - size_t len = 0; char *data, *redidmsg = NULL; undo *u = openfile->undotop; @@ -657,8 +653,7 @@ void do_redo(void) switch (u->type) { case ADD: redidmsg = _("text add"); - len = strlen(f->data) + strlen(u->strdata) + 1; - data = charalloc(len); + data = charalloc(strlen(f->data) + strlen(u->strdata) + 1); strncpy(data, f->data, u->begin); strcpy(&data[u->begin], u->strdata); strcpy(&data[u->begin + strlen(u->strdata)], &f->data[u->begin]); @@ -669,8 +664,7 @@ void do_redo(void) case BACK: case DEL: redidmsg = _("text delete"); - len = strlen(f->data) + strlen(u->strdata) + 1; - data = charalloc(len); + data = charalloc(strlen(f->data) + strlen(u->strdata) + 1); strncpy(data, f->data, u->begin); strcpy(&data[u->begin], &f->data[u->begin + strlen(u->strdata)]); free(f->data); @@ -706,8 +700,7 @@ void do_redo(void) #endif case JOIN: redidmsg = _("line join"); - len = strlen(f->data) + strlen(u->strdata) + 1; - f->data = charealloc(f->data, len); + f->data = charealloc(f->data, strlen(f->data) + strlen(u->strdata) + 1); strcat(f->data, u->strdata); if (f->next != NULL) { filestruct *tmp = f->next;