]> git.neil.brown.name Git - edlib.git/commitdiff
Change doc:step to return character directly.
authorNeilBrown <neil@brown.name>
Tue, 8 Dec 2015 00:33:08 +0000 (11:33 +1100)
committerNeilBrown <neil@brown.name>
Wed, 9 Dec 2015 23:00:50 +0000 (10:00 +1100)
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 <neil@brown.name>
core-doc.c
core-mark.c
doc-dir.c
doc-text.c

index 29d5870a0df1370562ed247af9ff503520cacc53..3cf7347b980125cf03234fda3d501e902536a1bf 100644 (file)
@@ -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)
index 925c0adb652d6dc599c853bfd1af7acf847e49f3..0a5eeff3a90e115e7e93873db2571264cc7c0cee 100644 (file)
@@ -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)
index 3725becf2a2c4a63f1514bc34bfe3ce78128978e..fe0e94ca5f4eda0d8ead6064f68d4f751c0c7296 100644 (file)
--- 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)
index 3daf41e00d7eea93fa68cca112013c4c82c9d00a..98fa4cefd6b62b2c453d9b5fecc7f8760162aae8 100644 (file)
@@ -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)