Compare commits

...

1 Commits

Author SHA1 Message Date
coah
6d43f6a01d fix(ezitext): align Chinese table-address return contract 2026-10-03 06:16:30 -05:00
2 changed files with 88 additions and 15 deletions

View File

@@ -133,7 +133,7 @@ typedef struct {
ziU8 phonetics[11];
} ZiChineseRecord;
extern ziPtr Zi8GetTableAddress(ziU8 language, ziU8 table, ziPtr work);
extern ziU32 Zi8GetTableAddress(ziU8 language, ziU8 table, ziPtr work);
extern ziU16 Zi8GetTableCount(ziU8 language, ziU8 table, ziPtr work);
extern ziU8 Zi8IsDupWChar(ziWChar character, ziPtr work);
extern ziU8 Zi8IsDupWordW(ziWChar* word, ziU8 length, ziPtr work);
@@ -1336,7 +1336,7 @@ dictionary_search:
Zi8GetFormatVersion(1, work) >= 8) {
lastCharHigh = (request->currentWord[request->wordCharCount - 1] >> 8) & 0xFF;
lastCharLow = request->currentWord[request->wordCharCount - 1];
phoneticGroups = Zi8GetTableAddress(1, 28, work);
phoneticGroups = (ziU8*)Zi8GetTableAddress(1, 28, work);
rangeCount = Zi8GetTableCount(1, 28, work);
rangeIndex = 0;
while (rangeIndex < rangeCount) {
@@ -1384,7 +1384,7 @@ numeric_setup:
default: ordinalCount = 0; break;
}
}
if (ordinalCount) ordinalTable = Zi8GetTableAddress(1, 29, work);
if (ordinalCount) ordinalTable = (ziU8*)Zi8GetTableAddress(1, 29, work);
}
if (!request->elementCount && (getMode == 7 || getMode == 8 || getMode == 9)) {
resultFallback = 0;
@@ -1451,7 +1451,7 @@ character_range_start:
firstOrdinal = 0;
rangeIndex = Zi8GetTableCount(1, 16, work);
if (Zi8GetFormatVersion(1, work) >= 4 && rangeIndex && elements[0] != 0xEF00) {
phoneticGroups = Zi8GetTableAddress(1, 16, work);
phoneticGroups = (ziU8*)Zi8GetTableAddress(1, 16, work);
rangeIndex = 0;
rangeCount = 0;
switch (phase) {
@@ -1912,7 +1912,7 @@ cangjie_components:
Zi8GetTableCount(1, 16, work) && elements[0] != 0xEF00 && getMode != 5) {
rangeIndex = 0;
rangeCount = 0;
phoneticGroups = Zi8GetTableAddress(1, 16, work);
phoneticGroups = (ziU8*)Zi8GetTableAddress(1, 16, work);
switch (phase) {
case 0: rangeIndex = 0; rangeCount = 2; phase = 1; break;
case 1:
@@ -2199,7 +2199,7 @@ phonetic_main:
if (Zi8GetFormatVersion(1, work) >= 4) rangeCount = Zi8GetTableCount(1, 23, work);
else rangeCount = 0;
if (rangeCount && match.nCand == 2 && emitWords) {
frequencyCursor = Zi8GetTableAddress(1, 24, work);
frequencyCursor = (ziU8*)Zi8GetTableAddress(1, 24, work);
frequencyEntry = frequencyCursor;
duplicateIndex = Zi8GetTableCount(1, 24, work);
if (!duplicateIndex) isFirstCandidate = 1;
@@ -2446,7 +2446,7 @@ engine_finish:
return totalResults;
filtered_search:
userIndex = Zi8GetTableCount(1, 31, work);
frequencyTable = Zi8GetTableAddress(1, 31, work);
frequencyTable = (ziU8*)Zi8GetTableAddress(1, 31, work);
for (; userIndex; --userIndex) {
index = frequencyTable[0] & 15;
if (!(*frequencyTable++ & charset)) goto filtered_next;
@@ -2645,20 +2645,20 @@ static int Zi8NewMatchPhonetic(ziGetParam* request, ZiChineseRecord* records,
if ((mask & 7) == 7) {
stopAfterTone = match & 7;
}
phoneticOffsets = Zi8GetTableAddress(1, 13, work);
ordinalTable = Zi8GetTableAddress(1, 14, work);
phoneticOffsets = (ziU16*)Zi8GetTableAddress(1, 13, work);
ordinalTable = (ziU16*)Zi8GetTableAddress(1, 14, work);
if (pinyin) {
phonetics = Zi8GetTableAddress(1, 3, work);
phonetics = (ziU8*)Zi8GetTableAddress(1, 3, work);
phoneticCount = Zi8GetTableCount(1, 3, work);
phoneticGroups = Zi8GetTableAddress(1, 17, work);
phoneticGroups = (ziU8*)Zi8GetTableAddress(1, 17, work);
groupCount = Zi8GetTableCount(1, 17, work);
candidateGroups = Zi8GetTableAddress(1, 18, work);
candidateGroups = (ziU8*)Zi8GetTableAddress(1, 18, work);
} else {
phonetics = Zi8GetTableAddress(1, 4, work);
phonetics = (ziU8*)Zi8GetTableAddress(1, 4, work);
phoneticCount = Zi8GetTableCount(1, 4, work);
phoneticGroups = Zi8GetTableAddress(1, 19, work);
phoneticGroups = (ziU8*)Zi8GetTableAddress(1, 19, work);
groupCount = Zi8GetTableCount(1, 19, work);
candidateGroups = Zi8GetTableAddress(1, 20, work);
candidateGroups = (ziU8*)Zi8GetTableAddress(1, 20, work);
}
if (groupCount) {

View File

@@ -0,0 +1,73 @@
# Chinese table-address contract, 2026-10-03
Base: `3dd12f63`, 43U. This is a source-contract consistency correction.
It has no exact, fuzzy, data or linking percentage gain.
## Definition and caller evidence
`zi8cgetc.c` locally declared `Zi8GetTableAddress` as returning `ziPtr`.
The exact definition in `zaddress.c:91` returns `ziU32`, forwarding
`Zi8GetTableData`. That helper's address selector explicitly converts the
computed dictionary pointer to `ziU32`. The local declaration therefore had
an incompatible cross-translation-unit function type, despite using the same
machine return register.
The change corrects that one return declaration and adds fourteen explicit
conversions at previously implicit assignments: twelve `ziU8*` conversions
and two `ziU16*` conversions. The latter preserve the exact phonetic helper's
halfword `phoneticOffsets` and `ordinalTable`. Its halfword ordinal table is
distinct from the giant engine's byte ordinal table. The fourteen existing
byte-pointer conversions remain unchanged. These are exactly fifteen changed
source lines; no argument, condition, statement order, initializer, local type,
scope, header, callee, symbol metadata or linking flag changes.
The project's typedefs make `ziU32` unsigned long and `ziPtr` void pointer.
A standalone compile-time assertion check using this unit's actual target
compiler and flags verifies `sizeof(ziU32) == sizeof(ziPtr) == 4`,
`sizeof(ziU16) == 2` and `sizeof(ziU8) == 1`. No host-width assumption is used.
## Original ABI verification
The original DOL SHA1 was verified independently. The wrapper at
`0x8145F3B0` calls `Zi8GetTableData` at `0x8145F1E0`, then leaves the full r3
return unchanged through its epilogue.
All 28 call relocations in this unit were checked against raw DOL branches:
20 in `zi8InternalGetZH` and eight in exact `Zi8NewMatchPhonetic`. Each first
return consumer stores or copies the entire address-sized r3 value. Those
consumer words also agree with the extracted original object. No byte or
halfword narrowing is introduced at the API boundary.
This establishes return-width and flow compatibility, not a uniquely proven
original pointer-versus-integer return spelling. The correction follows the
existing exact definition and the already corrected one-key/zconvert caller
contracts. No missing machine operation or new dictionary behavior is claimed.
## Prior-attempt distinction
`fz21.attempts.md:605` records MAX gM17, a byte-pointer return experiment that
failed to compile at a legitimate halfword-table consumer. It did not try the
callee's integer-address contract with per-consumer typed conversions.
The earlier zconvert and one-key contract corrections did not touch this unit.
## Fresh verification
- Rebuilt the unchanged baseline in a fresh leaf using the approved
`wibo-release64/wibo` wrapper and `WIBO_SJIS_MISSING_IMPORTS=1`
- Corrected entire `zi8cgetc.o` is byte-identical to baseline, including all
code/data sections, symbols and relocations
- After the full default build, all 1,027 source-object SHA256 hashes and the
complete generated report remain equal to pinned main
- All five exact functions retain zero normalized instruction differences:
SetFindCand 50/50, GetNextPhonetic 31/31, PartialMatch 51/51,
NewMatchPhonetic 755/755, GetChineseCandidates 155/155
- Unit unchanged: 5/8 exact, 4168/47816 exact code, 144/536 data,
96.65468% fuzzy; the giant engine remains 96.27482%
- Pool 0/0, identical; literal audit analyzes all eight functions with no
candidates, errors or skips, and zero narrow-string arguments to compare
- Full default, explicit progress/report and `build/43U/ok` targets pass
- DOL SHA1 remains `26116613f624061ba99c8d1a299aaa6efa85670d`
- `git diff --check` passes
No complete dictionary-engine or Wii runtime execution is claimed. Entire
object identity is the emitted-code neutrality evidence.