1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-13 15:18:14 +00:00

1398 Commits

Author SHA1 Message Date
Nick Briggs
51a33680f4 Resolves error and style complaints by Gemini code review 2025-10-20 15:50:52 -07:00
Nick Briggs
d4a882adc2 Uses sizeof() or passed size, where known, in calls to conc_name_and_version 2025-10-20 15:08:51 -07:00
Nick Briggs
67f8cc0cf0 Cleanup UnixVersionToLispVersion and LispVersionToUnixVersion
* implements these as functions rather than #define macros
  * moves definitions to ufs.c
  * adds parameter to UnixVersionToLispVersion for the storage
    size of the buffer being passed
  * removes inc/lispver2.h
  * adjusts makefile-dos an makefile-tail to update dependencies
2025-10-20 14:31:18 -07:00
Nick Briggs
04ad740ead Adds GETFILEATTRIBUTE processing for INODE_LO and INODE_HI attributes. 2025-08-18 23:05:53 -07:00
Nick Briggs
fe7beafcc1 "as if" => "as is" in comments. 2025-08-16 19:13:09 -07:00
Nick Briggs
e745381970 Fixup: wrong quoting function used in updates to enum_ufs, enum_ufs_prop 2025-08-16 18:56:56 -07:00
Nick Briggs
5190a3976f Resolves issue medley #2165 ignored quoting characters in filename 2025-08-16 18:56:56 -07:00
Nick Briggs
babe728d3a Improves performance of some file operations, fixes some memory leaks, and increases clarity.
* 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
2025-08-16 18:56:56 -07:00
Nick Briggs
38d65df90c Replaces unchecked strcpy/strcat with strlcpy/strlcat
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.
2025-08-16 18:56:56 -07:00
Nick Briggs
d4a9286962 Replaces unchecked strcpy with strlcpy. 2025-08-16 18:56:55 -07:00
Nick Briggs
24327920f2 Replaces unchecked strcpy with strlcpy. 2025-08-16 18:56:55 -07:00
Nick Briggs
987fa637a9 Replaces unchecked strcpy with strlcpy. 2025-08-16 18:56:55 -07:00
Nick Briggs
4de8b733fd Replaces unchecked strcpy/strcat with strlcpy/strlcat
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
2025-08-16 18:56:55 -07:00
Nick Briggs
353f6d202e Clean up quote_fname, quote_fname_ufs, and quote_dname
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.
2025-08-16 18:56:55 -07:00
Nick Briggs
55209aa7e7 Adds size of output parameter to lisppathname() and replaces various strcpy() with strlcpy() 2025-08-16 18:56:55 -07:00
Nick Briggs
dfb820cc62 Replace sprintf() with snprintf() 2025-08-16 18:56:55 -07:00
Nick Briggs
11b81f6c17 Replaces all calls to sprintf() with snprintf() in ufs.c 2025-08-16 18:56:55 -07:00
Nick Briggs
9557ae8f5b Updates unixpathname() signature to include output string length, replace strcpy with strlcpy 2025-08-16 18:56:55 -07:00
Nick Briggs
d1f7361429 Replaces strcat() with strlcat() in dsk.c 2025-08-16 18:56:55 -07:00
Nick Briggs
4c6aef8fd4 Replaces all strcpy() by strlcpy() in dsk.c 2025-08-16 18:56:55 -07:00
Nick Briggs
409617b506 Adds destination size to conc_... functions and switch to strlcpy/strlcat 2025-08-16 18:56:55 -07:00
Nick Briggs
6a550b4ca3 Replaces ConcNameAndVersion and ConcDirAndName macros with functions
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.
2025-08-16 18:56:55 -07:00
Nick Briggs
f0bd8e0f1f
Merge pull request #540 from Interlisp/nhb-string-handling-cleanup 2025-08-10 09:55:25 -07:00
Nick Briggs
c9e2759666 Replaces magic number with value calculated from appropriate constant 2025-07-29 19:59:03 -07:00
Nick Briggs
9960010129 Adds handling of strings with indirect headers for URaid object printing 2025-07-28 16:09:10 -07:00
Nick Briggs
ce20b3520e Replaces magic number 2 with BYTESPER_DLWORD in calculation of buffer size. 2025-07-26 22:11:44 -07:00
Nick Briggs
c4752e6caa Makes vmemsave.c lispstringP implementation local and updates header file accordingly 2025-07-26 17:54:17 -07:00
Nick Briggs
78dfa9b243 Adds warning note to lisp2c.c LispStringToCStr regarding endianness sensitivity 2025-07-26 17:47:24 -07:00
Nick Briggs
cfbd78007a Replaces #defined LispStringToCString with static procedure, reformats code 2025-07-26 17:46:13 -07:00
Nick Briggs
afe40004b8 Removes unnecessary dependency on lisp2c from kbdsubrs.c 2025-07-26 17:43:14 -07:00
Nick Briggs
fe8c991a11 Fixes possible buffer overrun when source string too long
If the Lisp string passed to LispStringToCString were longer than
  the destination buffer's MaxLen the could would have written the
  terminating nul past the end of the array.

  Fixes formatting of LispStringToCString

  Corrects English grammar in some comments.
