aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-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;
};