Update to commit af5309356bfa197d7a7ea09101c317f94e9b856b
authorJason Self <j@jxself.org>
Sun, 4 Apr 2021 17:16:54 +0000 (10:16 -0700)
committerJason Self <j@jxself.org>
Sun, 4 Apr 2021 17:16:54 +0000 (10:16 -0700)
Dated March 31 2021. These changes are similiarly relicensed to GPL
per Section 4(c)(ii) of the Artistic License 2.0.

22 files changed:
src/arrays.c
src/asm.c
src/bpatch.c
src/chars.c
src/directs.c
src/errors.c
src/expressc.c
src/expressp.c
src/files.c
src/header.h
src/inform.c
src/lexer.c
src/linker.c
src/memory.c
src/objects.c
src/states.c
src/symbols.c
src/syntax.c
src/tables.c
src/text.c
src/veneer.c
src/verbs.c

index c1f410ce34b9d47f1513c957c6ac5af927aaf18d..4c8f56feac5672331da185a4c0b9110eebd30991 100644 (file)
@@ -4,7 +4,7 @@
 /*               simpler form of the same thing.                             */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */
@@ -292,6 +292,9 @@ extern void make_global(int array_flag, int name_only)
     int array_type, data_type;
     int is_static = FALSE;
     assembly_operand AO;
+    
+    int extraspace;
+    int orig_area_size;
 
     int32 global_symbol;
     const char *global_name;
@@ -525,13 +528,11 @@ extern void make_global(int array_flag, int name_only)
 
     /*  Leave room to write the array size in later, if string/table array   */
     
-    int extraspace = 0;
+    extraspace = 0;
     if ((array_type==STRING_ARRAY) || (array_type==TABLE_ARRAY))
         extraspace += array_entry_size;
     if (array_type==BUFFER_ARRAY)
         extraspace += WORDSIZE;
