mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-20 06:43:14 +01:00
Fix some issues with fawzi's patch.
- It now actually compiles:
- import stdc.stdio for string formatting functions)
- remove extra '{'
- Use snprintf() instead of sprintf().
- Use return value from snprintf instead of strlen().
- Don't print the filename in Exception.writeOut() if it has zero length and
the line number is 0
(It would previously only skip these if the filename was null, but not if it
was a different empty string)
- Ignore empty filename + line number 0 in FrameInfo.writeOut() as well.
This commit is contained in:
@@ -45,7 +45,7 @@ private
|
||||
import tango.stdc.string; // : memcmp, memcpy, memmove;
|
||||
import tango.stdc.stdlib; // : calloc, realloc, free;
|
||||
import util.string;
|
||||
debug(PRINTF) import tango.stdc.stdio; // : printf;
|
||||
import tango.stdc.stdio; // : printf, snprintf;
|
||||
|
||||
extern (C) void onOutOfMemoryError();
|
||||
extern (C) Object _d_allocclass(ClassInfo ci);
|
||||
@@ -915,13 +915,15 @@ class Exception : Object
|
||||
void writeOut(void delegate(char[])sink){
|
||||
char[25] buf;
|
||||
sink(func);
|
||||
sprintf(buf.ptr,"@%zx ",address);
|
||||
sink(buf[0..strlen(buf.ptr)]);
|
||||
sprintf(buf.ptr," %+td ",address);
|
||||
sink(buf[0..strlen(buf.ptr)]);
|
||||
sink(file);
|
||||
sprintf(buf.ptr,":%ld",line);
|
||||
sink(buf[0..strlen(buf.ptr)]);
|
||||
auto len = snprintf(buf.ptr,buf.length,"@%zx ",address);
|
||||
sink(buf[0..len]);
|
||||
len = snprintf(buf.ptr,buf.length," %+td ",address);
|
||||
sink(buf[0..len]);
|
||||
if (file.length != 0 || line) {
|
||||
sink(file);
|
||||
len = snprintf(buf.ptr,buf.length,":%ld",line);
|
||||
sink(buf[0..len]);
|
||||
}
|
||||
}
|
||||
}
|
||||
interface TraceInfo
|
||||
@@ -947,7 +949,7 @@ class Exception : Object
|
||||
|
||||
this( char[] msg, Exception next=null )
|
||||
{
|
||||
this(msg,"",0,next,rt_createTraceContext(null));
|
||||
this(msg,null,0,next,rt_createTraceContext(null));
|
||||
}
|
||||
|
||||
this( char[] msg, char[] file, long line, Exception next=null )
|
||||
@@ -961,15 +963,15 @@ class Exception : Object
|
||||
}
|
||||
|
||||
void writeOut(void delegate(char[])sink){
|
||||
if (file)
|
||||
if (file.length != 0 || line)
|
||||
{
|
||||
char[25]buf;
|
||||
sink(this.classinfo.name);
|
||||
sink("@");
|
||||
sink(file);
|
||||
sink("(");
|
||||
sprintf(buf.ptr,"%ld",line);
|
||||
sink(buf[0..strlen(buf.ptr)]);
|
||||
auto len = snprintf(buf.ptr,buf.length,"%ld",line);
|
||||
sink(buf[0..len]);
|
||||
sink("): ");
|
||||
sink(toString());
|
||||
sink("\n");
|
||||
@@ -1027,7 +1029,7 @@ extern (C) void rt_setTraceHandler( TraceHandler h )
|
||||
* An object describing the current calling context or null if no handler is
|
||||
* supplied.
|
||||
*/
|
||||
extern(C) Exception.TraceInfo rt_createTraceContext( void* ptr ){
|
||||
extern(C) Exception.TraceInfo rt_createTraceContext( void* ptr )
|
||||
{
|
||||
if( traceHandler is null )
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user