Major refactoring of GenericPopUp
[xboard.git] / backend.c
index 14f4829..3f6229d 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -6131,7 +6131,6 @@ WriteMap (int s)
 static void
 ClearMap ()
 {
-    int j;
     safeStrCpy(exclusionHeader, "exclude: none best +tail                                          \n", MSG_SIZ);
     excludePtr = 24; exCnt = 0;
     WriteMap(0);
@@ -6163,7 +6162,7 @@ UpdateExcludeHeader (int fromY, int fromX, int toY, int toX, char promoChar, cha
 static int
 ExcludeOneMove (int fromY, int fromX, int toY, int toX, signed char promoChar, char state)
 {   // include or exclude the given move, as specified by state ('+' or '-'), or toggle
-    char *p, buf[MSG_SIZ];
+    char buf[MSG_SIZ];
     int j, k;
     ChessMove moveType;
     if(promoChar == -1) { // kludge to indicate best move
@@ -6190,7 +6189,6 @@ static void
 ExcludeClick (int index)
 {
     int i, j;
-    char buf[MSG_SIZ];
     Exclusion *e = excluTab;
     if(index < 25) { // none, best or tail clicked
        if(index < 13) { // none: include all
@@ -15536,8 +15534,8 @@ ParseOption (Option *opt, ChessProgramState *cps)
            if(sscanf(p, " -check %d", &def) < 1) return FALSE;
            opt->value = (def != 0);
            opt->type = CheckBox;
-       } else if(p = strstr(opt->name, " -combo ")) {
-           opt->textValue = (char*) (&cps->comboList[cps->comboCnt]); // cheat with pointer type
+       } else if(p = strstr(opt->name, " -combo ")) {
+           opt->textValue = (char*) (opt->choice = &cps->comboList[cps->comboCnt]); // cheat with pointer type
            cps->comboList[cps->comboCnt++] = q = p+8; // holds possible choices
            if(*q == '*') cps->comboList[cps->comboCnt-1]++;
            opt->value = n = 0;
@@ -15658,7 +15656,10 @@ ParseFeatures (char *args, ChessProgramState *cps)
     if (BoolFeature(&p, "memory", &cps->memSize, cps)) continue;
     if (BoolFeature(&p, "smp", &cps->maxCores, cps)) continue;
     if (StringFeature(&p, "egt", cps->egtFormats, cps)) continue;
-    if (StringFeature(&p, "option", cps->option[cps->nrOptions].name, cps)) {
+    if (StringFeature(&p, "option", buf, cps)) {
+       FREE(cps->option[cps->nrOptions].name);
+       cps->option[cps->nrOptions].name = malloc(MSG_SIZ);
+       safeStrCpy(cps->option[cps->nrOptions].name, buf, MSG_SIZ);
        if(!ParseOption(&(cps->option[cps->nrOptions++]), cps)) { // [HGM] options: add option feature
          snprintf(buf, MSG_SIZ, "rejected option %s\n", cps->option[--cps->nrOptions].name);
            SendToProgram(buf, cps);