Permalink
Browse files

backport fixes for carriage return to stages 0 and 1

  • Loading branch information...
1 parent 4cdcb56 commit c76378bb912bd100b8d3bee2bc6767b80e3d23d5 @NotFound committed Jun 9, 2012
Showing with 21 additions and 8 deletions.
  1. +10 −3 token.cpp
  2. +11 −5 winxedst1.winxed
View
@@ -1,5 +1,5 @@
// token.cpp
-// Revision 25-may-2012
+// Revision 9-jun-2012
#include "token.h"
#include "errors.h"
@@ -155,6 +155,7 @@ bool Token::isspace() const
(s.empty() ||
s[0] == ' ' ||
s[0] == '\t' ||
+ s[0] == '\r' ||
s[0] == '\n'
));
}
@@ -310,7 +311,10 @@ Token Tokenizer::getheredoc()
std::string mark;
char c;
while ((c = getchar()) != '\n' && c != '\0')
- mark += c;
+ {
+ if (c != '\r')
+ mark += c;
+ }
if (c == 0)
throw SyntaxError ("Unterminated heredoc ",
Token(TokenTQuoted, "<<:", linenum, name));
@@ -320,7 +324,10 @@ Token Tokenizer::getheredoc()
do {
line = "";
while ((c = getchar()) != '\n' && c != '\0')
- line += c;
+ {
+ if (c != '\r')
+ line += c;
+ }
if (c == 0)
throw SyntaxError ("Unterminated heredoc ",
Token(TokenTQuoted, "<<:", linenum, name));
View
@@ -10,7 +10,7 @@
function isspace(string c)
{
- return c == " " || c == "\n" || c == "\t";
+ return c == " " || c == "\n" || c == "\t" || c == "\r";
}
function isdigit(string c)
@@ -450,14 +450,17 @@ function getheredoc(var tk, string start, int linenum)
switch (c) {
case "":
UnterminatedHeredoc(tk, linenum);
+ case "\r":
+ break; // Quick fix for windows line-ending text files
case "\"":
case "\\":
// Encode the mark the same way as the heredoc content
// to simplify its detection
- c = "\\" + c;
+ mark = mark + "\\" + c;
break;
+ default:
+ mark = mark + c;
}
- mark = mark + c;
}
mark = mark + ":>>";
@@ -469,12 +472,15 @@ function getheredoc(var tk, string start, int linenum)
switch (c) {
case "":
UnterminatedHeredoc(tk, linenum);
+ case "\r":
+ break; // Quick fix for windows line-ending text files
case "\"":
case "\\":
- c = "\\" + c;
+ line = line + "\\" + c;
break;
+ default:
+ line = line + c;
}
- line = line + c;
}
if (line != mark)
content = content + line + "\\n";

0 comments on commit c76378b

Please sign in to comment.