Code

Use error codes when checking parse_int() return value sh/next
authorSebastian Harl <sh@tokkee.org>
Mon, 9 May 2011 06:17:03 +0000 (08:17 +0200)
committerSebastian Harl <sh@tokkee.org>
Mon, 9 May 2011 06:17:03 +0000 (08:17 +0200)
Usually, OPT_OK != OK, so we'd usually treat success as an error, leading e.g.
to errors like "Unable to parse '42' as a line number".

Reported by Christian Ohm in Debian bug #626124.

Signed-off-by: Sebastian Harl <sh@tokkee.org>
tig.c

diff --git a/tig.c b/tig.c
index 2baf56cdc6c5bd30bc28da30c542020661b298a0..2767fde330ff077902a2d8e06aee3563bd52b8b6 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -1029,7 +1029,7 @@ set_color(int *color, const char *name)
        if (map_enum(color, color_map, name))
                return TRUE;
        if (!prefixcmp(name, "color"))
-               return parse_int(color, name + 5, 0, 255) == OK;
+               return parse_int(color, name + 5, 0, 255) == OPT_OK;
        return FALSE;
 }
 
@@ -6916,7 +6916,7 @@ main(int argc, const char *argv[])
                        if (cmd && isdigit(*cmd)) {
                                int lineno = view->lineno + 1;
 
-                               if (parse_int(&lineno, cmd, 1, view->lines + 1) == OK) {
+                               if (parse_int(&lineno, cmd, 1, view->lines + 1) == OPT_OK) {
                                        select_view_line(view, lineno - 1);
                                        report("");
                                } else {