From 04095f4088255a6c9d2c0ce68dac616ca62539e4 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Fri, 19 Mar 2021 09:49:26 +0200 Subject: [PATCH] ci: fix failing `v -W build-tools` and `v -W build-examples`; run vfmt. --- cmd/tools/vbin2v.v | 6 +++--- cmd/tools/vcreate.v | 6 +++--- cmd/tools/vtest-cleancode.v | 1 + examples/buf_reader.v | 2 +- examples/net_raw_http.v | 4 ++-- examples/path_tracing.v | 2 +- vlib/x/ttf/common.v | 4 ++-- vlib/x/ttf/render_bmp.v | 4 ++-- vlib/x/ttf/render_sokol_cpu.v | 8 ++++---- vlib/x/ttf/ttf.v | 4 ++-- vlib/x/ttf/ttf_test.v | 2 +- 11 files changed, 22 insertions(+), 21 deletions(-) diff --git a/cmd/tools/vbin2v.v b/cmd/tools/vbin2v.v index f2ee1c3337..b612d426dd 100644 --- a/cmd/tools/vbin2v.v +++ b/cmd/tools/vbin2v.v @@ -131,11 +131,11 @@ fn main() { max_bname := context.max_bname_len(file_byte_map.keys()) if context.write_file.len > 0 { mut out_file := os.create(context.write_file) ? - out_file.write_str(context.header()) ? + out_file.write_string(context.header()) ? for bname, fbytes in file_byte_map { - out_file.write_str(context.file2v(bname, fbytes, max_bname)) ? + out_file.write_string(context.file2v(bname, fbytes, max_bname)) ? } - out_file.write_str(context.footer()) ? + out_file.write_string(context.footer()) ? } else { print(context.header()) for bname, fbytes in file_byte_map { diff --git a/cmd/tools/vcreate.v b/cmd/tools/vcreate.v index 562275b423..6047f4d7fd 100644 --- a/cmd/tools/vcreate.v +++ b/cmd/tools/vcreate.v @@ -77,7 +77,7 @@ fn (c &Create) write_vmod(new bool) { cerror(err.msg) exit(1) } - vmod.write_str(vmod_content(c)) or { panic(err) } + vmod.write_string(vmod_content(c)) or { panic(err) } vmod.close() } @@ -90,7 +90,7 @@ fn (c &Create) write_main(new bool) { cerror(err.msg) exit(2) } - mainfile.write_str(main_content()) or { panic(err) } + mainfile.write_string(main_content()) or { panic(err) } mainfile.close() } @@ -107,7 +107,7 @@ fn (c &Create) create_git_repo(dir string) { // We don't really need a .gitignore, it's just a nice-to-have return } - fl.write_str(gen_gitignore(c.name)) or { panic(err) } + fl.write_string(gen_gitignore(c.name)) or { panic(err) } fl.close() } } diff --git a/cmd/tools/vtest-cleancode.v b/cmd/tools/vtest-cleancode.v index d2350bc9e8..d2ecca4c44 100644 --- a/cmd/tools/vtest-cleancode.v +++ b/cmd/tools/vtest-cleancode.v @@ -9,6 +9,7 @@ const ( vet_folders = [ 'vlib/sqlite', 'vlib/v', + 'vlib/x/ttf/', 'cmd/v', 'cmd/tools', 'examples/2048', diff --git a/examples/buf_reader.v b/examples/buf_reader.v index 693a3ec023..5e1770b293 100644 --- a/examples/buf_reader.v +++ b/examples/buf_reader.v @@ -7,7 +7,7 @@ fn main() { // Make a new connection mut conn := net.dial_tcp('google.com:80') ? // Simple http HEAD request for a file - conn.write_str('GET /index.html HTTP/1.0\r\n\r\n') ? + conn.write_string('GET /index.html HTTP/1.0\r\n\r\n') ? // Wrap in a buffered reader mut r := io.new_buffered_reader(reader: io.make_reader(conn)) for { diff --git a/examples/net_raw_http.v b/examples/net_raw_http.v index 1b71183e0b..6ec423747f 100644 --- a/examples/net_raw_http.v +++ b/examples/net_raw_http.v @@ -5,10 +5,10 @@ fn main() { // Make a new connection mut conn := net.dial_tcp('google.com:80') ? defer { - conn.close() or { } + conn.close() or {} } // Simple http HEAD request for a file - conn.write_str('HEAD /index.html HTTP/1.0\r\n\r\n') ? + conn.write_string('HEAD /index.html HTTP/1.0\r\n\r\n') ? // Read all the data that is waiting result := io.read_all(reader: conn) ? // Cast to string and print result diff --git a/examples/path_tracing.v b/examples/path_tracing.v index 2c32ae96bc..6a7a5a866a 100644 --- a/examples/path_tracing.v +++ b/examples/path_tracing.v @@ -106,7 +106,7 @@ fn (image Image) save_as_ppm(file_name string) { c_r := to_int(unsafe { image.data[i] }.x) c_g := to_int(unsafe { image.data[i] }.y) c_b := to_int(unsafe { image.data[i] }.z) - f_out.write_str('$c_r $c_g $c_b ') or { panic(err) } + f_out.write_string('$c_r $c_g $c_b ') or { panic(err) } } f_out.close() } diff --git a/vlib/x/ttf/common.v b/vlib/x/ttf/common.v index e0d1160625..e3bf827e5e 100644 --- a/vlib/x/ttf/common.v +++ b/vlib/x/ttf/common.v @@ -87,7 +87,7 @@ fn (mut bmp BitMap) format_texture() { // write out a .ppm file pub fn (mut bmp BitMap) save_as_ppm(file_name string) { tmp_buf := bmp.buf - mut buf := unsafe {malloc(bmp.buf_size)} + mut buf := unsafe { malloc(bmp.buf_size) } unsafe { C.memcpy(buf, tmp_buf, bmp.buf_size) } bmp.buf = buf @@ -103,7 +103,7 @@ pub fn (mut bmp BitMap) save_as_ppm(file_name string) { c_r := bmp.buf[pos] c_g := bmp.buf[pos + 1] c_b := bmp.buf[pos + 2] - f_out.write_str('$c_r $c_g $c_b ') or { panic(err) } + f_out.write_string('$c_r $c_g $c_b ') or { panic(err) } } } f_out.close() diff --git a/vlib/x/ttf/render_bmp.v b/vlib/x/ttf/render_bmp.v index ef854df469..6cceff0224 100644 --- a/vlib/x/ttf/render_bmp.v +++ b/vlib/x/ttf/render_bmp.v @@ -800,8 +800,8 @@ pub fn (mut bmp BitMap) draw_glyph(index u16) (int, int) { // bmp.line(x0, y0, start_point.x, start_point.y, u32(0x00FF0000) // u32(0xFF000000)) - bmp.quadratic(x0, y0, start_point.x, start_point.y, (point.x + - start_point.x) / 2, (point.y + start_point.y) / 2, color) + bmp.quadratic(x0, y0, start_point.x, start_point.y, (point.x + start_point.x) / 2, + (point.y + start_point.y) / 2, color) } } else { // last point not in a curve diff --git a/vlib/x/ttf/render_sokol_cpu.v b/vlib/x/ttf/render_sokol_cpu.v index 79c1b976b5..c7e4668175 100644 --- a/vlib/x/ttf/render_sokol_cpu.v +++ b/vlib/x/ttf/render_sokol_cpu.v @@ -53,10 +53,10 @@ pub fn (mut tf_skl TTF_render_Sokol) create_text(in_txt string, in_font_size f32 // RAM buffer if sz > tf_skl.bmp.buf_size { if sz > 0 { - unsafe {free(tf_skl.bmp.buf)} + unsafe { free(tf_skl.bmp.buf) } } dprintln('create_text Alloc: $sz bytes') - tf_skl.bmp.buf = unsafe {malloc(sz)} + tf_skl.bmp.buf = unsafe { malloc(sz) } tf_skl.bmp.buf_size = sz } @@ -91,10 +91,10 @@ pub fn (mut tf_skl TTF_render_Sokol) create_text_block(in_txt string, in_w int, // RAM buffer if sz > tf_skl.bmp.buf_size { if sz > 0 { - unsafe {free(tf_skl.bmp.buf)} + unsafe { free(tf_skl.bmp.buf) } } dprintln('Alloc: $sz bytes') - tf_skl.bmp.buf = unsafe {malloc(sz)} + tf_skl.bmp.buf = unsafe { malloc(sz) } tf_skl.bmp.buf_size = sz } diff --git a/vlib/x/ttf/ttf.v b/vlib/x/ttf/ttf.v index 5aa0540c93..ed619c66db 100644 --- a/vlib/x/ttf/ttf.v +++ b/vlib/x/ttf/ttf.v @@ -519,8 +519,8 @@ fn (mut tf TTF_File) get_fword() i16 { } fn (mut tf TTF_File) get_u32() u32 { - x := (u32(tf.buf[tf.pos]) << u32(24)) | (u32(tf.buf[tf.pos + - 1]) << u32(16)) | (u32(tf.buf[tf.pos + 2]) << u32(8)) | u32(tf.buf[tf.pos + 3]) + x := (u32(tf.buf[tf.pos]) << u32(24)) | (u32(tf.buf[tf.pos + 1]) << u32(16)) | (u32(tf.buf[ + tf.pos + 2]) << u32(8)) | u32(tf.buf[tf.pos + 3]) tf.pos += 4 return x } diff --git a/vlib/x/ttf/ttf_test.v b/vlib/x/ttf/ttf_test.v index 9567dca990..646aa1a17b 100644 --- a/vlib/x/ttf/ttf_test.v +++ b/vlib/x/ttf/ttf_test.v @@ -183,7 +183,7 @@ fn test_main() { mut bmp := ttf.BitMap{ tf: &tf - buf: malloc(sz) + buf: unsafe { malloc(sz) } buf_size: sz scale: scale width: w