From ddeb486f6855a0fb8385a5440af9d7bc6034de2c Mon Sep 17 00:00:00 2001 From: Benjamin Byholm Date: Sat, 30 May 2015 03:37:56 +0300 Subject: [PATCH] Avoid duplicate warnings --- tools/1to2.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/1to2.js b/tools/1to2.js index d62f2d0a..3c29575e 100755 --- a/tools/1to2.js +++ b/tools/1to2.js @@ -11,6 +11,9 @@ var commander = require('commander'), fs = require('fs'), glob = require('glob'), groups = [], + total = 0, + warning1 = '/* ERROR: Rewrite using Buffer */\n', + warning2 = '\\/\\* ERROR\\: Rewrite using Buffer \\*\\/\\n', length, i; @@ -57,8 +60,8 @@ groups.push([2, '(?:(?:v8\\:\\:)?|(Nan)?)(TryCatch)']); /* NanNew("string") will likely not fail a ToLocalChecked(), key group 1 */ groups.push([1, ['(NanNew)', '(\\("[^\\"]*"[^\\)]*\\))(?!\\.ToLocalChecked\\(\\))'].join('')]); -/* Removed v8 APIs, warn that the code needs rewriting using node::Buffer, key group 1 */ -groups.push([1, ['^.*?(', [ +/* Removed v8 APIs, warn that the code needs rewriting using node::Buffer, key group 2 */ +groups.push([2, ['(', warning2, ')?', '^.*?(', [ 'GetIndexedPropertiesExternalArrayDataLength', 'GetIndexedPropertiesExternalArrayData', 'GetIndexedPropertiesExternalArrayDataType', @@ -175,7 +178,6 @@ function groupcount(s) { } /* compute the absolute position of each key group in the joined master RegExp */ -var total = 0; for (i = 1, length = groups.length; i < length; i++) { total += groupcount(groups[i - 1][1]); groups[i][0] += total; @@ -239,7 +241,7 @@ function replace() { case 'HasIndexedPropertiesInPixelData': case 'SetIndexedPropertiesToExternalArrayData': case 'SetIndexedPropertiesToPixelData': - return '// ERROR: Rewrite using Buffer\n' + arguments[0]; + return arguments[groups[4][0] - 1] ? arguments[0] : [warning1, arguments[0]].join(''); default: }