diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2026-02-11 17:53:16 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-11 17:53:16 +0000 |
| commit | 355b8a8c83badc64d23dbb34ea00bb89ac9245db (patch) | |
| tree | 1103d5bde2dd10c28a81f2104d9c17fa0f4c3166 /core/encoding/xml | |
| parent | b5bf28dc47dd1c32a45ba0bbedcbcef80409b798 (diff) | |
| parent | 1a37f4eb0cc792783784fca216c79e3f02a3234e (diff) | |
Merge pull request #6245 from odin-lang/new_os
`core:os/os2` -> `core:os` integration
Diffstat (limited to 'core/encoding/xml')
| -rw-r--r-- | core/encoding/xml/xml_os.odin | 18 | ||||
| -rw-r--r-- | core/encoding/xml/xml_reader.odin | 26 |
2 files changed, 24 insertions, 20 deletions
diff --git a/core/encoding/xml/xml_os.odin b/core/encoding/xml/xml_os.odin new file mode 100644 index 000000000..1e94572c6 --- /dev/null +++ b/core/encoding/xml/xml_os.odin @@ -0,0 +1,18 @@ +#+build !freestanding +#+build !js +package encoding_xml + +import "core:os" + +// Load an XML file +load_from_file :: proc(filename: string, options := DEFAULT_OPTIONS, error_handler := default_error_handler, allocator := context.allocator) -> (doc: ^Document, err: Error) { + context.allocator = allocator + options := options + + data, data_err := os.read_entire_file(filename, allocator) + if data_err != nil { return {}, .File_Error } + + options.flags += { .Input_May_Be_Modified } + + return parse_bytes(data, options, filename, error_handler, allocator) +} diff --git a/core/encoding/xml/xml_reader.odin b/core/encoding/xml/xml_reader.odin index 8f8fffe14..6d068466b 100644 --- a/core/encoding/xml/xml_reader.odin +++ b/core/encoding/xml/xml_reader.odin @@ -9,13 +9,12 @@ package encoding_xml - Jeroen van Rijn: Initial implementation. */ -import "core:bytes" -import "core:encoding/entity" -import "base:intrinsics" -import "core:mem" -import "core:os" -import "core:strings" -import "base:runtime" +import "base:runtime" +import "core:bytes" +import "core:encoding/entity" +import "base:intrinsics" +import "core:mem" +import "core:strings" likely :: intrinsics.expect @@ -373,19 +372,6 @@ parse_string :: proc(data: string, options := DEFAULT_OPTIONS, path := "", error parse :: proc { parse_string, parse_bytes } -// Load an XML file -load_from_file :: proc(filename: string, options := DEFAULT_OPTIONS, error_handler := default_error_handler, allocator := context.allocator) -> (doc: ^Document, err: Error) { - context.allocator = allocator - options := options - - data, data_ok := os.read_entire_file(filename) - if !data_ok { return {}, .File_Error } - - options.flags += { .Input_May_Be_Modified } - - return parse_bytes(data, options, filename, error_handler, allocator) -} - destroy :: proc(doc: ^Document, allocator := context.allocator) { context.allocator = allocator if doc == nil { return } |