From 0bec9c3d98ca9d16f581fd135395c55de8daa994 Mon Sep 17 00:00:00 2001 From: crc <> Date: Tue, 16 Apr 2024 10:26:04 +0000 Subject: [PATCH] revert part of the dev-files.c changes FossilOrigin-Name: 7d6327d42772249a797eb44f0d5fb90217f2e9e7de2530a9d890a0166665520c --- vm/nga-c/dev-files.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/vm/nga-c/dev-files.c b/vm/nga-c/dev-files.c index fbd8f17..22c0ee6 100644 --- a/vm/nga-c/dev-files.c +++ b/vm/nga-c/dev-files.c @@ -59,9 +59,17 @@ V file_open(NgaState *vm) { CELL name = stack_pop(vm); char *modes[] = {"rb", "w", "a", "rb+"}; char *request = string_extract(vm, name); - FILE *file = (slot > 0) ? fopen(request, modes[mode]) : NULL; - vm->OpenFileHandles[slot] = (file != NULL) ? file : 0; + if (slot > 0) { + vm->OpenFileHandles[slot] = fopen(request, modes[mode]); + } + if (vm->OpenFileHandles[slot] == NULL) { + vm->OpenFileHandles[slot] = 0; + slot = 0; + } stack_push(vm, slot); +// FILE *file = (slot > 0) ? fopen(request, modes[mode]) : NULL; +// vm->OpenFileHandles[slot] = (file != NULL) ? file : 0; +// stack_push(vm, slot); } /*---------------------------------------------------------------------