added +vet explicit-allocators to all files
This commit is contained in:
parent
0fc4e6180b
commit
44cecf02e8
16
gen.odin
16
gen.odin
@ -1,6 +1,6 @@
|
|||||||
|
#+vet explicit-allocators
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
||||||
import "core:fmt"
|
import "core:fmt"
|
||||||
import "core:os"
|
import "core:os"
|
||||||
import "core:strings"
|
import "core:strings"
|
||||||
@ -25,7 +25,7 @@ BLOG_BACK_MD := `
|
|||||||
`
|
`
|
||||||
generate_blog_md_file :: proc(path: string, allocator := context.allocator) {
|
generate_blog_md_file :: proc(path: string, allocator := context.allocator) {
|
||||||
|
|
||||||
blog_list := make([dynamic]string)
|
blog_list := make([dynamic]string, allocator)
|
||||||
sb := strings.builder_make(allocator)
|
sb := strings.builder_make(allocator)
|
||||||
blog_md_file := strings.builder_make(allocator)
|
blog_md_file := strings.builder_make(allocator)
|
||||||
|
|
||||||
@ -34,23 +34,27 @@ generate_blog_md_file :: proc(path: string, allocator := context.allocator) {
|
|||||||
blog_dir := strings.to_string(sb)
|
blog_dir := strings.to_string(sb)
|
||||||
|
|
||||||
//os.write_string(file, BLOG_START)
|
//os.write_string(file, BLOG_START)
|
||||||
blogs := walk_tree_and_get_md_names(blog_dir)
|
blogs := walk_tree_and_get_md_names(blog_dir, allocator)
|
||||||
|
|
||||||
for blog in blogs {
|
for blog in blogs {
|
||||||
b := strings.split(blog, blog_dir)
|
b := strings.split(blog, blog_dir, allocator)
|
||||||
trim_b := strings.trim_right(b[1], ".md")
|
trim_b := strings.trim_right(b[1], ".md")
|
||||||
if trim_b == "index" {continue}
|
if trim_b == "index" {continue}
|
||||||
if trim_b == "index_non_blank" {continue}
|
if trim_b == "index_non_blank" {continue}
|
||||||
if trim_b == "test" {continue}
|
if trim_b == "test" {continue}
|
||||||
if trim_b == "test_blog" {continue}
|
if trim_b == "test_blog" {continue}
|
||||||
|
if trim_b == "2026-03-16-Test" {continue}
|
||||||
if strings.starts_with(trim_b, "!") {continue}
|
if strings.starts_with(trim_b, "!") {continue}
|
||||||
append(&blog_list, blog)
|
append(&blog_list, blog)
|
||||||
}
|
}
|
||||||
|
|
||||||
for blog_entry in blog_list {
|
for blog_entry in blog_list {
|
||||||
b := strings.split(blog_entry, blog_dir)
|
b := strings.split(blog_entry, blog_dir, allocator)
|
||||||
trim_b := strings.trim_right(b[1], ".md")
|
trim_b := strings.trim_right(b[1], ".md")
|
||||||
strings.write_string(&blog_md_file, fmt.aprintf("* [%s](./%s.html)", trim_b, trim_b))
|
strings.write_string(
|
||||||
|
&blog_md_file,
|
||||||
|
fmt.aprintf("* [%s](./%s.html)", trim_b, trim_b, allocator = allocator),
|
||||||
|
)
|
||||||
strings.write_string(&blog_md_file, "\n")
|
strings.write_string(&blog_md_file, "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
31
main.odin
31
main.odin
@ -1,9 +1,9 @@
|
|||||||
|
#+vet explicit-allocators
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "core:fmt"
|
import "core:fmt"
|
||||||
import vmem "core:mem/virtual"
|
import vmem "core:mem/virtual"
|
||||||
import "core:os"
|
import "core:os"
|
||||||
import "core:sort"
|
|
||||||
import "core:strings"
|
import "core:strings"
|
||||||
import "core:time"
|
import "core:time"
|
||||||
|
|
||||||
@ -13,6 +13,12 @@ print_usage :: proc() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
|
arena: vmem.Arena
|
||||||
|
arena_err := vmem.arena_init_growing(&arena)
|
||||||
|
ensure(arena_err == nil)
|
||||||
|
arena_alloc := vmem.arena_allocator(&arena)
|
||||||
|
defer vmem.arena_destroy(&arena) //clean up everything!
|
||||||
|
|
||||||
if len(os.args) <= 2 || len(os.args) > 3 {
|
if len(os.args) <= 2 || len(os.args) > 3 {
|
||||||
print_usage()
|
print_usage()
|
||||||
return
|
return
|
||||||
@ -21,12 +27,6 @@ main :: proc() {
|
|||||||
directory := os.args[1]
|
directory := os.args[1]
|
||||||
output_dir := os.args[2]
|
output_dir := os.args[2]
|
||||||
|
|
||||||
arena: vmem.Arena
|
|
||||||
arena_err := vmem.arena_init_growing(&arena)
|
|
||||||
ensure(arena_err == nil)
|
|
||||||
arena_alloc := vmem.arena_allocator(&arena)
|
|
||||||
defer vmem.arena_destroy(&arena) //clean
|
|
||||||
|
|
||||||
start := time.tick_now() //start timer for footer
|
start := time.tick_now() //start timer for footer
|
||||||
|
|
||||||
generate_blog_md_file(directory, arena_alloc)
|
generate_blog_md_file(directory, arena_alloc)
|
||||||
@ -41,7 +41,7 @@ main :: proc() {
|
|||||||
fmt.eprintfln("ERROR: Could not open file %s: %s", file, os.error_string(parse_err))
|
fmt.eprintfln("ERROR: Could not open file %s: %s", file, os.error_string(parse_err))
|
||||||
}
|
}
|
||||||
|
|
||||||
filename := strings.split(file, directory)
|
filename := strings.split(file, directory, arena_alloc)
|
||||||
//fmt.printfln("INFO: filename: %s", filename)
|
//fmt.printfln("INFO: filename: %s", filename)
|
||||||
trimmed_filename := strings.trim_right(filename[1], ".md")
|
trimmed_filename := strings.trim_right(filename[1], ".md")
|
||||||
//fmt.printfln("INFO: trimmed_filename: %s", trimmed_filename)
|
//fmt.printfln("INFO: trimmed_filename: %s", trimmed_filename)
|
||||||
@ -71,12 +71,21 @@ main :: proc() {
|
|||||||
end := time.tick_since(start)
|
end := time.tick_since(start)
|
||||||
|
|
||||||
os.write_string(file, "<br><footer><hr />This site was generated με αγάπη on ")
|
os.write_string(file, "<br><footer><hr />This site was generated με αγάπη on ")
|
||||||
os.write_string(file, fmt.aprintf("%s ", time.to_string_dd_mm_yy(date, buf[:])))
|
os.write_string(
|
||||||
os.write_string(file, fmt.aprintf("in %v ", time.duration_round(end, time.Nanosecond)))
|
file,
|
||||||
|
fmt.aprintf("%s ", time.to_string_dd_mm_yy(date, buf[:]), allocator = arena_alloc),
|
||||||
|
)
|
||||||
|
os.write_string(
|
||||||
|
file,
|
||||||
|
fmt.aprintf(
|
||||||
|
"in %v ",
|
||||||
|
time.duration_round(end, time.Nanosecond),
|
||||||
|
allocator = arena_alloc,
|
||||||
|
),
|
||||||
|
)
|
||||||
os.write_string(file, "<font color=#ea76cb><3</font> </footer><br>")
|
os.write_string(file, "<font color=#ea76cb><3</font> </footer><br>")
|
||||||
|
|
||||||
}
|
}
|
||||||
//fmt.printfln("INFO: Wrote %s into HTML!", md_files[i])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#+vet explicit-allocators
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "core:fmt"
|
import "core:fmt"
|
||||||
@ -9,12 +10,14 @@ MD_SUFFIX :: ".md"
|
|||||||
|
|
||||||
UTF8_PREFIX :: "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n"
|
UTF8_PREFIX :: "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n"
|
||||||
CSS_PREFIX :: "<head><link rel=\"stylesheet\" href=\"./css/style.css\">\n"
|
CSS_PREFIX :: "<head><link rel=\"stylesheet\" href=\"./css/style.css\">\n"
|
||||||
|
FAVICON_PREFIX :: "<link rel=\"icon\" type=\"image\\x-icon\" href=\"/imgs/favicon.ico\">\n"
|
||||||
MASTODON_PREFIX :: "<a rel=me href=https://linuxrocks.online/@simonkellet></a>\n"
|
MASTODON_PREFIX :: "<a rel=me href=https://linuxrocks.online/@simonkellet></a>\n"
|
||||||
|
|
||||||
|
|
||||||
write_prefixs_to_html_file :: proc(file: ^os.File) {
|
write_prefixs_to_html_file :: proc(file: ^os.File) {
|
||||||
os.write_string(file, UTF8_PREFIX)
|
os.write_string(file, UTF8_PREFIX)
|
||||||
os.write_string(file, CSS_PREFIX)
|
os.write_string(file, CSS_PREFIX)
|
||||||
|
os.write_string(file, FAVICON_PREFIX)
|
||||||
os.write_string(file, MASTODON_PREFIX)
|
os.write_string(file, MASTODON_PREFIX)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user