summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cfe5791)
raw | patch | inline | side by side (parent: cfe5791)
author | Benjamin Otte <otte@gnome.org> | |
Wed, 19 May 2004 14:20:46 +0000 (14:20 +0000) | ||
committer | Benjamin Otte <otte@gnome.org> | |
Wed, 19 May 2004 14:20:46 +0000 (14:20 +0000) |
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.
* gst/gstvalue.c: (gst_value_deserialize_int_helper):
fix int variable deserialization and add a helper so we can actually
debug this.
ChangeLog | patch | blob | history | |
gst/gstvalue.c | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index f820d86c2f41e724c305a6312bd78875b430e1fb..003f61a5c4eaded4608e67c7f83f601e7df24ab9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+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
diff --git a/gst/gstvalue.c b/gst/gstvalue.c
index 52d38fa36f362494d30e774fe2cf4f4ccca39aa6..5af1ed9e4181776674501c670d1a212f4b22d54f 100644 (file)
--- a/gst/gstvalue.c
+++ b/gst/gstvalue.c
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) \
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; \
+ if (gst_value_deserialize_int_helper (&x, s, G_MIN ## _macro, G_MAX ## _macro)) { \
+ g_value_set_ ## _type (dest, x); \
+ return 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 { \
- g_value_set_ ## _type (dest, x); \
- } \
+ return FALSE; \
} \
- return ret; \
}
#define CREATE_USERIALIZATION(_type,_macro) \