From 373da010ac2e115b62675cca62e5823e3254b70d Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 21 Nov 2015 18:43:08 +0100 Subject: [PATCH 1/2] Move the `globals` comments in bidi.js and metadata.js to after the Copyright comments --- src/core/bidi.js | 2 +- src/display/metadata.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/bidi.js b/src/core/bidi.js index 0a347d3fc..6bd64b274 100644 --- a/src/core/bidi.js +++ b/src/core/bidi.js @@ -1,4 +1,3 @@ -/* globals PDFJS */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* globals PDFJS */ 'use strict'; diff --git a/src/display/metadata.js b/src/display/metadata.js index 148d6c7df..1adf72fb4 100644 --- a/src/display/metadata.js +++ b/src/display/metadata.js @@ -1,4 +1,3 @@ -/* globals Document, error, PDFJS */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* globals Document, error, PDFJS */ 'use strict'; From c310a3790e577cd6ff77ff748ce3181192c8a69c Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 21 Nov 2015 18:45:06 +0100 Subject: [PATCH 2/2] Make `stripCommentHeaders` less greedy, to ensure that it doesn't eat 'use strict' directive at the top of files (PR 6627 follow-up) While browsing through the latest PDF.js update on mozilla-central, see https://hg.mozilla.org/integration/fx-team/rev/aef06cd725fc, I noticed that the `'use strict';` directives were missing at the top of a number of files. This is fallout from the changes made in `make.js` in PR 6627, since `stripCommentHeaders` previously relied on the existence of the mode-lines. I'm assuming that we do want *all* of the code (e.g. the viewer too) to execute in strict mode, hence this patch tweaks `stripCommentHeaders` to make it less greedy. --- make.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/make.js b/make.js index 72f0f3fc0..bb36b4722 100644 --- a/make.js +++ b/make.js @@ -606,8 +606,9 @@ target.singlefile = function() { function stripCommentHeaders(content, filename) { var notEndOfComment = '(?:[^*]|\\*(?!/))+'; var reg = new RegExp( - '\n(?:/\\*' + notEndOfComment + '\\*/\\s*|//(?!#).*\n\\s*)+' + - '\'use strict\';', 'g'); + '\n/\\* Copyright' + notEndOfComment + '\\*/\\s*' + + '(?:/\\*' + notEndOfComment + '\\*/\\s*|//(?!#).*\n\\s*)*' + + '\\s*\'use strict\';', 'g'); content = content.replace(reg, ''); return content; }