Commit 32d85186 authored by David Griffith's avatar David Griffith 💬
Browse files

Fixed problem with garbage .aux filenames.

Applied patch found at
https://www.intfiction.org/forum/viewtopic.php?f=38&t=19767
I happened across it by chance, looking for proper responses to handling
.aux files.
parent 001335cb
......@@ -632,34 +632,20 @@ void z_restart (void)
* copy it to a string.
*
*/
char *filename_decoded = 0;
static void get_default_name (char *default_name, zword addr)
{
if (addr != 0) {
zbyte len;
int i;
LOW_BYTE (addr, len);
addr++;
for (i = 0; i < len; i++) {
zbyte c;
LOW_BYTE (addr, c);
addr++;
if (c >= 'A' && c <= 'Z')
c += 'a' - 'A';
default_name[i] = c;
}
int i;
default_name[i] = 0;
if (addr != 0) {
memset (default_name, 0, MAX_FILE_NAME + 1);
filename_decoded = default_name;
decode_text (FILENAME, addr);
filename_decoded = 0;
if (strchr (default_name, '.') == NULL)
strcpy (default_name + i, ".AUX");
strcpy (strchr (default_name, '\0'), EXT_AUX);
} else strcpy (default_name, f_setup.aux_name);
......@@ -671,7 +657,7 @@ static void get_default_name (char *default_name, zword addr)
*
* zargs[0] = address of area to restore (optional)
* zargs[1] = number of bytes to restore
* zargs[2] = address of suggested file name
* zargs[2] = packed address of suggested file name
*
*/
void z_restore (void)
......@@ -911,7 +897,7 @@ void z_restore_undo (void)
*
* zargs[0] = address of memory area to save (optional)
* zargs[1] = number of bytes to save
* zargs[2] = address of suggested file name
* zargs[2] = packed address of suggested file name
*
*/
void z_save (void)
......
......@@ -832,6 +832,15 @@ void os_init_setup (void);
void os_warn (const char *, ...);
void os_quit (void);
/*** text decoding API ***/
enum string_type {
LOW_STRING, ABBREVIATION, HIGH_STRING, EMBEDDED_STRING, VOCABULARY, FILENAME
};
void decode_text (enum string_type st, zword addr);
/**
* Called regularly by the interpreter, at least every few instructions
* (only when interpreting: e.g., not when waiting for input).
......
......@@ -20,14 +20,11 @@
#include "frotz.h"
enum string_type {
LOW_STRING, ABBREVIATION, HIGH_STRING, EMBEDDED_STRING, VOCABULARY
};
extern zword object_name (zword);
static zchar decoded[10];
static zword encoded[3];
extern zchar *filename_decoded;
/*
* According to Matteo De Luigi <matteo.de.luigi@libero.it>,
......@@ -369,12 +366,14 @@ void z_encode_text (void)
* HIGH_STRING - from the end of the memory map (packed address)
* EMBEDDED_STRING - from the instruction stream (at PC)
* VOCABULARY - from the dictionary (byte address)
* FIlENAME - high string used as a filename, to be decoded instead of
* printed out
*
* The last type is only used for word completion.
* The VOCABULARY type is only used for word completion.
*
*/
#define outchar(c) if (st==VOCABULARY) *ptr++=c; else print_char(c)
static void decode_text (enum string_type st, zword addr)
#define outchar(c) if (st==VOCABULARY||st==FILENAME) *ptr++=c; else print_char(c)
void decode_text (enum string_type st, zword addr)
{
zchar *ptr;
long byte_addr;
......@@ -394,7 +393,7 @@ static void decode_text (enum string_type st, zword addr)
byte_addr = (long) addr << 1;
else if (st == HIGH_STRING) {
else if (st == HIGH_STRING || st == FILENAME) {
if (h_version <= V3)
byte_addr = (long) addr << 1;
......@@ -415,6 +414,9 @@ static void decode_text (enum string_type st, zword addr)
if (st == VOCABULARY)
ptr = decoded;
else if (st == FILENAME)
ptr = filename_decoded;
do {
int i;
......@@ -424,7 +426,7 @@ static void decode_text (enum string_type st, zword addr)
if (st == LOW_STRING || st == VOCABULARY) {
LOW_WORD (addr, code)
addr += 2;
} else if (st == HIGH_STRING || st == ABBREVIATION) {
} else if (st == HIGH_STRING || st == ABBREVIATION || st == FILENAME) {
HIGH_WORD (byte_addr, code)
byte_addr += 2;
} else
......@@ -510,7 +512,7 @@ static void decode_text (enum string_type st, zword addr)
} while (!(code & 0x8000));
if (st == VOCABULARY)
if (st == VOCABULARY || st == FILENAME)
*ptr = 0;
}/* decode_text */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment