-/* $OpenBSD: io.c,v 1.14 2012/03/04 04:05:15 fgsch Exp $ */
+/* $OpenBSD: io.c,v 1.15 2014/05/09 00:03:41 schwarze Exp $ */
/* $NetBSD: io.c,v 1.9 1997/07/09 06:25:47 phil Exp $ */
/*-
if (brfrank)
addmsg("%1.1s", rankchar[c.rank]);
else
- addmsg(rankname[c.rank]);
+ addmsg("%s", rankname[c.rank]);
if (mid != NULL)
- addmsg(mid);
+ addmsg("%s", mid);
if (brfsuit)
addmsg("%1.1s", suitchar[c.suit]);
else
- addmsg(suitname[c.suit]);
+ addmsg("%s", suitname[c.suit]);
return (TRUE);
}
CARD crd;
if (n < 1) {
+ bye();
printf("\nINFROM: %d = n < 1!!\n", n);
exit(74);
}
for (;;) {
- msg(prompt);
+ msg("%s", prompt);
if (incard(&crd)) { /* if card is full card */
if (!isone(crd, hand, n))
msg("That's not in your hand");
hand[i].suit == crd.suit)
break;
if (i >= n) {
+ bye();
printf("\nINFROM: isone or something messed up\n");
exit(77);
}
int sum, tmp;
for (sum = 0;;) {
- msg(prompt);
+ msg("%s", prompt);
if (!(p = get_line()) || *p == '\0') {
msg(quiet ? "Not a number" :
"That doesn't look like a number");
char *
get_line(void)
{
- char *sp;
+ size_t pos;
int c, oy, ox;
WINDOW *oscr;
getyx(stdscr, oy, ox);
refresh();
/* loop reading in the string, and put it in a temporary buffer */
- for (sp = linebuf; (c = readchar()) != '\n'; clrtoeol(), refresh()) {
+ for (pos = 0; (c = readchar()) != '\n'; clrtoeol(), refresh()) {
if (c == -1)
continue;
else
if (c == erasechar()) { /* process erase character */
- if (sp > linebuf) {
+ if (pos > 0) {
int i;
- sp--;
- for (i = strlen(unctrl(*sp)); i; i--)
+ pos--;
+ for (i = strlen(unctrl(linebuf[pos])); i; i--)
addch('\b');
}
continue;
- } else
- if (c == killchar()) { /* process kill
- * character */
- sp = linebuf;
- move(oy, ox);
- continue;
- } else
- if (sp == linebuf && c == ' ')
- continue;
- if (sp >= &linebuf[LINESIZE - 1] || !(isprint(c) || c == ' '))
+ } else if (c == killchar()) { /* process kill character */
+ pos = 0;
+ move(oy, ox);
+ continue;
+ } else if (pos == 0 && c == ' ')
+ continue;
+ if (pos >= LINESIZE - 1 || !(isprint(c) || c == ' '))
putchar(CTRL('G'));
else {
if (islower(c))
c = toupper(c);
- *sp++ = c;
+ linebuf[pos++] = c;
addstr(unctrl(c));
Mpos++;
}
}
- *sp = '\0';
+ linebuf[pos] = '\0';
stdscr = oscr;
return (linebuf);
}