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

vlib: run vfmt over vlib files, so that v doc -m vlib/ can run without warnings

This commit is contained in:
Delyan Angelov
2020-10-21 12:23:03 +03:00
parent 5b1ab3b0bb
commit dab66593fc
27 changed files with 343 additions and 334 deletions

View File

@ -48,18 +48,15 @@ fn (dtp DTP) read() []byte {
break
}
for i in 0 .. len {
data << unsafe { buf[i] }
}
unsafe {
free(buf)
data << unsafe {buf[i]}
}
unsafe {free(buf)}
}
return data
}
fn (dtp DTP) close() {
dtp.sock.close() or {
}
dtp.sock.close() or { }
}
struct FTP {
@ -116,7 +113,7 @@ pub fn (mut ftp FTP) connect(ip string) bool {
return false
}
pub fn (ftp FTP) login(user, passwd string) bool {
pub fn (ftp FTP) login(user string, passwd string) bool {
ftp.write('USER $user') or {
$if debug {
println('ERROR sending user')
@ -145,10 +142,8 @@ pub fn (ftp FTP) login(user, passwd string) bool {
pub fn (ftp FTP) close() {
send_quit := 'QUIT\r\n'
ftp.sock.send_string(send_quit) or {
}
ftp.sock.close() or {
}
ftp.sock.send_string(send_quit) or { }
ftp.sock.close() or { }
}
pub fn (ftp FTP) pwd() string {
@ -201,8 +196,7 @@ fn new_dtp(msg string) ?DTP {
}
fn (ftp FTP) pasv() ?DTP {
ftp.write('PASV') or {
}
ftp.write('PASV') or { }
code, data := ftp.read()
$if debug {
println('pass: $data')
@ -210,7 +204,7 @@ fn (ftp FTP) pasv() ?DTP {
if code != passive_mode {
return error('pasive mode not allowed')
}
dtp := new_dtp(data)?
dtp := new_dtp(data) ?
return dtp
}
@ -218,8 +212,7 @@ pub fn (ftp FTP) dir() ?[]string {
dtp := ftp.pasv() or {
return error('cannot establish data connection')
}
ftp.write('LIST') or {
}
ftp.write('LIST') or { }
code, _ := ftp.read()
if code == denied {
return error('LIST denied')
@ -248,8 +241,7 @@ pub fn (ftp FTP) get(file string) ?[]byte {
dtp := ftp.pasv() or {
return error('Cannot stablish data connection')
}
ftp.write('RETR $file') or {
}
ftp.write('RETR $file') or { }
code, _ := ftp.read()
if code == denied {
return error('Permission denied')

View File

@ -39,7 +39,7 @@ fn is_close_tag(tag &Tag) bool {
return false
}
fn (mut dom DocumentObjectModel) where_is(item_name, attribute_name string) int {
fn (mut dom DocumentObjectModel) where_is(item_name string, attribute_name string) int {
if !(attribute_name in dom.attributes) {
temp_array := []string{}
dom.attributes[attribute_name] = temp_array
@ -101,7 +101,7 @@ fn (mut dom DocumentObjectModel) add_tag_by_attribute(tag &Tag) {
}
}
fn compare_string(a, b string) bool { // for some reason == doesn't work
fn compare_string(a string, b string) bool { // for some reason == doesn't work
if a.len != b.len {
return false
}
@ -113,7 +113,7 @@ fn compare_string(a, b string) bool { // for some reason == doesn't work
return true
}
fn (mut dom DocumentObjectModel) construct(tag_list []Tag_ptr) {
fn (mut dom DocumentObjectModel) construct(tag_list []&Tag) {
dom.constructed = true
mut temp_map := map[string]int{}
mut temp_int := C.INT_MIN
@ -179,7 +179,7 @@ fn (mut dom DocumentObjectModel) construct(tag_list []Tag_ptr) {
dom.root = tag_list[0]
}
pub fn (mut dom DocumentObjectModel) get_by_attribute_value(name, value string) []Tag_ptr {
pub fn (mut dom DocumentObjectModel) get_by_attribute_value(name string, value string) []&Tag {
location := dom.where_is(value, name)
if dom.tag_attributes[name].len > location {
return dom.tag_attributes[name][location]
@ -187,14 +187,14 @@ pub fn (mut dom DocumentObjectModel) get_by_attribute_value(name, value string)
return []&Tag{}
}
pub fn (dom DocumentObjectModel) get_by_tag(name string) []Tag_ptr {
pub fn (dom DocumentObjectModel) get_by_tag(name string) []&Tag {
if name in dom.tag_type {
return dom.tag_type[name]
}
return []&Tag{}
}
pub fn (dom DocumentObjectModel) get_by_attribute(name string) []Tag_ptr {
pub fn (dom DocumentObjectModel) get_by_attribute(name string) []&Tag {
if name in dom.all_attributes {
return dom.all_attributes[name]
}
@ -205,12 +205,14 @@ pub fn (dom DocumentObjectModel) get_root() &Tag {
return dom.root
}
pub fn (dom DocumentObjectModel) get_all_tags() []Tag_ptr {
pub fn (dom DocumentObjectModel) get_all_tags() []&Tag {
return dom.all_tags
}
/*pub fn (dom DocumentObjectModel) get_xpath() XPath {
/*
pub fn (dom DocumentObjectModel) get_xpath() XPath {
return XPath{
dom: dom
}
}*/
}
*/