Eina "Fix" printf conversion format on Windows. printf family on Windows is just plain weirdness

SVN revision: 67443
This commit is contained in:
Vincent Torri 2012-01-22 08:55:02 +00:00
parent 2b932abc9c
commit 37ccabf61c
3 changed files with 28 additions and 14 deletions

View File

@ -3023,7 +3023,7 @@ _eina_model_free(Eina_Model *model)
const Eina_Model_Description *desc = model->desc;
unsigned int i;
DBG("model %p (%s) refcount=%d deleted=%hhu",
DBG("model %p (%s) refcount=%d deleted=" FMT_UCHAR,
model, model->desc->cache.types[0]->name,
model->refcount, model->deleted);
@ -3081,7 +3081,7 @@ _eina_model_del(Eina_Model *model)
{
const Eina_Model_Description *desc = model->desc;
DBG("model %p (%s) refcount=%d deleted=%hhu",
DBG("model %p (%s) refcount=%d deleted=" FMT_UCHAR,
model, model->desc->cache.types[0]->name,
model->refcount, model->deleted);
@ -3098,7 +3098,7 @@ _eina_model_del(Eina_Model *model)
static void
_eina_model_unref(Eina_Model *model)
{
DBG("model %p (%s) refcount=%d deleted=%hhu",
DBG("model %p (%s) refcount=%d deleted=" FMT_UCHAR,
model, model->desc->cache.types[0]->name,
model->refcount, model->deleted);
@ -3291,7 +3291,7 @@ EAPI Eina_Model *
eina_model_ref(Eina_Model *model)
{
EINA_MODEL_INSTANCE_CHECK_VAL(model, NULL);
DBG("model %p (%s) refcount=%d deleted=%hhu",
DBG("model %p (%s) refcount=%d deleted=" FMT_UCHAR,
model, model->desc->cache.types[0]->name,
model->refcount, model->deleted);
model->refcount++;

View File

@ -42,6 +42,20 @@
max) (((x) > (max)) ? (max) : (((x) < (min)) ? (min) : (x)))
#endif
#ifdef _WIN32
# define FMT_CHAR "%c"
# define FMT_UCHAR "%c"
# define FMT_XCHAR "%c"
# define FMT_OCHAR "%c"
# define FMT_2XCHAR "%2c"
#else
# define FMT_CHAR "%hhd"
# define FMT_UCHAR "%hhu"
# define FMT_XCHAR "%hhx"
# define FMT_OCHAR "%hho"
# define FMT_2XCHAR "%02hhx"
#endif
#define EINA_INLIST_JUMP_SIZE 256
#define READBUFSIZ 65536

View File

@ -220,7 +220,7 @@ _eina_value_type_uchar_convert_to(const Eina_Value_Type *type __UNUSED__, const
{
const char *other_mem;
char buf[64];
snprintf(buf, sizeof(buf), "%hhu", v);
snprintf(buf, sizeof(buf), FMT_UCHAR , v);
other_mem = buf; /* required due &buf == buf */
return eina_value_type_pset(convert, convert_mem, &other_mem);
}
@ -1004,7 +1004,7 @@ _eina_value_type_char_convert_to(const Eina_Value_Type *type __UNUSED__, const E
{
const char *other_mem;
char buf[64];
snprintf(buf, sizeof(buf), "%hhd", v);
snprintf(buf, sizeof(buf), FMT_CHAR, v);
other_mem = buf; /* required due &buf == buf */
return eina_value_type_pset(convert, convert_mem, &other_mem);
}
@ -2122,9 +2122,9 @@ _eina_value_type_string_common_convert_to(const Eina_Value_Type *type __UNUSED__
if (convert == EINA_VALUE_TYPE_UCHAR)
{
unsigned char other_mem;
if ((sscanf(v, "%hhu", &other_mem) != 1) &&
(sscanf(v, "%hhx", &other_mem) != 1) &&
(sscanf(v, "%hho", &other_mem) != 1))
if ((sscanf(v, FMT_UCHAR, &other_mem) != 1) &&
(sscanf(v, FMT_XCHAR, &other_mem) != 1) &&
(sscanf(v, FMT_OCHAR, &other_mem) != 1))
return EINA_FALSE;
return eina_value_type_pset(convert, convert_mem, &other_mem);
}
@ -2167,9 +2167,9 @@ _eina_value_type_string_common_convert_to(const Eina_Value_Type *type __UNUSED__
else if (convert == EINA_VALUE_TYPE_CHAR)
{
char other_mem;
if ((sscanf(v, "%hhd", &other_mem) != 1) &&
(sscanf(v, "%hhx", &other_mem) != 1) &&
(sscanf(v, "%hho", &other_mem) != 1))
if ((sscanf(v, FMT_CHAR, &other_mem) != 1) &&
(sscanf(v, FMT_XCHAR, &other_mem) != 1) &&
(sscanf(v, FMT_OCHAR, &other_mem) != 1))
return EINA_FALSE;
return eina_value_type_pset(convert, convert_mem, &other_mem);
}
@ -3655,12 +3655,12 @@ _eina_value_type_blob_convert_to(const Eina_Value_Type *type __UNUSED__, const E
if (first)
{
first = EINA_FALSE;
if (!eina_strbuf_append_printf(str, "%02hhx", *ptr))
if (!eina_strbuf_append_printf(str, FMT_2XCHAR, *ptr))
goto error;
}
else
{
if (!eina_strbuf_append_printf(str, " %02hhx", *ptr))
if (!eina_strbuf_append_printf(str, " " FMT_2XCHAR, *ptr))
goto error;
}
}