]> git.neil.brown.name Git - edlib.git/commitdiff
python: use NULL for a mark->ref of None.
authorNeilBrown <neil@brown.name>
Wed, 16 Jun 2021 03:40:30 +0000 (13:40 +1000)
committerNeilBrown <neil@brown.name>
Fri, 18 Jun 2021 04:39:34 +0000 (14:39 +1000)
When mark references are shared (and possibly other times), it is
important that EOF is inidicated by the ref pointer being NULL.

So allow Python code to indicate NULL by using None.

Signed-off-by: NeilBrown <neil@brown.name>
lang-python.c

index 33db177adecbf51cc91af809e71ef1d025267ddc..d7b90b9389678bcff6ccc315cd6064a5689fe28a 100644 (file)
@@ -1937,17 +1937,19 @@ static int mark_setpos(Mark *m safe, PyObject *v, void *x)
                return -1;
        }
        d->refcnt(m->mark, -1);
+       if (v == Py_None)
+               v = NULL;
        /* If an adjacent mark has a ref.c with a matching value
         * use that instead, so that mark_same() works.
         */
        if ((m2 = mark_next(m->mark)) != NULL &&
            ((struct doc *safe)m2->owner->data)->refcnt == mark_refcnt &&
-           m2->ref.c != NULL &&
+           m2->ref.c != NULL && v != NULL &&
            PyObject_RichCompareBool(v, m2->ref.c, Py_EQ) == 1)
                m->mark->ref.c = m2->ref.c;
        else if ((m2 = mark_prev(m->mark)) != NULL &&
                 ((struct doc *safe)m2->owner->data)->refcnt == mark_refcnt &&
-                m2->ref.c != NULL &&
+                m2->ref.c != NULL && v != NULL &&
                 PyObject_RichCompareBool(v, m2->ref.c, Py_EQ) == 1)
                m->mark->ref.c = m2->ref.c;
        else