X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=src%2Ftables.c;h=cea36903917e88d891b400be50c77f0e1c0d6f18;hb=56a5292888e1d46fe3033cd1d5c636051692453f;hp=505b1e6b6559fe728bbd5401546ecb2244d96e05;hpb=20cbfff96015938809d0e3da6cd0d83b76d27f14;p=inform.git diff --git a/src/tables.c b/src/tables.c index 505b1e6..cea3690 100644 --- a/src/tables.c +++ b/src/tables.c @@ -3,8 +3,8 @@ /* of dynamic memory, gluing together all the required */ /* tables. */ /* */ -/* Part of Inform 6.41 */ -/* copyright (c) Graham Nelson 1993 - 2022 */ +/* Part of Inform 6.42 */ +/* copyright (c) Graham Nelson 1993 - 2024 */ /* */ /* Inform is free software: you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ @@ -112,17 +112,23 @@ extern void write_serial_number(char *buffer) the ability to work out today's date */ time_t tt; tt=time(0); - if (serial_code_given_in_program) + if (serial_code_given_in_program) { strcpy(buffer, serial_code_buffer); - else + } + else { #ifdef TIME_UNAVAILABLE sprintf(buffer,"970000"); #else - strftime(buffer,10,"%y%m%d",localtime(&tt)); + /* Write a six-digit date, null-terminated. Fall back to "970000" + if that fails. */ + int len = strftime(buffer,7,"%y%m%d",localtime(&tt)); + if (len != 6) + sprintf(buffer,"970000"); #endif + } } -static char percentage_buffer[32]; +static char percentage_buffer[64]; static char *show_percentage(int32 x, int32 total) { @@ -132,9 +138,12 @@ static char *show_percentage(int32 x, int32 total) else if (x == 0) { sprintf(percentage_buffer, " ( --- )"); } - else { + else if (memory_map_setting < 3) { sprintf(percentage_buffer, " (%.1f %%)", (float)x * 100.0 / (float)total); } + else { + sprintf(percentage_buffer, " (%.1f %%, %d bytes)", (float)x * 100.0 / (float)total, x); + } return percentage_buffer; } @@ -146,6 +155,7 @@ static char *version_name(int v) case 4: return "Plus"; case 5: return "Advanced"; case 6: return "Graphical"; + case 7: return "Extended Alternate"; case 8: return "Extended"; } return "experimental format"; @@ -263,31 +273,34 @@ static void construct_storyfile_z(void) grammar_table_at=0, charset_at=0, headerext_at=0, terminating_chars_at=0, unicode_at=0, id_names_length=0, static_arrays_at=0; + int32 rough_size; int skip_backpatching = FALSE; char *output_called = "story file"; ASSERT_ZCODE(); - individual_name_strings = - my_calloc(sizeof(int32), no_individual_properties, - "identifier name strings"); - action_name_strings = - my_calloc(sizeof(int32), no_actions + no_fake_actions, - "action name strings"); - attribute_name_strings = - my_calloc(sizeof(int32), 48, - "attribute name strings"); - array_name_strings = - my_calloc(sizeof(int32), - no_symbols, - "array name strings"); + if (!OMIT_SYMBOL_TABLE) { + individual_name_strings = + my_calloc(sizeof(int32), no_individual_properties, + "identifier name strings"); + action_name_strings = + my_calloc(sizeof(int32), no_actions + no_fake_actions, + "action name strings"); + attribute_name_strings = + my_calloc(sizeof(int32), 48, + "attribute name strings"); + array_name_strings = + my_calloc(sizeof(int32), + no_symbols, + "array name strings"); - write_the_identifier_names(); + write_the_identifier_names(); + } /* We now know how large the buffer to hold our construction has to be */ - zmachine_paged_memory = my_malloc(rough_size_of_paged_memory_z(), - "output buffer"); + rough_size = rough_size_of_paged_memory_z(); + zmachine_paged_memory = my_malloc(rough_size, "output buffer"); /* Foolish code to make this routine compile on all ANSI compilers */ @@ -297,7 +310,8 @@ static void construct_storyfile_z(void) points its value will be recorded for milestones like "dictionary table start". It begins at 0x40, just after the header */ - mark = 0x40; + for (mark=0; mark<0x40; mark++) + p[mark] = 0x0; /* ----------------- Low Strings and Abbreviations -------------------- */ @@ -444,7 +458,7 @@ static void construct_storyfile_z(void) identifier_names_offset = mark; - if (TRUE) + if (!OMIT_SYMBOL_TABLE) { p[mark++] = no_individual_properties/256; p[mark++] = no_individual_properties%256; for (i=1; i rough_size) + compiler_error("Paged size exceeds rough estimate."); + Write_Code_At = mark; if (!OMIT_UNUSED_ROUTINES) { code_length = zmachine_pc; @@ -697,11 +731,10 @@ or less."); } if (excess > 0) - { char memory_full_error[80]; - sprintf(memory_full_error, + { + fatalerror_fmt( "The %s exceeds version-%d limit (%dK) by %d bytes", output_called, version_number, limit, excess); - fatalerror(memory_full_error); } /* --------------------------- Offsets -------------------------------- */ @@ -735,26 +768,24 @@ or less."); */ excess = code_length + code_offset - (scale_factor*((int32) 0x10000L)); if (excess > 0) - { char code_full_error[80]; - sprintf(code_full_error, + { + fatalerror_fmt( "The code area limit has been exceeded by %d bytes", excess); - fatalerror(code_full_error); } excess = strings_length + strings_offset - (scale_factor*((int32) 0x10000L)); if (excess > 0) - { char strings_full_error[140]; + { if (oddeven_packing_switch) - sprintf(strings_full_error, + fatalerror_fmt( "The strings area limit has been exceeded by %d bytes", excess); else - sprintf(strings_full_error, + fatalerror_fmt( "The code+strings area limit has been exceeded by %d bytes. \ Try running Inform again with -B on the command line.", excess); - fatalerror(strings_full_error); } } else @@ -848,12 +879,15 @@ or less."); if (!skip_backpatching) { backpatch_zmachine_image_z(); - for (i=1; i rough_size) + compiler_error("RAM size exceeds rough estimate."); + Out_Size = Write_RAM_At + RAM_Size; /* --------------------------- Offsets -------------------------------- */ @@ -1590,18 +1642,23 @@ static void display_frequencies() for (i=0; i