From bebe9603e5df7b96ae3abd6949b7e2bab015333c Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Sun, 27 Nov 2016 18:03:51 +0100 Subject: [PATCH] Introduce contitional string options 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 | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/args.h b/args.h index f23f1ab..c518fad 100644 --- 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; -- 1.7.0.4