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

@ -44,7 +44,7 @@ fn setup_symlink_github() {
mut content := os.read_file(os.getenv('GITHUB_PATH')) or {
panic('Failed to read GITHUB_PATH.')
}
content += '\n$os.getwd()\n'
content += '\n${os.getwd()}\n'
os.write_file(os.getenv('GITHUB_PATH'), content) or { panic('Failed to write to GITHUB_PATH.') }
}
@ -59,7 +59,7 @@ fn setup_symlink_unix(vexe string) {
}
os.rm(link_path) or {}
os.symlink(vexe, link_path) or {
eprintln('Failed to create symlink "$link_path". Try again with sudo.')
eprintln('Failed to create symlink "${link_path}". Try again with sudo.')
exit(1)
}
}
@ -90,19 +90,19 @@ fn setup_symlink_windows(vexe string) {
os.symlink(vsymlink, vexe) or {
// typically only fails if you're on a network drive (VirtualBox)
// do batch file creation instead
eprintln('Could not create a native symlink: $err')
eprintln('Could not create a native symlink: ${err}')
eprintln('Creating a batch file instead...')
vsymlink = os.join_path(vsymlinkdir, 'v.bat')
if os.exists(vsymlink) {
os.rm(vsymlink) or { panic(err) }
}
os.write_file(vsymlink, '@echo off\n"$vexe" %*') or { panic(err) }
eprintln('$vsymlink file written.')
os.write_file(vsymlink, '@echo off\n"${vexe}" %*') or { panic(err) }
eprintln('${vsymlink} file written.')
}
if !os.exists(vsymlink) {
warn_and_exit('Could not create $vsymlink')
warn_and_exit('Could not create ${vsymlink}')
}
println('Symlink $vsymlink to $vexe created.')
println('Symlink ${vsymlink} to ${vexe} created.')
println('Checking system %PATH%...')
reg_sys_env_handle := get_reg_sys_env_handle() or {
warn_and_exit(err.msg())
@ -114,7 +114,7 @@ fn setup_symlink_windows(vexe string) {
// }
// if the above succeeded, and we cannot get the value, it may simply be empty
sys_env_path := get_reg_value(reg_sys_env_handle, 'Path') or { '' }
current_sys_paths := sys_env_path.split(os.path_delimiter).map(it.trim('/$os.path_separator'))
current_sys_paths := sys_env_path.split(os.path_delimiter).map(it.trim('/${os.path_separator}'))
mut new_paths := [vsymlinkdir]
for p in current_sys_paths {
if p == '' {
@ -161,7 +161,7 @@ fn get_reg_sys_env_handle() ?voidptr {
reg_key_path := 'Environment'
reg_env_key := unsafe { nil } // or HKEY (HANDLE)
if C.RegOpenKeyEx(os.hkey_current_user, reg_key_path.to_wide(), 0, 1 | 2, &reg_env_key) != 0 {
return error('Could not open "$reg_key_path" in the registry')
return error('Could not open "${reg_key_path}" in the registry')
}
return reg_env_key
}
@ -175,7 +175,7 @@ fn get_reg_value(reg_env_key voidptr, key string) ?string {
reg_value_size := u32(4095) // this is the max length (not for the registry, but for the system %PATH%)
mut reg_value := unsafe { &u16(malloc(int(reg_value_size))) }
if C.RegQueryValueExW(reg_env_key, key.to_wide(), 0, 0, reg_value, &reg_value_size) != 0 {
return error('Unable to get registry value for "$key".')
return error('Unable to get registry value for "${key}".')
}
return unsafe { string_from_wide(reg_value) }
}
@ -187,7 +187,7 @@ fn set_reg_value(reg_key voidptr, key string, value string) ?bool {
$if windows {
if C.RegSetValueExW(reg_key, key.to_wide(), 0, C.REG_EXPAND_SZ, value.to_wide(),
value.len * 2) != 0 {
return error('Unable to set registry value for "$key". %PATH% may be too long.')
return error('Unable to set registry value for "${key}". %PATH% may be too long.')
}
return true
}