Esempio n. 1
0
int safe_sprintf(std::string& buf, const char * fmt, ...)
{
    va_list argptr;
    va_start(argptr, fmt);

    int ret = safe_vsprintf(buf, fmt, argptr);

    va_end(argptr);

    return ret;
}
Esempio n. 2
0
static int append_sprintf(charT* bufStart, const charT* bufEnd,
                          const charT* fmt, ...) {
    va_list args;
    va_start(args, fmt); // initialize variable arguments list
    // compute space left in buffer: -1 for null terminator
    int maxlen = bufEnd - bufStart - 1;
    if (maxlen <= 0) return 0;
    int n = safe_vsprintf(bufStart, maxlen, fmt, args);
    va_end(args);
    if (n > maxlen) {
        n = maxlen;
    }
    bufStart[n] = 0;
    return n;
}
Esempio n. 3
0
void TParseContextBase::outputMessage(const TSourceLoc& loc, const char* szReason,
                                      const char* szToken,
                                      const char* szExtraInfoFormat,
                                      TPrefixType prefix, va_list args)
{
    const int maxSize = MaxTokenLength + 200;
    char szExtraInfo[maxSize];

    safe_vsprintf(szExtraInfo, maxSize, szExtraInfoFormat, args);

    infoSink.info.prefix(prefix);
    infoSink.info.location(loc);
    infoSink.info << "'" << szToken <<  "' : " << szReason << " " << szExtraInfo << "\n";

    if (prefix == EPrefixError) {
        ++numErrors;
    }
}