]> git.neil.brown.name Git - edlib.git/commitdiff
markup: make "priority" unsigned.
authorNeilBrown <neil@brown.name>
Sat, 6 May 2023 23:14:18 +0000 (09:14 +1000)
committerNeilBrown <neil@brown.name>
Sat, 6 May 2023 23:14:18 +0000 (09:14 +1000)
"priority" is now an unsigned short and the behaviour of integers
outside that range is sensible and documented.

Signed-off-by: NeilBrown <neil@brown.name>
DOC/Developer/06-rendering.md
lib-markup.c

index 7fcbc0fa9b9e5f6bd592621814041da1d4dcd2e1..cc5c490162d7a617cb71a91c8836a3283ad3af07 100644 (file)
@@ -390,7 +390,8 @@ Priorities 1-99 are for stable properties of the document, like colour
 to highlight directories in a file listing.  Properties 100-199 are for
 fairly stable results of analysing the document, such as spelling
 errors.  Properties 200-299 are for less stable results like search
-results of a selection.
+results of a selection.  Priorities larger than 65534 are all treated
+identically, as are priorities less than 1.
 
 Importantly and attribute which affects spacing, like 'tab' or 'centre'
 and which cannot be closed and re-opened must have priority of 0.
index ef5426913c3ba4939579413e831e67cccf0f0aec..6338899781c8d3a0b3b28f7b6997314bd8f9d2a9 100644 (file)
@@ -124,7 +124,7 @@ struct attr_return {
                struct attr_stack       *next;
                char                    *attr safe;
                int                     end;
-               short                   priority;
+               unsigned short          priority;
        } *ast, *tmpst;
        int min_end;
        int chars;
@@ -221,6 +221,10 @@ static void as_add(struct attr_return *ar safe,
        if (end == 0 || INT_MAX - end <= ar->chars)
                end = INT_MAX - 1 - ar->chars;
        new->end = ar->chars + end;
+       if (prio < 0)
+               prio = 0;
+       if (prio > 65535)
+               prio = 65535;
        new->priority = prio;
        *here = new;
 }