From 28fb279aba3af8bf1a57a9e36b2b183ef68c5454 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 14 Jan 2019 13:51:31 +0200 Subject: Diagnose target names with multiple trailing slashes as invalid --- build2/scope.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'build2/scope.cxx') diff --git a/build2/scope.cxx b/build2/scope.cxx index feac2fe..7ea4f42 100644 --- a/build2/scope.cxx +++ b/build2/scope.cxx @@ -667,7 +667,15 @@ namespace build2 fail (loc) << "invalid path '" << e.path << "'"; } - v.erase (0, p + 1); + // This is probably too general of a place to ignore multiple trailing + // slashes and treat it as a directory (e.g., we don't want to + // encourage this sloppiness in buildfiles). We could, however, do it + // for certain contexts, such as buildspec. Maybe a lax flag? + // + if (++p == v.size ()) + fail (loc) << "invalid name '" << v << "'"; + + v.erase (0, p); } // Extract the extension. -- cgit v1.1