From: Jonas Fonseca Date: Mon, 6 Oct 2008 19:28:50 +0000 (+0200) Subject: Improve handling of unmatched quotes in ~/.tigrc X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a6b02acc2ce43f5b6cc4c0768236cf97a19b939e;p=tig.git Improve handling of unmatched quotes in ~/.tigrc --- diff --git a/tig.c b/tig.c index 25fb237..f81686b 100644 --- a/tig.c +++ b/tig.c @@ -1171,18 +1171,17 @@ option_set_command(int argc, char *argv[]) } if (!strcmp(argv[0], "commit-encoding")) { - char *arg = argv[2]; - int delimiter = *arg; - int i; + const char *arg = argv[2]; + int arglen = strlen(arg); - switch (delimiter) { + switch (arg[0]) { case '"': case '\'': - for (arg++, i = 0; arg[i]; i++) - if (arg[i] == delimiter) { - arg[i] = 0; - break; - } + if (arglen == 1 || arg[arglen - 1] != arg[0]) { + config_msg = "Unmatched quotation"; + return ERR; + } + arg += 1; arglen -= 2; default: string_ncopy(opt_encoding, arg, strlen(arg)); return OK;