]> git.neil.brown.name Git - edlib.git/commitdiff
Remove doc arg from doc_next_mark.
authorNeilBrown <neil@brown.name>
Thu, 26 Nov 2015 23:46:05 +0000 (10:46 +1100)
committerNeilBrown <neil@brown.name>
Thu, 26 Nov 2015 23:46:05 +0000 (10:46 +1100)
It is no longer needed.

Signed-off-by: NeilBrown <neil@brown.name>
core-mark.c
core.h
lib-line-count.c

index 41ff70cc14e56c3f74688348a6a69d45bbf4f6f4..fb0ac3dc5e84fd0f03d71ab03271b1ec9290e734 100644 (file)
@@ -346,7 +346,7 @@ struct mark *doc_first_mark(struct doc *d, int view)
        return NULL;
 }
 
-struct mark *doc_next_mark(struct doc *d, struct mark *m)
+struct mark *doc_next_mark(struct mark *m)
 {
        struct tlist_head *tl = &m->view;
 
@@ -356,6 +356,16 @@ struct mark *doc_next_mark(struct doc *d, struct mark *m)
        return NULL;
 }
 
+struct mark *doc_prev_mark(struct mark *m)
+{
+       struct tlist_head *tl = &m->view;
+
+       tlist_for_each_continue_reverse(tl, GRP_HEAD)
+               if (TLIST_TYPE(tl) == GRP_MARK)
+                       return tlist_entry(tl, struct mark, view);
+       return NULL;
+}
+
 struct mark *doc_first_mark_all(struct doc *d)
 {
        if (d->marks.first)
diff --git a/core.h b/core.h
index a2e26bfa305e1b8e99eef40aa12f0ab9c358ffc9..a2927135aea61c1a1fac0712d1f3fdf97b10955a 100644 (file)
--- a/core.h
+++ b/core.h
@@ -152,8 +152,8 @@ struct mark *doc_next_mark_all(struct mark *m);
 struct mark *doc_prev_mark_all(struct mark *m);
 struct mark *doc_prev_mark_all_safe(struct doc *d, struct mark *m);
 struct mark *doc_first_mark(struct doc *d, int viewnum);
-struct mark *doc_next_mark(struct doc *d, struct mark *m);
-struct mark *doc_prev_mark(struct doc *d, struct mark *m);
+struct mark *doc_next_mark(struct mark *m);
+struct mark *doc_prev_mark(struct mark *m);
 void point_reset(struct point *p);
 void mark_reset(struct doc *d, struct mark *m);
 void __mark_reset(struct doc *d, struct mark *m, int new, int end);
index 40b25af76c05ad995c664c76ef499cf4e11e9862..6c89d088a9c4d5e5b7da611c8fffbdb771bd2b23 100644 (file)
@@ -111,7 +111,7 @@ static int need_recalc(struct doc *d, struct mark *m)
        if (!attr_find(*mark_attr(m), "lines"))
                ret = 1;
        while (1) {
-               next = doc_next_mark(d, m);
+               next = doc_next_mark(m);
                if (!next)
                        break;
                if (doc_prior(d, next) == '\n' &&
@@ -155,9 +155,9 @@ static void count_calculate(struct doc *d, struct mark *start, struct mark *end)
                        /* Force and update to make sure spacing stays sensible */
                        if (need_recalc(d, m))
                                /* need to update this one */
-                               do_count(d, m, doc_next_mark(d, m), &l, &w, &c, 1);
+                               do_count(d, m, doc_next_mark(m), &l, &w, &c, 1);
 
-                       m = doc_next_mark(d, m);
+                       m = doc_next_mark(m);
                }
                if (!m) {
                        /* fell off the end, just count directly */
@@ -167,7 +167,7 @@ static void count_calculate(struct doc *d, struct mark *start, struct mark *end)
        }
        if (need_recalc(d, m))
                /* need to update this one */
-               do_count(d, m, doc_next_mark(d, m), &l, &w, &c, 1);
+               do_count(d, m, doc_next_mark(m), &l, &w, &c, 1);
 
        /* 'm' is not before 'start', it might be after.
         * if 'm' is not before 'end' either, just count from
@@ -186,7 +186,7 @@ static void count_calculate(struct doc *d, struct mark *start, struct mark *end)
                lines = words = chars = 0;
        else
                do_count(d, start, m, &lines, &words, &chars, 0);
-       while ((m2 = doc_next_mark(d, m)) != NULL &&
+       while ((m2 = doc_next_mark(m)) != NULL &&
               (!end || mark_ordered(m2, end))) {
                /* Need everything from m to m2 */
                lines += attr_find_int(*mark_attr(m), "lines");
@@ -194,7 +194,7 @@ static void count_calculate(struct doc *d, struct mark *start, struct mark *end)
                chars += attr_find_int(*mark_attr(m), "chars");
                m = m2;
                if (need_recalc(d, m))
-                       do_count(d, m, doc_next_mark(d, m), &l, &w, &c, 1);
+                       do_count(d, m, doc_next_mark(m), &l, &w, &c, 1);
        }
        /* m is the last mark before end */
        if (!end) {