[gimp] libgimpconfig: gimp_scanner_parse_color(): parse nevative color values



commit 865d8796e094b443ac6bf0b95fdd86acb67112e8
Author: Michael Natterer <mitch gimp org>
Date:   Tue Oct 18 22:34:51 2016 +0200

    libgimpconfig: gimp_scanner_parse_color(): parse nevative color values
    
    instead of choking and aborting parsing of the entire config file. The
    negative values are still clamped away after parsing, but at least we
    properly read them now.

 libgimpconfig/gimpscanner.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/libgimpconfig/gimpscanner.c b/libgimpconfig/gimpscanner.c
index e6f62b7..16a8c01 100644
--- a/libgimpconfig/gimpscanner.c
+++ b/libgimpconfig/gimpscanner.c
@@ -693,8 +693,19 @@ gimp_scanner_parse_color (GScanner *scanner,
 
             for (i = 0; i < n_channels; i++)
               {
+                gboolean negate = FALSE;
+
+                if (g_scanner_peek_next_token (scanner) == '-')
+                  {
+                    negate = TRUE;
+                    g_scanner_get_next_token (scanner);
+                  }
+
                 if (! gimp_scanner_parse_float (scanner, &col[i]))
                   goto finish;
+
+                if (negate)
+                  col[i] = - col[i];
               }
 
             if (is_hsv)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]