Inform
Inform copied to clipboard
glk_buffer_to_title_case_uni() crashes
Stack trace:
0 CoreFoundation 0x00007ff8032261ba __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007ff802d4c42b objc_exception_throw + 48
2 CoreFoundation 0x00007ff8033003ea -[__NSCFString characterAtIndex:].cold.1 + 0
3 CoreFoundation 0x00007ff80326adf5 mutateError + 121
4 CoreFoundation 0x00007ff8031932b7 -[__NSCFString appendString:] + 69
5 GlkClient 0x00000001027be3fa glk_buffer_to_title_case_uni + 576
The crash only happens when the final argument (lowerrest
) is false. If it's true, the function seems to work correctly.
Test case pasted below. I've phrased it as an I7 game to make it easier to test in the I7 IDE.
"Test Game" by Andrew Plotkin.
The Kitchen is a room.
When play begins:
test loop;
To test loop: (- while (1) TestInput(); -)
Include (-
Array gbuffer --> INPUT_BUFFER_LEN;
[ ShowBuffer label count ix;
print (string) label, ": ", count, " chars, '";
for (ix=0 : ix<count : ix++) {
print (char) gbuffer-->ix;
}
print "'^";
];
[ TestInput ix count newlen;
print "^line input >>";
glk_request_line_event_uni(gg_mainwin, gbuffer, INPUT_BUFFER_LEN, 0);
while (true) {
glk_select(gg_event);
if (gg_event-->0 == 3 && gg_event-->1 == gg_mainwin) {
count = gg_event-->2;
break;
}
}
ShowBuffer("Input", count);
!count = glk_buffer_to_upper_case_uni(gbuffer, INPUT_BUFFER_LEN, count);
!ShowBuffer("Upcased", count);
!count = glk_buffer_to_lower_case_uni(gbuffer, INPUT_BUFFER_LEN, count);
!ShowBuffer("Downcased", count);
count = glk_buffer_to_title_case_uni(gbuffer, INPUT_BUFFER_LEN, count, 0);
ShowBuffer("Titlecased", count);
];
-).
The commented-out lines for glk_buffer_to_upper_case_uni() and glk_buffer_to_lower_case_uni() are in case you want to compare the behavior of those functions. They work correctly.
Useful test inputs:
abcde
αβγδε
fflfi (the first character of this line becomes three characters when title-cased)