From 736c4bb5b28103a3cce87264b8e66e00890b050e Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Thu, 17 Nov 2016 04:13:04 +0100 Subject: [PATCH] dastworx, upstream fix, patch AST error for pascal streaming --- dastworx/src/common.d | 57 +++++++++++++++++++++++++++++------------- dastworx/src/symlist.d | 2 +- src/ce_todolist.pas | 4 +++ 3 files changed, 44 insertions(+), 19 deletions(-) diff --git a/dastworx/src/common.d b/dastworx/src/common.d index e98af0b9..82f81c13 100644 --- a/dastworx/src/common.d +++ b/dastworx/src/common.d @@ -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; diff --git a/dastworx/src/symlist.d b/dastworx/src/symlist.d index b6f7ced0..5adfed5f 100644 --- a/dastworx/src/symlist.d +++ b/dastworx/src/symlist.d @@ -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"); } diff --git a/src/ce_todolist.pas b/src/ce_todolist.pas index 3b7eda5c..db2e65ac 100644 --- a/src/ce_todolist.pas +++ b/src/ce_todolist.pas @@ -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;