From 12622d7fd3f19936f2d235d8965491eb2adbae80 Mon Sep 17 00:00:00 2001 From: pommicket Date: Tue, 13 Feb 2024 09:13:59 -0500 Subject: handle longer keys/values in .editorconfig well i found a project somewhere with extremely long .editorconfig values that aren't documented in the spec whodathunk! --- config.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/config.c b/config.c index d18cc92..4eb536a 100644 --- a/config.c +++ b/config.c @@ -1461,7 +1461,7 @@ static void config_read_editorconfig(Ted *ted, RcStr *path_rc) { config_compile_regex(cfg, reader); break; default: { - char key[64] = {c}; + char key[128] = {c}; for (size_t i = 1; i < sizeof key - 1; i++) { c = config_getc(reader); if (!c || c == '\n') break; @@ -1469,18 +1469,14 @@ static void config_read_editorconfig(Ted *ted, RcStr *path_rc) { key[i] = c; } if (c != '=') { - config_err(reader, "expected key = value but didn't find ="); + config_err(reader, "expected key = value but didn't find = (just have %s)", key); break; } str_trim(key); str_ascii_to_lowercase(key); - char value[64] = {0}; - for (size_t i = 0; i < sizeof value - 1; i++) { - c = config_getc(reader); - if (!c || c == '\n') break; - value[i] = c; - } - str_trim(value); + config_read_to_eol(reader, line, sizeof line); + str_trim(line); + char *value = line; if (streq(key, "root")) { str_ascii_to_lowercase(value); if (cfg) { -- cgit v1.2.3