#define inline __inline__
#define LC_FUNCNAME __FUNCTION__
#define LC_UNUSED(x) x __attribute__((__unused__))
+#define LC_PRINTF(m) __attribute__((format(printf,m,(m)+1)))
#ifdef __STRICT_ANSI__
#define LC_LONGLONG long
#define LC_FUNCNAME "<unknown>"
#define LC_UNUSED(x) x
+#define LC_PRINTF(m)
+
#define LC_LONGLONG __int64
#define LC_LONGDOUBLE long double
#endif /* _MSC_VER <= 1200 */
/* default definitions */
-#else /* defined(_MSC_VER) */
+#else /* !defined(__GNUC__) && !defined(_MSC_VER) */
#define inline
#define LC_FUNCNAME "<unknown>"
#define LC_UNUSED(x)
#define LC_LONGLONG long
#define LC_LONGDOUBLE double
+#define LC_PRINTF(m)
#endif
mod[3] = '\0';
}
}
+ } else if (occ->modifier_length == 2) {
+ if (mod[0] == 'h' && mod[1] == 'h') {
+ /* no support for char in mscrt, but we can safely ignore it
+ * because the size is handled by the argument reader code */
+ mod[0] = '\0';
+ }
}
#endif
snprintf(buf, len, "%%%s%s%s%s%s%s%s%s%c",
*/
static int std_get_lc_arg_type(const lc_arg_occ_t *occ)
{
- int modlen = occ->modifier_length;
+ size_t modlen = occ->modifier_length;
/* check, if the type can be derived from the modifier */
if (modlen > 0) {
const char *mod = occ->modifier;
switch (mod[0]) {
+ case 'h':
+ return modlen > 1 && mod[1] == 'h' ? lc_arg_type_char : lc_arg_type_short;
case 'l':
return modlen > 1 && mod[1] == 'l' ? lc_arg_type_long_long : lc_arg_type_long;
#define TYPE_CASE(letter,type) case letter: return lc_arg_type_ ## type;
case 'n':
{
int *num = (int*)val->v_ptr;
- *num = app->written;
+ *num = (int)app->written;
}
break;
int lc_arg_append(lc_appendable_t *app, const lc_arg_occ_t *occ, const char *str, size_t len);
-int lc_epprintf(const lc_arg_env_t *env, lc_appendable_t *app, const char *fmt, ...);
+int lc_epprintf(const lc_arg_env_t *env, lc_appendable_t *app, const char *fmt, ...) LC_PRINTF(3);
int lc_evpprintf(const lc_arg_env_t *env, lc_appendable_t *app, const char *fmt, va_list args);
-int lc_pprintf(lc_appendable_t *app, const char *fmt, ...);
+int lc_pprintf(lc_appendable_t *app, const char *fmt, ...) LC_PRINTF(2);
int lc_vpprintf(lc_appendable_t *app, const char *fmt, va_list args);
-int lc_eprintf(const lc_arg_env_t *env, const char *fmt, ...);
-int lc_esnprintf(const lc_arg_env_t *env, char *buf, size_t len, const char *fmt, ...);
-int lc_efprintf(const lc_arg_env_t *env, FILE *file, const char *fmt, ...);
-int lc_eoprintf(const lc_arg_env_t *env, struct obstack *obst, const char *fmt, ...);
+int lc_eprintf(const lc_arg_env_t *env, const char *fmt, ...) LC_PRINTF(2);
+int lc_esnprintf(const lc_arg_env_t *env, char *buf, size_t len, const char *fmt, ...) LC_PRINTF(4);
+int lc_efprintf(const lc_arg_env_t *env, FILE *file, const char *fmt, ...) LC_PRINTF(3);
+int lc_eoprintf(const lc_arg_env_t *env, struct obstack *obst, const char *fmt, ...) LC_PRINTF(3);
int lc_evprintf(const lc_arg_env_t *env, const char *fmt, va_list args);
int lc_evsnprintf(const lc_arg_env_t *env, char *buf, size_t len, const char *fmt, va_list args);
int lc_evfprintf(const lc_arg_env_t *env, FILE *f, const char *fmt, va_list args);
int lc_evoprintf(const lc_arg_env_t *env, struct obstack *obst, const char *fmt, va_list args);
-int lc_printf(const char *fmt, ...);
-int lc_snprintf(char *buf, size_t len, const char *fmt, ...);
-int lc_fprintf(FILE *f, const char *fmt, ...);
-int lc_oprintf(struct obstack *obst, const char *fmt, ...);
+int lc_printf(const char *fmt, ...) LC_PRINTF(1);
+int lc_snprintf(char *buf, size_t len, const char *fmt, ...) LC_PRINTF(3);
+int lc_fprintf(FILE *f, const char *fmt, ...) LC_PRINTF(2);
+int lc_oprintf(struct obstack *obst, const char *fmt, ...) LC_PRINTF(2);
int lc_vprintf(const char *fmt, va_list args);
int lc_vsnprintf(char *buf, size_t len, const char *fmt, va_list args);