Bug 1620876 - Handle "//\n" webglsl comments. r=lsalzman
authorJeff Gilbert <jgilbert@mozilla.com>
Mon, 09 Mar 2020 03:19:25 +0000
changeset 517488 cad7268d33b0b922373221a1f34b4fbdb7884288
parent 517487 24dc59fa7381d59c6c72e45bd65199fb71bf3043
child 517489 7ac664c145986d1cb30064d652e8198b1b3f23a3
push id37195
push useraiakab@mozilla.com
push dateMon, 09 Mar 2020 09:18:41 +0000
treeherdermozilla-central@7ac664c14598 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsalzman
bugs1620876
milestone75.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1620876 - Handle "//\n" webglsl comments. r=lsalzman Differential Revision: https://phabricator.services.mozilla.com/D65929
dom/canvas/WebGLValidateStrings.cpp
--- a/dom/canvas/WebGLValidateStrings.cpp
+++ b/dom/canvas/WebGLValidateStrings.cpp
@@ -53,20 +53,25 @@ std::string CommentsToSpaces(const std::
     if (isBlockComment) {
       endRegex = &RE_BLOCK_COMMENT_END;
     }
 
     if (isBlockComment) {
       ret += "/*";
     }
 
-    const bool isTerminated = std::regex_search(itr, end, match, *endRegex);
-    if (!isTerminated) return ret;
+    auto commentEnd = end;
+    if (!isBlockComment && itr != end && *itr == '\n') {
+      commentEnd = itr + 1;  // '//\n'
+    } else if (std::regex_search(itr, end, match, *endRegex)) {
+      commentEnd = itr + match.position() + match.length();
+    } else {
+      return ret;
+    }
 
-    const auto commentEnd = itr + match.position() + match.length();
     for (; itr != commentEnd; ++itr) {
       const auto cur = *itr;
       if (cur == '\n') {
         ret += cur;
       }
     }
     if (isBlockComment) {
       ret += "*/";