From c47d3798a360b9b2a92aa76b9ea1ccc139a5dc24 Mon Sep 17 00:00:00 2001
From: Kalle Olavi Niemitalo <kon@iki.fi>
Date: Sun, 3 Feb 2008 14:19:22 +0200
Subject: [PATCH] config: Negate the value in redir_rd too.

So if ELinks is rewriting a configuration file that contains a "set"
command for a negated alias, then it properly writes the value of the
alias, rather than the value of the underlying option.
---
 src/config/opttypes.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/src/config/opttypes.c b/src/config/opttypes.c
index ff486027f..3c86a9665 100644
--- a/src/config/opttypes.c
+++ b/src/config/opttypes.c
@@ -90,19 +90,6 @@ exec_cmd(struct option *o, unsigned char ***argv, int *argc)
  * possibly changing ptr to structure containing target name and pointer to
  * options list? --pasky */
 
-#define wrap_or_(name_, call_, ret_) \
-{ \
-	struct option *real = get_opt_rec(config_options, opt->value.string); \
- \
-	assertm(real != NULL, "%s aliased to unknown option %s!", opt->name, opt->value.string); \
-	if_assert_failed { return ret_; } \
- \
-	if (option_types[real->type].name_) \
-		return option_types[real->type].call_; \
- \
-	return ret_; \
-}
-
 static unsigned char *
 redir_cmd(struct option *opt, unsigned char ***argv, int *argc)
 {
@@ -124,7 +111,22 @@ redir_cmd(struct option *opt, unsigned char ***argv, int *argc)
 
 static unsigned char *
 redir_rd(struct option *opt, unsigned char **file, int *line)
-	wrap_or_(read, read(real, file, line), NULL);
+{
+	struct option *real = get_opt_rec(config_options, opt->value.string);
+	unsigned char *ret = NULL;
+
+	assertm(real != NULL, "%s aliased to unknown option %s!", opt->name, opt->value.string);
+	if_assert_failed { return ret; }
+
+	if (option_types[real->type].read) {
+		ret = option_types[real->type].read(real, file, line);
+		if (ret && (opt->flags & OPT_ALIAS_NEGATE) && real->type == OPT_BOOL) {
+			*(long *) ret = !*(long *) ret;
+		}
+	}
+
+	return ret;
+}
 
 static void
 redir_wr(struct option *opt, struct string *string)