1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: deprecate size_t (#11443)

This commit is contained in:
Enzo
2021-09-08 12:09:32 +02:00
committed by GitHub
parent 892971024e
commit e3b65092d6
31 changed files with 160 additions and 152 deletions

View File

@@ -221,7 +221,7 @@ pub fn (mut f File) writeln(s string) ?int {
// write_string writes the string `s` into the file
// It returns how many bytes were actually written.
pub fn (mut f File) write_string(s string) ?int {
unsafe { f.write_full_buffer(s.str, size_t(s.len)) ? }
unsafe { f.write_full_buffer(s.str, usize(s.len)) ? }
return s.len
}
@@ -274,8 +274,8 @@ pub fn (mut f File) write_ptr(data voidptr, size int) int {
// write_full_buffer writes a whole buffer of data to the file, starting from the
// address in `buffer`, no matter how many tries/partial writes it would take.
[unsafe]
pub fn (mut f File) write_full_buffer(buffer voidptr, buffer_len size_t) ? {
if buffer_len <= size_t(0) {
pub fn (mut f File) write_full_buffer(buffer voidptr, buffer_len usize) ? {
if buffer_len <= usize(0) {
return
}
if !f.is_opened {

View File

@@ -133,4 +133,4 @@ pub fn (mut f File) close() {
#f.valueOf().fd.close()
}
pub fn (mut f File) write_full_buffer(s voidptr, buffer_len size_t) ? {}
pub fn (mut f File) write_full_buffer(s voidptr, buffer_len usize) ? {}

View File

@@ -13,7 +13,7 @@ struct C.dirent {
fn C.readdir(voidptr) &C.dirent
fn C.readlink(pathname &char, buf &char, bufsiz size_t) int
fn C.readlink(pathname &char, buf &char, bufsiz usize) int
fn C.getline(voidptr, voidptr, voidptr) int
@@ -531,7 +531,7 @@ pub fn get_raw_line() string {
return buf.vstring_with_len(offset)
}
} $else {
max := size_t(0)
max := usize(0)
buf := &char(0)
nr_chars := unsafe { C.getline(&buf, &max, C.stdin) }
return unsafe { tos(&byte(buf), if nr_chars < 0 { 0 } else { nr_chars }) }
@@ -567,7 +567,7 @@ pub fn get_raw_stdin() []byte {
}
}
} $else {
max := size_t(0)
max := usize(0)
buf := &char(0)
nr_chars := unsafe { C.getline(&buf, &max, C.stdin) }
return array{
@@ -996,7 +996,7 @@ pub fn is_atty(fd int) int {
// write_file_array writes the data in `buffer` to a file in `path`.
pub fn write_file_array(path string, buffer array) ? {
mut f := create(path) ?
unsafe { f.write_full_buffer(buffer.data, size_t(buffer.len * buffer.element_size)) ? }
unsafe { f.write_full_buffer(buffer.data, usize(buffer.len * buffer.element_size)) ? }
f.close()
}

View File

@@ -352,7 +352,7 @@ pub fn expand_tilde_to_home(path string) string {
// write_file writes `text` data to a file in `path`.
pub fn write_file(path string, text string) ? {
mut f := create(path) ?
unsafe { f.write_full_buffer(text.str, size_t(text.len)) ? }
unsafe { f.write_full_buffer(text.str, usize(text.len)) ? }
f.close()
}