summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 04e2b7b)
raw | patch | inline | side by side (parent: 04e2b7b)
author | Jonas Fonseca <fonseca@diku.dk> | |
Fri, 9 Jun 2006 00:08:28 +0000 (02:08 +0200) | ||
committer | Jonas Fonseca Madsen <fonseca@ask.diku.dk> | |
Fri, 9 Jun 2006 00:40:53 +0000 (02:40 +0200) |
tig.c | patch | blob | history |
index cb943bc8e4077f2f39888c23b6246296e2024020..8a14cb37ebb8d3007f0159cf094f6b75ccd2383f 100644 (file)
--- a/tig.c
+++ b/tig.c
return ERR;
}
- if (set_color(&info->fg, argv[1]) == ERR) {
- config_msg = "Unknown color";
- return ERR;
- }
-
- if (set_color(&info->bg, argv[2]) == ERR) {
+ if (set_color(&info->fg, argv[1]) == ERR ||
+ set_color(&info->bg, argv[2]) == ERR) {
config_msg = "Unknown color";
return ERR;
}
return OK;
}
+ config_msg = "Unknown variable name";
return ERR;
}
if (!strcmp(opt, "bind"))
return option_bind_command(argc, argv);
+ config_msg = "Unknown option command";
return ERR;
}
static int
read_option(char *opt, int optlen, char *value, int valuelen)
{
+ int status = OK;
+
config_lineno++;
config_msg = "Internal error";
+ /* Check for comment markers, since read_properties() will
+ * only ensure opt and value are split at first " \t". */
optlen = strcspn(opt, "#;");
- if (optlen == 0) {
- /* The whole line is a commend or empty. */
+ if (optlen == 0)
return OK;
- } else if (opt[optlen] != 0) {
- /* Part of the option name is a comment, so the value part
- * should be ignored. */
- valuelen = 0;
- opt[optlen] = value[valuelen] = 0;
- } else {
- /* Else look for comment endings in the value. */
- valuelen = strcspn(value, "#;");
- value[valuelen] = 0;
+ if (opt[optlen] != 0) {
+ config_msg = "No option value";
+ status = ERR;
+
+ } else {
+ /* Look for comment endings in the value. */
+ int len = strcspn(value, "#;");
+
+ if (len < valuelen) {
+ valuelen = len;
+ value[valuelen] = 0;
+ }
+
+ status = set_option(opt, value);
}
- if (set_option(opt, value) == ERR) {
- fprintf(stderr, "Error on line %d, near '%.*s' option: %s\n",
+ if (status == ERR) {
+ fprintf(stderr, "Error on line %d, near '%.*s': %s\n",
config_lineno, optlen, opt, config_msg);
config_errors = TRUE;
}