Updated copyright notice to 2012
[xboard.git] / uci.c
diff --git a/uci.c b/uci.c
index 5eeda2b..e0dfb15 100644 (file)
--- a/uci.c
+++ b/uci.c
@@ -5,6 +5,8 @@
  *
  * Copyright 2006 Alessandro Scotti
  *
+ * Enhancement Copyright 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+ *
  * ------------------------------------------------------------------------
  *
  * GNU XBoard is free software: you can redistribute it and/or modify
  * ------------------------------------------------------------------------
  */
 #include <stdio.h>
+#include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
 
-#if HAVE_MALLOC_H
-  #include <malloc.h>
-#endif
-
 #include "common.h"
 #include "backend.h"
 Boolean GetArgValue(char *a);                          
@@ -40,6 +39,7 @@ void InitEngineUCI( const char * iniDir, ChessProgramState * cps )
         char *p, *q;
         char polyglotCommand[MSG_SIZ];
 
+        if(cps->isUCI == 2) p = appData.ucciAdapter; else
         p = appData.adapterCommand;
         q = polyglotCommand;
         while(*p) {
@@ -50,13 +50,13 @@ void InitEngineUCI( const char * iniDir, ChessProgramState * cps )
               *s++ = cps == &first ? 'f' : 's';
               p++;
             }
-            while(*p >= '0' && *p) *s++ = *p++; // copy option name
+            while(isdigit(*p) || isalpha(*p)) *s++ = *p++; // copy option name
             *s = NULLCHAR;
             if(cps == &second) { // change options for first into those for second engine
               if(strstr(buf, "first") == buf) sprintf(argName, "second%s", buf+5); else
               if(buf[0] == 'f') sprintf(argName, "s%s", buf+1); else
-              strcpy(argName, buf);
-            } else strcpy(argName, buf);
+               safeStrCpy(argName, buf, sizeof(argName)/sizeof(argName[0]));
+            } else safeStrCpy(argName, buf, sizeof(argName)/sizeof(argName[0]));
             if(GetArgValue(argName)) { // look up value of option with this name
               s = argName;
               while(*s) *q++ = *s++;