projects
/
open-adventure.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7ce9f72
)
More SPEAK() hardening.
59/head
author
Jason S. Ninneman
<jsn@mbar.us>
Sun, 11 Jun 2017 02:00:44 +0000
(19:00 -0700)
committer
Jason S. Ninneman
<jsn@mbar.us>
Sun, 11 Jun 2017 02:00:54 +0000
(19:00 -0700)
misc.c
patch
|
blob
|
history
diff --git
a/misc.c
b/misc.c
index 91f2dfa6ad6406a3400c614495da52163410a124..fbfee4fca954c6b05062a7152665533beaedae92 100644
(file)
--- a/
misc.c
+++ b/
misc.c
@@
-3,6
+3,7
@@
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
+#include <ctype.h>
#include "advent.h"
#include "database.h"
#include "advent.h"
#include "database.h"
@@
-50,7
+51,7
@@
void SPEAK(vocab_t msg)
return;
if (prmtyp == ascii_to_advent['S']) {
SHFTXT(LNPOSN+2,-1);
return;
if (prmtyp == ascii_to_advent['S']) {
SHFTXT(LNPOSN+2,-1);
- INLINE[LNPOSN] =
55
;
+ INLINE[LNPOSN] =
ascii_to_advent['s']
;
if (PARMS[nparms] == 1)
SHFTXT(LNPOSN+1,-1);
++nparms;
if (PARMS[nparms] == 1)
SHFTXT(LNPOSN+1,-1);
++nparms;
@@
-94,7
+95,14
@@
void SPEAK(vocab_t msg)
PUTTXT(PARMS[nparms],&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'])
PUTTXT(PARMS[nparms],&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'])
- 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;
continue;
}
nparms += 2;
continue;
}