+ for (i=0; i<total_files; i++) close_sourcefile(i+1);
+}
+
+/* ------------------------------------------------------------------------- */
+/* Register an #origsource filename. This goes in the InputFiles table, */
+/* but we do not open the file or advance current_input_file. */
+/* ------------------------------------------------------------------------- */
+
+extern int register_orig_sourcefile(char *filename)
+{
+ int ix;
+
+ /* If the filename has already been used as an origsource filename,
+ return that entry. We check the most-recently-used file first, and
+ then search the list. */
+ if (current_origsource_file > 0 && current_origsource_file <= total_files) {
+ if (!strcmp(filename, InputFiles[current_origsource_file-1].filename))
+ return current_origsource_file;
+ }
+
+ for (ix=0; ix<total_files; ix++) {
+ if (InputFiles[ix].is_input)
+ continue;
+ if (!strcmp(filename, InputFiles[ix].filename)) {
+ current_origsource_file = ix+1;
+ return current_origsource_file;
+ }
+ }
+
+ /* This filename has never been used before. Allocate a new InputFiles
+ entry. */
+
+ char *name = filename; /* no translation */
+
+ if (total_files == MAX_SOURCE_FILES)
+ memoryerror("MAX_SOURCE_FILES", MAX_SOURCE_FILES);
+
+ if (filename_storage_left <= (int)strlen(name))
+ memoryerror("MAX_SOURCE_FILES", MAX_SOURCE_FILES);
+
+ filename_storage_left -= strlen(name)+1;
+ strcpy(filename_storage_p, name);
+ InputFiles[total_files].filename = filename_storage_p;
+
+ filename_storage_p += strlen(name)+1;
+
+ if (debugfile_switch)
+ { debug_file_printf("<source index=\"%d\">", total_files);
+ debug_file_printf("<given-path>");
+ debug_file_print_with_entities(filename);
+ debug_file_printf("</given-path>");
+ debug_file_printf("<language>Inform 7</language>");
+ debug_file_printf("</source>");
+ }
+
+ InputFiles[total_files].handle = NULL;
+ InputFiles[total_files].is_input = FALSE;
+
+ total_files++;
+ current_origsource_file = total_files;
+ return current_origsource_file;