Add gst_strtoi().

Original commit message from CVS:
Add gst_strtoi().
This commit is contained in:
David Schleef 2004-01-11 23:25:02 +00:00
parent c0f04fe675
commit ea1135ec9f
2 changed files with 20 additions and 1 deletions

View file

@ -1,3 +1,8 @@
2004-01-11 David Schleef,,, <set EMAIL_ADDRESS environment variable>
* gst/gststructure.c: (gst_strtoi), (gst_value_from_string): Add
a function to parse integers in ways that strto[u]l() does not.
2004-01-11 Benjamin Otte <in7y118@public.uni-hamburg.de>
* tools/gst-inspect.c: (print_caps):

View file

@ -1109,6 +1109,20 @@ _gst_structure_parse_string (gchar *s, gchar **end, gchar **next)
return TRUE;
}
static int
gst_strtoi (const char *s, char **end, int base)
{
int i;
if (s[0] == '-') {
i = - (int) strtoul (s + 1, end, base);
} else {
i = strtoul (s, end, base);
}
return i;
}
static gboolean
gst_value_from_string (GValue *value, const char *s)
{
@ -1122,7 +1136,7 @@ gst_value_from_string (GValue *value, const char *s)
case G_TYPE_INT:
{
int x;
x = strtol (s, &end, 0);
x = gst_strtoi (s, &end, 0);
if (*end == 0) {
ret = TRUE;
} else {