1
0
Fork 0
forked from fun/fun

Split ./src/vm/ini/* opcodes into seperate files. (0.36.3)

This commit is contained in:
Johannes Findeisen 2025-12-10 18:32:03 +01:00
commit ccd03d3bec
11 changed files with 237 additions and 167 deletions

32
src/vm/ini/unset.c Normal file
View file

@ -0,0 +1,32 @@
/*
* This file is part of the Fun programming language.
* https://fun-lang.xyz/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the Apache-2.0 license.
* https://opensource.org/license/apache-2-0
*
* Added: 2025-12-10 (split from set_unset_save.c)
*/
/* OP_INI_UNSET */
#ifdef FUN_WITH_INI
case OP_INI_UNSET: {
Value vkey = pop_value(vm);
Value vsec = pop_value(vm);
Value vh = pop_value(vm);
dictionary *d = ini_get((vh.type==VAL_INT)?(int)vh.i:0);
const char *key = (vkey.type==VAL_STRING)?vkey.s:NULL;
const char *sec = (vsec.type==VAL_STRING)?vsec.s:NULL;
int ok = 0;
if (d && sec && key) {
char full[1024]; snprintf(full, sizeof(full), "%s:%s", sec, key);
/* iniparser 4.2.6 dictionary_unset returns void; assume success if inputs are valid */
dictionary_unset(d, full);
ok = 1;
}
free_value(vkey); free_value(vsec); free_value(vh);
push_value(vm, make_int(ok));
break;
}
#endif