2025-07-26 11:33:14 -07:00
Nick Briggs
5343b12991 Eliminates nul at end of Lisp string since Lisp strings are not nul terminated 2025-07-25 18:39:53 -07:00
Nick Briggs
a0e703678c Replaces (expanded) lisp string base access pattern with STRING_BASE macro 2025-07-25 17:52:34 -07:00
Nick Briggs
364bc1f31c Removes StrNCpyFromLispToC(), renames StrNCpyFromCToLisp to MemCpyToLispFromNative
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".
2025-07-25 14:12:30 -07:00
Nick Briggs
428e7cf1a2
Merge pull request #539 from Interlisp/nhb-gc-cleanup
Minor cleanup of code style in gcfinal.c and additional array free list debugging from URaid
2025-07-25 14:02:13 -07:00
Nick Briggs
01d21b0a44 Revert integerlength() to pure (but more efficient) C as glibc does not provide fls() 2025-07-22 09:43:49 -07:00
Nick Briggs
3569e54524 Uses consistent naming (_np) for native pointer equivalents of Lisp addresses in GC aref1 2025-07-20 10:48:20 -07:00
Nick Briggs
b75e66d91c Renames struct buf to struct buffer to match corresponding Lisp datatype name 2025-07-19 23:19:19 -07:00
Nick Briggs
0e2cda2328 Cleans up releasingvmempage implementation
Uses consistent naming (_np) for native pointer equivalents of Lisp
    addresses
2025-07-19 22:44:27 -07:00
Nick Briggs
c58336f813 Cleans up checkarrayblock implementation
Uses consistent naming (_np) for native pointer equivalents of Lisp
    addresses
  Ensures non-zero return value if arrayblock fails check
2025-07-19 18:11:43 -07:00
Nick Briggs
f2bf026b07 Adds URaid F command to print array block free list heads 2025-07-19 17:50:55 -07:00
Nick Briggs
3fad090a6c Cleans up printarrayblock implementation
Uses consistent naming (_np) for native pointer equivalents of Lisp
    addresses
2025-07-19 17:34:52 -07:00
Nick Briggs
812e296fe8 Cleans up reclaimarrayblock implementation
Uses consistent naming (_np) for native pointer equivalents of Lisp
    addresses
  Adds comments regarding the parameter passed to reclaimarrayblock
2025-07-19 15:41:50 -07:00
Nick Briggs
7c7da4cd0c Cleans up mergeforward implementation
Uses consistent naming (_np) for native pointer equivalents of Lisp
    addresses
2025-07-19 13:19:27 -07:00
Nick Briggs
f375519dbc Cleans up mergebackward implementation
Uses consistent naming (_np) for native pointer equivalents of Lisp
    addresses
  Adds comments with a little explanation of what the code is doing
2025-07-19 12:35:02 -07:00
Nick Briggs
2c46a9473a Cleans up and makes static arrayblockmerger implementation
Uses consistent naming (_np) for native pointer equivalents of Lisp
    addresses
2025-07-19 12:29:33 -07:00
Nick Briggs
93b3a709c9 Cleans up makefreearrayblock implementation
Uses consistent naming (_np) for native pointer equivalents of Lisp
    addresses
  Adds comments regarding use of WORDPTR macro to hide BYTESWAP setting
2025-07-19 12:11:11 -07:00
Nick Briggs
31fcfb36ca Cleans up linkblock implementation to increase clarity
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.
2025-07-19 11:49:30 -07:00
Nick Briggs
1f18779eb8 Cleans up deleteblock implementation to increase clarity
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.
2025-07-18 10:09:41 -07:00
Nick Briggs
357336b5f1 Rewrites (and makes static) findptrsbuffer to avoid multiple conversions between Lisp and native pointers 2025-07-18 09:12:43 -07:00