]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - monop/getinp.c
printf() pedant - do not pass variable alone, use %s.
[bsdgames-darwin.git] / monop / getinp.c
index 62ea845f2dfd33dcc44e9872ef6aa044d937f0dd..664574488ee2181de6358a06dc2fc76d682a2ef5 100644 (file)
@@ -1,6 +1,8 @@
+/*     $NetBSD: getinp.c,v 1.9 2000/07/10 10:19:26 itojun Exp $        */
+
 /*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1980, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * SUCH DAMAGE.
  */
 
+#include <sys/cdefs.h>
 #ifndef lint
-static char sccsid[] = "@(#)getinp.c   5.4 (Berkeley) 2/28/91";
+#if 0
+static char sccsid[] = "@(#)getinp.c   8.1 (Berkeley) 5/31/93";
+#else
+__RCSID("$NetBSD: getinp.c,v 1.9 2000/07/10 10:19:26 itojun Exp $");
+#endif
 #endif /* not lint */
 
-# include      <stdio.h>
-# include      <ctype.h>
-
-# define       reg     register
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include "monop.ext"
 
-# define       LINE    70
+#define        LINE    70
 
 static char    buf[257];
 
-getinp(prompt, list)
-char   *prompt, *list[]; {
+static int comp __P((const char *));
 
-       reg int i, n_match, match;
-       char    *sp;
-       int     plen;
-       static int comp();
+int
+getinp(prompt, list)
+       const char *prompt, *const list[]; 
+{
+       int i, n_match, match = 0;
+       char *sp;
+       int c;
 
        for (;;) {
 inter:
-               printf(prompt);
-               for (sp = buf; (*sp=getchar()) != '\n'; )
-                       if (*sp == -1)  /* check for interupted system call */
+               printf("%s", prompt);
+               for (sp = buf; (c=getchar()) != '\n'; ) {
+                       *sp = c;
+                       if (c == -1)    /* check for interupted system call */
                                goto inter;
                        else if (sp != buf || *sp != ' ')
                                sp++;
+               }
+               *sp = c;
                if (buf[0] == '?' && buf[1] == '\n') {
                        printf("Valid inputs are: ");
                        for (i = 0, match = 18; list[i]; i++) {
@@ -72,7 +84,7 @@ inter:
                                        printf("<RETURN>");
                                }
                                else
-                                       printf(list[i]);
+                                       printf("%s", list[i]);
                                if (list[i+1])
                                        printf(", ");
                                else
@@ -93,15 +105,17 @@ inter:
                if (n_match == 1)
                        return match;
                else if (buf[0] != '\0')
-                       printf("Illegal response: \"%s\".  Use '?' to get list of valid answers\n", buf);
+                       printf("Illegal response: \"%s\".  "
+                           "Use '?' to get list of valid answers\n", buf);
        }
 }
 
-static
+static int
 comp(s1)
-char   *s1; {
-
-       reg char        *sp, *tsp, c;
+       const char *s1;
+{
+       const char *sp, *tsp;
+       char c;
 
        if (buf[0] != '\0')
                for (sp = buf, tsp = s1; *sp; ) {