int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args)
{
char c, pad = ' ';
- int minSize = 0, len;
+ int minSize = 0, precision = -1, len;
char tmpBuf[34]; // For Integers
const char *p = NULL;
int isLongLong = 0;
}
// - Padding Side Flag
- if(c == '+') {
+ if(c == '-') {
bPadLeft = 1;
c = *__format++;
}
else
minSize = 1;
+ // - Precision
+ precision = -1;
+ if( c == '.' ) {
+ c = *__format++;
+
+ if(c == '*') { // Dynamic length
+ precision = va_arg(args, unsigned int);
+ c = *__format++;
+ }
+ else if('1' <= c && c <= '9')
+ {
+ precision = 0;
+ while('0' <= c && c <= '9')
+ {
+ precision *= 10;
+ precision += c - '0';
+ c = *__format++;
+ }
+ }
+ }
+
// - Default, Long or LongLong?
isLongLong = 0;
if(c == 'l') // Long is actually the default on x86
// String - Null Terminated Array
case 's':
p = va_arg(args, char*); // Get Argument
- if( !CheckString(p) ) continue; // Avoid #PFs
+ if( !CheckString(p) ) p = "(inval)"; // Avoid #PFs
printString:
if(!p) p = "(null)";
len = strlen(p);
if( !bPadLeft ) while(len++ < minSize) PUTCH(pad);
- while(*p) PUTCH(*p++);
+ while(*p && precision--) PUTCH(*p++);
if( bPadLeft ) while(len++ < minSize) PUTCH(pad);
break;
char newData[ LOG_HDR_LEN + len + 2 + 1 ];
char _ident[9];
strncpy(_ident, Ident, 9);
- sprintf( newData, "%014lli%s [%+8s] ",
+ sprintf( newData, "%014lli%s [%-8s] ",
ent->Time, csaLevelCodes[Level], Ident);
strcpy( newData + LOG_HDR_LEN, ent->Data );
strcpy( newData + LOG_HDR_LEN + len, "\r\n" );
void Log_Int_PrintMessage(tLogEntry *Entry)
{
SHORTLOCK( &glLogOutput );
- LogF("%s%014lli%s [%+8s] %s",
+ LogF("%s%014lli%s [%-8s] %s",
csaLevelColours[Entry->Level],
Entry->Time,
csaLevelCodes[Entry->Level],