]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
ul: flip comparisons to lesser to greater order
authorSami Kerola <kerolasa@iki.fi>
Fri, 16 Oct 2020 21:35:06 +0000 (22:35 +0100)
committerSami Kerola <kerolasa@iki.fi>
Tue, 20 Oct 2020 20:13:25 +0000 (21:13 +0100)
1 < 2 < x < 4 is the order is the natural of values.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
text-utils/ul.c

index 0e0bf5dd717eedc4e96be806c4fe8dee01b64b44..1ef2fde849e78ede880744536e98cf2032b9bc75 100644 (file)
@@ -352,7 +352,7 @@ static void overstrike(struct ul_ctl *ctl)
                        break;
                case BOLD:
                        *p++ = ctl->buf[i].c_char;
-                       if (ctl->buf[i].c_width > 1)
+                       if (1 < ctl->buf[i].c_width)
                                i += ctl->buf[i].c_width - 1;
                        had_bold = 1;
                        break;
@@ -392,7 +392,7 @@ static void flush_line(struct ul_ctl *ctl, struct term_caps const *const tcs)
                                output_char(ctl, tcs, ' ', 1);
                } else
                        output_char(ctl, tcs, ctl->buf[i].c_char, ctl->buf[i].c_width);
-               if (ctl->buf[i].c_width > 1)
+               if (1 < ctl->buf[i].c_width)
                        i += ctl->buf[i].c_width - 1;
        }
        if (last_mode != NORMAL_CHARSET)
@@ -434,24 +434,24 @@ static int handle_escape(struct ul_ctl *ctl, struct term_caps const *const tcs,
 
        switch (c = getwc(f)) {
        case HREV:
-               if (ctl->half_position == 0) {
-                       ctl->mode |= SUPERSCRIPT;
-                       ctl->half_position--;
-               } else if (ctl->half_position > 0) {
+               if (0 < ctl->half_position) {
                        ctl->mode &= ~SUBSCRIPT;
                        ctl->half_position--;
+               } else if (ctl->half_position == 0) {
+                       ctl->mode |= SUPERSCRIPT;
+                       ctl->half_position--;
                } else {
                        ctl->half_position = 0;
                        reverse(ctl, tcs);
                }
                return 0;
        case HFWD:
-               if (ctl->half_position == 0) {
-                       ctl->mode |= SUBSCRIPT;
-                       ctl->half_position++;
-               } else if (ctl->half_position < 0) {
+               if (ctl->half_position < 0) {
                        ctl->mode &= ~SUPERSCRIPT;
                        ctl->half_position++;
+               } else if (ctl->half_position == 0) {
+                       ctl->mode |= SUBSCRIPT;
+                       ctl->half_position++;
                } else {
                        ctl->half_position = 0;
                        forward(ctl, tcs);
@@ -498,7 +498,7 @@ static void filter(struct ul_ctl *ctl, struct term_caps const *const tcs, FILE *
                        continue;
                case '_':
                        if (ctl->buf[ctl->column].c_char || ctl->buf[ctl->column].c_width < 0) {
-                               while (ctl->column > 0 && ctl->buf[ctl->column].c_width < 0)
+                               while (ctl->buf[ctl->column].c_width < 0 && 0 < ctl->column)
                                        ctl->column--;
                                width = ctl->buf[ctl->column].c_width;
                                for (i = 0; i < width; i++)