netsurf: branch master updated. release/3.0-152-ga4f6701

NetSurf Browser Project (Commit Mailer) no-reply at netsurf-browser.org
Wed May 29 08:00:08 BST 2013


Gitweb links:

...log http://git.netsurf-browser.org/netsurf.git/shortlog/a4f67018faf7755d077778b750524f3a7555f5c7
...commit http://git.netsurf-browser.org/netsurf.git/commit/a4f67018faf7755d077778b750524f3a7555f5c7
...tree http://git.netsurf-browser.org/netsurf.git/tree/a4f67018faf7755d077778b750524f3a7555f5c7

The branch, master has been updated
       via  a4f67018faf7755d077778b750524f3a7555f5c7 (commit)
      from  44f91c9fc8befb67211949008121cb0eae6de562 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=a4f67018faf7755d077778b750524f3a7555f5c7
commit a4f67018faf7755d077778b750524f3a7555f5c7
Author: Vincent Sanders <vince at netsurf-browser.org>
Commit: Vincent Sanders <vince at netsurf-browser.org>

    fix import of old broken Choices

diff --git a/utils/nsoption.c b/utils/nsoption.c
index 41a4d57..a9264de 100644
--- a/utils/nsoption.c
+++ b/utils/nsoption.c
@@ -133,8 +133,11 @@ strtooption(const char *value, struct nsoption_s *option)
 }
 
 /* validate options to sane values */
-static void nsoption_validate(struct nsoption_s *opts)
+static void nsoption_validate(struct nsoption_s *opts, struct nsoption_s *defs)
 {
+	int cloop;
+	bool black = true;
+
 	if (opts[NSOPTION_font_size].value.i  < 50) {
 		opts[NSOPTION_font_size].value.i = 50;
 	}
@@ -154,6 +157,27 @@ static void nsoption_validate(struct nsoption_s *opts)
 	if (opts[NSOPTION_memory_cache_size].value.i < 0) {
 		opts[NSOPTION_memory_cache_size].value.i = 0;
 	}
+
+	/* to aid migration from old, broken, configuration files this
+	 * checks to see if all the system colours are set to black
+	 * and returns them to defaults instead 
+	 */
+
+	for (cloop = NSOPTION_SYS_COLOUR_START; 
+	     cloop <= NSOPTION_SYS_COLOUR_END; 
+	     cloop++) {
+		if (opts[cloop].value.c != 0) {
+			black = false;
+			break;
+		}
+	}
+	if (black == true) {
+		for (cloop = NSOPTION_SYS_COLOUR_START; 
+		     cloop <= NSOPTION_SYS_COLOUR_END; 
+		     cloop++) {
+			opts[cloop].value.c = defs[cloop].value.c;
+		}
+	}
 }
 
 static bool 
@@ -468,6 +492,7 @@ nsoption_read(const char *path, struct nsoption_s *opts)
 {
 	char s[100];
 	FILE *fp;
+	struct nsoption_s *defs;
 
 	if (path == NULL) {
 		return NSERROR_BAD_PARAMETER;
@@ -478,6 +503,9 @@ nsoption_read(const char *path, struct nsoption_s *opts)
 		opts = nsoptions;
 	}
 
+	/* @todo is this and API bug not being a parameter */
+	defs = nsoptions_default;	
+
 	fp = fopen(path, "r");
 	if (!fp) {
 		LOG(("Failed to open file '%s'", path));
@@ -515,7 +543,7 @@ nsoption_read(const char *path, struct nsoption_s *opts)
 
 	fclose(fp);
 
-	nsoption_validate(opts);
+	nsoption_validate(opts, defs);
 
 	return NSERROR_OK;
 }


-----------------------------------------------------------------------

Summary of changes:
 utils/nsoption.c |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/utils/nsoption.c b/utils/nsoption.c
index 41a4d57..a9264de 100644
--- a/utils/nsoption.c
+++ b/utils/nsoption.c
@@ -133,8 +133,11 @@ strtooption(const char *value, struct nsoption_s *option)
 }
 
 /* validate options to sane values */
-static void nsoption_validate(struct nsoption_s *opts)
+static void nsoption_validate(struct nsoption_s *opts, struct nsoption_s *defs)
 {
+	int cloop;
+	bool black = true;
+
 	if (opts[NSOPTION_font_size].value.i  < 50) {
 		opts[NSOPTION_font_size].value.i = 50;
 	}
@@ -154,6 +157,27 @@ static void nsoption_validate(struct nsoption_s *opts)
 	if (opts[NSOPTION_memory_cache_size].value.i < 0) {
 		opts[NSOPTION_memory_cache_size].value.i = 0;
 	}
+
+	/* to aid migration from old, broken, configuration files this
+	 * checks to see if all the system colours are set to black
+	 * and returns them to defaults instead 
+	 */
+
+	for (cloop = NSOPTION_SYS_COLOUR_START; 
+	     cloop <= NSOPTION_SYS_COLOUR_END; 
+	     cloop++) {
+		if (opts[cloop].value.c != 0) {
+			black = false;
+			break;
+		}
+	}
+	if (black == true) {
+		for (cloop = NSOPTION_SYS_COLOUR_START; 
+		     cloop <= NSOPTION_SYS_COLOUR_END; 
+		     cloop++) {
+			opts[cloop].value.c = defs[cloop].value.c;
+		}
+	}
 }
 
 static bool 
@@ -468,6 +492,7 @@ nsoption_read(const char *path, struct nsoption_s *opts)
 {
 	char s[100];
 	FILE *fp;
+	struct nsoption_s *defs;
 
 	if (path == NULL) {
 		return NSERROR_BAD_PARAMETER;
@@ -478,6 +503,9 @@ nsoption_read(const char *path, struct nsoption_s *opts)
 		opts = nsoptions;
 	}
 
+	/* @todo is this and API bug not being a parameter */
+	defs = nsoptions_default;	
+
 	fp = fopen(path, "r");
 	if (!fp) {
 		LOG(("Failed to open file '%s'", path));
@@ -515,7 +543,7 @@ nsoption_read(const char *path, struct nsoption_s *opts)
 
 	fclose(fp);
 
-	nsoption_validate(opts);
+	nsoption_validate(opts, defs);
 
 	return NSERROR_OK;
 }


-- 
NetSurf Browser



More information about the netsurf-commits mailing list