Features and cleanups to angband-2.9.6-alpha3. L64.dif Portability: Eliminate L64. Use ANSI C's instead. charset.dif Portability: Make angband mostly charset-indepentent. conf-modules.dif Feature: Implement ./configure --enable-. conf-unused.dif Cleanup/Portability: Remove unused symbols from configure. datehack.dif Cleanup: Kill HIGHSCORE_DATE_HACK. gcu-win.dif Possible bugfix: Synchronize WINDOWS in main-gcu with main-cap. h-include.dif Comment: Change h-include.h to h-system.h in h-type.h. mk-rm.dif Bugfix: Makefile `\command' => `-command'. modules.dif Feature: Better usage line. Factor out module declarations. my_fgets.dif Feature: Handle lines that do not end with \n, and long lines. save-errno.dif Bugfix: Protect errno from signal handlers. sizeof-attr.dif Cleanup: Use N_ELEMENTS(*_to_attr) vowel.dif Comment: Y is not a `vowel' in is_a_vowel(). Makefile.std Feature: Module/feature-driven Makefile.std d-space.txt Cleanup: Move spaces at the end of monster.txt D: lines. -- Hallvard B. Furuseth Comments copied from the top of each file: ====== L64.dif ====== Portability: Eliminate L64. Use ANSI C's instead. The patches to *.h do the job. The final patch to z-util.c can be omitted, it's just an add-on which checks that the integer types are as desired. ====== charset.dif ====== Portability: Make angband mostly charset-indepentent. This patch is in 3 parts. #1 and #2 can be applied independently of each other, #3 assumes both have been applied. #1: - In wiz_create_itemtype(), use an offset into "abcd..." instead of computing the label as base_char+index. While I'm at it, increase the max number of items from 57 to 60 by adding 3 new label characters (%, &, *). It was 57 = 20+20+17 because of the overlap '0' + 17 == 'A'. - Change one (ch >= '0' && ch <= '9') to isdigit() in util.c. #2: - Introduce UN_KTRL() to match KTRL(), and use KTRL() and UN_KTRL() in text_to_ascii() and ascii_to_text(). No actual change in the computations, it's just written clearer now. I do wonder if KTRL() (and UN_KTRL()) can be right for VM, though: I would have thought KTRL(letter) would be == A2I(letter)+1, but then there would be no need for an alphatoindex() function. Oh well, hopefully the author of the VM port knew what he was doing. #3: - Update an h-system.h comment about VMS charsets. That takes care of most charset-dependencies I can see, except - A2I() & co, - expecting control chars to be 0-31 & 127, normal chars 32-126, - main-acn.c expects '0' + number == 'number', which is an ANSI C requirement anyway. ====== conf-modules.dif ====== Feature: Implement ./configure --enable-. ** THIS PATCH DEPENDS ON conf-unused.dif ** ** For some reason, this breaks size_t detection in autoconf 2.13, ** ** so apply the const/size_t patch in conf-unused.dif first. ** --enable- will attempt to compile into Angband. If libraries or include files for are missing, it is disabled despite --enable-. Also, --disable-x11 --disable-xaw --disable-xpj implies --without-x. Note: -enable-vcs does not test if /dev/vcsa0 exists, or anything like that. I didn't know whether or not all Linux computers have vcs. Maybe the compiling host doesn't have it, but the users's host does. Note: I've put all the -enable options inside `if !cygwin', since that seems to be how X11 is done. I don't know cygwin, so I don't know if this is the right thing for the other modules too. Note: These changes could use some re-indentation of old code, but then the patch would be much bigger. Tell me if you prefer that anyway. Or maybe I should submit a separate whitespace patch, to re-indent code and reformat comments all over Angband. ====== conf-unused.dif ====== Cleanup/Portability: Remove unused symbols from configure. ** THIS PATCH IS NEEDED BY conf-modules.dif ** The following symbols are set by configure but never used: * STDC_HEADERS from AC_HEADER_STDC. The ANSI headers are used unconditionally e.g. in h-system.h. * HAVE_*_H from AC_CHECK_HEADERS. The various headers are used unconditionally or #if . * TM_IN_SYS_TIME from AC_STRUCT_TM. * gcc -traditional. It doesn't work since the source uses prototypes. * If AC_FUNC_MEMCMP hits, it only adds memcmp.o to $LIBOBJS which is not used, and Angband has no matching memcmp.c source file anyway. memcmp() is used in z-virt.h. * RETSIGTYPE from AC_TYPE_SIGNAL. files.c's signal handlers return void. * HAVE_STRFTIME. strftime() is used unconditionally in Lua and main-acn.c, and if !defined(HIGHSCORE_DATE_HACK) in files.c. * HAVE_VPRINTF/HAVE_DOPRNT from AC_FUNC_VPRINTF. main-acn.c uses vsprintf() unconditionally, otherwise the functions are not used. * Most HAVE_s from AC_CHECK_FUNCS. They are used unconditionally (e.g. strtol()) or #if . So: The 1st configure.in patch removes these, except some header tests, and inserts some new header tests. The h-config.h patch removes an obsolete comment about string*.h. (USG is still used to decide if sys/params.h should be #included, so the comment is right except that the the example string*.h is wrong.) Then the h-system.h patch adds C code to use the remaining header tests. If you don't want the h-system.h patch (yet), you can instead delete the entire AC_CHECK_HEADERS() and AC_HEADER_TIME statements from configure.in. The h-system.h patch will be back in a later patch set from me, unless you tell me you are not interested:-) Finally, another configure.in patch removes AC_TYPE_SIZE_T and AC_C_CONST, since (a) ANSI C has size_t & const and (b) Lua uses them without autoconf.h. I put that in an optional patch since I don't know where you are going with portability. ====== datehack.dif ====== Cleanup: Kill HIGHSCORE_DATE_HACK. The HIGHSCORE_DATE_HACK date format is not Y2K-compliant. (Is it MMM (D)D YY or MMM (Y)Y DD? We used the format "DD. MMM YY" here.) And if it exists for C variants without strftime(), it's not needed since strftime() exists in ANSI C and is used in Lua anyway. ====== gcu-win.dif ====== Possible bugfix: Synchronize WINDOWS in main-gcu with main-cap. Angband 2.9.3 added '|| defined(WINDOWS)' in main-cap.c, but not in the matching code in main-gcu.c. I expect that's a bug. Um. Except I have a vague feeling I may have said that before, so maybe not... ====== h-include.dif ====== Comment: Change h-include.h to h-system.h in h-type.h. ====== mk-rm.dif ====== Bugfix: Makefile `\command' => `-command'. On UNIX Make, use `-command' to ignore exit status from a command. I've never heard of `\command', I don't know where that is used. It does not suppress errors. While I'm at it, combine some `rm' commands into one command. ====== modules.dif ====== Feature: Better usage line. Factor out module declarations. This patch - improves the usage message in main.c, e,g. prints a help_[] string which is added for each module in the main-*.c files. - moves module declarations from main.c to a new file modules.h. It is #included from externs.h and main.c. They #define a macro MODULE(), which modules.h expands once for each module. - gives each init_() the same prototype so they can be called via a function pointer. - updates Makefile dependencies and TODO. The help messages for modules DOS, EMX (OS/2), and VME (VM/ESA) could use some more text by someone who knows them. Main changes to the usage message: - add + after -m: " module description, subopts" lines, + after -o: "(default)" + after -s[num]: "(default: 10)" + after -f: "(verbose)" (-f does that at least in Vanilla), + after -w: a note that it can resurrect a dead player (since how to turn on `cheat death' without being marked as a cheater if you _don't_ die seems to be a FAQ). - upcase letters matching the options, e.g. -n start a New character. (I thought of renaming -u to -u for the occasion, but that is misleading.) - reduce the main usage message to one string since I'm changing it anyway. It stays just below ANSI C's 509-chars-per-string limit. Note: Tell me if you prefer either of these variants: - Start modules.h with #ifndef MODULE # define MODULE(name) #endif so that modules.h can be used like any other .h file. #include it in the main*.c files so externs.h doesn't need to #include it. - Do not use ANSI C #stringification and concat##enation. Call MODULE("xxx",init_xxx,help_xxx) instead of MODULE(xxx) in modules.h. ====== my_fgets.dif ====== Feature: Handle lines that do not end with \n, and long lines. This patch fixes two buglets: * If the last line of a file does not end with newline, my_fgets() does not "see" that line. * my_fgets() could not read lines longer than 1024 characters. (BTW, with this patch it can be changed to use a smaller buffer, if you wish.) ====== save-errno.dif ====== Bugfix: Protect errno from signal handlers. The signal handlers do library calls, so they can modify errno in the middle of normal code. (Of course, they can mangle other things as well, but that's no reason not to protect what _can_ be protected.) ====== sizeof-attr.dif ====== Cleanup: Use N_ELEMENTS(*_to_attr) - Replace relevant 128s and a 256 with N_ELEMENTS(*_to_attr). - Replace tval_to_attr[o_ptr->tval & 0x7F] with tval_to_attr[o_ptr->tval % N_ELEMENTS(tval_to_attr)]. (None are in tight loops, and anyway `gcc -O' optimizes it back to `& 0x7F'. No trouble with the sign; tval is unsigned.) ====== vowel.dif ====== Comment: Y is not a `vowel' in is_a_vowel(). ====== Makefile.std ====== Feature: Module/feature-driven Makefile.std Here is a rewrite of Makefile.std which lets you pick (uncomment) what you want to compile, feature by feature and module by module, instead of a few selected compile commands for some sepecific module/feature combinations. If you have not applied modules.dif, remove 'modules.h' from INCS. (The modules.dif patch should reinsert it if you apply it later.) ====== d-space.txt ====== Cleanup: Move spaces at the end of monster.txt D: lines. TODO says: - Move spaces at the end of description lines in monster.txt to the beginning of the next line. This command does that while reformatting all D: lines to max-76-char lines, ignoring the old linebreaks. It leaves a backup in monster.txt~. (...)