aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjason <jkercher43@gmail.com>2024-07-24 10:23:23 -0400
committerjason <jkercher43@gmail.com>2024-07-24 10:23:23 -0400
commita5fa93e06d7ebcb9ec54e9f587043cbd2ac8606b (patch)
tree019e192a5001304b8ebd5674fcd0762f4c79d2dd
parent215b21811e02437c074c03448d7337bdf0a23cc6 (diff)
remove ctprintf; use fmt.caprintf; fix pipe_linux that I broke.
-rw-r--r--core/os/os2/internal_util.odin13
-rw-r--r--core/os/os2/pipe_linux.odin4
-rw-r--r--core/os/os2/process_linux.odin4
3 files changed, 5 insertions, 16 deletions
diff --git a/core/os/os2/internal_util.odin b/core/os/os2/internal_util.odin
index c85a6bc10..e26cf7439 100644
--- a/core/os/os2/internal_util.odin
+++ b/core/os/os2/internal_util.odin
@@ -3,8 +3,7 @@ package os2
import "base:intrinsics"
import "base:runtime"
-import "core:fmt"
-import "core:strings"
+
// Splits pattern by the last wildcard "*", if it exists, and returns the prefix and suffix
// parts which are split by the last "*"
@@ -49,16 +48,6 @@ temp_cstring :: proc(s: string) -> (cstring, runtime.Allocator_Error) {
}
@(require_results)
-ctprintf :: proc(format: string, args: ..any, newline := false) -> cstring {
- str: strings.Builder
- strings.builder_init(&str, temp_allocator())
- fmt.sbprintf(&str, format, ..args, newline=newline)
- strings.write_byte(&str, 0)
- s := strings.to_string(str)
- return cstring(raw_data(s))
-}
-
-@(require_results)
string_from_null_terminated_bytes :: proc(b: []byte) -> (res: string) {
s := string(b)
i := 0
diff --git a/core/os/os2/pipe_linux.odin b/core/os/os2/pipe_linux.odin
index 0442d17ac..20c9e37f0 100644
--- a/core/os/os2/pipe_linux.odin
+++ b/core/os/os2/pipe_linux.odin
@@ -10,8 +10,8 @@ _pipe :: proc() -> (r, w: ^File, err: Error) {
return nil, nil,_get_platform_error(errno)
}
- r = _new_file(uintptr(fds[0]))
- w = _new_file(uintptr(fds[1]))
+ r = _new_file(uintptr(fds[0])) or_return
+ w = _new_file(uintptr(fds[1])) or_return
r_impl := (^File_Impl)(r.impl)
r_impl.kind = .Pipe
diff --git a/core/os/os2/process_linux.odin b/core/os/os2/process_linux.odin
index 89d54d272..7458d06d6 100644
--- a/core/os/os2/process_linux.odin
+++ b/core/os/os2/process_linux.odin
@@ -330,7 +330,7 @@ _process_start :: proc(desc: Process_Desc) -> (process: Process, err: Error) {
path_dirs := filepath.split_list(path_env, temp_allocator())
found: bool
for dir in path_dirs {
- executable_path = ctprintf("%s/%s", dir, executable_name)
+ executable_path = fmt.caprintf("%s/%s", dir, executable_name, temp_allocator())
fail: bool
if fail, errno = linux.faccessat(dir_fd, executable_path, linux.F_OK); errno == .NONE && !fail {
found = true
@@ -339,7 +339,7 @@ _process_start :: proc(desc: Process_Desc) -> (process: Process, err: Error) {
}
if !found {
// check in cwd to match windows behavior
- executable_path = ctprintf("./%s", name)
+ executable_path = fmt.caprintf("./%s", name, temp_allocator())
fail: bool
if fail, errno = linux.faccessat(dir_fd, executable_path, linux.F_OK); errno != .NONE || fail {
return process, .Not_Exist