Add -s option.
Re-enables pasting multiline sequences to the > prompt (for making checkfiles).
This commit is contained in:
parent
a02b387999
commit
66c22301ed
4 changed files with 25 additions and 13 deletions
|
@ -37,7 +37,9 @@ There have been no gameplay changes.
|
||||||
|
|
||||||
-l:: Log commands to specified file.
|
-l:: Log commands to specified file.
|
||||||
|
|
||||||
-o:: Old-style. Restores original interface, no prompt or command history.
|
-s:: Suppress Emacs-like line editing and command history.
|
||||||
|
|
||||||
|
-o:: Old-style. Restores original interface, no prompt or line editing.
|
||||||
|
|
||||||
== BUGS ==
|
== BUGS ==
|
||||||
|
|
||||||
|
|
7
advent.h
7
advent.h
|
@ -80,7 +80,7 @@ extern char rawbuf[LINESIZE], INLINE[LINESIZE+1];
|
||||||
extern const char ascii_to_advent[];
|
extern const char ascii_to_advent[];
|
||||||
extern const char advent_to_ascii[];
|
extern const char advent_to_ascii[];
|
||||||
extern FILE *logfp;
|
extern FILE *logfp;
|
||||||
extern bool oldstyle;
|
extern bool oldstyle, editline, prompt;
|
||||||
extern lcg_state lcgstate;
|
extern lcg_state lcgstate;
|
||||||
|
|
||||||
/* b is not needed for POSIX but harmless */
|
/* b is not needed for POSIX but harmless */
|
||||||
|
@ -174,6 +174,7 @@ enum speechpart {unknown, intransitive, transitive};
|
||||||
|
|
||||||
/* Phase codes for action returns.
|
/* Phase codes for action returns.
|
||||||
* These were at one time FORTRAN line numbers.
|
* These were at one time FORTRAN line numbers.
|
||||||
|
* The values don't matter, but perturb their order at your peril.
|
||||||
*/
|
*/
|
||||||
#define GO_TERMINATE 2
|
#define GO_TERMINATE 2
|
||||||
#define GO_MOVE 8
|
#define GO_MOVE 8
|
||||||
|
@ -181,12 +182,14 @@ enum speechpart {unknown, intransitive, transitive};
|
||||||
#define GO_CLEAROBJ 2012
|
#define GO_CLEAROBJ 2012
|
||||||
#define GO_CHECKHINT 2600
|
#define GO_CHECKHINT 2600
|
||||||
#define GO_CHECKFOO 2607
|
#define GO_CHECKFOO 2607
|
||||||
|
#define GO_CLOSEJUMP 2610
|
||||||
#define GO_DIRECTION 2620
|
#define GO_DIRECTION 2620
|
||||||
#define GO_LOOKUP 2630
|
#define GO_LOOKUP 2630
|
||||||
#define GO_WORD2 2800
|
#define GO_WORD2 2800
|
||||||
|
#define GO_SPECIALS 1900
|
||||||
#define GO_UNKNOWN 8000
|
#define GO_UNKNOWN 8000
|
||||||
#define GO_DWARFWAKE 19000
|
|
||||||
#define GO_ACTION 40000
|
#define GO_ACTION 40000
|
||||||
|
#define GO_DWARFWAKE 19000
|
||||||
|
|
||||||
/* hack to ignore GCC Unused Result */
|
/* hack to ignore GCC Unused Result */
|
||||||
#define IGNORE(r) do{if (r){}}while(0)
|
#define IGNORE(r) do{if (r){}}while(0)
|
||||||
|
|
19
main.c
19
main.c
|
@ -5,12 +5,13 @@
|
||||||
* is a result of running the original Fortran IV source through a
|
* is a result of running the original Fortran IV source through a
|
||||||
* home-brew Fortran-to-C converter.)
|
* home-brew Fortran-to-C converter.)
|
||||||
*
|
*
|
||||||
* Now that the code has been restructured into idiomatic C, the following
|
* Now that the code has been restructured into something much closer
|
||||||
* is more appropriate:
|
* to idiomatic C, the following is more appropriate:
|
||||||
*
|
*
|
||||||
* ESR apologizes for the remaing gotos (now confined to two functions in this
|
* ESR apologizes for the remaing gotos (now confined to two functions
|
||||||
* file - they used to be *everywhere*), and the offensive globals. Applying
|
* in this file - there used to be hundreds of them, *everywhere*),
|
||||||
* the Structured Program Theorem can be hard.
|
* and the offensive globals. Applying the Structured Program Theorem
|
||||||
|
* can be hard.
|
||||||
*/
|
*/
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -43,6 +44,8 @@ long WD1, WD1X, WD2, WD2X;
|
||||||
|
|
||||||
FILE *logfp;
|
FILE *logfp;
|
||||||
bool oldstyle = false;
|
bool oldstyle = false;
|
||||||
|
bool editline = true;
|
||||||
|
bool prompt = true;
|
||||||
lcg_state lcgstate;
|
lcg_state lcgstate;
|
||||||
|
|
||||||
extern void initialise();
|
extern void initialise();
|
||||||
|
@ -77,7 +80,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
/* Options. */
|
/* Options. */
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "l:o")) != EOF) {
|
while ((ch = getopt(argc, argv, "l:os")) != EOF) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'l':
|
case 'l':
|
||||||
logfp = fopen(optarg, "w");
|
logfp = fopen(optarg, "w");
|
||||||
|
@ -89,6 +92,10 @@ case 'l':
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
oldstyle = true;
|
oldstyle = true;
|
||||||
|
editline = prompt = false;
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
editline = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
6
misc.c
6
misc.c
|
@ -630,14 +630,14 @@ bool MAPLIN(FILE *fp)
|
||||||
* and is not changed thereafter unless the routines on this page choose
|
* and is not changed thereafter unless the routines on this page choose
|
||||||
* to do so. */
|
* to do so. */
|
||||||
|
|
||||||
if (!oldstyle && !isatty(1))
|
if (prompt)
|
||||||
fputs("> ", stdout);
|
fputs("> ", stdout);
|
||||||
do {
|
do {
|
||||||
if (oldstyle) {
|
if (!editline) {
|
||||||
IGNORE(fgets(rawbuf,sizeof(rawbuf)-1,fp));
|
IGNORE(fgets(rawbuf,sizeof(rawbuf)-1,fp));
|
||||||
eof = (feof(fp));
|
eof = (feof(fp));
|
||||||
} else {
|
} else {
|
||||||
char *cp = linenoise("> ");
|
char *cp = linenoise(prompt ? "> ": "");
|
||||||
eof = (cp == NULL);
|
eof = (cp == NULL);
|
||||||
if (!eof) {
|
if (!eof) {
|
||||||
strncpy(rawbuf, cp, sizeof(rawbuf)-1);
|
strncpy(rawbuf, cp, sizeof(rawbuf)-1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue