From b7855857b53a6c81a1e11c65fd97ce0b541c6cd6 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Fri, 11 Mar 2011 22:39:32 -0500 Subject: [PATCH] stop trimming all trailing whitespace. --- lib/nodes.js | 6 ++---- src/nodes.coffee | 8 +------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/nodes.js b/lib/nodes.js index 01713f8961..caa6e8afcd 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -1,5 +1,5 @@ (function() { - var Access, Arr, Assign, Base, Block, Call, Class, Closure, Code, Comment, Existence, Extends, For, IDENTIFIER, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, NEGATE, NO, Obj, Op, Param, Parens, Push, Range, Return, SIMPLENUM, Scope, Slice, Splat, Switch, TAB, THIS, TRAILING_WHITESPACE, Throw, Try, UTILITIES, Value, While, YES, compact, del, ends, extend, flatten, last, merge, multident, starts, unfoldSoak, utility, _ref; + var Access, Arr, Assign, Base, Block, Call, Class, Closure, Code, Comment, Existence, Extends, For, IDENTIFIER, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, NEGATE, NO, Obj, Op, Param, Parens, Push, Range, Return, SIMPLENUM, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, compact, del, ends, extend, flatten, last, merge, multident, starts, unfoldSoak, utility, _ref; var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } @@ -273,7 +273,6 @@ o.scope = new Scope(null, this, null); o.level = LEVEL_TOP; code = this.compileWithDeclarations(o); - code = code.replace(TRAILING_WHITESPACE, ''); if (o.bare) { return code; } else { @@ -2119,7 +2118,7 @@ } func = new Code([], Block.wrap([expressions])); args = []; - if ((mentionsArgs = expressions.contains(this.literalArgs)) || (expressions.contains(this.literalThis))) { + if ((mentionsArgs = expressions.contains(this.literalArgs)) || expressions.contains(this.literalThis)) { meth = new Literal(mentionsArgs ? 'apply' : 'call'); args = [new Literal('this')]; if (mentionsArgs) { @@ -2165,7 +2164,6 @@ LEVEL_OP = 5; LEVEL_ACCESS = 6; TAB = ' '; - TRAILING_WHITESPACE = /[ \t]+$/gm; IDENTIFIER = /^[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*$/; SIMPLENUM = /^[+-]?\d+$/; IS_STRING = /^['"]/; diff --git a/src/nodes.coffee b/src/nodes.coffee index d36009dbc5..ab56992620 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -233,7 +233,6 @@ exports.Block = class Block extends Base o.scope = new Scope null, this, null o.level = LEVEL_TOP code = @compileWithDeclarations o - code = code.replace TRAILING_WHITESPACE, '' if o.bare then code else "(function() {\n#{code}\n}).call(this);\n" # Compile the expressions body for the contents of a function, with @@ -1669,8 +1668,7 @@ Closure = return expressions if expressions.jumps() func = new Code [], Block.wrap [expressions] args = [] - if (mentionsArgs = expressions.contains @literalArgs) or - ( expressions.contains @literalThis) + if (mentionsArgs = expressions.contains @literalArgs) or expressions.contains @literalThis meth = new Literal if mentionsArgs then 'apply' else 'call' args = [new Literal 'this'] args.push new Literal 'arguments' if mentionsArgs @@ -1741,10 +1739,6 @@ LEVEL_ACCESS = 6 # ...[0] # Tabs are two spaces for pretty printing. TAB = ' ' -# Trim out all trailing whitespace, so that the generated code plays nice -# with Git. -TRAILING_WHITESPACE = /[ \t]+$/gm - IDENTIFIER = /^[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*$/ SIMPLENUM = /^[+-]?\d+$/