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:
@ -20,22 +20,22 @@ mut:
|
||||
|
||||
fn (context Context) header() string {
|
||||
mut header_s := ''
|
||||
header_s += 'module $context.module_name\n'
|
||||
header_s += 'module ${context.module_name}\n'
|
||||
header_s += '\n'
|
||||
allfiles := context.files.join(' ')
|
||||
mut options := []string{}
|
||||
if context.prefix.len > 0 {
|
||||
options << '-p $context.prefix'
|
||||
options << '-p ${context.prefix}'
|
||||
}
|
||||
if context.module_name.len > 0 {
|
||||
options << '-m $context.module_name'
|
||||
options << '-m ${context.module_name}'
|
||||
}
|
||||
if context.write_file.len > 0 {
|
||||
options << '-w $context.write_file'
|
||||
options << '-w ${context.write_file}'
|
||||
}
|
||||
soptions := options.join(' ')
|
||||
header_s += '// File generated by:\n'
|
||||
header_s += '// v bin2v $allfiles $soptions\n'
|
||||
header_s += '// v bin2v ${allfiles} ${soptions}\n'
|
||||
header_s += '// Please, do not edit this file.\n'
|
||||
header_s += '// Your changes may be overwritten.\n'
|
||||
header_s += 'const (\n'
|
||||
@ -49,9 +49,9 @@ fn (context Context) footer() string {
|
||||
fn (context Context) file2v(bname string, fbytes []u8, bn_max int) string {
|
||||
mut sb := strings.new_builder(1000)
|
||||
bn_diff_len := bn_max - bname.len
|
||||
sb.write_string('\t${bname}_len' + ' '.repeat(bn_diff_len - 4) + ' = $fbytes.len\n')
|
||||
sb.write_string('\t${bname}_len' + ' '.repeat(bn_diff_len - 4) + ' = ${fbytes.len}\n')
|
||||
fbyte := fbytes[0]
|
||||
bnmae_line := '\t$bname' + ' '.repeat(bn_diff_len) + ' = [u8($fbyte), '
|
||||
bnmae_line := '\t${bname}' + ' '.repeat(bn_diff_len) + ' = [u8(${fbyte}), '
|
||||
sb.write_string(bnmae_line)
|
||||
mut line_len := bnmae_line.len + 3
|
||||
for i := 1; i < fbytes.len; i++ {
|
||||
@ -65,7 +65,7 @@ fn (context Context) file2v(bname string, fbytes []u8, bn_max int) string {
|
||||
sb.write_string(b)
|
||||
line_len += b.len
|
||||
} else {
|
||||
sb.write_string('$b, ')
|
||||
sb.write_string('${b}, ')
|
||||
line_len += b.len + 2
|
||||
}
|
||||
}
|
||||
@ -76,8 +76,8 @@ fn (context Context) file2v(bname string, fbytes []u8, bn_max int) string {
|
||||
fn (context Context) bname_and_bytes(file string) !(string, []u8) {
|
||||
fname := os.file_name(file)
|
||||
fname_escaped := fname.replace_each(['.', '_', '-', '_'])
|
||||
byte_name := '$context.prefix$fname_escaped'.to_lower()
|
||||
fbytes := os.read_bytes(file) or { return error('Error: $err.msg()') }
|
||||
byte_name := '${context.prefix}${fname_escaped}'.to_lower()
|
||||
fbytes := os.read_bytes(file) or { return error('Error: ${err.msg()}') }
|
||||
return byte_name, fbytes
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ fn main() {
|
||||
exit(0)
|
||||
}
|
||||
files := fp.finalize() or {
|
||||
eprintln('Error: $err.msg()')
|
||||
eprintln('Error: ${err.msg()}')
|
||||
exit(1)
|
||||
}
|
||||
real_files := files.filter(it != 'bin2v')
|
||||
|
Reference in New Issue
Block a user