Code

Allow strings to be enclosed in either ' or "
authorJonas Fonseca <fonseca@diku.dk>
Wed, 14 Jun 2006 19:38:03 +0000 (21:38 +0200)
committerJonas Fonseca <fonseca@antimatter.localdomain>
Wed, 14 Jun 2006 19:39:48 +0000 (21:39 +0200)
So now you can use both:

set commit-encoding = "UTF-8"
set commit-encoding = 'UTF-8'
set commit-encoding =  UTF-8

tig.c

diff --git a/tig.c b/tig.c
index cda8a71e9a7d15882b82eb672c788257dfb00f09..a3b92c851d5b43bb98dd597344099a0d907d1ecd 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -946,8 +946,22 @@ option_set_command(int argc, char *argv[])
        }
 
        if (!strcmp(argv[0], "commit-encoding")) {
-               string_copy(opt_encoding, argv[2]);
-               return OK;
+               char *arg = argv[2];
+               int delimiter = *arg;
+               int i;
+
+               switch (delimiter) {
+               case '"':
+               case '\'':
+                       for (arg++, i = 0; arg[i]; i++)
+                               if (arg[i] == delimiter) {
+                                       arg[i] = 0;
+                                       break;
+                               }
+               default:
+                       string_copy(opt_encoding, arg);
+                       return OK;
+               }
        }
 
        config_msg = "Unknown variable name";