|
42 | 42 | #endif
|
43 | 43 |
|
44 | 44 | #if defined(__EMSCRIPTEN__)
|
45 |
| - #include <emscripten.h> |
46 |
| - /* older Emscriptens don't have this, but we need to for wasm64 compatibility. */ |
47 |
| - #ifndef MAIN_THREAD_EM_ASM_PTR |
48 |
| - #ifdef __wasm64__ |
49 |
| - #error You need to upgrade your Emscripten compiler to support wasm64 |
50 |
| - #else |
51 |
| - #define MAIN_THREAD_EM_ASM_PTR MAIN_THREAD_EM_ASM_INT |
52 |
| - #endif |
53 |
| - #endif |
| 45 | +#include <emscripten.h> |
54 | 46 | #endif
|
55 | 47 |
|
56 | 48 | /* The size of the stack buffer to use for rendering assert messages. */
|
@@ -259,34 +251,39 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data,
|
259 | 251 | for (;;) {
|
260 | 252 | SDL_bool okay = SDL_TRUE;
|
261 | 253 | /* *INDENT-OFF* */ /* clang-format off */
|
262 |
| - char *buf = (char *) MAIN_THREAD_EM_ASM_PTR({ |
| 254 | + int reply = MAIN_THREAD_EM_ASM_INT({ |
263 | 255 | var str =
|
264 | 256 | UTF8ToString($0) + '\n\n' +
|
265 | 257 | 'Abort/Retry/Ignore/AlwaysIgnore? [ariA] :';
|
266 | 258 | var reply = window.prompt(str, "i");
|
267 | 259 | if (reply === null) {
|
268 | 260 | reply = "i";
|
269 | 261 | }
|
270 |
| - return allocate(intArrayFromString(reply), 'i8', ALLOC_NORMAL); |
| 262 | + return reply.length === 1 ? reply.charCodeAt(0) : -1; |
271 | 263 | }, message);
|
272 | 264 | /* *INDENT-ON* */ /* clang-format on */
|
273 | 265 |
|
274 |
| - if (SDL_strcmp(buf, "a") == 0) { |
| 266 | + switch (reply) { |
| 267 | + case 'a': |
275 | 268 | state = SDL_ASSERTION_ABORT;
|
276 | 269 | #if 0 /* (currently) no break functionality on Emscripten */
|
277 |
| - } else if (SDL_strcmp(buf, "b") == 0) { |
| 270 | + case 'b': |
278 | 271 | state = SDL_ASSERTION_BREAK;
|
| 272 | + break; |
279 | 273 | #endif
|
280 |
| - } else if (SDL_strcmp(buf, "r") == 0) { |
| 274 | + case 'r': |
281 | 275 | state = SDL_ASSERTION_RETRY;
|
282 |
| - } else if (SDL_strcmp(buf, "i") == 0) { |
| 276 | + break; |
| 277 | + case 'i': |
283 | 278 | state = SDL_ASSERTION_IGNORE;
|
284 |
| - } else if (SDL_strcmp(buf, "A") == 0) { |
| 279 | + break; |
| 280 | + case 'A': |
285 | 281 | state = SDL_ASSERTION_ALWAYS_IGNORE;
|
286 |
| - } else { |
| 282 | + break; |
| 283 | + default: |
287 | 284 | okay = SDL_FALSE;
|
| 285 | + break; |
288 | 286 | }
|
289 |
| - free(buf); |
290 | 287 |
|
291 | 288 | if (okay) {
|
292 | 289 | break;
|
|
0 commit comments