-
-    int orig_area_size;
     
     if (!is_static) {
         orig_area_size = dynamic_array_area_size;
@@ -693,12 +694,14 @@ advance as part of 'Zcharacter table':", unicode);
     finish_array(i, is_static);
 
     if (debugfile_switch)
-    {   debug_file_printf("<array>");
+    {
+        int32 new_area_size;
+        debug_file_printf("<array>");
         debug_file_printf("<identifier>%s</identifier>", global_name);
         debug_file_printf("<value>");
         write_debug_array_backpatch(svals[global_symbol]);
         debug_file_printf("</value>");
-        int32 new_area_size = (!is_static ? dynamic_array_area_size : static_array_area_size);
+        new_area_size = (!is_static ? dynamic_array_area_size : static_array_area_size);
         debug_file_printf
             ("<byte-count>%d</byte-count>",
              new_area_size - array_base);
index e8a20fe9dd5a4f6708cfd9ca345e1b002164e861..faace9c168ad549a8c3e6ebfcacb751bd18931b9 100644 (file)
--- a/src/asm.c
+++ b/src/asm.c
@@ -2,7 +2,7 @@
 /*   "asm" : The Inform assembler                                            */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */
index 4e6aa4be6ed5acf0269b7a13c693600e2302d7fb..b3a467e1c107065df97ab53ccb13c5609cfdabf0 100644 (file)
@@ -3,7 +3,7 @@
 /*              correcting symbol values not known at compilation time       */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */
index 9bd257a8b706734a1c56abcad206d948473ec353..239d576fb26854133fbc5757e81cca881d24063b 100644 (file)
@@ -2,7 +2,7 @@
 /*   "chars" : Character set mappings and the Z-machine alphabet table       */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */
index fc725a0d611263044028c358f04f3a39839d602d..5df6b0b666f6a4249a0a29966205ec4194f48523 100644 (file)
@@ -2,7 +2,7 @@
 /*   "directs" : Directives (# commands)                                     */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */
@@ -106,9 +106,8 @@ extern int parse_given_directive(int internal_flag)
            if ((token_type == SEP_TT) && (token_value == SEMICOLON_SEP))
                return FALSE;
 
-           /* Z-code has a 64-abbrev limit; Glulx doesn't. */
-           if (!glulx_mode && no_abbreviations==64)
-           {   error("All 64 abbreviations already declared");
+           if (!glulx_mode && no_abbreviations==96)
+           {   error("All 96 Z-machine abbreviations already declared");
                panic_mode_error_recovery(); return FALSE;
            }
            if (no_abbreviations==MAX_ABBREVS)
@@ -608,6 +607,10 @@ Fake_Action directives to a point after the inclusion of \"Parser\".)");
         {   error("'LowString' cannot be used in -M (Module) mode");
             panic_mode_error_recovery(); return FALSE;
         }
+        if (glulx_mode) {
+            error("The LowString directive has no meaning in Glulx.");
+            panic_mode_error_recovery(); return FALSE;
+        }
         get_next_token(); i = token_value;
         if (token_type != SYMBOL_TT)
             return ebf_error_recover("new low string name", token_text);
index c1e62412873f35669fdde5852bfb38fd56ceef0e..08dd87efa21a698074499f4fe492b907a668e59e 100644 (file)
@@ -3,7 +3,7 @@
 /*              (with error throwback code for RISC OS machines)             */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */
@@ -93,6 +93,10 @@ static void print_preamble(void)
 
 static char *location_text(brief_location report_line)
 {
+    int j;
+    char *p;
+    int len;
+
     /* Convert the location to a brief string. 
        (Some error messages need to report a secondary location.)
        This uses the static buffer other_pos_buff. */
@@ -104,9 +108,6 @@ static char *location_text(brief_location report_line)
     errpos.main_flag = 0;
     errpos.orig_source = NULL;
     export_brief_location(report_line, &errpos);
-
-    int j;
-    char *p;
     
     j = errpos.file_number;
     if (j <= 0 || j > total_files) p = errpos.source;
@@ -114,7 +115,7 @@ static char *location_text(brief_location report_line)
     
     if (!p) p = "";
 
-    int len = 0;
+    len = 0;
     
     if (!(errpos.main_flag)) {
         snprintf(other_pos_buff+len, ERROR_BUFLEN-len,
index 3b5fe6a4b63c274f5cb625dbd5ed4ac7bc7b2e2d..378582ed5d08873a74273d7ce6dcd99689a22bc9 100644 (file)
@@ -2,7 +2,7 @@
 /*   "expressc" :  The expression code generator                             */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */
index ce063c2fd886188ebf13b566412e1aa27ac1701a..c5577db6e5145dc52cb2d638087df6ade5be2a5e 100644 (file)
@@ -2,7 +2,7 @@
 /*   "expressp" :  The expression parser                                     */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */
index c4651399eb48a89867abf76c71e8640ba3def705..70cfc90705de86c9289e4f8e72e2c6e91593aee0 100644 (file)
@@ -8,7 +8,7 @@
 /*             settings and are very host OS-dependent.                      */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */
@@ -195,6 +195,7 @@ extern void close_all_source(void)
 extern int register_orig_sourcefile(char *filename)
 {
     int ix;
+    char *name;
 
     /* If the filename has already been used as an origsource filename,
        return that entry. We check the most-recently-used file first, and
@@ -216,7 +217,7 @@ extern int register_orig_sourcefile(char *filename)
     /* This filename has never been used before. Allocate a new InputFiles
        entry. */
 
-    char *name = filename; /* no translation */
+    name = filename; /* no translation */
 
     if (total_files == MAX_SOURCE_FILES)
         memoryerror("MAX_SOURCE_FILES", MAX_SOURCE_FILES);
index 652a0c8b83dc08336644380ccef03b35c8e8693e..82d064456d038bc0639685deb0ae45c975cbb773 100644 (file)
@@ -4,7 +4,7 @@
 /*                              Inform 6.35                                  */
 /*                                                                           */
 /*   This header file and the others making up the Inform source code are    */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   copyright (c) Graham Nelson 1993 - 2021                                 */
 /*                                                                           */
 /* This file is part of Inform.                                              */
 /*                                                                           */
@@ -2538,7 +2538,7 @@ extern int MAX_QTEXT_SIZE,  MAX_SYMBOLS,    HASH_TAB_SIZE,   MAX_DICT_ENTRIES,
            MAX_EXPRESSION_NODES, MAX_LABELS,            MAX_LINESPACE,
            MAX_LOW_STRINGS,      MAX_CLASSES,           MAX_VERBS,
            MAX_VERBSPACE,        MAX_ARRAYS,            MAX_INCLUSION_DEPTH,
-           MAX_SOURCE_FILES;
+           MAX_SOURCE_FILES,     MAX_DYNAMIC_STRINGS;
 
 extern int32 MAX_STATIC_STRINGS, MAX_ZCODE_SIZE, MAX_LINK_DATA_SIZE,
            MAX_TRANSCRIPT_SIZE,  MAX_INDIV_PROP_TABLE_SIZE,
@@ -2745,8 +2745,6 @@ extern int32 static_strings_extent;
 extern int32 no_strings, no_dynamic_strings;
 extern int no_unicode_chars;
 
-#define MAX_DYNAMIC_STRINGS (64)
-
 typedef struct unicode_usage_s unicode_usage_t;
 struct unicode_usage_s {
   int32 ch;
index 93bfcc7964f738609f7f4a418a9743e81ce78e5b..9b30ad3b8ff0d3610fa74c63dddeed3fff3d1b56 100644 (file)
@@ -3,7 +3,7 @@
 /*               conventions, ICL (Inform Command Line) files, main          */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */
@@ -219,6 +219,34 @@ static void select_target(int targ)
       DICT_ENTRY_FLAG_POS = (4+DICT_WORD_BYTES);
     }
   }
+
+  if (!targ) {
+    /* Z-machine */
+    /* The Z-machine's 96 abbreviations are used for these two purposes.
+       Make sure they are set consistently. If exactly one has been
+       set non-default, set the other to match. */
+    if (MAX_DYNAMIC_STRINGS == 32 && MAX_ABBREVS != 64) {
+        MAX_DYNAMIC_STRINGS = 96 - MAX_ABBREVS;
+    }
+    if (MAX_ABBREVS == 64 && MAX_DYNAMIC_STRINGS != 32) {
+        MAX_ABBREVS = 96 - MAX_DYNAMIC_STRINGS;
+    }
+    if (MAX_ABBREVS + MAX_DYNAMIC_STRINGS != 96
+        || MAX_ABBREVS < 0
+        || MAX_DYNAMIC_STRINGS < 0) {
+      warning("MAX_ABBREVS plus MAX_DYNAMIC_STRINGS must be 96 in Z-code; resetting both");
+      MAX_DYNAMIC_STRINGS = 32;
+      MAX_ABBREVS = 64;
+    }
+  }
+  else {
+    if (MAX_DYNAMIC_STRINGS > 100) {
+      MAX_DYNAMIC_STRINGS = 100;
+      warning("MAX_DYNAMIC_STRINGS cannot exceed 100; resetting to 100");
+      /* This is because they are specified in text literals like "@00",
+         with two digits. */
+    }
+  }
 }
 
 /* ------------------------------------------------------------------------- */
@@ -1238,7 +1266,7 @@ static void cli_print_help(int help_level)
     printf(
 "\nThis program is a compiler of Infocom format (also called \"Z-machine\")\n\
 story files, as well as \"Glulx\" story files:\n\
-Copyright (c) Graham Nelson 1993 - 2020.\n\n");
+Copyright (c) Graham Nelson 1993 - 2021.\n\n");
 
    /* For people typing just "inform", a summary only: */
 
@@ -1917,8 +1945,9 @@ static void read_command_line(int argc, char **argv)
     for (i=1, cli_files_specified=0; i<argc; i++)
         if (argv[i][0] == '-' && argv[i][1] == '-') {
             char *nextarg = NULL;
+            int consumed2;
             if (i+1 < argc) nextarg = argv[i+1];
-            int consumed2 = execute_dashdash_command(argv[i]+2, nextarg);
+            consumed2 = execute_dashdash_command(argv[i]+2, nextarg);
             if (consumed2 && i+1 < argc) {
                 i++;
             }
index b741ff0bdc99bd63e0d311a465d95989c0913fd6..f79a6e6118c823aed23552c54b77431786ca41c0 100644 (file)
@@ -2,7 +2,7 @@
 /*   "lexer" : Lexical analyser                                              */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */
@@ -953,6 +953,8 @@ extern int is_systemfile(void)
 
 extern void set_origsource_location(char *source, int32 line, int32 charnum)
 {
+    int file_no;
+
     if (!source) {
         /* Clear the Origsource declaration. */
         CurrentLB->orig_file = 0;
@@ -963,7 +965,7 @@ extern void set_origsource_location(char *source, int32 line, int32 charnum)
     }
 
     /* Get the file number for a new or existing InputFiles entry. */
-    int file_no = register_orig_sourcefile(source);
+    file_no = register_orig_sourcefile(source);
 
     CurrentLB->orig_file = file_no;
     CurrentLB->orig_source = InputFiles[file_no-1].filename;
index ab9dabe60cf7c380a276b0e8999f953bf3d48082..d05310a3909704c8e3f0a048bce66e0d74716bb0 100644 (file)
@@ -2,7 +2,7 @@
 /*   "linker" : For compiling and linking modules                            */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */
index 9b4a6693994ca37d54a323e6401bd1c197297423..6b817274161d7bacaa5f61a576bfd701155bb347 100644 (file)
@@ -3,7 +3,7 @@
 /*              (For "memoryerror", see "errors.c")                          */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */
@@ -255,6 +255,7 @@ int MAX_DICT_ENTRIES;
 int MAX_STATIC_DATA;
 int MAX_PROP_TABLE_SIZE;
 int MAX_ABBREVS;
+int MAX_DYNAMIC_STRINGS;
 int MAX_EXPRESSION_NODES;
 int MAX_VERBS;
 int MAX_VERBSPACE;
@@ -299,6 +300,7 @@ static int MAX_LOCAL_VARIABLES_z, MAX_LOCAL_VARIABLES_g;
 static int DICT_WORD_SIZE_z, DICT_WORD_SIZE_g;
 static int NUM_ATTR_BYTES_z, NUM_ATTR_BYTES_g;
 static int ALLOC_CHUNK_SIZE_z, ALLOC_CHUNK_SIZE_g;
+static int MAX_DYNAMIC_STRINGS_z, MAX_DYNAMIC_STRINGS_g;
 
 /* ------------------------------------------------------------------------- */
 /*   Memory control from the command line                                    */
@@ -319,6 +321,7 @@ static void list_memory_sizes(void)
     printf("|  %25s = %-7d |\n","DICT_WORD_SIZE",DICT_WORD_SIZE);
     if (glulx_mode)
       printf("|  %25s = %-7d |\n","DICT_CHAR_SIZE",DICT_CHAR_SIZE);
+    printf("|  %25s = %-7d |\n","MAX_DYNAMIC_STRINGS",MAX_DYNAMIC_STRINGS);
     printf("|  %25s = %-7d |\n","MAX_EXPRESSION_NODES",MAX_EXPRESSION_NODES);
     printf("|  %25s = %-7d |\n","MAX_GLOBAL_VARIABLES",MAX_GLOBAL_VARIABLES);
     printf("|  %25s = %-7d |\n","HASH_TAB_SIZE",HASH_TAB_SIZE);
@@ -396,8 +399,6 @@ extern void set_memory_sizes(int size_flag)
         MAX_PROP_TABLE_SIZE_z = 30000;
         MAX_PROP_TABLE_SIZE_g = 60000;
 
-        MAX_ABBREVS = 64;
-
         MAX_EXPRESSION_NODES = 100;
         MAX_VERBS = 200;
         MAX_VERBSPACE = 4096;
@@ -446,8 +447,6 @@ extern void set_memory_sizes(int size_flag)
         MAX_PROP_TABLE_SIZE_z = 15000;
         MAX_PROP_TABLE_SIZE_g = 30000;
 
-        MAX_ABBREVS = 64;
-
         MAX_EXPRESSION_NODES = 100;
         MAX_VERBS = 140;
         MAX_VERBSPACE = 4096;
@@ -496,8 +495,6 @@ extern void set_memory_sizes(int size_flag)
         MAX_PROP_TABLE_SIZE_z = 8000;
         MAX_PROP_TABLE_SIZE_g = 16000;
 
-        MAX_ABBREVS = 64;
-
         MAX_EXPRESSION_NODES = 40;
         MAX_VERBS = 110;
         MAX_VERBSPACE = 2048;
@@ -539,6 +536,9 @@ extern void set_memory_sizes(int size_flag)
     DICT_WORD_SIZE_g = 9;
     NUM_ATTR_BYTES_z = 6;
     NUM_ATTR_BYTES_g = 7;
+    MAX_ABBREVS = 64;
+    MAX_DYNAMIC_STRINGS_z = 32;
+    MAX_DYNAMIC_STRINGS_g = 64;
     /* Backwards-compatible behavior: allow for a unicode table
        whether we need one or not. The user can set this to zero if
        there's no unicode table. */
@@ -569,6 +569,7 @@ extern void adjust_memory_sizes()
     DICT_WORD_SIZE = DICT_WORD_SIZE_z;
     NUM_ATTR_BYTES = NUM_ATTR_BYTES_z;
     ALLOC_CHUNK_SIZE = ALLOC_CHUNK_SIZE_z;
+    MAX_DYNAMIC_STRINGS = MAX_DYNAMIC_STRINGS_z;
     INDIV_PROP_START = 64;
   }
   else {
@@ -579,6 +580,7 @@ extern void adjust_memory_sizes()
     DICT_WORD_SIZE = DICT_WORD_SIZE_g;
     NUM_ATTR_BYTES = NUM_ATTR_BYTES_g;
     ALLOC_CHUNK_SIZE = ALLOC_CHUNK_SIZE_g;
+    MAX_DYNAMIC_STRINGS = MAX_DYNAMIC_STRINGS_g;
     INDIV_PROP_START = 256;
   }
 }
@@ -696,7 +698,13 @@ static void explain_parameter(char *command)
     if (strcmp(command,"MAX_ABBREVS")==0)
     {   printf(
 "  MAX_ABBREVS is the maximum number of declared abbreviations.  It is not \n\
-  allowed to exceed 64.\n");
+  allowed to exceed 96 in Z-code.\n");
+        return;
+    }
+    if (strcmp(command,"MAX_DYNAMIC_STRINGS")==0)
+    {   printf(
+"  MAX_DYNAMIC_STRINGS is the maximum number of string substitution variables\n\
+  (\"@00\").  It is not allowed to exceed 96 in Z-code or 100 in Glulx.\n");
         return;
     }
     if (strcmp(command,"MAX_ARRAYS")==0)
@@ -1033,6 +1041,10 @@ extern void memory_command(char *command)
                 flag=2;
             if (strcmp(command,"MAX_ABBREVS")==0)
                 MAX_ABBREVS=j, flag=1;
+            if (strcmp(command,"MAX_DYNAMIC_STRINGS")==0)
+            {   MAX_DYNAMIC_STRINGS=j, flag=1;
+                MAX_DYNAMIC_STRINGS_g=MAX_DYNAMIC_STRINGS_z=j;
+            }
             if (strcmp(command,"MAX_ARRAYS")==0)
                 MAX_ARRAYS=j, flag=1;
             if (strcmp(command,"MAX_EXPRESSION_NODES")==0)
index 9d54ec21a30e3537100aa49ffdddc6571fc7556a..242ec3cdc16fac241f4a5edf07fc8f76c0e808e8 100644 (file)
@@ -7,7 +7,7 @@
 /*                    specifications for the object-maker.                   */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */
@@ -1433,7 +1433,8 @@ the names '%s' and '%s' actually refer to the same property",
             if (token_type == SEGMENT_MARKER_TT) { put_token_back(); break; }
 
             if ((!individual_property) && (property_number==1)
-                && (token_type != SQ_TT) && (token_type != DQ_TT)
+                && ((token_type != SQ_TT) || (strlen(token_text) <2 )) 
+                && (token_type != DQ_TT)
                 )
                 warning ("'name' property should only contain dictionary words");
 
index 8feb6a765148e61c1c0c4f8c9021a3994f7146e7..3f0e8740a09a85b90266f8d603a2e1a74fc816e4 100644 (file)
@@ -2,7 +2,7 @@
 /*   "states" :  Statement translator                                        */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */
@@ -1191,6 +1191,14 @@ static void parse_statement_z(int break_label, int continue_label)
 
                  statements.enabled = TRUE;
                  get_next_token();
+
+                 /* An #if directive around the ELSE clause is legal. */
+                 while ((token_type == SEP_TT) && (token_value == HASH_SEP))
+                 {   parse_directive(TRUE);
+                     statements.enabled = TRUE;
+                     get_next_token();
+                 }
+                 
                  if ((token_type == STATEMENT_TT) && (token_value == ELSE_CODE))
                  {   flag = TRUE;
                      if (ln >= 0)
@@ -1589,6 +1597,15 @@ static void parse_statement_z(int break_label, int continue_label)
                  assemblez_2_to(loadw_zc, AO, AO2, AO3);
                  AO2 = code_generate(parse_expression(QUANTITY_CONTEXT),
                      QUANTITY_CONTEXT, -1);
+                 if (is_constant_ot(AO2.type) && AO2.marker == 0) {
+                     if (AO2.value >= 96)
+                     {   error("Z-machine dynamic strings are limited to 96");
+                         AO2.value = 0;
+                     }
+                     if (AO2.value < 0 || AO2.value >= MAX_DYNAMIC_STRINGS) {
+                         memoryerror("MAX_DYNAMIC_STRINGS", MAX_DYNAMIC_STRINGS);
+                     }
+                 }
                  get_next_token();
                  if (token_type == DQ_TT)
                  {   INITAOT(&AO4, LONG_CONSTANT_OT);
@@ -2165,6 +2182,14 @@ static void parse_statement_g(int break_label, int continue_label)
 
                  statements.enabled = TRUE;
                  get_next_token();
+                 
+                 /* An #if directive around the ELSE clause is legal. */
+                 while ((token_type == SEP_TT) && (token_value == HASH_SEP))
+                 {   parse_directive(TRUE);
+                     statements.enabled = TRUE;
+                     get_next_token();
+                 }
+                 
                  if ((token_type == STATEMENT_TT) && (token_value == ELSE_CODE))
                  {   flag = TRUE;
                      if (ln >= 0)
@@ -2513,6 +2538,11 @@ static void parse_statement_g(int break_label, int continue_label)
         case STRING_CODE:
                  AO2 = code_generate(parse_expression(QUANTITY_CONTEXT),
                      QUANTITY_CONTEXT, -1);
+                 if (is_constant_ot(AO2.type) && AO2.marker == 0) {
+                     if (AO2.value < 0 || AO2.value >= MAX_DYNAMIC_STRINGS) {
+                         memoryerror("MAX_DYNAMIC_STRINGS", MAX_DYNAMIC_STRINGS);
+                     }
+                 }
                  get_next_token();
                  if (token_type == DQ_TT)
                  {   INITAOT(&AO4, CONSTANT_OT);
index d2f42dac576c4c2d7e01a8ca89b9fd074c9fc173..90ec3bfe427cdc85fa9e2586bbbc68d8ad144fbd 100644 (file)
@@ -2,7 +2,7 @@
 /*   "symbols" :  The symbols table; creating stock of reserved words        */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */
@@ -1223,6 +1223,8 @@ uint32 df_stripped_offset_for_code_offset(uint32 offset, int *stripped)
 {
     df_function_t *func;
     int count;
+    int beg;
+    int end;
 
     if (!track_unused_routines)
         compiler_error("DF: df_stripped_offset_for_code_offset called, but function references have not been mapped");
@@ -1250,13 +1252,14 @@ uint32 df_stripped_offset_for_code_offset(uint32 offset, int *stripped)
 
     /* Do a binary search. Maintain beg <= res < end, where res is the
        function containing the desired address. */
-    int beg = 0;
-    int end = df_functions_sorted_count;
+    beg = 0;
+    end = df_functions_sorted_count;
 
     /* Set stripped flag until we decide on a non-stripped function. */
     *stripped = TRUE;
 
     while (1) {
+        int new;
         if (beg >= end) {
             error("DF: offset_for_code_offset: Could not locate address.");
             return 0;
@@ -1268,7 +1271,7 @@ uint32 df_stripped_offset_for_code_offset(uint32 offset, int *stripped)
             *stripped = FALSE;
             return func->newaddress + (offset - func->address);
         }
-        int new = (beg + end) / 2;
+        new = (beg + end) / 2;
         if (new <= beg || new >= end)
             compiler_error("DF: binary search went off the rails");
 
index 08e61c90da922db2ccc7dc159f2026419d8683bc..982d49f101ff934383b19d180d42ededd6f73600 100644 (file)
@@ -2,7 +2,7 @@
 /*   "syntax" : Syntax analyser and compiler                                 */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */
index 8a29da8b3d7f3bd9534cd03911b49f30e0248f7c..1f7ba01dff72d9d58c4111030a31e16dfb34a68a 100644 (file)
@@ -4,7 +4,7 @@
 /*               tables.                                                     */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */
@@ -295,13 +295,23 @@ static void construct_storyfile_z(void)
         p[0x42+i]=low_strings[i];
 
     abbrevs_at = mark;
-    for (i=0; i<3*32; i++)                       /* Initially all 96 entries */
-    {   p[mark++]=0; p[mark++]=0x20;                     /* are set to "   " */
+    
+    if (MAX_ABBREVS + MAX_DYNAMIC_STRINGS != 96)
+        fatalerror("MAX_ABBREVS + MAX_DYNAMIC_STRINGS is not 96");
+    
+    /* Initially all 96 entries are set to "   ". (We store half of 0x40,
+       the address of the "   " we wrote above.) */
+    for (i=0; i<3*32; i++)
+    {   p[mark++]=0; p[mark++]=0x20;
     }
-    for (i=0; i<no_abbreviations; i++)            /* Write any abbreviations */
-    {   j=abbrev_values[i];                            /* into banks 2 and 3 */
-        p[abbrevs_at+64+2*i]=j/256;               /* (bank 1 is reserved for */
-        p[abbrevs_at+65+2*i]=j%256;                   /* "variable strings") */
+    
+    /* Entries from 0 to MAX_DYNAMIC_STRINGS (default 32) are "variable 
+       strings". Write the abbreviations after these. */
+    k = abbrevs_at+2*MAX_DYNAMIC_STRINGS;
+    for (i=0; i<no_abbreviations; i++)
+    {   j=abbrev_values[i];
+        p[k++]=j/256;
+        p[k++]=j%256;
     }
 
     /*  ------------------- Header extension table ------------------------- */
index 8a1ae31058614acefb4d4832484545d76eb9089b..064a5da340638c267067b6d86495d63334b7847e 100644 (file)
@@ -2,7 +2,7 @@
 /*   "text" : Text translation, the abbreviations optimiser, the dictionary  */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */
@@ -38,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                           */
-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
@@ -459,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 (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);
             }
         }
 
@@ -516,15 +514,25 @@ advance as part of 'Zcharacter table':", unicode);
             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
-                {   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
@@ -2211,7 +2219,6 @@ extern void init_text_vars(void)
     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;
 
index cbb4c3edc54721a35c86193fd2a9abc2c10811d0..d32ad40c125db1e0460160e8e22cce81e24f235b 100644 (file)
@@ -4,7 +4,7 @@
 /*              provide                                                      */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */
index 8b7e64974ac004b16ced8277312eba82a3100991..2caa67cb4d4e2998b042299c0a50d3c100ffdcda 100644 (file)
@@ -3,7 +3,7 @@
 /*              Verb and Extend.                                             */
 /*                                                                           */
 /*   Part of Inform 6.35                                                     */
-/*   copyright (c) Graham Nelson 1993 - 2020                                 */
+/*   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      */