More SPEAK() hardening.
This commit is contained in:
parent
7ce9f7270f
commit
3ed8b91eb7
1 changed files with 10 additions and 2 deletions
12
misc.c
12
misc.c
|
@ -3,6 +3,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "advent.h"
|
#include "advent.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
|
@ -50,7 +51,7 @@ void SPEAK(vocab_t msg)
|
||||||
return;
|
return;
|
||||||
if (prmtyp == ascii_to_advent['S']) {
|
if (prmtyp == ascii_to_advent['S']) {
|
||||||
SHFTXT(LNPOSN+2,-1);
|
SHFTXT(LNPOSN+2,-1);
|
||||||
INLINE[LNPOSN] = 55;
|
INLINE[LNPOSN] = ascii_to_advent['s'];
|
||||||
if (PARMS[nparms] == 1)
|
if (PARMS[nparms] == 1)
|
||||||
SHFTXT(LNPOSN+1,-1);
|
SHFTXT(LNPOSN+1,-1);
|
||||||
++nparms;
|
++nparms;
|
||||||
|
@ -94,7 +95,14 @@ void SPEAK(vocab_t msg)
|
||||||
PUTTXT(PARMS[nparms],&state,casemake);
|
PUTTXT(PARMS[nparms],&state,casemake);
|
||||||
PUTTXT(PARMS[nparms+1],&state,casemake);
|
PUTTXT(PARMS[nparms+1],&state,casemake);
|
||||||
if (prmtyp == ascii_to_advent['C'] && INLINE[i] >= ascii_to_advent['a'] && INLINE[i] <= ascii_to_advent['z'])
|
if (prmtyp == ascii_to_advent['C'] && INLINE[i] >= ascii_to_advent['a'] && INLINE[i] <= ascii_to_advent['z'])
|
||||||
INLINE[i] -= 26;
|
{
|
||||||
|
// Convert to uppercase.
|
||||||
|
// Round-trip to ASCII and back so that this code doesn't break when the mapping changes.
|
||||||
|
// This can be simplified when mapping goes away.
|
||||||
|
char this = advent_to_ascii[INLINE[i]];
|
||||||
|
char uc_this = toupper(this);
|
||||||
|
INLINE[i] = ascii_to_advent[uc_this];
|
||||||
|
}
|
||||||
nparms += 2;
|
nparms += 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue