handle negative integers.

2003-02-03  Michael Natterer  <mitch@gimp.org>

	* app/config/gimpscanner.c (gimp_scanner_parse_int): handle
	negative integers.

	(gimp_scanner_parse_string[no_validate]): return NULL for empty
	strings (don't simply leave the return location untouched).
This commit is contained in:
Michael Natterer 2003-02-03 14:48:39 +00:00 committed by Michael Natterer
parent daf60f2582
commit b55203abb5
3 changed files with 44 additions and 2 deletions

View File

@ -1,3 +1,11 @@
2003-02-03 Michael Natterer <mitch@gimp.org>
* app/config/gimpscanner.c (gimp_scanner_parse_int): handle
negative integers.
(gimp_scanner_parse_string[no_validate]): return NULL for empty
strings (don't simply leave the return location untouched).
2003-02-03 Sven Neumann <sven@gimp.org>
* app/config/gimpconfig-deserialize.c

View File

@ -149,6 +149,10 @@ gimp_scanner_parse_string (GScanner *scanner,
*dest = g_strdup (scanner->value.v_string);
}
else
{
*dest = NULL;
}
return TRUE;
}
@ -164,6 +168,8 @@ gimp_scanner_parse_string_no_validate (GScanner *scanner,
if (*scanner->value.v_string)
*dest = g_strdup (scanner->value.v_string);
else
*dest = NULL;
return TRUE;
}
@ -172,12 +178,23 @@ gboolean
gimp_scanner_parse_int (GScanner *scanner,
gint *dest)
{
gboolean negate = FALSE;
if (g_scanner_peek_next_token (scanner) == '-')
{
negate = TRUE;
g_scanner_get_next_token (scanner);
}
if (g_scanner_peek_next_token (scanner) != G_TOKEN_INT)
return FALSE;
g_scanner_get_next_token (scanner);
*dest = scanner->value.v_int;
if (negate)
*dest = -scanner->value.v_int;
else
*dest = scanner->value.v_int;
return TRUE;
}

View File

@ -149,6 +149,10 @@ gimp_scanner_parse_string (GScanner *scanner,
*dest = g_strdup (scanner->value.v_string);
}
else
{
*dest = NULL;
}
return TRUE;
}
@ -164,6 +168,8 @@ gimp_scanner_parse_string_no_validate (GScanner *scanner,
if (*scanner->value.v_string)
*dest = g_strdup (scanner->value.v_string);
else
*dest = NULL;
return TRUE;
}
@ -172,12 +178,23 @@ gboolean
gimp_scanner_parse_int (GScanner *scanner,
gint *dest)
{
gboolean negate = FALSE;
if (g_scanner_peek_next_token (scanner) == '-')
{
negate = TRUE;
g_scanner_get_next_token (scanner);
}
if (g_scanner_peek_next_token (scanner) != G_TOKEN_INT)
return FALSE;
g_scanner_get_next_token (scanner);
*dest = scanner->value.v_int;
if (negate)
*dest = -scanner->value.v_int;
else
*dest = scanner->value.v_int;
return TRUE;
}