Commit b55203ab authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

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).
parent daf60f25
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
......
......@@ -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;
}
......
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment