mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-03 05:59:10 +00:00
gst/gstvalue.c: fix int variable deserialization and add a helper so we can actually debug this.
Original commit message from CVS: * gst/gstvalue.c: (gst_value_deserialize_int_helper): fix int variable deserialization and add a helper so we can actually debug this.
This commit is contained in:
parent
cfe5791765
commit
182b3195cd
2 changed files with 47 additions and 31 deletions
|
@ -1,3 +1,9 @@
|
|||
2004-05-19 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||
|
||||
* gst/gstvalue.c: (gst_value_deserialize_int_helper):
|
||||
fix int variable deserialization and add a helper so we can actually
|
||||
debug this.
|
||||
|
||||
2004-05-18 David Schleef <ds@schleef.org>
|
||||
|
||||
* testsuite/debug/commandline.c: (main): Call ./commandline, not
|
||||
|
|
|
@ -944,7 +944,43 @@ gst_value_serialize_ ## _type (const GValue * value) \
|
|||
g_assert_not_reached (); \
|
||||
/* NO_COPY_MADNESS!!! */ \
|
||||
return (char *) g_value_get_string (&val); \
|
||||
} \
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_value_deserialize_int_helper (long long *to, const char *s, long long min,
|
||||
long long max)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
char *end;
|
||||
|
||||
*to = gst_strtoll (s, &end, 0);
|
||||
if (*end == 0) {
|
||||
ret = TRUE;
|
||||
} else {
|
||||
if (g_ascii_strcasecmp (s, "little_endian") == 0) {
|
||||
*to = G_LITTLE_ENDIAN;
|
||||
ret = TRUE;
|
||||
} else if (g_ascii_strcasecmp (s, "big_endian") == 0) {
|
||||
*to = G_BIG_ENDIAN;
|
||||
ret = TRUE;
|
||||
} else if (g_ascii_strcasecmp (s, "byte_order") == 0) {
|
||||
*to = G_BYTE_ORDER;
|
||||
ret = TRUE;
|
||||
} else if (g_ascii_strcasecmp (s, "min") == 0) {
|
||||
*to = min;
|
||||
ret = TRUE;
|
||||
} else if (g_ascii_strcasecmp (s, "max") == 0) {
|
||||
*to = max;
|
||||
ret = TRUE;
|
||||
}
|
||||
}
|
||||
if (ret) {
|
||||
if (*to < min || *to > max) {
|
||||
ret = FALSE;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define CREATE_SERIALIZATION(_type,_macro) \
|
||||
CREATE_SERIALIZATION_START(_type,_macro) \
|
||||
|
@ -953,39 +989,13 @@ static gboolean \
|
|||
gst_value_deserialize_ ## _type (GValue * dest, const char *s) \
|
||||
{ \
|
||||
long long x; \
|
||||
char *end; \
|
||||
gboolean ret = FALSE; \
|
||||
\
|
||||
x = gst_strtoll (s, &end, 0); \
|
||||
if (*end == 0) { \
|
||||
ret = TRUE; \
|
||||
} else { \
|
||||
if (g_ascii_strcasecmp (s, "little_endian") == 0) { \
|
||||
x = G_LITTLE_ENDIAN; \
|
||||
ret = TRUE; \
|
||||
} else if (g_ascii_strcasecmp (s, "big_endian") == 0) { \
|
||||
x = G_BIG_ENDIAN; \
|
||||
ret = TRUE; \
|
||||
} else if (g_ascii_strcasecmp (s, "byte_order") == 0) { \
|
||||
x = G_BYTE_ORDER; \
|
||||
ret = TRUE; \
|
||||
} else if (g_ascii_strcasecmp (s, "min") == 0) { \
|
||||
x = G_MIN ## _macro; \
|
||||
ret = TRUE; \
|
||||
} else if (g_ascii_strcasecmp (s, "max") == 0) { \
|
||||
x = G_MAX ## _macro; \
|
||||
ret = TRUE; \
|
||||
} \
|
||||
} \
|
||||
if (ret) { \
|
||||
if (x > G_MAX ## _macro || \
|
||||
x < G_MIN ## _macro) {\
|
||||
ret = FALSE; \
|
||||
} else { \
|
||||
if (gst_value_deserialize_int_helper (&x, s, G_MIN ## _macro, G_MAX ## _macro)) { \
|
||||
g_value_set_ ## _type (dest, x); \
|
||||
return TRUE; \
|
||||
} else { \
|
||||
return FALSE; \
|
||||
} \
|
||||
} \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
#define CREATE_USERIALIZATION(_type,_macro) \
|
||||
|
|
Loading…
Reference in a new issue