Introduce contitional string options
authorH.G.Muller <hgm@hgm-xboard.(none)>
Sun, 27 Nov 2016 17:03:51 +0000 (18:03 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Fri, 13 Jan 2017 15:39:24 +0000 (16:39 +0100)
A string option that specifies a value starting with "@@@@@" (five at signs)
will be treated in a special way: if the current value of this option is
not the empty string, it will not be changed. If it is, it will be set
to the given value after the @@@@@ prefix has been stripped off the latter.
 This is introduced to make it possible to set hitherto unused persistent
options from the master settings file, by includig them in the latter after
the user settigs file was read. Options in this location will overrule
whatever was in the saved settings, effectively making the option volatile
with a new default. But by using the @@@@@ prefix for the value, users
that already have assigned a value to the option will not be affected,
and only for users that were not yet using the option a new value will
be defined for it.

args.h

diff --git a/args.h b/args.h
index f23f1ab..c518fad 100644 (file)
--- a/args.h
+++ b/args.h
@@ -1182,6 +1182,10 @@ ParseArgs(GetFunc get, void *cl)
         ASSIGN(*(char **) ad->argLoc, buf);
         break;
       }
+      if(!strncmp(argValue, "@@@@@", 5)) { // conditional string argument
+        if(*(char**) ad->argLoc == 0) { ASSIGN(*(char **) ad->argLoc, argValue+5); } // only used to replace empty string
+       break;
+      }
       ASSIGN(*(char **) ad->argLoc, argValue);
       break;