From: 
Subject: Debian changes

The Debian packaging of node-postcss-comment is maintained in git, using a workflow
similar to the one described in dgit-maint-merge(7).
The Debian delta is represented by this one combined patch; there isn't a
patch queue that can be represented as a quilt series.

A detailed breakdown of the changes is available from their canonical
representation -- git commits in the packaging repository.
For example, to see the changes made by the Debian maintainer in the first
upload of upstream version 1.2.3, you could use:

    % git clone https://git.dgit.debian.org/node-postcss-comment
    % cd node-postcss-comment
    % git log --oneline 1.2.3..debian/1.2.3-1 -- . ':!debian'

(If you have dgit, use `dgit clone node-postcss-comment`, rather than plain `git clone`.)

We don't use debian/source/options single-debian-patch because it has bugs.
Therefore, NMUs etc. may nevertheless have made additional patches.

---

diff --git a/hookRequire.js b/hookRequire.js
index 3a763a0..bfedaff 100644
--- a/hookRequire.js
+++ b/hookRequire.js
@@ -1,9 +1,14 @@
-var Parser = require('postcss/lib/parser')
-var tokenizer = require('./lib/tokenize')
+var postcss = require('postcss')
+var parse = require('./lib/parse')
 
-Parser.prototype.createTokenizer = function () {
-  this.tokenizer = tokenizer(this.input)
-}
+var process = postcss.Processor.prototype.process
 
-module.exports = require('postcss')
+postcss.Processor.prototype.process = function (css, opts) {
+  opts = opts || {}
+  if (!opts.parser && !opts.syntax) {
+    opts = Object.assign({}, opts, { parser: parse })
+  }
+  return process.call(this, css, opts)
+}
 
+module.exports = postcss
diff --git a/lib/parser.js b/lib/parser.js
index 06b9517..9cee35b 100644
--- a/lib/parser.js
+++ b/lib/parser.js
@@ -1,15 +1,10 @@
-var inherits = require('util').inherits
 var Parser = require('postcss/lib/parser')
 var tokenizer = require('./tokenize')
 
