* 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 <bensberg@justemail.net>
* src/nano.c (main): Let the value of a --fill option on the
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) {
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);
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]);
/* Redo the last thing(s) we undid. */
void do_redo(void)
{
- size_t len = 0;
char *data, *redidmsg = NULL;
undo *u = openfile->undotop;
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]);
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);
#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;