Printf attribute added

This commit is contained in:
Jack Andersen 2015-09-23 15:00:30 -10:00
parent 5309dcd56b
commit aa1a36e991
3 changed files with 23 additions and 5 deletions

View File

@ -126,6 +126,9 @@ public:
m_parent->m_lock = false;
}
}
#if __GNUC__
__attribute__((__format__ (__printf__, 2, 3)))
#endif
void format(const char* fmt, ...)
{
if (!m_parent || !m_parent->m_lock)

View File

@ -218,7 +218,7 @@ public:
if (submessageLen)
{
if (messageLen > half-submessageLen-1)
HECL::Printf(_S("%.*s... "), half-submessageLen-4, message);
HECL::Printf(_S("%.*s... "), half-int(submessageLen)-4, message);
else
{
HECL::Printf(_S("%s"), message);
@ -246,9 +246,9 @@ public:
size_t rem = blocks - filled;
HECL::Printf(_S("" BOLD "%3d%% ["), iFactor);
for (int b=0 ; b<filled ; ++b)
HECL::Printf(_S("#"), message);
HECL::Printf(_S("#"));
for (int b=0 ; b<rem ; ++b)
HECL::Printf(_S("-"), message);
HECL::Printf(_S("-"));
HECL::Printf(_S("]" NORMAL ""));
}
else
@ -258,9 +258,9 @@ public:
size_t rem = blocks - filled;
HECL::Printf(_S("%3d%% ["), iFactor);
for (int b=0 ; b<filled ; ++b)
HECL::Printf(_S("#"), message);
HECL::Printf(_S("#"));
for (int b=0 ; b<rem ; ++b)
HECL::Printf(_S("-"), message);
HECL::Printf(_S("-"));
HECL::Printf(_S("]"));
}

View File

@ -231,6 +231,9 @@ static inline int Stat(const SystemChar* path, Sstat* statOut)
#endif
}
#if __GNUC__
__attribute__((__format__ (__printf__, 1, 2)))
#endif
static inline void Printf(const SystemChar* format, ...)
{
va_list va;
@ -243,6 +246,9 @@ static inline void Printf(const SystemChar* format, ...)
va_end(va);
}
#if __GNUC__
__attribute__((__format__ (__printf__, 2, 3)))
#endif
static inline void FPrintf(FILE* fp, const SystemChar* format, ...)
{
va_list va;
@ -255,6 +261,9 @@ static inline void FPrintf(FILE* fp, const SystemChar* format, ...)
va_end(va);
}
#if __GNUC__
__attribute__((__format__ (__printf__, 3, 4)))
#endif
static inline void SNPrintf(SystemChar* str, size_t maxlen, const SystemChar* format, ...)
{
va_list va;
@ -269,6 +278,9 @@ static inline void SNPrintf(SystemChar* str, size_t maxlen, const SystemChar* fo
#define FORMAT_BUF_SZ 1024
#if __GNUC__
__attribute__((__format__ (__printf__, 1, 2)))
#endif
static inline SystemString SysFormat(const SystemChar* format, ...)
{
SystemChar resultBuf[FORMAT_BUF_SZ];
@ -283,6 +295,9 @@ static inline SystemString SysFormat(const SystemChar* format, ...)
return SystemString(resultBuf, printSz);
}
#if __GNUC__
__attribute__((__format__ (__printf__, 1, 2)))
#endif
static inline std::string Format(const char* format, ...)
{
char resultBuf[FORMAT_BUF_SZ];