cleaned up an old #ifdef in zippy
[xboard.git] / backend.c
index 29f55db..1f424e3 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -77,6 +77,7 @@
 #if STDC_HEADERS
 # include <stdlib.h>
 # include <string.h>
+# include <stdarg.h>
 #else /* not STDC_HEADERS */
 # if HAVE_STRING_H
 #  include <string.h>
@@ -1423,12 +1424,14 @@ KeepAlive()
 /* added routine for printf style output to ics */
 void ics_printf(char *format, ...)
 {
-       char buffer[MSG_SIZ], *args;
-       
-       args = (char *)&format + sizeof(format);
-       vsnprintf(buffer, sizeof(buffer), format, args);
-       buffer[sizeof(buffer)-1] = '\0';
-       SendToICS(buffer);
+    char buffer[MSG_SIZ];
+    va_list args;
+
+    va_start(args, format);
+    vsnprintf(buffer, sizeof(buffer), format, args);
+    buffer[sizeof(buffer)-1] = '\0';
+    SendToICS(buffer);
+    va_end(args);
 }
 
 void
@@ -2218,8 +2221,8 @@ read_from_ics(isr, closure, data, count, error)
                  sprintf(str,
                          "/set-quietly interface %s\n/set-quietly style 12\n",
                          programVersion);
-                 strcat(str, "/set-quietly wrap 0\n");
-
+          if (!appData.noJoin)
+              strcat(str, "/set-quietly wrap 0\n");
                } else if (ics_type == ICS_CHESSNET) {
                  sprintf(str, "/style 12\n");
                } else {
@@ -2229,7 +2232,8 @@ read_from_ics(isr, closure, data, count, error)
 #ifdef WIN32
                  strcat(str, "$iset nohighlight 1\n");
 #endif
-                 strcat(str, "$iset nowrap 1\n");
+          if (!appData.noJoin)
+              strcat(str, "$iset nowrap 1\n");
                  strcat(str, "$iset lock 1\n$style 12\n");
                }
                SendToICS(str);
@@ -9595,7 +9599,7 @@ SaveGamePGN(f)
            fprintf(f, " ");
            linelen++;
        }
-       fprintf(f, numtext);
+       fprintf(f, "%s", numtext);
        linelen += numlen;
 
        /* Get move */
@@ -9613,7 +9617,7 @@ SaveGamePGN(f)
            fprintf(f, " ");
            linelen++;
        }
-       fprintf(f, move_buffer);
+       fprintf(f, "%s", move_buffer);
        linelen += movelen;
 
         /* [AS] Add PV info if present */
@@ -9657,7 +9661,7 @@ SaveGamePGN(f)
                fprintf(f, " ");
                linelen++;
            }
-           fprintf(f, move_buffer);
+           fprintf(f, "%s", move_buffer);
            linelen += movelen;
         }