* Avoids unnecessary alarm(0) when it is about to be set again, only
cleans up after it’s all done.
* Renames DIRCHAR to LISPDIRCHAR to be more descriptive, adds LISPDIRSTR
for contexts where a string is required rather than a character.
* Avoids leaks of directory structures by ensuring that any opendir()
has a matching closedir(), with a timeout check, on the return path
* Ensures that closedir() calls that could smash errno happen after
errno is saved for Lisp’s consumption
* Simplifies code to take advantage of strlcpy()/strlcat() guarantee
that destination string is NUL terminated
* Reduces number of unnecessary copies into scratch buffer for file name
processing
* Removes some commented out code left over from copy/paste of functions
Unchecked strcpy/strcat can result in memory smashes if provided with
overly long source arguments. Replacing these with the strl... functions
protects against overruns of the destination memory.
Requires changing the signature of various functions to pass destination
storage size when destination argument is a pointer rather than something
amenable to sizeof() operator.
Unchecked writes to strings using strcpy and strcat can cause memory smashes,
replacing them with (destination) bounds checked strl... equivalents can
avoid this.
Incidentally, fix construction of file name for $HOME/.Xdefaults
Moves definitions of the quote_xxx functions from ufs.c where they are not
used to dir.c where they are used.
Adds a parameter to each of the quote_xxx functions to supply the length
of the storage allocated for the result string, and change strcpy() to
strlcpy() to avoid potential memory smash if used carelessly.
Replaces ConcNameAndVersion and ConcDirAndName macros with
conc_name_and_version and conc_dir_and_name functions respectively,
moves the definitions from locfile.h to dsk.c, and adds them to
dskdefs.h for use by other source files.
Removes StrNCpyFromLispToC and the single use of it in
LispStringToCString in the BYTESWAP implementation case.
Rename StrNCpyFromCToLisp, which does NOT follow "strncpy" semantics,
to be MemCpyToLispFromNative, where the types in the name match the
types of the arguments, and the semantics (and argument order) are
those of the C library "memcpy".
Procedure can be static as it is only used within this file
Uses consistent naming (_np) for native pointer equivalents of Lisp
addresses, and better matches Lisp implementation naming of variables.
Improve readability by reducing if/else nesting with early outs in
exceptional cases. Still equivalent to the original Lisp version.
Adds comments with a little explanation of what the code is doing.
Procedure can be static void as there was only an unused constant result.
Uses consistent naming (_np) for native pointer equivalents of Lisp
addresses, and better matches Lisp implementation naming of variables.
Adds comments with a little explanation of what the code is doing.
Unify the LispDisplayRequested... and lispDisplayRequested...
variables from the SDL and X11 display modules.
Move the storage definitions for LispDisplayRequested... to main.c
leaving external references in the modules that utilize them.
The implementation of various JUMP opcodes tried to use a common tail
that did a POP and branched to the next opcode. While the extra gotos
probably aren't harmful, neither are they beneficial to code size or speed.
A missing check for the applicability of a versioned file cache
caused loadups to fail in the case where the modification timestamp
of a directory and its parent were identical, and the file being
looked up had the same name (when lowercased) as the directory it was
contained within. E.g., looking up TEDIT in library/tedit/ where
the modification times of library and library/tedit were identical.
The inode number of the directory containing the file must be the
same as the inode number of the directory the cache was built from.
Redesign of exit status handling, instead of overloading the FAST flag
of (LOGOUT fast), add an optional 2nd argument, EXITSTATUS.
Retains compatability, with behavior unchanged, between new emulator
and older sysouts which do not pass the second argument to LISPFINISH.
Newer sysouts, which pass the 2nd argument, will continue to work with
older emulators though will not get the exit status set.
These changes add (LOGOUT <number>) to the traditional
(LOGOUT) and (LOGOUT T) calls. If an integer <number> is provided
it will be used as the exit status code, while NIL and T result
in an EXIT_SUCCESS.
If the argument passed is none of NIL, T, or a number, the exit
status code will be a generic EXIT_FAILURE (typically 1).
(LOGOUT) and (LOGOUT T) virtual memory behavior is unaffected.
When a <number> is passed Lisp will exit without saving the
virtual memory state, as is the case for (LOGOUT T), although
this behavior is determined by Lisp rather than the Maiko emulator.