mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Merge pull request #5749 from samwega/deprecate_c_procs
Deprecate c procs
This commit is contained in:
@@ -199,7 +199,7 @@ _get_full_path :: proc(fd: linux.Fd, allocator: runtime.Allocator) -> (fullpath:
|
|||||||
buf: [32]u8
|
buf: [32]u8
|
||||||
copy(buf[:], PROC_FD_PATH)
|
copy(buf[:], PROC_FD_PATH)
|
||||||
|
|
||||||
strconv.itoa(buf[len(PROC_FD_PATH):], int(fd))
|
strconv.write_int(buf[len(PROC_FD_PATH):], i64(fd), 10)
|
||||||
|
|
||||||
if fullpath, err = _read_link_cstr(cstring(&buf[0]), allocator); err != nil || fullpath[0] != '/' {
|
if fullpath, err = _read_link_cstr(cstring(&buf[0]), allocator); err != nil || fullpath[0] != '/' {
|
||||||
delete(fullpath, allocator)
|
delete(fullpath, allocator)
|
||||||
|
|||||||
@@ -908,7 +908,7 @@ _dup :: proc(fd: Handle) -> (Handle, Error) {
|
|||||||
@(require_results)
|
@(require_results)
|
||||||
absolute_path_from_handle :: proc(fd: Handle) -> (string, Error) {
|
absolute_path_from_handle :: proc(fd: Handle) -> (string, Error) {
|
||||||
buf : [256]byte
|
buf : [256]byte
|
||||||
fd_str := strconv.itoa( buf[:], cast(int)fd )
|
fd_str := strconv.write_int( buf[:], cast(i64)fd, 10 )
|
||||||
|
|
||||||
procfs_path := strings.concatenate( []string{ "/proc/self/fd/", fd_str } )
|
procfs_path := strings.concatenate( []string{ "/proc/self/fd/", fd_str } )
|
||||||
defer delete(procfs_path)
|
defer delete(procfs_path)
|
||||||
|
|||||||
@@ -36,3 +36,27 @@ append_u128 :: proc(buf: []byte, u: u128, base: int) -> string {
|
|||||||
append_float :: proc(buf: []byte, f: f64, fmt: byte, prec, bit_size: int) -> string {
|
append_float :: proc(buf: []byte, f: f64, fmt: byte, prec, bit_size: int) -> string {
|
||||||
return write_float(buf, f, fmt, prec, bit_size)
|
return write_float(buf, f, fmt, prec, bit_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2025-10-03 Deprecated C short names and implementations
|
||||||
|
|
||||||
|
@(deprecated="Use strconv.write_int() instead")
|
||||||
|
itoa :: proc(buf: []byte, i: int) -> string {
|
||||||
|
return write_int(buf, i64(i), 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
@(deprecated="Use strconv.parse_int() instead")
|
||||||
|
atoi :: proc(s: string) -> int {
|
||||||
|
v, _ := parse_int(s)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
@(deprecated="Use strconv.parse_f64() instead")
|
||||||
|
atof :: proc(s: string) -> f64 {
|
||||||
|
v, _ := parse_f64(s)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
@(deprecated="Use strconv.write_float() instead")
|
||||||
|
ftoa :: proc(buf: []byte, f: f64, fmt: byte, prec, bit_size: int) -> string {
|
||||||
|
return string(generic_ftoa(buf, f, fmt, prec, bit_size))
|
||||||
|
}
|
||||||
@@ -1547,85 +1547,8 @@ write_u128 :: proc(buf: []byte, u: u128, base: int) -> string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Converts an integer value to a string and stores it in the given buffer
|
`ftoa` C name deprecated, use `write_float` instead (same procedure)
|
||||||
|
|
||||||
**Inputs**
|
|
||||||
- buf: The buffer to store the resulting string
|
|
||||||
- i: The integer value to be converted
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
import "core:fmt"
|
|
||||||
import "core:strconv"
|
|
||||||
itoa_example :: proc() {
|
|
||||||
buf: [4]byte
|
|
||||||
result := strconv.itoa(buf[:], 42)
|
|
||||||
fmt.println(result, buf) // "42"
|
|
||||||
}
|
|
||||||
|
|
||||||
Output:
|
|
||||||
|
|
||||||
42 [52, 50, 0, 0]
|
|
||||||
|
|
||||||
**Returns**
|
|
||||||
- The resulting string after converting the integer value
|
|
||||||
*/
|
|
||||||
itoa :: proc(buf: []byte, i: int) -> string {
|
|
||||||
return write_int(buf, i64(i), 10)
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
Converts a string to an integer value
|
|
||||||
|
|
||||||
**Inputs**
|
|
||||||
- s: The string to be converted
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
import "core:fmt"
|
|
||||||
import "core:strconv"
|
|
||||||
atoi_example :: proc() {
|
|
||||||
fmt.println(strconv.atoi("42"))
|
|
||||||
}
|
|
||||||
|
|
||||||
Output:
|
|
||||||
|
|
||||||
42
|
|
||||||
|
|
||||||
**Returns**
|
|
||||||
- The resulting integer value
|
|
||||||
*/
|
|
||||||
atoi :: proc(s: string) -> int {
|
|
||||||
v, _ := parse_int(s)
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
Converts a string to a float64 value
|
|
||||||
|
|
||||||
**Inputs**
|
|
||||||
- s: The string to be converted
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
import "core:fmt"
|
|
||||||
import "core:strconv"
|
|
||||||
atof_example :: proc() {
|
|
||||||
fmt.printfln("%.3f", strconv.atof("3.14"))
|
|
||||||
}
|
|
||||||
|
|
||||||
Output:
|
|
||||||
|
|
||||||
3.140
|
|
||||||
|
|
||||||
**Returns**
|
|
||||||
- The resulting float64 value after converting the string
|
|
||||||
*/
|
|
||||||
atof :: proc(s: string) -> f64 {
|
|
||||||
v, _ := parse_f64(s)
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
// Alias to `write_float`
|
|
||||||
ftoa :: write_float
|
|
||||||
/*
|
|
||||||
Writes a float64 value as a string to the given buffer with the specified format and precision
|
Writes a float64 value as a string to the given buffer with the specified format and precision
|
||||||
|
|
||||||
**Inputs**
|
**Inputs**
|
||||||
|
|||||||
Reference in New Issue
Block a user