diff options
| author | 2025-12-07 20:55:20 +0000 | |
|---|---|---|
| committer | 2025-12-07 20:55:20 +0000 | |
| commit | 79c01cb2a2615fbcb2a568d5a49c6d470459cf45 (patch) | |
| tree | be0f4c84145b8902abec690e5885831a061407f3 /src/configparser.cpp | |
| parent | Avoid using deprecated functions in ssl_openssl. (diff) | |
| parent | Release v4.9.0. (diff) | |
Merge branch 'insp4' into master.
Diffstat (limited to 'src/configparser.cpp')
| -rw-r--r-- | src/configparser.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/configparser.cpp b/src/configparser.cpp index 1844f4537..45f96f66a 100644 --- a/src/configparser.cpp +++ b/src/configparser.cpp @@ -37,6 +37,17 @@ # include <unistd.h> #endif +namespace +{ + std::string GetPrintable(int chr) + { + if (isprint(chr)) + return INSP_FORMAT("{} (0x{:x})", (char)chr, chr); + else + return INSP_FORMAT("0x{:x}", chr); + } +} + enum ParseFlags { // Executable includes are disabled. @@ -158,14 +169,14 @@ struct Parser final } else if (ch != '=') { - throw CoreException("Invalid character " + std::string(1, ch) + " in key (" + key + ")"); + throw CoreException("Invalid character in key " + key + ": " + GetPrintable(ch)); } std::string value; ch = next(); if (ch != '"') { - throw CoreException("Invalid character in value of <" + tag->name + ":" + key + ">"); + throw CoreException("Invalid character in value of <" + tag->name + ":" + key + ">: " + GetPrintable(ch)); } while (true) { @@ -244,7 +255,9 @@ struct Parser final if (spc == '>') unget(spc); else if (!isspace(spc)) - throw CoreException("Invalid character in tag name"); + { + throw CoreException("Invalid character in tag name: " + GetPrintable(spc)); + } if (name.empty()) throw CoreException("Empty tag name"); |
