mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
*char => charptr everywhere
This commit is contained in:
@ -330,7 +330,7 @@ pub fn (b []byte) hex() string {
|
||||
mut hex := malloc(b.len*2+1)
|
||||
mut ptr := &hex[0]
|
||||
for i := 0; i < b.len ; i++ {
|
||||
ptr += C.sprintf(*char(ptr), '%02x', b[i])
|
||||
ptr += C.sprintf(charptr(ptr), '%02x', b[i])
|
||||
}
|
||||
return string(hex)
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ $if msvc {
|
||||
mut si := &sic.syminfo
|
||||
si.f_size_of_struct = sizeof(SymbolInfo) // Note: C.SYMBOL_INFO is 88
|
||||
si.f_max_name_len = sizeof(SymbolInfoContainer) - sizeof(SymbolInfo) - 1
|
||||
fname := *char( &si.f_name )
|
||||
fname := charptr( &si.f_name )
|
||||
mut sline64 := Line64{}
|
||||
sline64.f_size_of_struct = sizeof(Line64)
|
||||
|
||||
|
@ -161,4 +161,4 @@ fn C.CreateDirectory(byteptr, int) bool
|
||||
fn C.BCryptGenRandom(int,voidptr,int,int) int
|
||||
fn C.CreateMutex(int,bool,byteptr) voidptr
|
||||
fn C.WaitForSingleObject(voidptr,int) int
|
||||
fn C.ReleaseMutex(voidptr) bool
|
||||
fn C.ReleaseMutex(voidptr) bool
|
||||
|
@ -8,13 +8,13 @@ module builtin
|
||||
|
||||
pub fn (d f64) str() string {
|
||||
buf := malloc(sizeof(double) * 5 + 1)// TODO
|
||||
C.sprintf(*char(buf), '%f', d)
|
||||
C.sprintf(charptr(buf), '%f', d)
|
||||
return tos(buf, vstrlen(buf))
|
||||
}
|
||||
|
||||
pub fn (d f32) str() string {
|
||||
buf := malloc(sizeof(double) * 5 + 1)// TODO
|
||||
C.sprintf(*char(buf), '%f', d)
|
||||
C.sprintf(charptr(buf), '%f', d)
|
||||
return tos(buf, vstrlen(buf))
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ module builtin
|
||||
|
||||
pub fn ptr_str(ptr voidptr) string {
|
||||
buf := malloc(sizeof(double) * 5 + 1)// TODO
|
||||
C.sprintf(*char(buf), '%p', ptr)
|
||||
C.sprintf(charptr(buf), '%p', ptr)
|
||||
return tos(buf, vstrlen(buf))
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ pub fn (n int) hex() string {
|
||||
11
|
||||
}
|
||||
hex := malloc(len) // 0x + \n
|
||||
count := int(C.sprintf(*char(hex), '0x%x', n))
|
||||
count := int(C.sprintf(charptr(hex), '0x%x', n))
|
||||
return tos(hex, count)
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ pub fn (n i64) hex() string {
|
||||
19
|
||||
}
|
||||
hex := malloc(len)
|
||||
count := int(C.sprintf(*char(hex), '0x%' C.PRIx64, n))
|
||||
count := int(C.sprintf(charptr(hex), '0x%' C.PRIx64, n))
|
||||
return tos(hex, count)
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ pub:
|
||||
}
|
||||
|
||||
pub fn vstrlen(s byteptr) int {
|
||||
return C.strlen(*char(s))
|
||||
return C.strlen(charptr(s))
|
||||
}
|
||||
|
||||
// Converts a C string to a V string.
|
||||
@ -200,11 +200,11 @@ pub fn (s string) i64() i64 {
|
||||
}
|
||||
|
||||
pub fn (s string) f32() f32 {
|
||||
return C.atof(*char(s.str))
|
||||
return C.atof(charptr(s.str))
|
||||
}
|
||||
|
||||
pub fn (s string) f64() f64 {
|
||||
return C.atof(*char(s.str))
|
||||
return C.atof(charptr(s.str))
|
||||
}
|
||||
|
||||
pub fn (s string) u32() u32 {
|
||||
|
@ -181,8 +181,8 @@ fn test_replace() {
|
||||
assert lol.replace('lol', 'LOL') == 'LOL LOL LOL'
|
||||
b = 'oneBtwoBBthree'
|
||||
assert b.replace('B', '') == 'onetwothree'
|
||||
b = '**char'
|
||||
assert b.replace('*char', 'byteptr') == '*byteptr'
|
||||
b = '*charptr'
|
||||
assert b.replace('charptr', 'byteptr') == '*byteptr'
|
||||
c :='abc'
|
||||
assert c.replace('','-') == c
|
||||
}
|
||||
|
Reference in New Issue
Block a user