Skip to content

size_t/ptrdiff_t transition part 4: libast regex and string sublibraries#950

Open
JohnoKing wants to merge 10 commits intoksh93:devfrom
JohnoKing:thickfold-part-4-submission
Open

size_t/ptrdiff_t transition part 4: libast regex and string sublibraries#950
JohnoKing wants to merge 10 commits intoksh93:devfrom
JohnoKing:thickfold-part-4-submission

Conversation

@JohnoKing
Copy link

@JohnoKing JohnoKing commented Mar 21, 2026

This is the fourth of the thickfold patch series, which enables ksh93 to operate within a 64-bit address space.

The parts of ksh93 affected by this commit are:

  • The libast string library.
  • The libast regex engine.
  • The libcmd paste builtin.
  • A few scattered bits of miscellaneous code using stresc (which now returns a ptrdiff_t result, a recent change after re-reviewing this patch prior to submission). Full changes for other libcmd builtins and pty are currently held for later parts of thickfold.

Change in the number of warnings on Linux when compiling with clang using -Wsign-compare -Wshorten-64-to-32 -Wsign-conversion -Wimplicit-int-conversion: 3,084 => 2,450 => 37 (progression from part 3 => part 4 => part 13)

(Part 13's warnings lowered in number due to minor fixes for that patch. It's of course currently held for a later PR.)

Progresses #592

This is the fourth of the thickfold patch series, which enables ksh93
to operate within a 64-bit address space.

The parts of ksh93 affected by this commit are:
- The libast string library.
- The libast regex engine.
- The libcmd paste builtin.
- A few scattered bits of miscellaneous code using stresc (which now
  returns a ptrdiff_t result). Full changes for other libcmd builtins
  and pty are currently held for later parts of thickfold.

Change in the number of warnings on Linux when compiling with clang using
-Wsign-compare -Wshorten-64-to-32 -Wsign-conversion -Wimplicit-int-conversion:
3,084 => 2,474 => 37 (progression from part 3 => part 4 => part 13)

Progresses ksh93#592
These changes are what were supposed to accompany the changes to
features/api, but the previous commit omitted them. (I did a
'git checkout thickfold-size_t -- src/lib/libast/features'
when I made that patch, which swept in the features/api file.)
*/

int
sfkeyprintf_20000308(Sfio_t* sp, void* handle, const char* format, Sf_key_lookup_t lookup, Sf_key_convert_t convert)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're deleting the wrong version here. The sfkeyprintf version is currently used by one thing in the code base, the pids built-in command, and if I'm not mistaken, the API logic causes this version to be used and not the old/"original" one.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're incorrect. Patch the 'original' sfkeyprintf on the dev branch to use abort():

diff --git a/src/lib/libast/disc/sfkeyprintf.c b/src/lib/libast/disc/sfkeyprintf.c
index 91c4d6806..26d4cbd19 100644
--- a/src/lib/libast/disc/sfkeyprintf.c
+++ b/src/lib/libast/disc/sfkeyprintf.c
@@ -355,6 +355,7 @@ sfkeyprintf(Sfio_t* sp, void* handle, const char* format, Sf_key_lookup_t lookup
 	for (i = 0; i < elementsof(fmt.re); i++)
 		if (fmt.re[i])
 			regfree(fmt.re[i]);
+	abort();
 	return r;
 }
 
$ bin/package use
«0»8:~/GitRepos/KornShell/ksh[dev] $ pids
PID=231169 PPID=222248 PGID=231169 TID=231169 SID=-1Abort(coredump)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants