From 64c5cbd033e4cc0d4997ce55a49514e4f15ec16a Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Mon, 23 Nov 2009 20:17:25 -0800 Subject: [PATCH] use linux style options for config file and add a system config file for XBoard This patch makes XBoard write the options to its conf file in Linux style, "-option value" rather than Windows style "/option=value". The WinBoard option parsing code has always understood both formats (including any hybrids), but the format it preferred for writing might look quite strange to Linux users. I also attached a file to be installed as /etc/xboard/xboard.conf on "make install". --- Makefile.am | 3 ++ args.h | 22 ++++++++-------- winboard/winboard.c | 3 ++ xboard.c | 10 ++++--- xboard.conf | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+), 15 deletions(-) create mode 100644 xboard.conf diff --git a/Makefile.am b/Makefile.am index e06b568..d973700 100644 --- a/Makefile.am +++ b/Makefile.am @@ -40,5 +40,8 @@ info_TEXINFOS = xboard.texi xboard_TEXINFOS = copyright.texi man6_MANS = xboard.man +install-data-local: $(srcdir)/xboard.conf + $(INSTALL_DATA) $(srcdir)/xboard.conf $(DESTDIR)/etc/xboard + xboard.man: xboard.texi copyright.texi gpl.texinfo version.texi $(srcdir)/texi2man $(srcdir)/xboard.texi > xboard.man || (rm -f xboard.man ; false) diff --git a/args.h b/args.h index f1e0320..a916780 100644 --- a/args.h +++ b/args.h @@ -1264,10 +1264,10 @@ SaveSettings(char* name) if ((strchr(p, '\\') || strchr(p, '\n')) && !strchr(p, '}')) { /* Quote multiline values or \-containing values with { } if possible */ - fprintf(f, "/%s={%s}\n", ad->argName, p); + fprintf(f, OPTCHAR "%s" SEPCHAR "{%s}\n", ad->argName, p); } else { /* Else quote with " " */ - fprintf(f, "/%s=\"", ad->argName); + fprintf(f, OPTCHAR "%s" SEPCHAR "\"", ad->argName); while (*p) { if (*p == '\n') fprintf(f, "\n"); else if (*p == '\r') fprintf(f, "\\r"); @@ -1286,26 +1286,26 @@ SaveSettings(char* name) break; case ArgInt: case ArgZ: - fprintf(f, "/%s=%d\n", ad->argName, *(int *)ad->argLoc); + fprintf(f, OPTCHAR "%s" SEPCHAR "%d\n", ad->argName, *(int *)ad->argLoc); break; case ArgX: - fprintf(f, "/%s=%d\n", ad->argName, *(int *)ad->argLoc - wpMain.x); // [HGM] placement: stor relative value + fprintf(f, OPTCHAR "%s" SEPCHAR "%d\n", ad->argName, *(int *)ad->argLoc - wpMain.x); // [HGM] placement: store relative value break; case ArgY: - fprintf(f, "/%s=%d\n", ad->argName, *(int *)ad->argLoc - wpMain.y); + fprintf(f, OPTCHAR "%s" SEPCHAR "%d\n", ad->argName, *(int *)ad->argLoc - wpMain.y); break; case ArgFloat: - fprintf(f, "/%s=%g\n", ad->argName, *(float *)ad->argLoc); + fprintf(f, OPTCHAR "%s" SEPCHAR "%g\n", ad->argName, *(float *)ad->argLoc); break; case ArgBoolean: - fprintf(f, "/%s=%s\n", ad->argName, + fprintf(f, OPTCHAR "%s" SEPCHAR "%s\n", ad->argName, (*(Boolean *)ad->argLoc) ? "true" : "false"); break; case ArgTrue: - if (*(Boolean *)ad->argLoc) fprintf(f, "/%s\n", ad->argName); + if (*(Boolean *)ad->argLoc) fprintf(f, OPTCHAR "%s\n", ad->argName); break; case ArgFalse: - if (!*(Boolean *)ad->argLoc) fprintf(f, "/%s\n", ad->argName); + if (!*(Boolean *)ad->argLoc) fprintf(f, OPTCHAR "%s\n", ad->argName); break; case ArgColor: SaveColor(f, ad); @@ -1316,9 +1316,9 @@ SaveSettings(char* name) case ArgFilename: if(*(char**)ad->argLoc == NULL) break; // just in case if (strchr(*(char **)ad->argLoc, '\"')) { - fprintf(f, "/%s='%s'\n", ad->argName, *(char **)ad->argLoc); + fprintf(f, OPTCHAR "%s" SEPCHAR "'%s'\n", ad->argName, *(char **)ad->argLoc); } else { - fprintf(f, "/%s=\"%s\"\n", ad->argName, *(char **)ad->argLoc); + fprintf(f, OPTCHAR "%s" SEPCHAR "\"%s\"\n", ad->argName, *(char **)ad->argLoc); } break; case ArgBoardSize: diff --git a/winboard/winboard.c b/winboard/winboard.c index b34afa1..7c8142c 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -884,6 +884,9 @@ InitMenuChecks() #define ICS_TEXT_MENU_SIZE (IDM_CommandXLast - IDM_CommandX + 1) #define XBOARD FALSE +#define OPTCHAR "/" +#define SEPCHAR "=" + #include "args.h" // front-end part of option handling diff --git a/xboard.c b/xboard.c index b99438e..d505eb5 100644 --- a/xboard.c +++ b/xboard.c @@ -1247,6 +1247,8 @@ BoardToTop() #define ICS_TEXT_MENU_SIZE 90 #define SetCurrentDirectory chdir #define GetCurrentDirectory(SIZE, NAME) getcwd(NAME, SIZE) +#define OPTCHAR "-" +#define SEPCHAR " " // these two must some day move to frontend.h, when they are implemented Boolean EvalGraphIsUp(); @@ -1355,7 +1357,7 @@ SaveFontArg(FILE *f, ArgDescriptor *ad) default: return; } - fprintf(f, "/%s=%s\n", ad->argName, name); + fprintf(f, OPTCHAR "%s" SEPCHAR "%s\n", ad->argName, name); } void @@ -1366,20 +1368,20 @@ ExportSounds() void SaveAttribsArg(FILE *f, ArgDescriptor *ad) { // here the "argLoc" defines a table index. It could have contained the 'ta' pointer itself, though - fprintf(f, "/%s=%s\n", ad->argName, (&appData.colorShout)[(int)ad->argLoc]); + fprintf(f, OPTCHAR "%s" SEPCHAR "%s\n", ad->argName, (&appData.colorShout)[(int)ad->argLoc]); } void SaveColor(FILE *f, ArgDescriptor *ad) { // in WinBoard the color is an int and has to be converted to text. In X it would be a string already? if(colorVariable[(int)ad->argLoc]) - fprintf(f, "/%s=%s\n", ad->argName, *(char**)colorVariable[(int)ad->argLoc]); + fprintf(f, OPTCHAR "%s" SEPCHAR "%s\n", ad->argName, *(char**)colorVariable[(int)ad->argLoc]); } void SaveBoardSize(FILE *f, char *name, void *addr) { // wrapper to shield back-end from BoardSize & sizeInfo - fprintf(f, "/%s=%s\n", name, appData.boardSize); + fprintf(f, OPTCHAR "%s" SEPCHAR "%s\n", name, appData.boardSize); } void diff --git a/xboard.conf b/xboard.conf new file mode 100644 index 0000000..387ba39 --- /dev/null +++ b/xboard.conf @@ -0,0 +1,71 @@ +; +; xboard 4.4.1.20091022 Save Settings file +; +; This file contains the system-wide settings of XBoard, in so far they +; deviate from the compiled-in defaults, and are not settable through menus, +; to comfort users that have no history of xboard usage. +; You can edit the values of options that are already set in this file, +; or add other options that you think are convenient as defaults for all users. +; This file is not automatically overwritten, because it redefines the +; -saveSettingsFile to .xboardrc in the user's home directory, so that +; user settings will be saved in a place the user has write access to. +; +; Looks +; +-internetChessServerInputBox false +-titleInWindow false +-showButtonBar true +-moveHistoryUp false +-evalGraphUp false +-engineOutputUp false +-monoMode false +-flashCount 0 +-flashRate 5 +-fontSizeTolerance 4 +-clockFont -adobe-helvetica-bold-r-normal--34-240-100-100-p-182-iso8859-1 +-font -adobe-helvetica-medium-r-normal--14-100-100-100-p-76-iso8859-1 +-coordFont -adobe-helvetica-bold-r-normal--12-120-75-75-p-70-iso8859-1 +-pixmapDirectory "" +-bitmapDirectory "" +; +; Behavior +; +-soundProgram "aplay -q" +-pasteSelection false +-keepLineBreaksICS false +-timeDelay 1 +-autoDisplayComment true +-autoDisplayTags true +-lowTimeWarning false +-icsAlarm false +-icsAlarmTime 5000 +-msLoginDelay 0 +-delayBeforeQuit 0 +-delayAfterQuit 0 +; +; PGN format & Game List +; +-pgnExtendedInfo true +-saveOutOfBookInfo true +-gameListTags "eprd" +; +; Engines & adjudicatons in engine-engine games +; +-firstChessProgram fairymax +-secondChessProgram fairymax +-niceEngines 0 +-polyglotDir "" +-defaultPathEGTB "/egtb" +-egtFormats "" +-testClaims true +-checkMates true +-materialDraws true +-trivialDraws false +; +; Save user settings. +; Must be last in file to make user options prevail over system-wide settings! +; +-saveSettingsOnExit true +-saveSettingsFile "~/.xboardrc" +-settingsFile "~/.xboardrc" + -- 1.7.0.4