From 4af4152da761b1cc91723fa60a6fdffd0c481a9f Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Tue, 26 Feb 2013 17:15:39 +0100 Subject: [PATCH] Add -backupSettingsFile option For better configurability of WinBoard, an option is added to optionally read a settings file, namely if no other settings file (other than the master file) was read so far. This can be used to import settings from a previous version, without destroying its settings file. --- args.h | 6 +++++- gtk/xboard.c | 1 + xaw/xboard.c | 1 + 3 files changed, 7 insertions(+), 1 deletions(-) diff --git a/args.h b/args.h index f6e755b..9533406 100644 --- a/args.h +++ b/args.h @@ -60,7 +60,7 @@ typedef enum { ArgString, ArgInt, ArgFloat, ArgBoolean, ArgTrue, ArgFalse, ArgNone, ArgColor, ArgAttribs, ArgFilename, ArgBoardSize, ArgFont, ArgCommSettings, - ArgSettingsFilename, ArgTwo, + ArgSettingsFilename, ArgBackupSettingsFile, ArgTwo, ArgX, ArgY, ArgZ // [HGM] placement: for window-placement options stored relative to main window } ArgType; @@ -490,6 +490,7 @@ ArgDescriptor argDescriptors[] = { { "at", ArgSettingsFilename, (void *) NULL, FALSE, INVALID }, { "opt", ArgSettingsFilename, (void *) NULL, FALSE, INVALID }, { "saveSettingsFile", ArgFilename, (void *) &settingsFileName, FALSE, INVALID }, + { "backupSettingsFile", ArgBackupSettingsFile, (void *) &settingsFileName, FALSE, INVALID }, { "saveSettingsOnExit", ArgBoolean, (void *) &saveSettingsOnExit, TRUE, (ArgIniType) TRUE }, { "chessProgram", ArgBoolean, (void *) &chessProgram, FALSE, (ArgIniType) FALSE }, { "cp", ArgTrue, (void *) &chessProgram, FALSE, INVALID }, @@ -1105,6 +1106,8 @@ ParseArgs(GetFunc get, void *cl) ASSIGN(*(char **) ad->argLoc, argValue); break; + case ArgBackupSettingsFile: // no-op if non-default settings-file already successfully read + if(strcmp(*(char**)ad->argLoc, SETTINGS_FILE)) break; case ArgSettingsFilename: { if (ParseSettingsFile(argValue, (char**)ad->argLoc)) { @@ -1537,6 +1540,7 @@ SaveSettings(char* name) PrintCommPortSettings(f, ad->argName); case ArgTwo: case ArgNone: + case ArgBackupSettingsFile: case ArgSettingsFilename: ; } } diff --git a/gtk/xboard.c b/gtk/xboard.c index a5b015c..c872973 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -644,6 +644,7 @@ PrintArg (ArgType t) case ArgString: p = " STR"; break; case ArgBoolean: p = " TF"; break; case ArgSettingsFilename: + case ArgBackupSettingsFile: case ArgFilename: p = " FILE"; break; case ArgX: p = " Nx"; break; case ArgY: p = " Ny"; break; diff --git a/xaw/xboard.c b/xaw/xboard.c index 7986db9..172fbac 100644 --- a/xaw/xboard.c +++ b/xaw/xboard.c @@ -934,6 +934,7 @@ PrintArg (ArgType t) case ArgString: p = " STR"; break; case ArgBoolean: p = " TF"; break; case ArgSettingsFilename: + case ArgBackupSettingsFile: case ArgFilename: p = " FILE"; break; case ArgX: p = " Nx"; break; case ArgY: p = " Ny"; break; -- 1.7.0.4