libgimpconfig: allow calling gimp_scanner_new_string (NULL, -1, ...)

Allow calling gimp_scanner_new_string() with a NULL `text` and a
negative `text_len` (which is interpreted as 0), instead of
requiring `text_len == 0` in this case.  This allows passing a
negative `text_len` unconditionally to infer the length, even when
the string may be NULL.
This commit is contained in:
Ell 2020-01-29 21:08:35 +02:00
parent cd2adfbede
commit dcea2348c6
1 changed files with 2 additions and 2 deletions

View File

@ -243,11 +243,11 @@ gimp_scanner_new_string (const gchar *text,
{
GimpScanner *scanner;
g_return_val_if_fail (text != NULL || text_len == 0, NULL);
g_return_val_if_fail (text != NULL || text_len <= 0, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
if (text_len < 0)
text_len = strlen (text);
text_len = text ? strlen (text) : 0;
scanner = gimp_scanner_new (NULL, NULL, NULL, error);