mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builtin: fix substr()
This commit is contained in:
parent
77d5fcca59
commit
667a26335f
@ -604,17 +604,17 @@ fn (s string) substr2(start int, _end int, end_max bool) string {
|
|||||||
// Example: assert 'ABCD'.substr(1,3) == 'BC'
|
// Example: assert 'ABCD'.substr(1,3) == 'BC'
|
||||||
pub fn (s string) substr(start int, end int) string {
|
pub fn (s string) substr(start int, end int) string {
|
||||||
$if !no_bounds_checking ? {
|
$if !no_bounds_checking ? {
|
||||||
/*
|
if start > end || start > s.len || end > s.len || start < 0 || end < 0 {
|
||||||
$if debug {
|
/*
|
||||||
if start > end || start > s.len || end > s.len || start < 0 || end < 0 {
|
$if debug {
|
||||||
println('substr($start, $end) out of bounds (len=$s.len)')
|
println('substr($start, $end) out of bounds (len=$s.len)')
|
||||||
println('s="$s"')
|
println('s="$s"')
|
||||||
print_backtrace()
|
print_backtrace()
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
panic('substr($start, $end) out of bounds (len=$s.len)')
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
panic('substr($start, $end) out of bounds (len=$s.len)')
|
|
||||||
}
|
}
|
||||||
len := end - start
|
len := end - start
|
||||||
if len == s.len {
|
if len == s.len {
|
||||||
|
Loading…
Reference in New Issue
Block a user