From 65dde00f70eb5665455a18fcae5bafa7a2c976c8 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 8 Dec 2015 11:33:08 +1100 Subject: [PATCH] Change doc:step to return character directly. Don't use ci for returing things. As a char could be zero and WEOF could appear negative, use high bits to make the number look positive. Signed-off-by: NeilBrown --- core-doc.c | 8 +++++--- core-mark.c | 9 ++++++++- doc-dir.c | 4 ++-- doc-text.c | 4 ++-- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/core-doc.c b/core-doc.c index 29d5870a..3cf7347b 100644 --- a/core-doc.c +++ b/core-doc.c @@ -639,6 +639,7 @@ DEF_CMD(docs_step) struct mark *m = ci->mark; bool forward = ci->numeric; bool move = ci->extra; + int ret; struct pane *p = m->ref.p, *next; @@ -665,10 +666,11 @@ DEF_CMD(docs_step) if (move) m->ref.p = next; if (p == NULL) - ci->extra = WEOF; + ret = WEOF; else - ci->extra = ' '; - return 1; + ret = ' '; + /* return value must be +ve, so use high bits to ensure this. */ + return (ret & 0xFFFFF) | 0x100000; } DEF_CMD(docs_set_ref) diff --git a/core-mark.c b/core-mark.c index 925c0adb..0a5eeff3 100644 --- a/core-mark.c +++ b/core-mark.c @@ -496,7 +496,14 @@ void mark_backward_over(struct mark *m, struct mark *mp) wint_t mark_step(struct doc *d, struct mark *m, int forward, int move, struct cmd_info *ci) { - return call_extra("doc:step", d->home, forward, m, move); + int ret = call5("doc:step", d->home, forward, m, NULL, move); + + if (ret <= 0) + return ret; + if (ret >= 0x1fffff) + return WEOF; + else + return ret & 0xfffff; } wint_t mark_step2(struct doc *d, struct mark *m, int forward, int move) diff --git a/doc-dir.c b/doc-dir.c index 3725becf..fe0e94ca 100644 --- a/doc-dir.c +++ b/doc-dir.c @@ -298,8 +298,8 @@ DEF_CMD(dir_step) } if (move && ret != WEOF) m->ref.d = d; - ci->extra = ret; - return 1; + /* return value must be +ve, so use high bits to ensure this. */ + return (ret & 0xFFFFF) | 0x100000; } DEF_CMD(dir_set_ref) diff --git a/doc-text.c b/doc-text.c index 3daf41e0..98fa4cef 100644 --- a/doc-text.c +++ b/doc-text.c @@ -998,8 +998,8 @@ DEF_CMD(text_step) ret = text_prev(t, &r); if (ret != WEOF && move) m->ref = *(struct doc_ref*)&r; - ci->extra = ret; - return 1; + /* return value must be +ve, so use high bits to ensure this. */ + return (ret & 0xFFFFF) | 0x100000; } static int text_ref_same(struct text *t, struct doc_ref *r1, struct doc_ref *r2) -- 2.39.5