From a6b02acc2ce43f5b6cc4c0768236cf97a19b939e Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Mon, 6 Oct 2008 21:28:50 +0200 Subject: [PATCH] Improve handling of unmatched quotes in ~/.tigrc --- tig.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) 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; -- 2.30.2