Merge pull request #6297 from krnowak/krnowak/fix-tools-and-examples

Fix some tools and examples after core:os update and using-stmt feature
This commit is contained in:
Jeroen van Rijn
2026-02-17 23:20:54 +01:00
committed by GitHub
4 changed files with 36 additions and 22 deletions

View File

@@ -1,4 +1,4 @@
package weistrass_tools
package edwards_tools
import ed "core:crypto/_edwards25519"
import field "core:crypto/_fiat/field_curve25519"
@@ -78,7 +78,11 @@ main :: proc() {
}
}
fn := path.join({ODIN_ROOT, "core", "crypto", "_edwards25519", "edwards25519_table.odin"})
fn, err := path.join({ODIN_ROOT, "core", "crypto", "_edwards25519", "edwards25519_table.odin"}, context.allocator)
if err != .None {
fmt.eprintfln("Join path error for edwards25519_table.odin: %v", err);
os.exit(1);
}
bld: strings.Builder
w := strings.to_writer(&bld)

View File

@@ -1,4 +1,4 @@
package weistrass_tools
package weierstrass_tools
import secec "core:crypto/_weierstrass"
import "core:fmt"
@@ -68,7 +68,11 @@ gen_tables :: proc($CURVE: string) {
}
fn_ := "sec" + CURVE + "_table.odin"
fn := path.join({ODIN_ROOT, "core", "crypto", "_weierstrass", fn_})
fn, err := path.join({ODIN_ROOT, "core", "crypto", "_weierstrass", fn_}, context.allocator)
if err != .None {
fmt.eprintfln("Join path error for %s: %v", fn_, err);
os.exit(1);
}
bld: strings.Builder
w := strings.to_writer(&bld)

View File

@@ -10,8 +10,6 @@ import "core:hash"
N :: 1
example :: proc() {
using fmt
docs: [N]^xml.Document
errs: [N]xml.Error
times: [N]time.Duration
@@ -59,23 +57,23 @@ example :: proc() {
fmt.printf("[Average]: %v bytes in %.2f ms (%.2f MiB/s).\n", len(input), average_ms, average_speed)
if errs[0] != .None {
printf("Load/Parse error: %v\n", errs[0])
fmt.eprintf("Load/Parse error: %v\n", errs[0])
if errs[0] == .File_Error {
println("\"unicode.xml\" not found. Did you run \"tests\\download_assets.py\"?")
fmt.eprintln("\"unicode.xml\" not found. Did you run \"tests\\download_assets.py\"?")
}
return
}
charlist, charlist_ok := xml.find_child_by_ident(docs[0], 0, "charlist")
if !charlist_ok {
eprintln("Could not locate top-level `<charlist>` tag.")
return
fmt.eprintln("Could not locate top-level `<charlist>` tag.")
return
}
printf("Found `<charlist>` with %v children, %v elements total\n", len(docs[0].elements[charlist].value), docs[0].element_count)
fmt.printf("Found `<charlist>` with %v children, %v elements total\n", len(docs[0].elements[charlist].value), docs[0].element_count)
crc32 := doc_hash(docs[0], false)
printf("[%v] CRC32: 0x%08x\n", "🎉" if crc32 == 0x420dbac5 else "🤬", crc32)
fmt.printf("[%v] CRC32: 0x%08x\n", "🎉" if crc32 == 0x420dbac5 else "🤬", crc32)
for round in 0..<N {
defer xml.destroy(docs[round])
@@ -94,8 +92,6 @@ doc_hash :: proc(doc: ^xml.Document, print := false) -> (crc32: u32) {
}
main :: proc() {
using fmt
track: mem.Tracking_Allocator
mem.tracking_allocator_init(&track, context.allocator)
context.allocator = mem.tracking_allocator(&track)
@@ -103,10 +99,10 @@ main :: proc() {
example()
if len(track.allocation_map) > 0 {
println()
fmt.println()
for _, v in track.allocation_map {
printf("%v Leaked %v bytes.\n", v.location, v.size)
fmt.printf("%v Leaked %v bytes.\n", v.location, v.size)
}
}
println("Done and cleaned up!")
fmt.println("Done and cleaned up!")
}

View File

@@ -1,4 +1,4 @@
package xml_example
package xml_tools
import "core:encoding/xml"
import "core:os"
@@ -20,17 +20,27 @@ Entity :: struct {
}
main :: proc() {
filename := path.join({ODIN_ROOT, "tests", "core", "assets", "XML", "unicode.xml"})
filename, err_xml := path.join({ODIN_ROOT, "tests", "core", "assets", "XML", "unicode.xml"}, context.allocator)
defer delete(filename)
generated_filename := path.join({ODIN_ROOT, "core", "encoding", "entity", "generated.odin"})
if err_xml != .None {
fmt.eprintfln("Join path error for unicode.xml: %v", err_xml);
os.exit(1);
}
generated_filename, err_generated := path.join({ODIN_ROOT, "core", "encoding", "entity", "generated.odin"}, context.allocator)
defer delete(generated_filename)
if err_generated != .None {
fmt.eprintfln("Join path error for generated.odin: %v", err_generated);
os.exit(1);
}
doc, err := xml.load_from_file(filename, OPTIONS, Error_Handler)
defer xml.destroy(doc)
if err != .None {
fmt.printfln("Load/Parse error: %v", err)
fmt.eprintfln("Load/Parse error: %v", err)
if err == .File_Error {
fmt.eprintfln("%q not found. Did you run \"tests\\download_assets.py\"?", filename)
}
@@ -265,4 +275,4 @@ is_dotted_name :: proc(name: string) -> (dotted: bool) {
if r == '.' { return true}
}
return false
}
}