fix PChat to String conv issues caused by missing null terminator

This commit is contained in:
Basile Burg 2020-04-13 20:57:50 +02:00
parent 5e17d5617e
commit 37e2d75022
5 changed files with 11 additions and 10 deletions

View File

@ -3,6 +3,7 @@ module ddemangle;
import core.demangle : demangle; import core.demangle : demangle;
import std.regex : replaceAll, Captures, regex, Regex; import std.regex : replaceAll, Captures, regex, Regex;
import core.stdc.string : strlen; import core.stdc.string : strlen;
import std.string : toStringz;
extern(C): extern(C):
@ -15,7 +16,7 @@ const(char)* ddemangle(const(char)* line)
reInit = true; reInit = true;
reDemangle = regex(r"\b_?_D[0-9a-zA-Z_]+\b"); reDemangle = regex(r"\b_?_D[0-9a-zA-Z_]+\b");
} }
return replaceAll!(demangleMatch)(line[0 .. line.strlen], reDemangle).ptr; return replaceAll!(demangleMatch)(line[0 .. line.strlen], reDemangle).toStringz;
} }
extern(D): private: extern(D): private:

View File

@ -3,7 +3,7 @@ module ddoc_template;
import import
core.stdc.string; core.stdc.string;
import import
std.array, std.conv; std.array, std.conv, std.string;
import import
iz.memory, iz.sugar; iz.memory, iz.sugar;
import import
@ -65,7 +65,7 @@ public:
c2 = plusComment ? "++" : "**"; c2 = plusComment ? "++" : "**";
} }
const(char)* result() { return app.data.ptr; } const(char)* result() { return app.data.toStringz(); }
override void visit(const(ThrowStatement) ts) override void visit(const(ThrowStatement) ts)
{ {

View File

@ -3,7 +3,7 @@ module halstead;
import import
core.stdc.string; core.stdc.string;
import import
std.algorithm, std.conv, std.json, std.meta; std.algorithm, std.conv, std.json, std.meta, std.string;
import import
std.stdio, std.ascii, std.digest.crc, std.range: iota; std.stdio, std.ascii, std.digest.crc, std.range: iota;
import import
@ -138,7 +138,7 @@ private final class HalsteadMetric: ASTVisitor
{ {
JSONValue js; JSONValue js;
js["functions"] = fs; js["functions"] = fs;
return js.toString.ptr; return js.toString.toStringz();
} }
override void visit(const(PragmaExpression)){} override void visit(const(PragmaExpression)){}

View File

@ -4,7 +4,7 @@ import
core.stdc.string; core.stdc.string;
import import
std.array, std.traits, std.conv, std.json, std.format, std.array, std.traits, std.conv, std.json, std.format,
std.algorithm; std.algorithm, std.string;
import import
iz.memory: construct, destruct; iz.memory: construct, destruct;
import import
@ -157,16 +157,16 @@ final class SymbolListBuilder(ListFmt Fmt): ASTVisitor
static if (Fmt == ListFmt.Pas) static if (Fmt == ListFmt.Pas)
{ {
pasStream.put(">\rend"); pasStream.put(">\rend");
return pasStream.data.ptr; return pasStream.data.toStringz;
} }
else else
{ {
JSONValue result = parseJSON("{}"); JSONValue result = parseJSON("{}");
result["items"] = json; result["items"] = json;
version (assert) version (assert)
return result.toPrettyString.ptr; return result.toPrettyString.toStringz;
else else
return result.toString.ptr; return result.toString.toStringz;
} }
} }

View File

@ -25,7 +25,7 @@ extern(C) const(char)* todoItems(const(char)* joinedFiles)
analyze(token, fname, stream); analyze(token, fname, stream);
} }
stream.put(">end"); stream.put(">end");
return stream.data.ptr; return stream.data.toStringz();
} }
private void analyze(const(Token) token, const(char)[] fname, ref Appender!string stream) private void analyze(const(Token) token, const(char)[] fname, ref Appender!string stream)