Tons of INI parser fixes to realy make it work. (0.37.40)
This commit is contained in:
parent
0fe3e8e357
commit
d9372ce874
15 changed files with 264 additions and 66 deletions
50
examples/ini_diag.fun
Normal file
50
examples/ini_diag.fun
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* 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: 2026-01-02
|
||||
*/
|
||||
|
||||
// Minimal diagnostic for INI lookups
|
||||
|
||||
path = "./examples/data/complex.ini"
|
||||
h = ini_load(path)
|
||||
print("h=" + to_string(h))
|
||||
if h == 0
|
||||
print("Failed to load: " + path)
|
||||
else
|
||||
print("[try app:name]")
|
||||
v1 = ini_get_string(h, "app", "name", "<def>")
|
||||
print("app:name => " + v1)
|
||||
|
||||
print("[try app:version]")
|
||||
v2 = ini_get_string(h, "app", "version", "<def>")
|
||||
print("app:version => " + v2)
|
||||
|
||||
print("[try database:port]")
|
||||
v3 = ini_get_int(h, "database", "port", -1)
|
||||
print("database:port => " + to_string(v3))
|
||||
|
||||
print("[try network:ssl]")
|
||||
v4 = ini_get_bool(h, "network", "ssl", -9)
|
||||
print("network:ssl => " + to_string(v4))
|
||||
|
||||
ini_free(h)
|
||||
|
||||
/* Expected output:
|
||||
h=1
|
||||
[try app:name]
|
||||
app:name => FunApp
|
||||
[try app:version]
|
||||
app:version => 1.2.3
|
||||
[try database:port]
|
||||
database:port => 5432
|
||||
[try network:ssl]
|
||||
network:ssl => 1
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue