From bc899becb66e37df6dc93aeca885c68b96e33a1a Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 4 Dec 2018 12:17:03 +0300 Subject: Fix build exclusion reason sanitization to properly detect if reason starts with word --- mod/build-config.cxx | 31 ++++++++++++++++++++++--------- 1 file 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; }; -- cgit v1.1