[Geany] utils_strtod, invalid_test + patch

Pierre pierre.php at xxxxx
Sun May 21 23:19:08 UTC 2006


Hello,

A little fix fpr utils_strtod. It should use integer if it needs to
test values lower than 0 (<= 0 incl.). A better fix would be to use
the start address :)

Patch again svn head attached (with some other sanity checks).

Cheers,
--Pierre
-------------- next part --------------
Index: utils.c
===================================================================
--- utils.c	(revision 352)
+++ utils.c	(working copy)
@@ -2173,17 +2173,24 @@
  * hex colour values before ANSI-C99, utils_strtod does only work for numbers like 0x... */
 double utils_strtod(const char *source, char **end)
 {
-	unsigned int i;
+	int i;
 	unsigned short tmp;
 	double exp, result;
+	const char * str = source;
 
+	if (!source) {
+		return (double) -1.0f;
+	}
+
 	// input should be 0x... or 0X...
 	if (strlen(source) < 3 || source[0] != '0' || (source[1] != 'x' && source[1] != 'X'))
 		return -1.0;
+
 	source += 2;
 
 	exp = 0.0;
 	result = 0;
+		
 	for (i = (strlen(source) - 1); i >= 0; i--)
 	{
 		if (isdigit(source[i]))
Index: highlighting.c
===================================================================
--- highlighting.c	(revision 352)
+++ highlighting.c	(working copy)
@@ -104,11 +104,10 @@
 
 	list = g_key_file_get_string_list(configh, section, key, &len, NULL);
 	if (list == NULL) list = g_key_file_get_string_list(config, section, key, &len, NULL);
-
 	if (list != NULL && list[0] != NULL) array[0] = (gint) utils_strtod(list[0], NULL);
-	else array[0] = (gint) utils_strtod(foreground, NULL);
-	if (list != NULL && list[1] != NULL) array[1] = (gint) utils_strtod(list[1], NULL);
-	else array[1] = (gint) utils_strtod(background, NULL);
+	else if (foreground) array[0] = (gint) utils_strtod(foreground, NULL);
+	if (list && list != NULL && list[1] != NULL) array[1] = (gint) utils_strtod(list[1], NULL);
+	else if (background) array[1] = (gint) utils_strtod(background, NULL);
 	if (list != NULL && list[2] != NULL) array[2] = utils_atob(list[2]);
 	else array[2] = utils_atob(bold);
 	if (list != NULL && list[3] != NULL) array[3] = utils_atob(list[3]);



More information about the Users mailing list