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

cgen: match: do not use a temp var; minor fixes

This commit is contained in:
Alexander Medvednikov
2020-03-16 10:53:28 +01:00
parent cf094c6265
commit 900ada1112
9 changed files with 71 additions and 71 deletions

View File

@@ -9,7 +9,7 @@ import (
)
const (
default_vpm_server_urls = ['https://vpm.best', 'https://vpm.vlang.io']
default_vpm_server_urls = ['https://vpm.vlang.io']
valid_vpm_commands = ['help', 'search', 'install', 'update', 'remove']
excluded_dirs = ['cache', 'vlib']
supported_vcs_systems = ['git', 'hg']
@@ -344,7 +344,7 @@ fn get_all_modules() []string {
panic(err)
}
if r.status_code != 200 {
println('Failed to search vpm.best. Status code: $r.status_code')
println('Failed to search vpm.vlang.io. Status code: $r.status_code')
exit(1)
}
s := r.text

View File

@@ -6,12 +6,12 @@ Usage:
Examples:
v hello.v Compile the file `hello.v` and output it as `hello` or `hello.exe`.
v run hello.v Same as above but also run the produced executable immediately after compilation.
v -o h.c hello.v Translate `hello.v` to `h.c` . Do not compile further.
v -o h.c hello.v Translate `hello.v` to `h.c`. Do not compile further.
The commands are:
build Build V code in the provided path (default).
create Setup the file structure for a V project.
doc Generates the documentation for a V module (coming soon in 0.3).
doc Generate the documentation for a V module.
fmt Format the V code provided.
repl Run the REPL.
run Compile and run a V program.

View File

@@ -1,33 +0,0 @@
// Copyright (c) 2019-2020 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
module main
import (
os
v.pref
)
fn create_symlink() {
$if windows {
return
}
vexe := pref.vexe_path()
mut link_path := '/usr/local/bin/v'
mut ret := os.exec('ln -sf $vexe $link_path') or { panic(err) }
if ret.exit_code == 0 {
println('Symlink "$link_path" has been created')
}
else if os.system('uname -o | grep -q \'[A/a]ndroid\'') == 0 {
println('Failed to create symlink "$link_path". Trying again with Termux path for Android.')
link_path = '/data/data/com.termux/files/usr/bin/v'
ret = os.exec('ln -sf $vexe $link_path') or { panic(err) }
if ret.exit_code == 0 {
println('Symlink "$link_path" has been created')
} else {
println('Failed to create symlink "$link_path". Try again with sudo.')
}
} else {
println('Failed to create symlink "$link_path". Try again with sudo.')
}
}

View File

@@ -11,6 +11,7 @@ import (
os
v.table
v.doc
v.pref
)
const (
@@ -149,3 +150,27 @@ fn disallow_unknown_flags(prefs flag.MainCmdPreferences) {
println('V Error: Unexpected flag found: $prefs.unknown_flag')
exit(1)
}
fn create_symlink() {
$if windows {
return
}
vexe := pref.vexe_path()
mut link_path := '/usr/local/bin/v'
mut ret := os.exec('ln -sf $vexe $link_path') or { panic(err) }
if ret.exit_code == 0 {
println('Symlink "$link_path" has been created')
}
else if os.system('uname -o | grep -q \'[A/a]ndroid\'') == 0 {
println('Failed to create symlink "$link_path". Trying again with Termux path for Android.')
link_path = '/data/data/com.termux/files/usr/bin/v'
ret = os.exec('ln -sf $vexe $link_path') or { panic(err) }
if ret.exit_code == 0 {
println('Symlink "$link_path" has been created')
} else {
println('Failed to create symlink "$link_path". Try again with sudo.')
}
} else {
println('Failed to create symlink "$link_path". Try again with sudo.')
}
}