Update to Inform v6.35
[inform.git] / src / verbs.c
index f9f13be90eb94530318d9fffdfaf756fa9d5c43b..962b32f847a3e9a46962745549da8488547e0ece 100644 (file)
@@ -2,9 +2,8 @@
 /*   "verbs" :  Manages actions and grammar tables; parses the directives    */
 /*              Verb and Extend.                                             */
 /*                                                                           */
-/*  Copyright (c) Graham Nelson 1993 - 2020                                  */
-/*                                                                           */
-/* 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      */
@@ -62,6 +61,8 @@ int no_adjectives;                     /* Number of adjectives made so far   */
 /*           for example the English verbs "take" and "drop" both normally   */
 /*           correspond in a game's dictionary to the same Inform verb.  An  */
 /*           Inform verb is essentially a list of grammar lines.             */
+/*           (Calling them "English verbs" is of course out of date. Read    */
+/*           this as jargon for "dict words which are verbs".                */
 /* ------------------------------------------------------------------------- */
 /*   Arrays defined below:                                                   */
 /*                                                                           */
@@ -92,6 +93,9 @@ static char *English_verb_list,        /* First byte of first record         */
 static int English_verb_list_size;     /* Size of the list in bytes
                                           (redundant but convenient)         */
 
+/* Maximum synonyms in a single Verb/Extend directive */
+#define MAX_VERB_SYNONYMS (32)
+
 /* ------------------------------------------------------------------------- */
 /*   Arrays used by this file                                                */
 /* ------------------------------------------------------------------------- */
@@ -146,13 +150,15 @@ extern void make_fake_action(void)
         ebf_error("new fake action name", token_text);
         panic_mode_error_recovery(); return;
     }
+    /* Action symbols (including fake_actions) may collide with other kinds of symbols. So we don't check that. */
 
     snprintf(action_sub, MAX_IDENTIFIER_LENGTH+4, "%s__A", token_text);
     i = symbol_index(action_sub, -1);
 
     if (!(sflags[i] & UNKNOWN_SFLAG))
     {   discard_token_location(beginning_debug_location);
-        ebf_error("new fake action name", token_text);
+        /* The user didn't know they were defining FOO__A, but they were and it's a problem. */
+        ebf_symbol_error("new fake action name", action_sub, typename(stypes[i]), slines[i]);
         panic_mode_error_recovery(); return;
     }
 
@@ -725,7 +731,8 @@ extern void make_verb(void)
 
     int Inform_verb, meta_verb_flag=FALSE, verb_equals_form=FALSE;
 
-    char *English_verbs_given[32]; int no_given = 0, i;
+    char *English_verbs_given[MAX_VERB_SYNONYMS];
+    int no_given = 0, i;
 
     directive_keywords.enabled = TRUE;
 
@@ -737,7 +744,12 @@ extern void make_verb(void)
     }
 
     while ((token_type == DQ_TT) || (token_type == SQ_TT))
-    {   English_verbs_given[no_given++] = token_text;
+    {
+        if (no_given >= MAX_VERB_SYNONYMS) {
+            error("Too many synonyms in a Verb directive.");
+            panic_mode_error_recovery(); return;
+        }
+        English_verbs_given[no_given++] = token_text;
         get_next_token();
     }