From aaae5fdc3f084cb632b29d6cedbeb41622c878d2 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 30 Nov 2026 21:08:39 -0500 Subject: [PATCH 1/7] Add Mac OS 9 RelString probe --- ReferenceTests/Retro68/RelStringCapture.c | 83 +++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 ReferenceTests/Retro68/RelStringCapture.c diff --git a/ReferenceTests/Retro68/RelStringCapture.c b/ReferenceTests/Retro68/RelStringCapture.c new file mode 100644 index 0000000..789c112 --- /dev/null +++ b/ReferenceTests/Retro68/RelStringCapture.c @@ -0,0 +1,83 @@ +/* + * Captures RelString, the ordering HFS catalogs sort names by, into + * "RelString.bin" in the application's folder. It refuses to overwrite an + * existing capture. + * + * Format GRS1: four ASCII magic bytes; four 256 x 256 matrices of one-byte + * pairs in mode order caseSensitive * 2 + diacriticSensitive, rows in + * first-byte order, each byte RelString's result (-1, 0 or 1) as a signed + * byte; then the count of multi-byte cases and, for each, its four results + * in mode order. The cases are listed in `cases` below, in order, and in + * Graphite's TextUtilitiesTests. + */ +#include +#include + +static const unsigned char header[] = { 'G', 'R', 'S', '1' }; +static const unsigned char fileName[] = { 13, 'R', 'e', 'l', 'S', 't', 'r', 'i', 'n', 'g', '.', 'b', 'i', 'n' }; +static signed char row[256]; + +/* Pascal strings: a length byte, then the bytes. */ +static const unsigned char *const cases[][2] = { + { (const unsigned char *)"\001a", (const unsigned char *)"\001a" }, + { (const unsigned char *)"\001a", (const unsigned char *)"\002ab" }, + { (const unsigned char *)"\002ab", (const unsigned char *)"\001a" }, + { (const unsigned char *)"\000", (const unsigned char *)"\001a" }, + { (const unsigned char *)"\001a", (const unsigned char *)"\000" }, + { (const unsigned char *)"\000", (const unsigned char *)"\000" }, + { (const unsigned char *)"\002ab", (const unsigned char *)"\001b" }, + { (const unsigned char *)"\001b", (const unsigned char *)"\002ab" }, + { (const unsigned char *)"\002Ab", (const unsigned char *)"\002aB" }, + { (const unsigned char *)"\002aB", (const unsigned char *)"\002Ab" }, + { (const unsigned char *)"\003abc", (const unsigned char *)"\003abd" }, + { (const unsigned char *)"\003ABC", (const unsigned char *)"\003abd" }, + { (const unsigned char *)"\002e\216", (const unsigned char *)"\002ee" }, + { (const unsigned char *)"\002\216x", (const unsigned char *)"\002ez" }, + { (const unsigned char *)"\003a b", (const unsigned char *)"\003a\312b" }, + { (const unsigned char *)"\004Zeta", (const unsigned char *)"\005alpha" }, + { (const unsigned char *)"\006File10", (const unsigned char *)"\005File2" }, + { (const unsigned char *)"\002a\000", (const unsigned char *)"\001a" }, + { (const unsigned char *)"\002\216a", (const unsigned char *)"\002Eb" }, + { (const unsigned char *)"\002Ea", (const unsigned char *)"\002\216b" }, +}; + +static OSErr writeBytes(short ref, const void *bytes, long length) +{ + long actual = length; + OSErr error = FSWrite(ref, &actual, bytes); + return error != noErr ? error : (actual == length ? noErr : writErr); +} + +int main(void) +{ + unsigned char first[2] = { 1, 0 }, second[2] = { 1, 0 }; + unsigned char count = sizeof(cases) / sizeof(cases[0]); + signed char results[4]; + short ref; + int mode, a, b, i; + OSErr error; + + error = Create(fileName, 0, 'Grph', 'DATA'); + if (error != noErr) return 1; + error = FSOpen(fileName, 0, &ref); + if (error != noErr) return 2; + error = writeBytes(ref, header, sizeof(header)); + for (mode = 0; mode < 4 && error == noErr; ++mode) { + for (a = 0; a < 256 && error == noErr; ++a) { + first[1] = a; + for (b = 0; b < 256; ++b) { + second[1] = b; + row[b] = (signed char)RelString(first, second, (mode & 2) != 0, (mode & 1) != 0); + } + error = writeBytes(ref, row, sizeof(row)); + } + } + if (error == noErr) error = writeBytes(ref, &count, 1); + for (i = 0; i < count && error == noErr; ++i) { + for (mode = 0; mode < 4; ++mode) + results[mode] = (signed char)RelString(cases[i][0], cases[i][1], (mode & 2) != 0, (mode & 1) != 0); + error = writeBytes(ref, results, sizeof(results)); + } + if (FSClose(ref) != noErr) return 3; + return error == noErr ? 0 : 4; +} From 4d11cdf29bb49be93843d324fc7065970435f28a Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 30 Nov 2026 21:08:39 -0500 Subject: [PATCH 2/7] Build the RelString probe with Retro68 --- ReferenceTests/Retro68/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/ReferenceTests/Retro68/CMakeLists.txt b/ReferenceTests/Retro68/CMakeLists.txt index 5aac916..f6ad228 100644 --- a/ReferenceTests/Retro68/CMakeLists.txt +++ b/ReferenceTests/Retro68/CMakeLists.txt @@ -3,3 +3,4 @@ project(GraphiteReferenceTests C CXX) add_application(EqualStringCapture EqualStringCapture.c) add_application(FileManagerCapture FileManagerCapture.c) +add_application(RelStringCapture RelStringCapture.c) From 0d8ebf459e6b3a55f0e066f8a0114f065e847463 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 30 Nov 2026 21:08:39 -0500 Subject: [PATCH 3/7] Add Mac OS 9.2.2 RelString capture --- .../Retro68/RelString-macos-9.2.2-ppc.bin | Bin 0 -> 262229 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 ReferenceTests/Retro68/RelString-macos-9.2.2-ppc.bin diff --git a/ReferenceTests/Retro68/RelString-macos-9.2.2-ppc.bin b/ReferenceTests/Retro68/RelString-macos-9.2.2-ppc.bin new file mode 100644 index 0000000000000000000000000000000000000000..569fc0c7f62d0d30c17608fc6e245597f0360f4a GIT binary patch literal 262229 zcmeI4X`1XPtfuqqp*Pa2xc_hOe=XH$Ku92l$cV5pN>@E$gv9WE3?_z?|MS29@BjY% z7yJ4bT!4SU1^5?SfW#kq1^|C#0gyki0K^|x0Ok)XK<1Asfba(upzy~OK=FqZK=Vfw z!0-nY!1BivpyCfFK+PXbfQCPq04;wk0UZ8N0(kt91aSES3E=a`5un2#Mt~lF6al*Y zK?LaY#}Ht^A3}f;e*^)B`~d_Q^Pexkg#SST{O*hV8UJ$x`1h+Ha!mOjBfz)#A0fcM zfB$9vlzicukN+dS9{(!;17^T?`S%y#%lz95@NNFx1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^A;eTZYIH(6?m3M=)aXJ9jL&*PNVutS@ zJiHoT&f})L<;dT4vm@7%quGWVo_W~DG!%hscwK!8K=hHt3&3lN0A zD?k+fo&aI^I|9Vv_XP;V?+Or!-xDAdzau~_{#Jls{EYz7_-g^e@mB)G@@E0U^0NSO`ALAl{3t+Veh?rue-a=z|G%IA^OG+6H68qH ejwXc81Mg4yLlgh~z#n5y|3M6hm&<^XkpBN7AG`7Z literal 0 HcmV?d00001 From 8ffea4837f81644359917c07da8d6e668d0748a7 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 30 Nov 2026 21:08:39 -0500 Subject: [PATCH 4/7] Add RelString sort keys measured on Mac OS 9.2.2 --- Sources/GraphiteCore/RelStringKeys.swift | 95 ++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 Sources/GraphiteCore/RelStringKeys.swift diff --git a/Sources/GraphiteCore/RelStringKeys.swift b/Sources/GraphiteCore/RelStringKeys.swift new file mode 100644 index 0000000..db8c865 --- /dev/null +++ b/Sources/GraphiteCore/RelStringKeys.swift @@ -0,0 +1,95 @@ +// RelString's ordering: for each combination of case and diacritic +// sensitivity, every byte's sort key. RelString compares two strings byte by +// byte through these keys; the first difference decides, and when one string +// is a prefix of the other the shorter sorts first. Bytes with equal keys are +// those EqualString finds equal. +// +// The keys are measured, not derived: they rank the 256 bytes as RelString +// on Mac OS 9.2.2 (PowerPC, under UTM) ordered every pair of one-byte strings, +// captured by ReferenceTests/Retro68/RelStringCapture.c into +// ReferenceTests/Retro68/RelString-macos-9.2.2-ppc.bin. TextUtilitiesTests +// checks all 262,144 pairs against that capture. + +extension TextUtilities { + + /// The sort keys, indexed by caseSensitive * 2 + diacriticSensitive, then + /// by byte. + static let relStringKeys: [[UInt8]] = [ + // caseInsensitiveDiacriticInsensitive + [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 0x00 + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, // 0x10 + 32, 33, 34, 39, 40, 41, 42, 43, 46, 47, 48, 49, 50, 51, 52, 53, // 0x20 + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, // 0x30 + 70, 71, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, // 0x40 + 89, 90, 91, 92, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, // 0x50 + 73, 71, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, // 0x60 + 89, 90, 91, 92, 94, 95, 96, 97, 98, 99, 100, 106, 107, 108, 109, 110, // 0x70 + 71, 71, 75, 77, 86, 87, 95, 71, 71, 71, 71, 71, 71, 75, 77, 77, // 0x80 + 77, 77, 81, 81, 81, 81, 86, 87, 87, 87, 87, 87, 95, 95, 95, 95, // 0x90 + 111, 112, 113, 114, 115, 116, 117, 93, 118, 119, 120, 121, 122, 123, 72, 87, // 0xA0 + 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 71, 87, 135, 72, 87, // 0xB0 + 136, 137, 138, 139, 140, 141, 142, 37, 38, 143, 32, 71, 71, 87, 88, 88, // 0xC0 + 144, 145, 35, 36, 44, 45, 146, 147, 99, 148, 149, 150, 151, 152, 153, 154, // 0xD0 + 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, // 0xE0 + 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, // 0xF0 + ], + // caseInsensitiveDiacriticSensitive + [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 0x00 + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, // 0x10 + 32, 33, 34, 39, 40, 41, 42, 43, 46, 47, 48, 49, 50, 51, 52, 53, // 0x20 + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, // 0x30 + 70, 71, 81, 82, 84, 85, 90, 91, 92, 93, 98, 99, 100, 101, 102, 104, // 0x40 + 113, 114, 115, 116, 118, 119, 124, 125, 126, 127, 129, 130, 131, 132, 133, 134, // 0x50 + 77, 71, 81, 82, 84, 85, 90, 91, 92, 93, 98, 99, 100, 101, 102, 104, // 0x60 + 113, 114, 115, 116, 118, 119, 124, 125, 126, 127, 129, 135, 136, 137, 138, 139, // 0x70 + 73, 75, 83, 86, 103, 105, 120, 78, 72, 79, 73, 74, 75, 83, 86, 87, // 0x80 + 88, 89, 94, 95, 96, 97, 103, 109, 110, 111, 105, 106, 121, 122, 123, 120, // 0x90 + 140, 141, 142, 143, 144, 145, 146, 117, 147, 148, 149, 150, 151, 152, 76, 107, // 0xA0 + 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 80, 112, 164, 76, 107, // 0xB0 + 165, 166, 167, 168, 169, 170, 171, 37, 38, 172, 32, 72, 74, 106, 108, 108, // 0xC0 + 173, 174, 35, 36, 44, 45, 175, 176, 128, 177, 178, 179, 180, 181, 182, 183, // 0xD0 + 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, // 0xE0 + 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, // 0xF0 + ], + // caseSensitiveDiacriticInsensitive + [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 0x00 + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, // 0x10 + 32, 33, 34, 39, 40, 41, 42, 43, 46, 47, 48, 49, 50, 51, 52, 53, // 0x20 + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, // 0x30 + 70, 71, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, // 0x40 + 105, 107, 109, 111, 114, 116, 118, 120, 122, 124, 126, 128, 129, 130, 131, 132, // 0x50 + 133, 73, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 103, // 0x60 + 106, 108, 110, 112, 115, 117, 119, 121, 123, 125, 127, 134, 135, 136, 137, 138, // 0x70 + 71, 71, 77, 81, 99, 101, 116, 73, 73, 73, 73, 73, 73, 78, 82, 82, // 0x80 + 82, 82, 90, 90, 90, 90, 100, 103, 103, 103, 103, 103, 117, 117, 117, 117, // 0x90 + 139, 140, 141, 142, 143, 144, 145, 113, 146, 147, 148, 149, 150, 151, 72, 101, // 0xA0 + 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 73, 103, 163, 74, 103, // 0xB0 + 164, 165, 166, 167, 168, 169, 170, 37, 38, 171, 32, 71, 71, 101, 102, 104, // 0xC0 + 172, 173, 35, 36, 44, 45, 174, 175, 125, 176, 177, 178, 179, 180, 181, 182, // 0xD0 + 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, // 0xE0 + 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, // 0xF0 + ], + // caseSensitiveDiacriticSensitive + [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 0x00 + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, // 0x10 + 32, 33, 34, 39, 40, 41, 42, 43, 46, 47, 48, 49, 50, 51, 52, 53, // 0x20 + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, // 0x30 + 70, 71, 86, 88, 92, 94, 101, 103, 105, 107, 113, 115, 117, 119, 121, 125, // 0x40 + 139, 141, 143, 145, 148, 150, 157, 159, 161, 163, 166, 168, 169, 170, 171, 172, // 0x50 + 173, 77, 87, 90, 93, 96, 102, 104, 106, 108, 114, 116, 118, 120, 123, 130, // 0x60 + 140, 142, 144, 146, 149, 152, 158, 160, 162, 164, 167, 174, 175, 176, 177, 178, // 0x70 + 73, 75, 89, 95, 122, 126, 151, 78, 79, 80, 81, 82, 83, 91, 97, 98, // 0x80 + 99, 100, 109, 110, 111, 112, 124, 131, 132, 133, 134, 135, 153, 154, 155, 156, // 0x90 + 179, 180, 181, 182, 183, 184, 185, 147, 186, 187, 188, 189, 190, 191, 76, 128, // 0xA0 + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 84, 137, 203, 85, 136, // 0xB0 + 204, 205, 206, 207, 208, 209, 210, 37, 38, 211, 32, 72, 74, 127, 129, 138, // 0xC0 + 212, 213, 35, 36, 44, 45, 214, 215, 165, 216, 217, 218, 219, 220, 221, 222, // 0xD0 + 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, // 0xE0 + 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, // 0xF0 + ], + ] +} From 2ac8e3a5d82c5a7526b73226a6e6b24026a0eba4 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 30 Nov 2026 21:08:39 -0500 Subject: [PATCH 5/7] Add RelString --- Sources/GraphiteCore/TextUtilities.swift | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Sources/GraphiteCore/TextUtilities.swift b/Sources/GraphiteCore/TextUtilities.swift index e9aafed..a1d4a32 100644 --- a/Sources/GraphiteCore/TextUtilities.swift +++ b/Sources/GraphiteCore/TextUtilities.swift @@ -18,6 +18,26 @@ public enum TextUtilities { } } + /// RelString: how the first string sorts against the second, -1 before, + /// 0 equal or 1 after, by the ordering HFS sorts catalog names with. + /// Strings compare byte by byte through `relStringKeys`, the first + /// difference deciding; a prefix sorts before the longer string. This + /// operation does not apply the rules of other script systems. + public static func relString( + _ first: PascalString, + _ second: PascalString, + caseSensitive: Bool, + diacriticSensitive: Bool + ) -> Int16 { + let keys = relStringKeys[(caseSensitive ? 2 : 0) + (diacriticSensitive ? 1 : 0)] + for (left, right) in zip(first.bytes, second.bytes) { + let (a, b) = (keys[Int(left)], keys[Int(right)]) + if a != b { return a < b ? -1 : 1 } + } + if first.count == second.count { return 0 } + return first.count < second.count ? -1 : 1 + } + // The original Macintosh character set stops at 0xD8. Executor's // osutil.c records comparison tables measured on a Macintosh: // https://github.com/ctm/executor/blob/master/src/osutil.c From 04903941283ee020a7f0f5c3ceb9465b642455c6 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 30 Nov 2026 21:08:39 -0500 Subject: [PATCH 6/7] Test RelString against the Mac OS 9 capture --- .../TextUtilitiesTests.swift | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/Tests/GraphiteCoreTests/TextUtilitiesTests.swift b/Tests/GraphiteCoreTests/TextUtilitiesTests.swift index ff585f0..63566f2 100644 --- a/Tests/GraphiteCoreTests/TextUtilitiesTests.swift +++ b/Tests/GraphiteCoreTests/TextUtilitiesTests.swift @@ -110,4 +110,80 @@ import Foundation } } } + + // MARK: RelString + + /// The multi-byte cases of RelStringCapture.c, in its order. + private static let relStringCases: [([UInt8], [UInt8])] = [ + (Array("a".utf8), Array("a".utf8)), + (Array("a".utf8), Array("ab".utf8)), + (Array("ab".utf8), Array("a".utf8)), + ([], Array("a".utf8)), + (Array("a".utf8), []), + ([], []), + (Array("ab".utf8), Array("b".utf8)), + (Array("b".utf8), Array("ab".utf8)), + (Array("Ab".utf8), Array("aB".utf8)), + (Array("aB".utf8), Array("Ab".utf8)), + (Array("abc".utf8), Array("abd".utf8)), + (Array("ABC".utf8), Array("abd".utf8)), + ([0x65, 0x8E], Array("ee".utf8)), + ([0x8E, 0x78], Array("ez".utf8)), + ([0x61, 0x20, 0x62], [0x61, 0xCA, 0x62]), + (Array("Zeta".utf8), Array("alpha".utf8)), + (Array("File10".utf8), Array("File2".utf8)), + ([0x61, 0x00], Array("a".utf8)), + ([0x8E, 0x61], Array("Eb".utf8)), + (Array("Ea".utf8), [0x8E, 0x62]), + ] + + @Test func relStringMatchesMacOS9() throws { + let root = URL(fileURLWithPath: #filePath).deletingLastPathComponent() + .deletingLastPathComponent().deletingLastPathComponent() + let fixture = root.appendingPathComponent("ReferenceTests/Retro68/RelString-macos-9.2.2-ppc.bin") + let path = ProcessInfo.processInfo.environment["GRAPHITE_RELSTRING_CAPTURE"] + let bytes = [UInt8](try Data(contentsOf: path.map { URL(fileURLWithPath: $0) } ?? fixture)) + let matrices = 4 + 4 * 256 * 256 + guard bytes.count == matrices + 1 + Self.relStringCases.count * 4, + Array(bytes.prefix(4)) == Array("GRS1".utf8), + Int(bytes[matrices]) == Self.relStringCases.count else { + Issue.record("Invalid or incomplete RelString capture") + return + } + var mismatches = 0 + for mode in 0 ..< 4 { + for first in 0 ..< 256 { + for second in 0 ..< 256 { + let expected = Int16(Int8(bitPattern: bytes[4 + (mode * 256 + first) * 256 + second])) + let actual = TextUtilities.relString(PascalString(bytes: [UInt8(first)]), PascalString(bytes: [UInt8(second)]), + caseSensitive: mode & 2 != 0, diacriticSensitive: mode & 1 != 0) + if actual != expected { + mismatches += 1 + if mismatches <= 10 { Issue.record("RelString mismatch: mode \(mode), bytes \(first), \(second)") } + } + } + } + } + #expect(mismatches == 0) + for (index, (first, second)) in Self.relStringCases.enumerated() { + for mode in 0 ..< 4 { + let expected = Int16(Int8(bitPattern: bytes[matrices + 1 + index * 4 + mode])) + let actual = TextUtilities.relString(PascalString(bytes: first), PascalString(bytes: second), + caseSensitive: mode & 2 != 0, diacriticSensitive: mode & 1 != 0) + #expect(actual == expected, "case \(index + 1), mode \(mode)") + } + } + } + + @Test func relStringOrdersHFSNames() { + func order(_ a: PascalString, _ b: PascalString) -> Int16 { + TextUtilities.relString(a, b, caseSensitive: false, diacriticSensitive: true) + } + // HFS's comparison: case does not matter, diacritics do, and a + // prefix sorts first. + #expect(order("readme", "ReadMe") == 0) + #expect(order("Read", "Read Me") == -1) + #expect(order("Zeta", "alpha") == 1) + #expect(order(PascalString(bytes: [0x8E]), "e") == 1) + } } From 0c0827ee6dc8e7f91835a4e4001b7f4347e79b43 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 30 Nov 2026 21:08:39 -0500 Subject: [PATCH 7/7] Document the RelString capture --- ReferenceTests/Retro68/README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ReferenceTests/Retro68/README.md b/ReferenceTests/Retro68/README.md index 2be1d9a..44b8d31 100644 --- a/ReferenceTests/Retro68/README.md +++ b/ReferenceTests/Retro68/README.md @@ -101,3 +101,26 @@ removes the folder. Its output on Mac OS 9.2.2 is then fails with wrPermErr (-61). Opening it for writing returned -5000 (afpAccessDenied) because File Sharing was on; without it the File Manager documents permErr (-54), which Graphite returns. + +## RelString + +`RelStringCapture.c` records RelString, the ordering HFS sorts catalog names +by, for every pair of one-byte strings in each combination of case and +diacritic sensitivity, then for a list of multi-byte cases. Its output on Mac +OS 9.2.2 is `RelString-macos-9.2.2-ppc.bin` (format `GRS1`, described in the +source). SHA-256: +`a7f76c55b4c4d23cd6542452957e47383412c2eeb20716a7b19caf3af314b475` + +- Each mode is a total order of the 256 bytes, and the bytes it finds equal + are exactly those EqualString finds equal. +- Strings compare in one pass, byte by byte, the first difference deciding: + with diacritics significant, "éx" sorts after "ez". A prefix sorts before + the longer string, an embedded NUL included. +- Case-sensitive, uppercase sorts before lowercase. Space and the + non-breaking space (0xCA) are equal in every mode. +- The diacritic-insensitive orders are not the fully sensitive order applied + to folded letters, so Graphite keeps one measured key table per mode + (`Sources/GraphiteCore/RelStringKeys.swift`). + +`TextUtilitiesTests/relStringMatchesMacOS9()` checks Graphite against the +capture, or against `GRAPHITE_RELSTRING_CAPTURE` when it is set.