-inherits(InlineParser, Parser)
-
-module.exports = InlineParser
-
-function InlineParser(input) {
-  Parser.call(this, input)
+class InlineParser extends Parser {
+  createTokenizer() {
+    this.tokenizer = tokenizer(this.input)
+  }
 }
 
-InlineParser.prototype.createTokenizer = function() {
-  this.tokenizer = tokenizer(this.input)
-}
+module.exports = InlineParser
diff --git a/lib/tokenize.js b/lib/tokenize.js
index ca0f343..26257e3 100644
--- a/lib/tokenize.js
+++ b/lib/tokenize.js
@@ -1,7 +1,7 @@
 'use strict'
 
 /**
- * Cloned from https://github.com/postcss/postcss/blob/master/lib/tokenize.es6
+ * Cloned from https://github.com/postcss/postcss/blob/main/lib/tokenize.js
  *
  */
 const SINGLE_QUOTE      = '\''.charCodeAt(0);
@@ -44,18 +44,24 @@ module.exports = function tokenizer(input, options) {
     let buffer = [];
     let returned = [];
 
+    function position() {
+        return pos;
+    }
+
     function unclosed(what) {
-        throw input.error('Unclosed ' + what, line, pos - offset);
+        throw input.error('Unclosed ' + what, pos);
     }
 
     function endOfFile() {
         return returned.length === 0 && pos >= length;
     }
 
-    function nextToken() {
+    function nextToken(opts) {
         if ( returned.length ) return returned.pop();
         if ( pos >= length ) return;
 
+        let ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
+
         code = css.charCodeAt(pos);
         if ( code === NEWLINE || code === FEED ||
              code === CR && css.charCodeAt(pos + 1) !== NEWLINE ) {
@@ -88,27 +94,27 @@ module.exports = function tokenizer(input, options) {
             break;
 
         case OPEN_SQUARE:
-            currentToken = ['[', '[', line, pos - offset];
+            currentToken = ['[', '[', pos];
             break;
 
         case CLOSE_SQUARE:
-            currentToken = [']', ']', line, pos - offset];
+            currentToken = [']', ']', pos];
             break;
 
         case OPEN_CURLY:
-            currentToken = ['{', '{', line, pos - offset];
+            currentToken = ['{', '{', pos];
             break;
 
         case CLOSE_CURLY:
-            currentToken = ['}', '}', line, pos - offset];
+            currentToken = ['}', '}', pos];
             break;
 
         case COLON:
-            currentToken = [':', ':', line, pos - offset];
+            currentToken = [':', ':', pos];
             break;
 
         case SEMICOLON:
-            currentToken = [';', ';', line, pos - offset];
+            currentToken = [';', ';', pos];
             break;
 
         case OPEN_PARENTHESES:
@@ -123,7 +129,7 @@ module.exports = function tokenizer(input, options) {
                     escaped = false;
                     next    = css.indexOf(')', next + 1);
                     if ( next === -1 ) {
-                        if ( ignore ) {
+                        if ( ignore || ignoreUnclosed ) {
                             next = pos;
                             break;
                         } else {
@@ -138,8 +144,7 @@ module.exports = function tokenizer(input, options) {
                 } while ( escaped );
 
                 currentToken = ['brackets', css.slice(pos, next + 1),
-                    line, pos  - offset,
-                    line, next - offset
+                    pos, next
                 ];
 
                 pos = next;
@@ -149,11 +154,10 @@ module.exports = function tokenizer(input, options) {
                 content = css.slice(pos, next + 1);
 
                 if ( next === -1 || RE_BAD_BRACKET.test(content) ) {
-                    currentToken = ['(', '(', line, pos - offset];
+                    currentToken = ['(', '(', pos];
                 } else {
                     currentToken = ['brackets', content,
-                        line, pos  - offset,
-                        line, next - offset
+                        pos, next
                     ];
                     pos = next;
                 }
@@ -162,7 +166,7 @@ module.exports = function tokenizer(input, options) {
             break;
 
         case CLOSE_PARENTHESES:
-            currentToken = [')', ')', line, pos - offset];
+            currentToken = [')', ')', pos];
             break;
 
         case SINGLE_QUOTE:
@@ -173,7 +177,7 @@ module.exports = function tokenizer(input, options) {
                 escaped = false;
                 next    = css.indexOf(quote, next + 1);
                 if ( next === -1 ) {
-                    if ( ignore ) {
+                    if ( ignore || ignoreUnclosed ) {
                         next = pos + 1;
                         break;
                     } else {
@@ -200,8 +204,7 @@ module.exports = function tokenizer(input, options) {
             }
 
             currentToken = ['string', css.slice(pos, next + 1),
-                line, pos  - offset,
-                nextLine, next - nextOffset
+                pos, next
             ];
 
             offset = nextOffset;
@@ -219,8 +222,7 @@ module.exports = function tokenizer(input, options) {
             }
 
             currentToken = ['at-word', css.slice(pos, next + 1),
-                line, pos  - offset,
-                line, next - offset
+                pos, next
             ];
 
             pos = next;
@@ -252,8 +254,7 @@ module.exports = function tokenizer(input, options) {
             }
 
             currentToken = ['word', css.slice(pos, next + 1),
-                line, pos  - offset,
-                line, next - offset
+                pos, next
             ];
 
             pos = next;
@@ -263,7 +264,7 @@ module.exports = function tokenizer(input, options) {
             if ( code === SLASH && css.charCodeAt(pos + 1) === ASTERISK ) {
                 next = css.indexOf('*/', pos + 2) + 1;
                 if ( next === 0 ) {
-                    if ( ignore ) {
+                    if ( ignore || ignoreUnclosed ) {
                         next = css.length;
                     } else {
                         unclosed('comment');
@@ -283,8 +284,7 @@ module.exports = function tokenizer(input, options) {
                 }
 
                 currentToken = ['comment', content,
-                    line,     pos  - offset,
-                    nextLine, next - nextOffset
+                    pos, next
                 ];
 
                 offset = nextOffset;
@@ -303,8 +303,7 @@ module.exports = function tokenizer(input, options) {
                 content = content.replace(/\*\//g, '*\\/') + ' */'
 
                 currentToken = ['comment', content,
-                    line,     pos  - offset,
-                    line,     next - offset
+                    pos, next
                 ];
 
                 pos    = next;
@@ -319,8 +318,7 @@ module.exports = function tokenizer(input, options) {
                 }
 
                 currentToken = ['word', css.slice(pos, next + 1),
-                    line, pos  - offset,
-                    line, next - offset
+                    pos, next
                 ];
 
                 buffer.push(currentToken);
@@ -342,7 +340,7 @@ module.exports = function tokenizer(input, options) {
     return {
         back,
         nextToken,
-        endOfFile
+        endOfFile,
+        position
     };
 }
-
