From 42c89ba6d30856fadb08a5ce3efab930ac21c168 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Fri, 18 Dec 2020 15:49:20 +0000 Subject: [PATCH] simgear/props/props.cxx: parse_name(): improved exception text. Also fixed indentation. --- simgear/props/props.cxx | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/simgear/props/props.cxx b/simgear/props/props.cxx index 5c27ad16..ec77d895 100755 --- a/simgear/props/props.cxx +++ b/simgear/props/props.cxx @@ -143,28 +143,33 @@ parse_name (const SGPropertyNode *node, const Range &path) i++; } if (i != max && *i != '/') - throw std::runtime_error("illegal character after . or .. in '" + node->getPath() + "'"); - } else if (isalpha_c(*i) || *i == '_') { + throw std::runtime_error("illegal character after . or .. in '" + node->getPath() + "'"); + } + else if (isalpha_c(*i) || *i == '_') { i++; - // The rules inside a name are a little - // less restrictive. + // The rules inside a name are a little + // less restrictive. while (i != max) { - if (isalpha_c(*i) || isdigit_c(*i) || isspecial_c(*i)) { - // name += path[i]; - } else if (*i == '[' || *i == '/') { - break; - } else { + if (isalpha_c(*i) || isdigit_c(*i) || isspecial_c(*i)) { + // name += path[i]; + } + else if (*i == '[' || *i == '/') { + break; + } + else { std::string err = "'"; err.push_back(*i); - err.append("' found in propertyname after '"+node->getPath()+"'"); - err.append("\nname may contain only ._- and alphanumeric characters"); + err.append("' found in propertyname after '"+node->getPath()+"'."); + err.append(" name may contain only ._- and alphanumeric characters."); + err.append(" Complete path is: '"); + for (auto j: path) err.push_back(j); + err.append("'"); throw std::runtime_error(err); } i++; } } - else { if (path.begin() == i) { std::string err = "'";