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

vfmt: change all '$expr' to '${expr}' (#16428)

This commit is contained in:
yuyi
2022-11-15 21:53:13 +08:00
committed by GitHub
parent 56239b4a23
commit 017ace6ea7
859 changed files with 7156 additions and 7135 deletions

View File

@@ -78,13 +78,13 @@ fn test_atof() {
fn test_atof_errors() {
if x := strconv.atof64('') {
eprintln('> x: $x')
eprintln('> x: ${x}')
assert false // strconv.atof64 should have failed
} else {
assert err.str() == 'expected a number found an empty string'
}
if x := strconv.atof64('####') {
eprintln('> x: $x')
eprintln('> x: ${x}')
assert false // strconv.atof64 should have failed
} else {
assert err.str() == 'not a number'

View File

@@ -24,10 +24,10 @@ pub fn common_parse_uint(s string, _base int, _bit_size int, error_on_non_digit
// TODO: error_on_non_digit and error_on_high_digit have no difference
if err != 0 && (error_on_non_digit || error_on_high_digit) {
match err {
-1 { return error('common_parse_uint: wrong base $_base for $s') }
-2 { return error('common_parse_uint: wrong bit size $_bit_size for $s') }
-3 { return error('common_parse_uint: integer overflow $s') }
else { return error('common_parse_uint: syntax error $s') }
-1 { return error('common_parse_uint: wrong base ${_base} for ${s}') }
-2 { return error('common_parse_uint: wrong bit size ${_bit_size} for ${s}') }
-3 { return error('common_parse_uint: integer overflow ${s}') }
else { return error('common_parse_uint: syntax error ${s}') }
}
}
return result
@@ -196,7 +196,7 @@ pub fn atoi(s string) !int {
start_idx++
if s.len - start_idx < 1 {
// return 0, &NumError{fnAtoi, s0, ErrSyntax}
return error('strconv.atoi: parsing "$s": invalid syntax')
return error('strconv.atoi: parsing "${s}": invalid syntax')
}
}
mut n := 0
@@ -204,7 +204,7 @@ pub fn atoi(s string) !int {
ch := s[i] - `0`
if ch > 9 {
// return 0, &NumError{fnAtoi, s0, ErrSyntax}
return error('strconv.atoi: parsing "$s": invalid syntax')
return error('strconv.atoi: parsing "${s}": invalid syntax')
}
n = n * 10 + int(ch)
}

View File

@@ -209,7 +209,7 @@ mut x := 0
sc8 := '[%20g][%20G]|'
for x < 12 {
temp_s := strconv.v_sprintf(sc8, ft, ft)
println('$temp_s\n')
println('${temp_s}\n')
ft = ft * 10.0
x++
}

View File

@@ -8,7 +8,7 @@ const base_digits = '0123456789abcdefghijklmnopqrstuvwxyz'
pub fn format_int(n i64, radix int) string {
unsafe {
if radix < 2 || radix > 36 {
panic('invalid radix: $radix . It should be => 2 and <= 36')
panic('invalid radix: ${radix} . It should be => 2 and <= 36')
}
if n == 0 {
return '0'
@@ -45,7 +45,7 @@ pub fn format_int(n i64, radix int) string {
pub fn format_uint(n u64, radix int) string {
unsafe {
if radix < 2 || radix > 36 {
panic('invalid radix: $radix . It should be => 2 and <= 36')
panic('invalid radix: ${radix} . It should be => 2 and <= 36')
}
if n == 0 {
return '0'

View File

@@ -538,7 +538,7 @@ pub fn v_sprintf(str string, pt ...voidptr) string {
}
if p_index != pt.len {
panic('$p_index % conversion specifiers, but given $pt.len args')
panic('${p_index} % conversion specifiers, but given ${pt.len} args')
}
return res.str()
@@ -547,7 +547,7 @@ pub fn v_sprintf(str string, pt ...voidptr) string {
[inline]
fn v_sprintf_panic(idx int, len int) {
if idx >= len {
panic('${idx + 1} % conversion specifiers, but given only $len args')
panic('${idx + 1} % conversion specifiers, but given only ${len} args')
}
}