Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 1732

Show
Ignore:
Timestamp:
07/06/10 01:32:14 (14 years ago)
Author:
walter
Message:

fix various unit test and test suite failures from std.format

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/phobos/std/format.d

    r1725 r1732  
    16991699            } // end switch 
    17001700        } // end for 
    17011701        enforce(false, text("Incorrect format specifier: ", fmt)); 
    17021702    } 
    17031703} 
    17041704 
    17051705//------------------------------------------------------------------------------ 
    17061706// Writes characters in the format strings up to the first format 
    17071707// specifier and updates the format specifier to remove the written 
    17081708// portion The updated format fmt does not include the '%' 
    1709 private void writeUpToFormatSpec(OutRange, S)(OutRange w, ref S fmt) 
     1709private void writeUpToFormatSpec(OutRange, S)(ref OutRange w, ref S fmt) 
    17101710{ 
    17111711    for (size_t i = 0; i < fmt.length; ++i) 
    17121712    { 
    17131713        if (fmt[i] != '%') continue; 
    17141714        if (fmt[++i] != '%') 
    17151715        { 
    17161716            // spec found, print and bailout 
    17171717            w.put(fmt[0 .. i - 1]); 
    17181718            fmt = fmt[i .. $]; 
    17191719            return; 
     
    17451745    writeUpToFormatSpec(w, fmt); 
    17461746    assert(w.data == "ab%cd%ef" && fmt == "sg%%h%sij"); 
    17471747    writeUpToFormatSpec(w, fmt); 
    17481748    assert(w.data == "ab%cd%efsg%h" && fmt == "sij"); 
    17491749} 
    17501750 
    17511751/* 
    17521752 * Formats an integral number 'arg' according to 'f' and writes it to 
    17531753 * 'w'. 
    17541754 */ 
    1755 private void formatImpl(Writer, D)(Writer w, D argx, FormatInfo f) 
     1755private void formatImpl(Writer, D)(ref Writer w, D argx, FormatInfo f) 
    17561756if (isIntegral!(D)) 
    17571757{ 
    17581758    Unqual!(D) arg = argx; 
    17591759    if (f.spec == 'r') 
    17601760    { 
    17611761        // raw write, skip all else and write the thing 
    17621762        auto begin = cast(const char*) &arg; 
    17631763        if (std.system.endian == Endian.LittleEndian && f.flPlus 
    17641764            || std.system.endian == Endian.BigEndian && f.flDash) 
    17651765        { 
     
    21672167The positional and non-positional styles can be mixed in the same 
    21682168format string. (POSIX leaves this behavior undefined.) The internal 
    21692169counter for non-positional parameters tracks the next parameter after 
    21702170the largest positional parameter already used. 
    21712171 
    21722172Warning: 
    21732173This is the function internally used by writef* but it's still 
    21742174undergoing active development. Do not rely on it. 
    21752175 */ 
    21762176 
    2177 void formattedWrite(Writer, F, A...)(Writer w, const(F)[] fmt, A args) 
     2177void formattedWrite(Writer, F, A...)(ref Writer w, const(F)[] fmt, A args) 
    21782178{ 
    21792179    enum len = args.length; 
    21802180    void function(ref Writer, const(void)*, FormatInfo) funs[len] = void; 
    21812181    const(void)* argsAddresses[len] = void; 
    21822182    foreach (i, arg; args) 
    21832183    { 
    21842184        funs[i] = &formatGeneric!(Writer, typeof(arg)); 
    21852185        argsAddresses[i] = &arg; 
    21862186    } 
    21872187    // Are we already done with formats? Then just dump each parameter in turn