nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 06b449b22c85cce628875cf80fbaa3ae21eb8259
parent fe9cf6f399bdd8366c1c456a018ea1aa6125d5b4
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Sun,  8 May 2016 10:51:40 +0200

utils: provide a failure message for all uses of 'fsfromline'

Diffstat:
Msrc/text.c | 19++++++++-----------
Msrc/utils.c | 5++++-
2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/text.c b/src/text.c @@ -478,7 +478,7 @@ void redo_cut(undo *u) void do_undo(void) { undo *u = openfile->current_undo; - filestruct *t = NULL; + filestruct *f, *t = NULL; char *data, *undidmsg = NULL; if (!u) { @@ -486,12 +486,10 @@ void do_undo(void) return; } - filestruct *f = fsfromline(u->mark_begin_lineno); - if (!f) { - statusbar(_("Internal error: can't match line %d. " - "Please save your work."), u->mark_begin_lineno); + f = fsfromline(u->mark_begin_lineno); + if (!f) return; - } + #ifdef DEBUG fprintf(stderr, " >> Undoing a type %d...\n", u->type); fprintf(stderr, " >> Data we're about to undo = \"%s\"\n", f->data); @@ -621,6 +619,7 @@ void do_undo(void) /* Redo the last thing(s) we undid. */ void do_redo(void) { + filestruct *f; char *data, *redidmsg = NULL; undo *u = openfile->undotop; @@ -638,12 +637,10 @@ void do_redo(void) return; } - filestruct *f = fsfromline(u->type == INSERT ? 1 : u->mark_begin_lineno); - if (!f) { - statusbar(_("Internal error: can't match line %d. " - "Please save your work."), u->mark_begin_lineno); + f = fsfromline(u->type == INSERT ? 1 : u->mark_begin_lineno); + if (!f) return; - } + #ifdef DEBUG fprintf(stderr, " >> Redo running for type %d\n", u->type); fprintf(stderr, " >> Data we're about to redo = \"%s\"\n", f->data); diff --git a/src/utils.c b/src/utils.c @@ -623,8 +623,11 @@ filestruct *fsfromline(ssize_t lineno) while (f->lineno != lineno && f->next != NULL) f = f->next; - if (f->lineno != lineno) + if (f->lineno != lineno) { + statusbar(_("Internal error: can't match line %d. " + "Please save your work."), lineno); return NULL; + } return f; }