projects
/
inform.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update to commit af5309356bfa197d7a7ea09101c317f94e9b856b
[inform.git]
/
src
/
text.c
diff --git
a/src/text.c
b/src/text.c
index cd2fcd8c7b589fc8a642eb983621cb635f1d6aa1..064a5da340638c267067b6d86495d63334b7847e 100644
(file)
--- a/
src/text.c
+++ b/
src/text.c
@@
-1,9
+1,8
@@
/* ------------------------------------------------------------------------- */
/* "text" : Text translation, the abbreviations optimiser, the dictionary */
/* */
/* ------------------------------------------------------------------------- */
/* "text" : Text translation, the abbreviations optimiser, the dictionary */
/* */
-/* Copyright (c) Graham Nelson 1993 - 2018 */
-/* */
-/* This file is part of Inform. */
+/* Part of Inform 6.35 */
+/* copyright (c) Graham Nelson 1993 - 2021 */
/* */
/* Inform is free software: you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* */
/* Inform is free software: you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
@@
-16,7
+15,7
@@
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
-/* along with Inform. If not, see https://gnu.org/licenses/ *
/
+/* along with Inform. If not, see https://gnu.org/licenses/ *
/* */
/* ------------------------------------------------------------------------- */
/* */
/* ------------------------------------------------------------------------- */
@@
-39,10
+38,7
@@
char *all_text, *all_text_top; /* Start and next byte free in (large)
text buffer holding the entire text
of the game, when it is being
recorded */
text buffer holding the entire text
of the game, when it is being
recorded */
-int put_strings_in_low_memory, /* When TRUE, put static strings in
- the low strings pool at 0x100 rather
- than in the static strings area */
- is_abbreviation, /* When TRUE, the string being trans
+int is_abbreviation, /* When TRUE, the string being trans
is itself an abbreviation string
so can't make use of abbreviations */
abbrevs_lookup_table_made, /* The abbreviations lookup table is
is itself an abbreviation string
so can't make use of abbreviations */
abbrevs_lookup_table_made, /* The abbreviations lookup table is
@@
-460,8
+456,9
@@
extern uchar *translate_text(uchar *p, uchar *p_limit, char *s_text)
if ((economy_switch) && (!is_abbreviation)
&& ((k=abbrevs_lookup[text_in[i]])!=-1))
{ if ((j=try_abbreviations_from(text_in, i, k))!=-1)
if ((economy_switch) && (!is_abbreviation)
&& ((k=abbrevs_lookup[text_in[i]])!=-1))
{ if ((j=try_abbreviations_from(text_in, i, k))!=-1)
- { if (j<32) { write_z_char_z(2); write_z_char_z(j); }
- else { write_z_char_z(3); write_z_char_z(j-32); }
+ { /* abbreviations run from MAX_DYNAMIC_STRINGS to 96 */
+ j += MAX_DYNAMIC_STRINGS;
+ write_z_char_z(j/32+1); write_z_char_z(j%32);
}
}
}
}
@@
-517,15
+514,25
@@
advance as part of 'Zcharacter table':", unicode);
else if (isdigit(text_in[i+1])!=0)
{ int d1, d2;
else if (isdigit(text_in[i+1])!=0)
{ int d1, d2;
- /* @.. */
+ /* @..
(dynamic string)
*/
d1 = character_digit_value[text_in[i+1]];
d2 = character_digit_value[text_in[i+2]];
if ((d1 == 127) || (d1 >= 10) || (d2 == 127) || (d2 >= 10))
error("'@..' must have two decimal digits");
else
d1 = character_digit_value[text_in[i+1]];
d2 = character_digit_value[text_in[i+2]];
if ((d1 == 127) || (d1 >= 10) || (d2 == 127) || (d2 >= 10))
error("'@..' must have two decimal digits");
else
- { i+=2;
- write_z_char_z(1); write_z_char_z(d1*10 + d2);
+ {
+ j = d1*10 + d2;
+ if (!glulx_mode && j >= 96)
+ { error("Z-machine dynamic strings are limited to 96");
+ j = 0;
+ }
+ if (j >= MAX_DYNAMIC_STRINGS) {
+ memoryerror("MAX_DYNAMIC_STRINGS", MAX_DYNAMIC_STRINGS);
+ j = 0;
+ }
+ i+=2;
+ write_z_char_z(j/32+1); write_z_char_z(j%32);
}
}
else
}
}
else
@@
-1573,6
+1580,8
@@
static void dictionary_prepare_z(char *dword, uchar *optresult)
applying to the text of dictionary entries: first produce a sequence
of 6 (v3) or 9 (v4+) Z-characters */
applying to the text of dictionary entries: first produce a sequence
of 6 (v3) or 9 (v4+) Z-characters */
+ int dictsize = (version_number==3) ? 6 : 9;
+
number_and_case = 0;
for (i=0, j=0; dword[j]!=0; i++, j++)
number_and_case = 0;
for (i=0, j=0; dword[j]!=0; i++, j++)
@@
-1588,7
+1597,7
@@
to give number of dictionary word", dword);
}
break;
}
}
break;
}
- if (i>=
9
) break;
+ if (i>=
dictsize
) break;
k=(int) dword[j];
if (k==(int) '\'')
k=(int) dword[j];
if (k==(int) '\'')
@@
-2210,7
+2219,6
@@
extern void init_text_vars(void)
grandflags = NULL;
no_chars_transcribed = 0;
is_abbreviation = FALSE;
grandflags = NULL;
no_chars_transcribed = 0;
is_abbreviation = FALSE;
- put_strings_in_low_memory = FALSE;
for (j=0; j<256; j++) abbrevs_lookup[j] = -1;
for (j=0; j<256; j++) abbrevs_lookup[j] = -1;