I HATE WINDOWS
This commit is contained in:
Hackerpilot 2013-08-26 00:18:53 -07:00
parent 42cf96c6d2
commit bfeb20776e
2 changed files with 20 additions and 7 deletions

1
build.bat Normal file
View File

@ -0,0 +1 @@
dmd main.d stats.d imports.d highlighter.d ctags.d astprinter.d stdx/d/lexer.d stdx/d/parser.d stdx/d/entities.d stdx/d/ast.d -wi -ofdscanner

View File

@ -10,12 +10,6 @@ import std.stdio;
import std.array; import std.array;
import stdx.d.lexer; import stdx.d.lexer;
void writeSpan(string cssClass, string value)
{
stdout.write(`<span class="`, cssClass, `">`, value.replace("&", "&amp;").replace("<", "&lt;"), `</span>`);
}
// http://ethanschoonover.com/solarized // http://ethanschoonover.com/solarized
void highlight(R)(TokenRange!R tokens, string fileName) void highlight(R)(TokenRange!R tokens, string fileName)
{ {
@ -54,11 +48,29 @@ html { background-color: #fdf6e3; color: #002b36; }
else if (isOperator(t.type)) else if (isOperator(t.type))
writeSpan("op", t.value); writeSpan("op", t.value);
else else
stdout.write(t.value.replace("<", "&lt;")); {
version(Windows)
{
// Stupid Windows automatically does a LF → CRLF, so CRLF → CRCRLF, which is obviously wrong.
// Strip out the CR characters here to avoid this.
stdout.write(t.value.replace("<", "&lt;").replace("\r", ""));
}
else
stdout.write(t.value.replace("<", "&lt;");
}
} }
stdout.writeln("</pre>\n</body></html>"); stdout.writeln("</pre>\n</body></html>");
} }
void writeSpan(string cssClass, string value)
{
version(Windows)
stdout.write(`<span class="`, cssClass, `">`, value.replace("&", "&amp;").replace("<", "&lt;").replace("\r", ""), `</span>`);
else
stdout.write(`<span class="`, cssClass, `">`, value.replace("&", "&amp;").replace("<", "&lt;"), `</span>`);
}
/+void main(string[] args) /+void main(string[] args)
{ {
LexerConfig config; LexerConfig config;