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

operator | not defined on bool

This commit is contained in:
Alexander Medvednikov
2019-09-15 19:07:40 +03:00
parent 48c05b5a45
commit 3db4d66824
6 changed files with 27 additions and 18 deletions

View File

@@ -457,12 +457,12 @@ pub fn filename(path string) string {
// get_line returns a one-line string from stdin
pub fn get_line() string {
str := get_raw_line()
$if windows {
return str.trim_right('\r\n')
}
$else {
return str.trim_right('\n')
}
$if windows {
return str.trim_right('\r\n')
}
$else {
return str.trim_right('\n')
}
}
// get_raw_line returns a one-line string from stdin along with '\n' if there is any
@@ -476,16 +476,13 @@ pub fn get_raw_line() string {
return ''
}
$else {
//u64 is used because C.getline needs a size_t as second argument
//Otherwise, it would cause a valgrind warning and may be dangerous
//Malloc takes an int as argument so a cast has to be made
max := u64(256)
buf := malloc(int(max))
max := size_t(256)
buf := *char(malloc(int(max)))
nr_chars := C.getline(&buf, &max, stdin)
if nr_chars == 0 {
return ''
}
return string(buf, nr_chars)
return string(byteptr(buf), nr_chars)
}
}
@@ -591,6 +588,9 @@ fn on_segfault(f voidptr) {
}
}
fn C.getpid() int
fn C.proc_pidpath (int, byteptr, int) int
pub fn executable() string {
$if linux {
mut result := malloc(MAX_PATH)
@@ -738,6 +738,10 @@ pub fn signal(signum int, handler voidptr) {
C.signal(signum, handler)
}
fn C.fork() int
fn C.wait() int
pub fn fork() int {
$if !windows {
pid := C.fork()

View File

@@ -39,7 +39,7 @@ pub fn ls(path string) []string {
if isnil(ent) {
break
}
name := tos_clone(ent.d_name)
name := tos_clone(byteptr(ent.d_name))
if name != '.' && name != '..' && name != '' {
res << name
}

View File

@@ -38,6 +38,8 @@ struct C.tm {
tm_sec int
}
fn C.time(int) i64
pub fn now() Time {
t := C.time(0)
mut now := &C.tm{!}