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 std.regex : replaceAll, Captures, regex, Regex;
import core.stdc.string : strlen;
import std.string : toStringz;
extern(C):
@ -15,7 +16,7 @@ const(char)* ddemangle(const(char)* line)
reInit = true;
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:

View File

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

View File

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

View File

@ -4,7 +4,7 @@ import
core.stdc.string;
import
std.array, std.traits, std.conv, std.json, std.format,
std.algorithm;
std.algorithm, std.string;
import
iz.memory: construct, destruct;
import
@ -157,16 +157,16 @@ final class SymbolListBuilder(ListFmt Fmt): ASTVisitor
static if (Fmt == ListFmt.Pas)
{
pasStream.put(">\rend");
return pasStream.data.ptr;
return pasStream.data.toStringz;
}
else
{
JSONValue result = parseJSON("{}");
result["items"] = json;
version (assert)
return result.toPrettyString.ptr;
return result.toPrettyString.toStringz;
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);
}
stream.put(">end");
return stream.data.ptr;
return stream.data.toStringz();
}
private void analyze(const(Token) token, const(char)[] fname, ref Appender!string stream)