[sodipodi] Fix parsing error for numbers with leading space



commit 8226ba679fae270404a2d5f94efb84da0a9a713e
Author: Hans Breuer <hans breuer org>
Date:   Sat Apr 18 13:18:47 2009 +0200

    Fix parsing error for numbers with leading space
    
    * src/style.c(trim_space) : ensure right being bigger than left
    (sp_style_merge_from_style_string) : use it to get the right length
    for values with leading spaces; before they contained the trailing
    ';' and thus were not interpreted correctly
---
 src/style.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/style.c b/src/style.c
index 4d2a580..b40d3e4 100644
--- a/src/style.c
+++ b/src/style.c
@@ -639,7 +639,7 @@ trim_space (const unsigned char *str, unsigned int length,
 			unsigned int *left, unsigned int *right)
 {
 	const unsigned char *p;
-	unsigned int i;
+	unsigned int i = 0, j;
 	
 	if (left) {
 		for (i = 0, p = str;
@@ -649,11 +649,11 @@ trim_space (const unsigned char *str, unsigned int length,
 		*left = i;
 	}
 	if (right) {
-		for (i = length - 1, p = str + i;
-			 p && isspace (*p) && i >= 0;
-			 i--, p--)
+		for (j = length - 1, p = str + j;
+			 p && isspace (*p) && j >= i;
+			 j--, p--)
 			;
-		*right = i + 1;
+		*right = j + 1;
 	}
 }
 
@@ -696,8 +696,8 @@ sp_style_merge_from_style_string (SPStyle *style, const guchar *p)
 			len = MIN (e - s - 1, 4095);
 			if (len > 0) {
 				trim_space (s + 1, len, &left, &right);
-				memcpy (c, s + 1 + left, right);
-				c[right] = '\0';
+				memcpy (c, s + 1 + left, right - left);
+				c[right - left] = '\0';
 				sp_style_merge_property (style, idx, c);
 			} else {
 				g_warning ("Strange style property value at: %s", p);



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