projects
/
open-adventure.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Document test comment format.
[open-adventure.git]
/
misc.c
diff --git
a/misc.c
b/misc.c
index f1bd954c7932cdf9c463c072c2f1a970b166e340..8ea3db40c6cde454344abef1f86fa9b338f1530c 100644
(file)
--- a/
misc.c
+++ b/
misc.c
@@
-1,6
+1,7
@@
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include "main.h"
#include "share.h" /* for SETUP */
#include "misc.h"
#include "main.h"
#include "share.h" /* for SETUP */
#include "misc.h"
@@
-173,7
+174,7
@@
void fSETPRM(long FIRST, long P1, long P2) {
#define WORD1X (*wORD1X)
#define WORD2 (*wORD2)
#define WORD2X (*wORD2X)
#define WORD1X (*wORD1X)
#define WORD2 (*wORD2)
#define WORD2X (*wORD2X)
-
void
fGETIN(FILE *input, long *wORD1, long *wORD1X, long *wORD2, long *wORD2X) {
+
bool
fGETIN(FILE *input, long *wORD1, long *wORD1X, long *wORD2, long *wORD2X) {
long JUNK;
/* Get a command from the adventurer. Snarf out the first word, pad it with
long JUNK;
/* Get a command from the adventurer. Snarf out the first word, pad it with
@@
-185,7
+186,8
@@
long JUNK;
L10: if(BLKLIN)TYPE0();
MAPLIN(input);
L10: if(BLKLIN)TYPE0();
MAPLIN(input);
- if(input == stdin && feof(stdin)) score(1);
+ if (feof(input))
+ return false;
WORD1=GETTXT(true,true,true,0);
if(BLKLIN && WORD1 < 0) goto L10;
WORD1X=GETTXT(false,true,true,0);
WORD1=GETTXT(true,true,true,0);
if(BLKLIN && WORD1 < 0) goto L10;
WORD1X=GETTXT(false,true,true,0);
@@
-195,7
+197,7
@@
L12: JUNK=GETTXT(false,true,true,0);
WORD2X=GETTXT(false,true,true,0);
L22: JUNK=GETTXT(false,true,true,0);
if(JUNK > 0) goto L22;
WORD2X=GETTXT(false,true,true,0);
L22: JUNK=GETTXT(false,true,true,0);
if(JUNK > 0) goto L22;
- if(GETTXT(true,true,true,0) <= 0)return;
+ if(GETTXT(true,true,true,0) <= 0)return
true
;
RSPEAK(53);
goto L10;
}
RSPEAK(53);
goto L10;
}
@@
-723,7
+725,8
@@
L2: ATDWRF=I;
-/* Utility routines (SETBIT, TSTBIT, set_seed, get_next_lcg_value, randrange, RNDVOC, BUG) */
+/* Utility routines (SETBIT, TSTBIT, set_seed, get_next_lcg_value,
+ * randrange, RNDVOC, BUG) */
#undef SETBIT
long fSETBIT(long BIT) {
#undef SETBIT
long fSETBIT(long BIT) {
@@
-760,8
+763,7
@@
long TSTBIT;
void set_seed(long seedval)
{
void set_seed(long seedval)
{
- srand(seedval);
- lcgstate.x = (unsigned long) rand() % lcgstate.m;
+ lcgstate.x = (unsigned long) seedval % lcgstate.m;
}
unsigned long get_next_lcg_value(void)
}
unsigned long get_next_lcg_value(void)
@@
-854,8
+856,8
@@
void fBUG(long NUM) {
#define BUG(NUM) fBUG(NUM)
#undef MAPLIN
void fMAPLIN(FILE *OPENED) {
#define BUG(NUM) fBUG(NUM)
#undef MAPLIN
void fMAPLIN(FILE *OPENED) {
-
signed char *cp
;
-
+
long I, VAL
;
+
/* Read a line of input, from the specified input source,
* translate the chars to integers in the range 0-126 and store
* them in the common array "INLINE". Integer values are as follows:
/* Read a line of input, from the specified input source,
* translate the chars to integers in the range 0-126 and store
* them in the common array "INLINE". Integer values are as follows:
@@
-883,20
+885,27
@@
void fMAPLIN(FILE *OPENED) {
if(MAP2[1] == 0)MPINIT();
if(MAP2[1] == 0)MPINIT();
- if (!oldstyle && SETUP)
- fputs("> ", stdout);
- IGNORE(fgets(raw_input,sizeof(INLINE)-1,OPENED));
+ if (!oldstyle && SETUP && OPENED == stdin)
+ fputs("> ", stdout);
+ do {
+ IGNORE(fgets(rawbuf,sizeof(INLINE)-1,OPENED));
+ } while
+ (!feof(OPENED) && INLINE[1] == '#');
if (feof(OPENED)) {
if (feof(OPENED)) {
- if (logfp)
+ if (logfp
&& OPENED == stdin
)
fclose(logfp);
} else {
fclose(logfp);
} else {
- if (logfp)
- IGNORE(fputs(raw
_input
, logfp));
+ if (logfp
&& OPENED == stdin
)
+ IGNORE(fputs(raw
buf
, logfp));
else if (!isatty(0))
else if (!isatty(0))
- IGNORE(fputs(raw_input, stdout));
- for (cp = raw_input; *cp; cp++)
- INLINE[cp - raw_input + 1]=MAP1[*cp + 1];
- LNLENG = (cp - raw_input);
+ IGNORE(fputs(rawbuf, stdout));
+ strcpy(INLINE+1, rawbuf);
+ LNLENG=0;
+ for (I=1; I<=sizeof(INLINE) && INLINE[I]!=0; I++) {
+ VAL=INLINE[I]+1;
+ INLINE[I]=MAP1[VAL];
+ if(INLINE[I] != 0)LNLENG=I;
+ } /* end loop */
LNPOSN=1;
}
}
LNPOSN=1;
}
}