X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=JSDOC%2FCompressWhite.js;h=50d7476e10984fdd2a4d6bfb8af89db6e7ce894d;hb=4874ad3e1d08502e88986231f3de271795ca2302;hp=293c3187bb49c37f5bf77d1b60653eee51e46346;hpb=78311bb94a758645c148c3dd19b3f9a99ce4e51d;p=gnome.introspection-doc-generator diff --git a/JSDOC/CompressWhite.js b/JSDOC/CompressWhite.js index 293c318..50d7476 100644 --- a/JSDOC/CompressWhite.js +++ b/JSDOC/CompressWhite.js @@ -8,19 +8,22 @@ @arg packer {Packer} */ -CompressWhite = function (ts, packer) +const CompressWhite = function (ts, packer, keepWhite) { - + keepWhite = keepWhite || false; ts.rewind(); //var str = File.read(fn); var rep_var = 1; + + while (true) { var tok = ts.next(); if (!tok) { break; } if (tok.type == "WHIT") { + continue; //if (tok._isDoc) { // continue; @@ -268,18 +271,27 @@ CompressWhite = function (ts, packer) var out = ''; var outoff = 0; - out.length = ts.slen; // prealloc. + try { out.length = ts.slen; } catch (e) {} // prealloc. + out = ''; + var tok; while (true) { - var tok = ts.nextTok(); - + + tok = keepWhite ? ts.next() : ts.nextTok(); + if (!tok) { break; } + if (tok.type == "COMM") { + tok.outData = '\n'; + } + ///print(tok.type + ':' + tok.data); - if (tok.type == "NAME" && tok.identifier && tok.identifier.mungedValue && tok.identifier.mungedValue.length) { + if (tok.type == "NAME" && tok.identifier + && tok.identifier.mungedValue && tok.identifier.mungedValue.length) { //f.write(tok.identifier.mungedValue); + //print("MUNGED: " + tok.identifier.mungedValue); out += tok.identifier.mungedValue; continue; }