dastworx, upstream fix, patch AST error for pascal streaming

This commit is contained in:
Basile Burg 2016-11-17 04:13:04 +01:00
parent 94e5e8c81a
commit 736c4bb5b2
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
3 changed files with 44 additions and 19 deletions

View File

@ -193,31 +193,52 @@ private void fillBadVersions()
/**
* Make a D string compatible with an Object Pascal string literal.
*/
string patchPascalString(string value)
string patchPascalString(size_t lenLimit = 0)(string value)
{
Appender!string app;
app.reserve(value.length);
static if (lenLimit)
const size_t len = value.length > 100 ? 100 : value.length;
else
const size_t len = value.length;
app.reserve(len);
bool skip;
foreach (immutable i; 0..value.length)
L: foreach (immutable i; 0..value.length)
{
const char c = value[i];
if (c > 0x7F)
switch (c)
{
app ~= value[i];
skip = true;
}
else if (c == '\'')
{
if (skip)
case 0x80: .. case 0xFF:
{
app ~= value[i];
else
app ~= "'#39'";
skip = false;
}
else
{
app ~= value[i];
skip = false;
skip = true;
break;
}
case '\'':
{
if (skip)
app ~= value[i];
else
app ~= "'#39'";
skip = false;
break;
}
case '\r': case '\n':
{
if (skip)
app ~= value[i];
else
app ~= "'#10'";
skip = false;
break;
}
default:
{
app ~= value[i];
skip = false;
static if (lenLimit)
if (app.data.length >= len)
break L;
}
}
}
return app.data;

View File

@ -104,7 +104,7 @@ class SymbolListBuilder(ListFmt Fmt): ASTVisitor
pasStream.put("\ritem\r");
pasStream.put(format("line=%d\r", error.line));
pasStream.put(format("col=%d\r", error.column));
pasStream.put(format("name='%s'\r", patchPascalString(error.message)));
pasStream.put(format("name='%s'\r", patchPascalString!100(error.message)));
pasStream.put(format("symType=%s\r", type));
pasStream.put("end");
}

View File

@ -482,6 +482,10 @@ procedure TCETodoListWidget.toolTerminated(Sender: TObject);
begin
fToolProc.OutputStack.Position := 0;
fTodos.loadFromTxtStream(fToolProc.OutputStack);
// TODO-cmaintenance: remove this from version 3 gold
tryRaiseFromStdErr(fToolProc);
fillTodoList;
fToolProc.OnTerminate := nil;
end;