mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen_test: skip empty lines; os: make vc_gen compile
This commit is contained in:
parent
78c706ab71
commit
47908c22df
24
vlib/os/os.v
24
vlib/os/os.v
@ -293,16 +293,6 @@ pub fn open_append(path string) ?File {
|
||||
return file
|
||||
}
|
||||
|
||||
// convert any value to []byte (LittleEndian) and write it
|
||||
// for example if we have write(7, 4), "07 00 00 00" gets written
|
||||
// write(0x1234, 2) => "34 12"
|
||||
pub fn (f mut File) write_bytes(data voidptr, size int) {
|
||||
$if linux {
|
||||
C.syscall(sys_write, f.fd, data, 1)
|
||||
} $else {
|
||||
C.fwrite(data, 1, size, f.cfile)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
pub fn (f mut File) write_bytes_at(data voidptr, size, pos int) {
|
||||
@ -324,20 +314,6 @@ pub fn (f mut File) flush() {
|
||||
C.fflush(f.cfile)
|
||||
}
|
||||
|
||||
pub fn (f mut File) close() {
|
||||
if !f.opened {
|
||||
return
|
||||
}
|
||||
f.opened = false
|
||||
$if linux {
|
||||
//$if linux_or_macos {
|
||||
C.syscall(sys_close, f.fd)
|
||||
return
|
||||
}
|
||||
C.fflush(f.cfile)
|
||||
C.fclose(f.cfile)
|
||||
}
|
||||
|
||||
// system starts the specified command, waits for it to complete, and returns its code.
|
||||
fn vpopen(path string) voidptr {
|
||||
// *C.FILE {
|
||||
|
@ -216,3 +216,29 @@ pub fn symlink(origin, target string) ?bool {
|
||||
if res == 0 { return true }
|
||||
return error(get_error_msg(C.errno))
|
||||
}
|
||||
|
||||
// convert any value to []byte (LittleEndian) and write it
|
||||
// for example if we have write(7, 4), "07 00 00 00" gets written
|
||||
// write(0x1234, 2) => "34 12"
|
||||
pub fn (f mut File) write_bytes(data voidptr, size int) {
|
||||
$if linux {
|
||||
C.syscall(sys_write, f.fd, data, 1)
|
||||
} $else {
|
||||
C.fwrite(data, 1, size, f.cfile)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (f mut File) close() {
|
||||
if !f.opened {
|
||||
return
|
||||
}
|
||||
f.opened = false
|
||||
$if linux {
|
||||
//$if linux_or_macos {
|
||||
C.syscall(sys_close, f.fd)
|
||||
return
|
||||
}
|
||||
C.fflush(f.cfile)
|
||||
C.fclose(f.cfile)
|
||||
}
|
||||
|
||||
|
@ -340,3 +340,16 @@ pub fn symlink(origin, target string) ?bool {
|
||||
}
|
||||
return error(get_error_msg(int(C.GetLastError())))
|
||||
}
|
||||
|
||||
pub fn (f mut File) write_bytes(data voidptr, size int) {
|
||||
C.fwrite(data, 1, size, f.cfile)
|
||||
}
|
||||
|
||||
pub fn (f mut File) close() {
|
||||
if !f.opened {
|
||||
return
|
||||
}
|
||||
f.opened = false
|
||||
C.fflush(f.cfile)
|
||||
C.fclose(f.cfile)
|
||||
}
|
||||
|
@ -35,8 +35,10 @@ fn test_c_files() {
|
||||
}
|
||||
|
||||
fn compare_texts(a, b string) bool {
|
||||
lines_a := a.trim_space().split_into_lines()
|
||||
lines_b := b.trim_space().split_into_lines()
|
||||
lines_a_ := a.trim_space().split_into_lines()
|
||||
lines_b_ := b.trim_space().split_into_lines()
|
||||
lines_a := lines_a_.filter(it != '')
|
||||
lines_b := lines_b_.filter(it != '')
|
||||
if lines_a.len != lines_b.len {
|
||||
println(term.red('different len'))
|
||||
// return false
|
||||
@ -44,7 +46,8 @@ fn compare_texts(a, b string) bool {
|
||||
for i, line_a in lines_a {
|
||||
line_b := lines_b[i]
|
||||
if line_a.trim_space() != line_b.trim_space() {
|
||||
println(term.red('!' + line_a))
|
||||
println(term.red('i=$i a="$line_a" b="$line_b"'))
|
||||
// exit(1)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +54,11 @@ void init_array() {
|
||||
});
|
||||
}
|
||||
|
||||
void end() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
||||
|
@ -53,7 +53,6 @@ fn function2() {
|
||||
j := 0
|
||||
}
|
||||
|
||||
|
||||
fn init_array() {
|
||||
nums := [1,2,3]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user