Commit 662bc348 authored by Michael Beck's avatar Michael Beck
Browse files

Enable lc_printf and friends handling of j, t, and z length modifier.

Add a work-around for non-C99 MSCRT.

Use ir_printf now instead of printf.

[r28212]
parent 3398ae4a
......@@ -172,6 +172,39 @@ static char *make_fmt(char *buf, size_t len, const lc_arg_occ_t *occ)
strncpy(mod, occ->modifier, sizeof(mod) - 1);
mod[LC_MIN(sizeof(mod) - 1, occ->modifier_length)] = '\0';
#ifdef _MSC_VER
/* work-around for buggy mscrt not supporting z, j, and t modifier */
if (occ->modifier_length == 1) {
if (mod[0] == 'z') {
if (sizeof(size_t) == sizeof(int))
mod[0] = '\0';
if (sizeof(size_t) == sizeof(__int64)) {
mod[0] = 'I';
mod[1] = '6';
mod[2] = '4';
mod[3] = '\0';
}
} else if (mod[0] == 't') {
if (sizeof(ptrdiff_t) == sizeof(int))
mod[0] = '\0';
if (sizeof(ptrdiff_t) == sizeof(__int64)) {
mod[0] = 'I';
mod[1] = '6';
mod[2] = '4';
mod[3] = '\0';
}
} else if (mod[0] == 'j') {
if (sizeof(intmax_t) == sizeof(int))
mod[0] = '\0';
if (sizeof(intmax_t) == sizeof(__int64)) {
mod[0] = 'I';
mod[1] = '6';
mod[2] = '4';
mod[3] = '\0';
}
}
}
#endif
snprintf(buf, len, "%%%s%s%s%s%s%s%s%s%c",
occ->flag_space ? "#" : "",
occ->flag_hash ? "#" : "",
......@@ -198,11 +231,9 @@ static int std_get_lc_arg_type(const lc_arg_occ_t *occ)
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;
#if 0
TYPE_CASE('j', intmax_t);
TYPE_CASE('z', size_t);
TYPE_CASE('t', ptrdiff_t);
#endif
TYPE_CASE('L', long_double);
#undef TYPE_CASE
}
......
......@@ -25,12 +25,13 @@
* @date 3.1.2005
*/
#ifndef _LIBCORE_XPRINTF_H
#define _LIBCORE_XPRINTF_H
#ifndef _LIBCORE_LC_PRINTF_H
#define _LIBCORE_LC_PRINTF_H
#include <stddef.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
#include <obstack.h>
......
......@@ -4,3 +4,6 @@ LC_ARG_TYPE(LC_LONGLONG, long_long)
LC_ARG_TYPE(double, double)
LC_ARG_TYPE(LC_LONGDOUBLE, long_double)
LC_ARG_TYPE(void *, ptr)
LC_ARG_TYPE(intmax_t, intmax_t)
LC_ARG_TYPE(ptrdiff_t, ptrdiff_t)
LC_ARG_TYPE(size_t, size_t)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment