]> git.neil.brown.name Git - edlib.git/commitdiff
Have all "render-line" function fail cleanly if point/mark are NULL.
authorNeilBrown <neil@brown.name>
Wed, 25 Nov 2015 22:36:49 +0000 (09:36 +1100)
committerNeilBrown <neil@brown.name>
Wed, 25 Nov 2015 22:36:49 +0000 (09:36 +1100)
This makes it a bit cleaner to find the render-line pane with a void call.

Signed-off-by: NeilBrown <neil@brown.name>
doc-text.c
render-complete.c
render-format.c
render-hex.c

index df8ddf6e098331e99b2aaea8ebe19a75f06ce270..4f6dcefa557ca8267abe0edee838d0f0019185e4 100644 (file)
@@ -1592,12 +1592,16 @@ DEF_CMD(render_line)
         */
        struct buf b;
        struct point **ptp = ci->pointp;
-       struct doc *d = (*ptp)->doc;
+       struct doc *d;
        struct mark *m = ci->mark;
        int o = ci->numeric;
        wint_t ch = WEOF;
        int chars = 0;
 
+       if (!m || !ptp)
+               return -1;
+       d = (*ptp)->doc;
+
        buf_init(&b);
        while (1) {
                char *attr = __text_get_attr(d, m, 1, "highlight");
index 7f4412fe92ec841e830d345994482829211a4513..c1c135e6b1dec27f28f783e2220e6e21a3641f9b 100644 (file)
@@ -29,9 +29,12 @@ DEF_CMD(render_complete_line)
         */
        struct cmd_info ci2 = {0};
        struct complete_data *cd = ci->home->data;
-       struct doc *d = (*ci->pointp)->doc;
+       struct doc *d;
        int plen;
 
+       if (!ci->pointp || !ci->mark)
+               return -1;
+       d = (*ci->pointp)->doc;
        ci2.key = ci->key;
        ci2.mark = ci->mark;
        ci2.pointp = ci->pointp;
@@ -310,15 +313,13 @@ REDEF_CMD(complete_attach)
        /* Need to interpose a new pane between the 'render-lines' pane,
         * which we assume is 'ci->focus' and its parent, so we can
         * re-interpret lines.
-        * Find the 'render-line-prev' pane by sending a render-lines request
-        * and grabbing 'home'
+        * Find the 'render-line-prev' pane by sending a render-line request
+        * (with NULLs so it fails) and grabbing 'home'
         */
-       ci2.key = "render-line-prev";
-       ci2.pointp = ci->pointp;
-       ci2.numeric = 0;
-       ci2.mark = mark_at_point(*ci->pointp, MARK_UNGROUPED);
+       ci2.key = "render-line";
        ci2.focus = ci->focus;
-       key_handle_focus(&ci2);
+       if (key_handle_focus(&ci2) == 0)
+               return -1;
        parent = ci2.home;
        lines = pane_child(parent);
        mark_free(ci2.mark);
index ed14341d9b1fe1855e9ec4abb6858d4dc700d4f2..07628de8c4c239745049859b65a6cc6c38fb48ad 100644 (file)
@@ -27,13 +27,17 @@ DEF_CMD(render_line)
        char *body = pane_attr_get(ci->focus, "line-format");
        struct rf_data *rf = ci->home->data;
        struct buf ret;
-       struct doc *d = (*ci->pointp)->doc;
+       struct doc *d;
        struct mark *m = ci->mark;
        char *n;
        wint_t ch;
        int home;
        int field = 0;
 
+       if (!ci->pointp || !ci->mark)
+               return -1;
+
+       d = (*ci->pointp)->doc;
        if (RPT_NUM(ci) < 0 &&
            !mark_same(d, &(*ci->pointp)->m, m))
                ci->numeric = NO_NUMERIC;
index 7d0a1e814a3017954a258c8b7c99fbfaa8f5ca33..af8941a31254321bb8eb9813e275861694768ea2 100644 (file)
@@ -123,13 +123,16 @@ DEF_CMD(render_line)
 {
        struct buf ret;
        struct point **ptp = ci->pointp;
-       struct doc *d = (*ptp)->doc;
+       struct doc *d;
        struct cmd_info ci2 = {0};
        struct mark *m = NULL;
        int pos;
        int i;
        char buf[10];
 
+       if (!ptp || !ci->mark)
+               return -1;
+       d = (*ptp)->doc;
        ci2.key = "CountLines";
        ci2.pointp = ptp;
        ci2.mark = ci->mark;