[Issue 2479] sformat is broken

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 31 01:59:59 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=2479


Don <clugdbug at yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug at yahoo.com.au




--- Comment #4 from Don <clugdbug at yahoo.com.au>  2009-08-31 01:59:58 PDT ---
Even further reduced, removing all imports. My patch to bug 814 does not fix
this.
------
alias void* va_list;

T va_arg(T)(inout va_list _argptr) {
    T arg = *cast(T*)_argptr;
    _argptr = _argptr + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1));
    return arg;
}

void doFormat(void delegate(dchar) myputc, TypeInfo[] args, va_list
argptr){
    string fmt = va_arg!(string)(argptr);
    assert(!(fmt is null)); // fires when it shouldn't.
}

char[] sformat(char[] s, ...){
    void putc(dchar c) { s[0] = cast(char)c; }

    doFormat(&putc, _arguments, _argptr);
    return s[0 .. 1];
}

void main(){
    char[32] tmp;
    sformat(tmp, "%s", "hi");
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list