4 * Non-template definitions of formatting-related internal
8 #include <source/utility.hxx>
14 const char* const file
,
16 const char* const msg
,
19 size_t chars
= snprintf(buf
, len
, "%s:%d: ", file
, line
);
21 // If buffer was too small, chars contains length
22 // of chars that would've been written. Chars must
23 // be lower than length or else we could not fit
24 // the message into buffer, too.
25 bool didFitIntoBuffer
= chars
< len
;
27 if (didFitIntoBuffer
) {
28 size_t newLength
= len
- chars
;
29 char* const newBuffer
= buf
+ chars
;
30 chars
= vsnprintf(newBuffer
, newLength
, msg
, ap
);
31 didFitIntoBuffer
= chars
<= newLength
;
34 return didFitIntoBuffer
;
40 const char* const file
,
42 const char* const msg
,
48 bool result
= vformat(buf
, len
, file
, line
, msg
, ap
);