mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
strconv: make string.int() stop parsing on invalid digit
This commit is contained in:

committed by
Alexander Medvednikov

parent
9374168b26
commit
f6ec1b29f9
@ -61,7 +61,7 @@ pub:
|
||||
|
||||
pub fn vstrlen(s byteptr) int {
|
||||
return C.strlen(*char(s))
|
||||
}
|
||||
}
|
||||
|
||||
// Converts a C string to a V string.
|
||||
// String data is reused, not copied.
|
||||
@ -187,11 +187,11 @@ pub fn (s string) replace(rep, with string) string {
|
||||
|
||||
|
||||
pub fn (s string) int() int {
|
||||
return int(strconv.parse_int(s,0,32))
|
||||
return int(strconv.common_parse_int(s,0,32, false, false))
|
||||
}
|
||||
|
||||
pub fn (s string) i64() i64 {
|
||||
return strconv.parse_int(s, 0, 64)
|
||||
return strconv.common_parse_int(s, 0, 64, false, false)
|
||||
}
|
||||
|
||||
pub fn (s string) f32() f32 {
|
||||
@ -203,11 +203,11 @@ pub fn (s string) f64() f64 {
|
||||
}
|
||||
|
||||
pub fn (s string) u32() u32 {
|
||||
return u32(strconv.parse_uint(s, 0, 32))
|
||||
return u32(strconv.common_parse_uint(s, 0, 32, false, false))
|
||||
}
|
||||
|
||||
pub fn (s string) u64() u64 {
|
||||
return strconv.parse_uint(s, 0, 64)
|
||||
return strconv.common_parse_uint(s, 0, 64, false, false)
|
||||
}
|
||||
|
||||
// ==
|
||||
@ -614,7 +614,7 @@ pub fn (s string) title() string {
|
||||
}
|
||||
title := tit.join(' ')
|
||||
|
||||
return title
|
||||
return title
|
||||
}
|
||||
|
||||
// 'hey [man] how you doin'
|
||||
|
Reference in New Issue
Block a user