Changeset 41045 in webkit for trunk/JavaScriptCore/parser/Lexer.h


Ignore:
Timestamp:
Feb 17, 2009, 4:14:30 PM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2009-02-17 Geoffrey Garen <[email protected]>

Reviewed by Sam Weinig.


Fixed <rdar://problem/6595040> REGRESSION: http://www.amnestyusa.org/
fails to load.


amnestyusa.org uses the Optimist JavaScript library, which adds event
listeners by concatenating string-ified functions. This is only sure to
be syntactically valid if the string-ified functions end in semicolons.

  • parser/Lexer.cpp: (JSC::Lexer::isWhiteSpace):
  • parser/Lexer.h: (JSC::Lexer::isWhiteSpace): (JSC::Lexer::isLineTerminator): Added some helper functions for examining whitespace.
  • runtime/FunctionPrototype.cpp: (JSC::appendSemicolonIfNeeded): (JSC::functionProtoFuncToString): When string-ifying a function, insert a semicolon in the last non-whitespace position, if one doesn't already exist.

LayoutTests:

2009-02-17 Geoffrey Garen <[email protected]>

Reviewed by Sam Weinig.


Test for <rdar://problem/6595040> REGRESSION: http://www.amnestyusa.org/
fails to load.

  • fast/js/function-toString-semicolon-insertion-expected.txt: Added.
  • fast/js/function-toString-semicolon-insertion.html: Added.
  • fast/js/resources/function-toString-semicolon-insertion.js: Added. (compileAndSerialize):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/parser/Lexer.h

    r40214 r41045  
    2828#include "SourceCode.h"
    2929#include <wtf/Vector.h>
     30#include <wtf/unicode/Unicode.h>
    3031
    3132namespace JSC {
     
    9091        void clear();
    9192        SourceCode sourceCode(int openBrace, int closeBrace, int firstLine) { return SourceCode(m_source->provider(), openBrace, closeBrace + 1, firstLine); }
     93
     94        static inline bool isWhiteSpace(int ch)
     95        {
     96            return ch == '\t' || ch == 0x0b || ch == 0x0c || WTF::Unicode::isSeparatorSpace(ch);
     97        }
     98
     99        static inline bool isLineTerminator(int ch)
     100        {
     101            return ch == '\r' || ch == '\n' || ch == 0x2028 || ch == 0x2029;
     102        }
    92103
    93104    private:
Note: See TracChangeset for help on using the changeset viewer.