Split ./src/vm/ini/* opcodes into seperate files. (0.36.3)
This commit is contained in:
parent
3722df654b
commit
ccd03d3bec
11 changed files with 237 additions and 167 deletions
34
src/vm/ini/get_string.c
Normal file
34
src/vm/ini/get_string.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* 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 getters.c)
|
||||
*/
|
||||
|
||||
/* OP_INI_GET_STRING */
|
||||
#ifdef FUN_WITH_INI
|
||||
case OP_INI_GET_STRING: {
|
||||
Value vdef = pop_value(vm);
|
||||
Value vkey = pop_value(vm);
|
||||
Value vsec = pop_value(vm);
|
||||
Value vh = pop_value(vm);
|
||||
const char *def = (vdef.type==VAL_STRING && vdef.s) ? vdef.s : "";
|
||||
const char *key = (vkey.type==VAL_STRING) ? vkey.s : NULL;
|
||||
const char *sec = (vsec.type==VAL_STRING) ? vsec.s : NULL;
|
||||
int h = (vh.type==VAL_INT) ? (int)vh.i : 0;
|
||||
dictionary *d = ini_get(h);
|
||||
const char *res = def;
|
||||
if (d && sec && key) {
|
||||
char full[1024]; ini_make_full_key(full, sizeof(full), sec, key);
|
||||
const char *s = iniparser_getstring(d, full, def);
|
||||
res = s ? s : "";
|
||||
}
|
||||
free_value(vdef); free_value(vkey); free_value(vsec); free_value(vh);
|
||||
push_value(vm, make_string(res));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue