From deb0bc214fa41a647853e74a7eb433f2598682ac Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Tue, 26 Feb 2013 17:27:59 +0100 Subject: [PATCH] Make skipping of unknown option smarter To make XBoard better resistant to the presence of disbanded or future options in its settings file, encountering those is no longer a fatal error. But the error recovery only consisted of skipping the rest of the line. This fails badly on string options with a multi-line value, which is enclosed by {braces}. We now detect that case, to skip to } instead. --- args.h | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/args.h b/args.h index 9533406..76b2452 100644 --- a/args.h +++ b/args.h @@ -919,8 +919,9 @@ ParseArgs(GetFunc get, void *cl) for (ad = argDescriptors; ad->argName != NULL; ad++) if (strcmp(ad->argName, argName + 1) == 0) break; if (ad->argName == NULL) { + char endChar = (ch && ch != '\n' && (ch = get(cl)) == '{' ? '}' : '\n'); ExitArgError(_("Unrecognized argument %s"), argName, get != &FileGet); // [HGM] make unknown argument non-fatal - while (ch != '\n' && ch != NULLCHAR) ch = get(cl); // but skip rest of line it is on + while (ch != endChar && ch != NULLCHAR) ch = get(cl); // but skip rest of line it is on (or until closing '}' ) continue; // so that when it is in a settings file, it is the only setting that will be purged from it } } else if (ch == '@') { -- 1.7.0.4