Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Array.join() to build strings in the PostScript parser #5053

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/core/ps_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,12 @@ var PostScriptLexer = (function PostScriptLexerClosure() {
return PostScriptToken.RBRACE;
}
// operator
var str = String.fromCharCode(ch);
var strBuf = [String.fromCharCode(ch)];
while ((ch = this.nextChar()) >= 0 && // and 'A'-'Z', 'a'-'z'
((ch >= 0x41 && ch <= 0x5A) || (ch >= 0x61 && ch <= 0x7A))) {
str += String.fromCharCode(ch);
strBuf.push(String.fromCharCode(ch));
}
var str = strBuf.join('');
switch (str.toLowerCase()) {
case 'if':
return PostScriptToken.IF;
Expand All @@ -193,16 +194,16 @@ var PostScriptLexer = (function PostScriptLexerClosure() {
},
getNumber: function PostScriptLexer_getNumber() {
var ch = this.currentChar;
var str = String.fromCharCode(ch);
var strBuf = [String.fromCharCode(ch)];
while ((ch = this.nextChar()) >= 0) {
if ((ch >= 0x30 && ch <= 0x39) || // '0'-'9'
ch === 0x2D || ch === 0x2E) { // '-', '.'
str += String.fromCharCode(ch);
strBuf.push(String.fromCharCode(ch));
} else {
break;
}
}
var value = parseFloat(str);
var value = parseFloat(strBuf.join(''));
if (isNaN(value)) {
error('Invalid floating point number: ' + value);
}
Expand Down