summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e6d4219)
raw | patch | inline | side by side (parent: e6d4219)
author | Jonas Fonseca <fonseca@diku.dk> | |
Wed, 23 Jul 2008 17:23:12 +0000 (19:23 +0200) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Wed, 23 Jul 2008 17:23:12 +0000 (19:23 +0200) |
tig.c | patch | blob | history |
index 8679025a83aa2b8e4a9c7b1b5a43d83475f18317..5b7b1ea0cf74f865096d8c46cb087cf21faa9a43 100644 (file)
--- a/tig.c
+++ b/tig.c
!strcmp(s, "yes")) ? TRUE : FALSE;
}
+static int
+parse_int(const char *s, int default_value, int min, int max)
+{
+ int value = atoi(s);
+
+ return (value < min || value > max) ? default_value : value;
+}
+
/* Wants: name = value */
static int
option_set_command(int argc, char *argv[])
}
if (!strcmp(argv[0], "line-number-interval")) {
- opt_num_interval = atoi(argv[2]);
+ opt_num_interval = parse_int(argv[2], opt_num_interval, 1, 1024);
return OK;
}
if (!strcmp(argv[0], "author-width")) {
- opt_author_cols = atoi(argv[2]);
+ opt_author_cols = parse_int(argv[2], opt_author_cols, 0, 1024);
return OK;
}
if (!strcmp(argv[0], "tab-size")) {
- opt_tab_size = atoi(argv[2]);
+ opt_tab_size = parse_int(argv[2], opt_tab_size, 1, 1024);
return OK;
}