From 5c01f7c08f223ebfa671a9f36ac1fd8203880c9e Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Thu, 27 Feb 2020 18:52:00 +0000 Subject: [PATCH] Standardise the characters allowed in config identifiers. --- src/configparser.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/configparser.cpp b/src/configparser.cpp index 6fdc56c32..4748fa847 100644 --- a/src/configparser.cpp +++ b/src/configparser.cpp @@ -158,12 +158,20 @@ struct Parser } } + bool wordchar(char ch) + { + return isalnum(ch) + || ch == '-' + || ch == '.' + || ch == '_'; + } + void nextword(std::string& rv) { int ch = next(); while (isspace(ch)) ch = next(); - while (isalnum(ch) || ch == '_'|| ch == '-') + while (wordchar(ch)) { rv.push_back(ch); ch = next(); @@ -205,7 +213,7 @@ struct Parser while (1) { ch = next(); - if (isalnum(ch) || (varname.empty() && ch == '#') || ch == '.') + if (wordchar(ch) || (varname.empty() && ch == '#')) varname.push_back(ch); else if (ch == ';') break; -- 2.39.2