From 8b1a039732458f38015e8b5b11332517391b34e2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 5 Sep 2019 15:49:11 +0200 Subject: Improve /showIncludes parsing to handle internal (debug?) builds of MSVC --- libbuild2/cc/compile-rule.cxx | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'libbuild2') diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx index 8cebef0..450fbe9 100644 --- a/libbuild2/cc/compile-rule.cxx +++ b/libbuild2/cc/compile-rule.cxx @@ -1600,14 +1600,26 @@ namespace build2 // // Plus, it seems the quote character could to be multi-byte. // - size_t p1 (l.find (':', p + 5)); - size_t p2 (l.rfind (':')); + // Plus, in some internal (debug?) builds the second part + // may have the "No such file or directory (c:\...\p0prepro.c:1722)" + // form. + + // Find first leading ':' that's followed by a space. + // + size_t p1 (p + 4); // 1083 + while ((p1 = l.find (':', p1 + 1)) != string::npos && l[p1 + 1] != ' ') + ; + + // Find first trailing ':' that's followed by a space. + // + size_t p2 (l.size ()); + while ((p2 = l.rfind (':', p2 - 1)) != string::npos && l[p2 + 1] != ' ') + ; if (p1 != string::npos && p2 != string::npos && - (p2 - p1) > 4 && // At least ": 'x':". - l[p1 + 1] == ' ' && - l[p2 + 1] == ' ') + (p2 - p1) > 4 ) // At least ": 'x':". + { p1 += 3; // First character of the path. p2 -= 1; // One past last character of the path. -- cgit v1.1