summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-01-05 13:18:08 -0500
committerpommicket <pommicket@gmail.com>2023-01-05 13:18:36 -0500
commit3e0548caa2cf7d6b32cc029dbc9044ef877f6cee (patch)
treecab5e9412ebe19f1ce4793ab989fc03012e2938a /config.c
parentbe318b18a01481d16149c34f649c9cdb1f91979d (diff)
allow `-delimited multiline strings in ted.cfg
also fix multiline string highlighting of keywords/# in config files
Diffstat (limited to 'config.c')
-rw-r--r--config.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/config.c b/config.c
index 41dc3dd..b49b031 100644
--- a/config.c
+++ b/config.c
@@ -521,10 +521,10 @@ static i64 config_read_string(Ted *ted, ConfigReader *cfg, char **ptext) {
char *p;
int backslashes = 0;
u32 start_line = cfg->line_number;
+ char delimiter = **ptext;
char *start = *ptext + 1;
char *str = NULL;
for (p = start; ; ++p) {
- bool done = false;
switch (*p) {
case '\\':
++backslashes;
@@ -532,6 +532,7 @@ static i64 config_read_string(Ted *ted, ConfigReader *cfg, char **ptext) {
switch (*p) {
case '\\':
case '"':
+ case '`':
break;
case 'n':
arr_add(str, '\n');
@@ -551,9 +552,6 @@ static i64 config_read_string(Ted *ted, ConfigReader *cfg, char **ptext) {
return -1;
}
break;
- case '"':
- done = true;
- break;
case '\n':
++cfg->line_number;
break;
@@ -565,7 +563,8 @@ static i64 config_read_string(Ted *ted, ConfigReader *cfg, char **ptext) {
arr_clear(str);
return -1;
}
- if (done) break;
+ if (*p == delimiter)
+ break;
arr_add(str, *p);
}
@@ -747,7 +746,7 @@ static void config_parse_line(ConfigReader *cfg, Settings *settings, const Confi
char *endp;
argument = strtoll(value, &endp, 10);
value = endp;
- } else if (*value == '"') {
+ } else if (*value == '"' || *value == '`') {
// string argument
// restore newline to handle multi-line strings
@@ -816,7 +815,7 @@ static void config_parse_line(ConfigReader *cfg, Settings *settings, const Confi
boolean = false;
}
- if (value[0] == '"') {
+ if (value[0] == '"' || value[0] == '`') {
// restore newline to handle multi-line strings
// a little bit hacky oh well
*newline = '\n';