mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: array init: []string
=> []string{}
This commit is contained in:
@@ -5,7 +5,7 @@ module cmdline
|
||||
// param: '-d'
|
||||
// ret: ['aa', 'bb', 'cc']
|
||||
pub fn options(args []string, param string) []string {
|
||||
mut flags := []string
|
||||
mut flags := []string{}
|
||||
for i, v in args {
|
||||
if v == param {
|
||||
if i + 1 < args.len {
|
||||
@@ -39,7 +39,7 @@ pub fn option(args []string, param string, def string) string {
|
||||
// what: ['test']
|
||||
// ret: ['-stat']
|
||||
pub fn options_before(args []string, what []string) []string {
|
||||
mut args_before := []string
|
||||
mut args_before := []string {}
|
||||
for a in args {
|
||||
if a in what {
|
||||
break
|
||||
@@ -55,7 +55,7 @@ pub fn options_before(args []string, what []string) []string {
|
||||
// ret: ['aaa.v']
|
||||
pub fn options_after(args []string, what []string) []string {
|
||||
mut found := false
|
||||
mut args_after := []string
|
||||
mut args_after := []string{}
|
||||
for a in args {
|
||||
if a in what {
|
||||
found = true
|
||||
|
10
vlib/os/os.v
10
vlib/os/os.v
@@ -24,7 +24,7 @@ fn C.readdir(voidptr) C.dirent
|
||||
|
||||
|
||||
pub const (
|
||||
args = []string
|
||||
args = []string{}
|
||||
MAX_PATH = 4096
|
||||
)
|
||||
|
||||
@@ -245,7 +245,7 @@ fn read_ulines(path string) ?[]ustring {
|
||||
return error(err)
|
||||
}
|
||||
// mut ulines := new_array(0, lines.len, sizeof(ustring))
|
||||
mut ulines := []ustring
|
||||
mut ulines := []ustring{}
|
||||
for myline in lines {
|
||||
// ulines[i] = ustr
|
||||
ulines << myline.ustring()
|
||||
@@ -722,7 +722,7 @@ pub fn get_raw_line() string {
|
||||
|
||||
pub fn get_lines() []string {
|
||||
mut line := ''
|
||||
mut inputstr := []string
|
||||
mut inputstr := []string{}
|
||||
for {
|
||||
line = get_line()
|
||||
if line.len <= 0 {
|
||||
@@ -1043,7 +1043,7 @@ pub fn is_abs_path(path string) bool {
|
||||
|
||||
// join returns path as string from string parameter(s).
|
||||
pub fn join_path(base string, dirs ...string) string {
|
||||
mut result := []string
|
||||
mut result := []string{}
|
||||
result << base.trim_right('\\/')
|
||||
for d in dirs {
|
||||
result << d
|
||||
@@ -1059,7 +1059,7 @@ pub fn walk_ext(path, ext string) []string {
|
||||
mut files := os.ls(path) or {
|
||||
return []
|
||||
}
|
||||
mut res := []string
|
||||
mut res := []string{}
|
||||
separator := if path.ends_with(os.path_separator) { '' } else { os.path_separator }
|
||||
for i, file in files {
|
||||
if file.starts_with('.') {
|
||||
|
@@ -19,7 +19,7 @@ const (
|
||||
fn C.symlink(charptr, charptr) int
|
||||
|
||||
fn init_os_args(argc int, argv &byteptr) []string {
|
||||
mut args := []string
|
||||
mut args := []string{}
|
||||
//mut args := []string(make(0, argc, sizeof(string)))
|
||||
//mut args := []string{len:argc}
|
||||
for i in 0 .. argc {
|
||||
@@ -31,7 +31,7 @@ fn init_os_args(argc int, argv &byteptr) []string {
|
||||
}
|
||||
|
||||
pub fn ls(path string) ?[]string {
|
||||
mut res := []string
|
||||
mut res := []string{}
|
||||
dir := C.opendir(path.str)
|
||||
if isnil(dir) {
|
||||
return error('ls() couldnt open dir "$path"')
|
||||
|
Reference in New Issue
Block a user