aboutsummaryrefslogtreecommitdiff
path: root/mod/build-config.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-12-04 12:17:03 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-12-04 12:17:32 +0300
commitbc899becb66e37df6dc93aeca885c68b96e33a1a (patch)
tree50f325f82e1ea6886b60206677c071ee91121b12 /mod/build-config.cxx
parent7fae3a84a27b81380a10a7ea798205da68e69d53 (diff)
Fix build exclusion reason sanitization to properly detect if reason starts with word
Diffstat (limited to 'mod/build-config.cxx')
-rw-r--r--mod/build-config.cxx31
1 files changed, 22 insertions, 9 deletions
diff --git a/mod/build-config.cxx b/mod/build-config.cxx
index 6f2bc43..7e1416d 100644
--- a/mod/build-config.cxx
+++ b/mod/build-config.cxx
@@ -157,21 +157,34 @@ namespace brep
string* reason)
{
// Save the first sentence of the reason, lower-case the first letter if
- // the beginning looks like a word (the second character is the
- // lower-case letter or space).
+ // the beginning looks like a word (all subsequent characters until a
+ // whitespace are lower-case letters).
//
auto sanitize = [] (const string& reason)
{
string r (reason.substr (0, reason.find ('.')));
- char c;
- size_t n (r.size ());
+ char c (r[0]); // Can be '\0'.
+ if (alpha (c) && c == ucase (c))
+ {
+ bool word (true);
+
+ for (size_t i (1);
+ i != r.size () && (c = r[i]) != ' ' && c != '\t' && c != '\n';
+ ++i)
+ {
+ // Is not a word if contains a non-letter or an upper-case letter.
+ //
+ if (!alpha (c) || c == ucase (c))
+ {
+ word = false;
+ break;
+ }
+ }
- if (n > 0 &&
- alpha (c = r[0]) &&
- c == ucase (c) &&
- (n == 1 || (alpha (c = r[1]) && c == lcase (c)) || c == ' '))
- r[0] = lcase (r[0]);
+ if (word)
+ r[0] = lcase (r[0]);
+ }
return r;
};