Skip to content

Commit 138cc7d

Browse files
authored
Merge pull request #5749 from samwega/deprecate_c_procs
Deprecate c procs
2 parents 3ad7240 + 9da10de commit 138cc7d

File tree

4 files changed

+27
-80
lines changed

4 files changed

+27
-80
lines changed

core/os/os2/path_linux.odin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ _get_full_path :: proc(fd: linux.Fd, allocator: runtime.Allocator) -> (fullpath:
199199
buf: [32]u8
200200
copy(buf[:], PROC_FD_PATH)
201201

202-
strconv.itoa(buf[len(PROC_FD_PATH):], int(fd))
202+
strconv.write_int(buf[len(PROC_FD_PATH):], i64(fd), 10)
203203

204204
if fullpath, err = _read_link_cstr(cstring(&buf[0]), allocator); err != nil || fullpath[0] != '/' {
205205
delete(fullpath, allocator)

core/os/os_linux.odin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ _dup :: proc(fd: Handle) -> (Handle, Error) {
908908
@(require_results)
909909
absolute_path_from_handle :: proc(fd: Handle) -> (string, Error) {
910910
buf : [256]byte
911-
fd_str := strconv.itoa( buf[:], cast(int)fd )
911+
fd_str := strconv.write_int( buf[:], cast(i64)fd, 10 )
912912

913913
procfs_path := strings.concatenate( []string{ "/proc/self/fd/", fd_str } )
914914
defer delete(procfs_path)

core/strconv/deprecated.odin

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,27 @@ append_u128 :: proc(buf: []byte, u: u128, base: int) -> string {
3636
append_float :: proc(buf: []byte, f: f64, fmt: byte, prec, bit_size: int) -> string {
3737
return write_float(buf, f, fmt, prec, bit_size)
3838
}
39+
40+
// 2025-10-03 Deprecated C short names and implementations
41+
42+
@(deprecated="Use strconv.write_int() instead")
43+
itoa :: proc(buf: []byte, i: int) -> string {
44+
return write_int(buf, i64(i), 10)
45+
}
46+
47+
@(deprecated="Use strconv.parse_int() instead")
48+
atoi :: proc(s: string) -> int {
49+
v, _ := parse_int(s)
50+
return v
51+
}
52+
53+
@(deprecated="Use strconv.parse_f64() instead")
54+
atof :: proc(s: string) -> f64 {
55+
v, _ := parse_f64(s)
56+
return v
57+
}
58+
59+
@(deprecated="Use strconv.write_float() instead")
60+
ftoa :: proc(buf: []byte, f: f64, fmt: byte, prec, bit_size: int) -> string {
61+
return string(generic_ftoa(buf, f, fmt, prec, bit_size))
62+
}

core/strconv/strconv.odin

Lines changed: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,85 +1547,8 @@ write_u128 :: proc(buf: []byte, u: u128, base: int) -> string {
15471547
}
15481548

15491549
/*
1550-
Converts an integer value to a string and stores it in the given buffer
1550+
`ftoa` C name deprecated, use `write_float` instead (same procedure)
15511551
1552-
**Inputs**
1553-
- buf: The buffer to store the resulting string
1554-
- i: The integer value to be converted
1555-
1556-
Example:
1557-
1558-
import "core:fmt"
1559-
import "core:strconv"
1560-
itoa_example :: proc() {
1561-
buf: [4]byte
1562-
result := strconv.itoa(buf[:], 42)
1563-
fmt.println(result, buf) // "42"
1564-
}
1565-
1566-
Output:
1567-
1568-
42 [52, 50, 0, 0]
1569-
1570-
**Returns**
1571-
- The resulting string after converting the integer value
1572-
*/
1573-
itoa :: proc(buf: []byte, i: int) -> string {
1574-
return write_int(buf, i64(i), 10)
1575-
}
1576-
/*
1577-
Converts a string to an integer value
1578-
1579-
**Inputs**
1580-
- s: The string to be converted
1581-
1582-
Example:
1583-
1584-
import "core:fmt"
1585-
import "core:strconv"
1586-
atoi_example :: proc() {
1587-
fmt.println(strconv.atoi("42"))
1588-
}
1589-
1590-
Output:
1591-
1592-
42
1593-
1594-
**Returns**
1595-
- The resulting integer value
1596-
*/
1597-
atoi :: proc(s: string) -> int {
1598-
v, _ := parse_int(s)
1599-
return v
1600-
}
1601-
/*
1602-
Converts a string to a float64 value
1603-
1604-
**Inputs**
1605-
- s: The string to be converted
1606-
1607-
Example:
1608-
1609-
import "core:fmt"
1610-
import "core:strconv"
1611-
atof_example :: proc() {
1612-
fmt.printfln("%.3f", strconv.atof("3.14"))
1613-
}
1614-
1615-
Output:
1616-
1617-
3.140
1618-
1619-
**Returns**
1620-
- The resulting float64 value after converting the string
1621-
*/
1622-
atof :: proc(s: string) -> f64 {
1623-
v, _ := parse_f64(s)
1624-
return v
1625-
}
1626-
// Alias to `write_float`
1627-
ftoa :: write_float
1628-
/*
16291552
Writes a float64 value as a string to the given buffer with the specified format and precision
16301553
16311554
**Inputs**

0 commit comments

Comments
 (0)