Changeset 2101 for trunk


Ignore:
Timestamp:
Nov 21, 2012, 2:11:20 AM (7 years ago)
Author:
sam
Message:

core: do not use va_copy since Visual Studio doesn’t know about it.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/string.cpp

    r2100 r2101  
    3030{
    3131    String ret;
    32 
    33     va_list ap, aq;
    34     va_start(ap, format);
    35     va_copy(aq, ap);
     32    va_list ap;
    3633
    3734    /* vsnprintf() tells us how many character we need, and we need to
    3835     * add one for the terminating null byte. */
    39     size_t needed = vsnprintf(NULL, 0, format, aq) + 1;
     36    va_start(ap, format);
     37    size_t needed = vsnprintf(NULL, 0, format, ap) + 1;
     38    va_end(ap);
     39
    4040    ((Super &)ret).Reserve(needed);
    4141    ret.m_count = needed;
    42     vsnprintf(&ret[0], needed, format, ap);
    4342
    44     va_end(aq);
     43    /* We don’t use va_copy because Visual Studio 2010 does not support it. */
     44    va_start(ap, format);
     45    std::vsnprintf(&ret[0], needed, format, ap);
    4546    va_end(ap);
    4647
  • trunk/test/unit/string.cpp

    r2100 r2101  
    128128
    129129        LOLUNIT_ASSERT(s1 == s2);
     130
     131        String s3 = "abc 3";
     132        String s4 = String::Printf("abc %d", 3);
     133
     134        LOLUNIT_ASSERT(s3 == s4);
    130135    }
    131136};
Note: See TracChangeset for help on using the changeset viewer.