Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glk_buffer_to_title_case_uni() crashes #41

Open
erkyrath opened this issue May 19, 2023 · 2 comments
Open

glk_buffer_to_title_case_uni() crashes #41

erkyrath opened this issue May 19, 2023 · 2 comments

Comments

@erkyrath
Copy link

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);

];

-).
@erkyrath
Copy link
Author

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.

@erkyrath
Copy link
Author

Useful test inputs:

abcde
αβγδε
fflfi (the first character of this line becomes three characters when title-cased)

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

No branches or pull requests

1 participant