From 743db7dd1c0ced6d4aeb4d4719e4985e8f83890b Mon Sep 17 00:00:00 2001 From: Wolfgang Müller Date: Tue, 27 Jul 2021 12:20:03 +0200 Subject: Clarify warning on duplicate keys In order to alert the user to any potential errors in the configuration files, we keep track of configuration entries that we have not accessed and print them out. These might include misspellings or otherwise malformed strings. To collect those unparsed configuration entries, we remove the ones that have been successfully parsed from our in-memory KeyFile. The remaining keys are the offending ones. Unfortunately, because KeyFile.remove_key() removes only one matching key, we might also be left with any duplicates that would otherwise be valid entries. So, if the entry misc.font is specified twice, we currently warn about an "unknown" key, the second misc.font entry. This could potentially be misleading to the user. Since it is too expensive to fix this issue in the code, make sure we warn instead about "unknown or duplicate" keys. This way we say the correct thing without incurring a big complexity cost. --- configreader.vala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'configreader.vala') diff --git a/configreader.vala b/configreader.vala index 8336637..4c68901 100644 --- a/configreader.vala +++ b/configreader.vala @@ -107,9 +107,9 @@ class ConfigReader { if (keys.length > 0) { var keylist = string.joinv(", ", keys); - // TRANSLATORS: %s is the list of unknown keys joined with ', ' - var warning = ngettext("unknown key in config: %s", - "unknown keys in config: %s", keys.length).printf(keylist); + // TRANSLATORS: %s is the list of unknown or duplicate keys joined with ', ' + var warning = ngettext("unknown or duplicate key in config: %s", + "unknown or duplicate keys in config: %s", keys.length).printf(keylist); append_warning(warning); } -- cgit v1.2.3-2-gb3c3