Skip to content

Commit

Permalink
vlib: fix typos and formatting (#19649)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm authored Oct 25, 2023
1 parent fc2e755 commit f98bb86
Show file tree
Hide file tree
Showing 23 changed files with 152 additions and 154 deletions.
2 changes: 1 addition & 1 deletion vlib/builtin/array_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ fn test_hex() {
assert st1.hex() == '41'.repeat(100)
}

fn test_left_shift_precendence() {
fn test_left_shift_precedence() {
mut arr := []int{}
arr << 1 + 1
arr << 1 - 1
Expand Down
2 changes: 1 addition & 1 deletion vlib/builtin/backtraces_windows.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub mut:
f_reserved [2]u64
f_index u32
f_size u32
f_mod_base u64 // Base Address of module comtaining this symbol
f_mod_base u64 // Base Address of module containing this symbol
f_flags u32
f_value u64 // Value of symbol, ValuePresent should be 1
f_address u64 // Address of symbol including base address of module
Expand Down
12 changes: 6 additions & 6 deletions vlib/builtin/js/array.js.v
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct array_buffer {

fn (mut a array_buffer) make_copy() {
if a.index_start != 0 || a.has_slice {
mut new_arr := JS.makeEmtpyJSArray()
mut new_arr := JS.makeEmptyJSArray()
for i in 0 .. a.len {
#new_arr.push(a.val.get(i))

Expand Down Expand Up @@ -148,10 +148,10 @@ pub fn (a array) repeat(count int) array {
}

#function makeEmptyArray() { return new array(new array_buffer({ arr: [], len: new int(0), index_start: new int(0), cap: new int(0) })); }
#function makeEmtpyJSArray() { return new Array(); }
#function makeEmptyJSArray() { return new Array(); }

fn JS.makeEmptyArray() array
fn JS.makeEmtpyJSArray() JS.Array
fn JS.makeEmptyJSArray() JS.Array
fn empty_array() array {
return JS.makeEmptyArray()
}
Expand Down Expand Up @@ -222,13 +222,13 @@ fn v_filter(arr array, callback fn (voidptr) bool) array {
}

fn v_map(arr array, callback fn (voidptr) voidptr) array {
mut maped := empty_array()
mut mapped := empty_array()

for i := 0; i < arr.arr.len; i++ {
maped.push(callback(arr.arr.get(i)))
mapped.push(callback(arr.arr.get(i)))
}

return maped
return mapped
}

struct array_iterator {
Expand Down
2 changes: 1 addition & 1 deletion vlib/builtin/js/array_test.js.v
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ fn test_hex() {
assert st1.hex() == '41'.repeat(100)
}*/

fn test_left_shift_precendence() {
fn test_left_shift_precedence() {
mut arr := []int{}
arr << 1 + 1
arr << 1 - 1
Expand Down
10 changes: 5 additions & 5 deletions vlib/builtin/js/int_test.js.v
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn test_str_methods() {
// assert u64(-1).str() == '18446744073709551615'
}

fn test_and_precendence() {
fn test_and_precedence() {
assert (2 & 0 == 0) == ((2 & 0) == 0)
assert (2 & 0 != 0) == ((2 & 0) != 0)
assert (0 & 0 >= 0) == ((0 & 0) >= 0)
Expand All @@ -41,7 +41,7 @@ fn test_and_precendence() {
assert (1 & 2 > 0) == ((1 & 2) > 0)
}

fn test_or_precendence() {
fn test_or_precedence() {
assert (1 | 0 == 0) == ((1 | 0) == 0)
assert (1 | 0 != 1) == ((1 | 0) != 1)
assert (1 | 0 >= 2) == ((1 | 0) >= 2)
Expand All @@ -50,7 +50,7 @@ fn test_or_precendence() {
assert (1 | 0 > 1) == ((1 | 0) > 1)
}

fn test_xor_precendence() {
fn test_xor_precedence() {
assert (1 ^ 0 == 2) == ((1 ^ 0) == 2)
assert (1 ^ 0 != 2) == ((1 ^ 0) != 2)
assert (1 ^ 0 >= 0) == ((1 ^ 0) >= 0)
Expand All @@ -59,12 +59,12 @@ fn test_xor_precendence() {
assert (1 ^ 0 > 1) == ((1 ^ 0) > 1)
}

fn test_left_shift_precendence() {
fn test_left_shift_precedence() {
assert (2 << 4 | 3) == ((2 << 4) | 3)
assert (2 << 4 | 3) != (2 << (4 | 3))
}

fn test_right_shift_precendence() {
fn test_right_shift_precedence() {
assert (256 >> 4 | 3) == ((256 >> 4) | 3)
assert (256 >> 4 | 3) != (256 >> (4 | 3))
}
Expand Down
6 changes: 3 additions & 3 deletions vlib/builtin/js/promise.js.v
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module builtin

pub interface JS.Promise {
then(onFullfilled JS.Any, onRejected JS.Any)
then(onFullfiled JS.Any, onRejected JS.Any)
catch(onCatch JS.Any) JS.Promise
finally(callback JS.Any) JS.Promise
}
Expand All @@ -24,8 +24,8 @@ pub fn promise_new[T](executor fn (resolve fn (T), reject fn (JS.Any))) Promise[
return Promise[T]{promise}
}

pub fn (p Promise[T]) then(on_fullfilled fn (T), on_rejected fn (JS.Any)) {
p.promise.then(on_fullfilled, on_rejected)
pub fn (p Promise[T]) then(on_fulfilled fn (T), on_rejected fn (JS.Any)) {
p.promise.then(on_fulfilled, on_rejected)
}

// catch method returns a Promise and deals with rejected cases only.
Expand Down
2 changes: 1 addition & 1 deletion vlib/builtin/linux_bare/old/linuxsys_bare.v
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ https://blog.rchapman.org/posts/Linux_System_Call_Table_for_x86_64/
239 sys_get_mempolicy int *policy unsigned long *nmask unsigned long maxnode unsigned long addr unsigned long flags
240 sys_mq_open const char *u_name int oflag mode_t mode struct mq_attr *u_attr
241 sys_mq_unlink const char *u_name
242 sys_mq_timedsend mqd_t mqdes const char *u_msg_ptr size_t msg_len unsigned int msg_prio const stuct timespec *u_abs_timeout
242 sys_mq_timedsend mqd_t mqdes const char *u_msg_ptr size_t msg_len unsigned int msg_prio const struct timespec *u_abs_timeout
243 sys_mq_timedreceive mqd_t mqdes char *u_msg_ptr size_t msg_len unsigned int *u_msg_prio const struct timespec *u_abs_timeout
244 sys_mq_notify mqd_t mqdes const struct sigevent *u_notification
245 sys_mq_getsetattr mqd_t mqdes const struct mq_attr *u_mqstat struct mq_attr *u_omqstat
Expand Down
32 changes: 16 additions & 16 deletions vlib/builtin/string_interpolation.v
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn abs64(x i64) u64 {
//_9876543210987654321098765432109876543210
//_nPPPPPPPPBBBBWWWWWWWWWWTDDDDDDDSUAA=====
// = data type 5 bit max 32 data type
// A allign 2 bit Note: for now only 1 used!
// A align 2 bit Note: for now only 1 used!
// U uppercase 1 bit 0 do nothing, 1 do to_upper()
// S sign 1 bit show the sign if positive
// D decimals 7 bit number of decimals digit to show
Expand All @@ -116,7 +116,7 @@ fn abs64(x i64) u64 {
// convert from data format to compact u64
pub fn get_str_intp_u64_format(fmt_type StrIntpType, in_width int, in_precision int, in_tail_zeros bool, in_sign bool, in_pad_ch u8, in_base int, in_upper_case bool) u64 {
width := if in_width != 0 { abs64(in_width) } else { u64(0) }
allign := if in_width > 0 { u64(1 << 5) } else { u64(0) } // two bit 0 .left 1 .rigth, for now we use only one
align := if in_width > 0 { u64(1 << 5) } else { u64(0) } // two bit 0 .left 1 .right, for now we use only one
upper_case := if in_upper_case { u64(1 << 7) } else { u64(0) }
sign := if in_sign { u64(1 << 8) } else { u64(0) }
precision := if in_precision != 987698 {
Expand All @@ -126,14 +126,14 @@ pub fn get_str_intp_u64_format(fmt_type StrIntpType, in_width int, in_precision
}
tail_zeros := if in_tail_zeros { u32(1) << 16 } else { u32(0) }
base := u64(u32(in_base & 0xf) << 27)
res := u64((u64(fmt_type) & 0x1F) | allign | upper_case | sign | precision | tail_zeros | (u64(width & 0x3FF) << 17) | base | (u64(in_pad_ch) << 31))
res := u64((u64(fmt_type) & 0x1F) | align | upper_case | sign | precision | tail_zeros | (u64(width & 0x3FF) << 17) | base | (u64(in_pad_ch) << 31))
return res
}

// convert from data format to compact u32
pub fn get_str_intp_u32_format(fmt_type StrIntpType, in_width int, in_precision int, in_tail_zeros bool, in_sign bool, in_pad_ch u8, in_base int, in_upper_case bool) u32 {
width := if in_width != 0 { abs64(in_width) } else { u32(0) }
allign := if in_width > 0 { u32(1 << 5) } else { u32(0) } // two bit 0 .left 1 .rigth, for now we use only one
align := if in_width > 0 { u32(1 << 5) } else { u32(0) } // two bit 0 .left 1 .right, for now we use only one
upper_case := if in_upper_case { u32(1 << 7) } else { u32(0) }
sign := if in_sign { u32(1 << 8) } else { u32(0) }
precision := if in_precision != 987698 {
Expand All @@ -143,7 +143,7 @@ pub fn get_str_intp_u32_format(fmt_type StrIntpType, in_width int, in_precision
}
tail_zeros := if in_tail_zeros { u32(1) << 16 } else { u32(0) }
base := u32(u32(in_base & 0xf) << 27)
res := u32((u32(fmt_type) & 0x1F) | allign | upper_case | sign | precision | tail_zeros | (u32(width & 0x3FF) << 17) | base | (u32(in_pad_ch & 1) << 31))
res := u32((u32(fmt_type) & 0x1F) | align | upper_case | sign | precision | tail_zeros | (u32(width & 0x3FF) << 17) | base | (u32(in_pad_ch & 1) << 31))
return res
}

Expand All @@ -152,7 +152,7 @@ pub fn get_str_intp_u32_format(fmt_type StrIntpType, in_width int, in_precision
fn (data &StrIntpData) process_str_intp_data(mut sb strings.Builder) {
x := data.fmt
typ := unsafe { StrIntpType(x & 0x1F) }
allign := int((x >> 5) & 0x01)
align := int((x >> 5) & 0x01)
upper_case := ((x >> 7) & 0x01) > 0
sign := int((x >> 8) & 0x01)
precision := int((x >> 9) & 0x7F)
Expand All @@ -166,7 +166,7 @@ fn (data &StrIntpData) process_str_intp_data(mut sb strings.Builder) {
return
}

// if width > 0 { println("${x.hex()} Type: ${x & 0x7F} Width: ${width} Precision: ${precision} allign:${allign}") }
// if width > 0 { println("${x.hex()} Type: ${x & 0x7F} Width: ${width} Precision: ${precision} align:${align}") }

// manage base if any
if base > 0 {
Expand All @@ -190,20 +190,20 @@ fn (data &StrIntpData) process_str_intp_data(mut sb strings.Builder) {
len1: len1_set // number of decimal digits, if needed
positive: true // mandatory: the sign of the number passed
sign_flag: sign_set // flag for print sign as prefix in padding
allign: .left // alignment of the string
align: .left // alignment of the string
rm_tail_zero: tail_zeros // false // remove the tail zeros from floats
}

// allign
// align
if fmt_pad_ch == 0 {
match allign {
0 { bf.allign = .left }
1 { bf.allign = .right }
// 2 { bf.allign = .center }
else { bf.allign = .left }
match align {
0 { bf.align = .left }
1 { bf.align = .right }
// 2 { bf.align = .center }
else { bf.align = .left }
}
} else {
bf.allign = .right
bf.align = .right
}

unsafe {
Expand Down Expand Up @@ -708,7 +708,7 @@ pub fn str_intp_g64(in_str string) string {
[manualfree]
pub fn str_intp_sub(base_str string, in_str string) string {
index := base_str.index('%%') or {
eprintln('No strin interpolation %% parameteres')
eprintln('No string interpolation %% parameters')
exit(1)
}
// return base_str[..index] + in_str + base_str[index+2..]
Expand Down
4 changes: 2 additions & 2 deletions vlib/flag/flag.v
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn (mut f Flag) free() {
// str returns a string representation of the given Flag
pub fn (f Flag) str() string {
return '' + ' flag:\n' + ' name: ${f.name}\n' +
' abbr: `${f.abbr.ascii_str()}`\n' + ' usag: ${f.usage}\n' +
' abbr: `${f.abbr.ascii_str()}`\n' + ' usage: ${f.usage}\n' +
' desc: ${f.val_desc}'
}

Expand Down Expand Up @@ -266,7 +266,7 @@ fn (mut fs FlagParser) parse_value(longhand string, shorthand u8) []string {
}
}
for i, del in to_delete {
// i entrys are deleted so it's shifted left i times.
// i entries are deleted so it's shifted left i times.
fs.args.delete(del - i)
}
return found_entries
Expand Down
2 changes: 1 addition & 1 deletion vlib/flag/flag_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ fn test_could_expect_no_free_args() {
assert args.len < 0 // expect an error and need to use args
}

fn test_allow_abreviations() {
fn test_allow_abbreviations() {
mut fp := flag.new_flag_parser(['-v', '-o', 'some_file', '-i', '42', '-f', '2.0'])
v := fp.bool('version', `v`, false, '')
o := fp.string('output', `o`, 'empty', '')
Expand Down
2 changes: 1 addition & 1 deletion vlib/gg/draw.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ pub fn (ctx &Context) draw_ellipse_empty(x f32, y f32, rw f32, rh f32, c gx.Colo
sgl.end()
}

// draw_ellipse_filled draws an opaque elipse.
// draw_ellipse_filled draws an opaque ellipse.
// `x`,`y` defines the center of the ellipse.
// `rw` defines the *width* radius of the ellipse.
// `rh` defines the *height* radius of the ellipse.
Expand Down
Loading

0 comments on commit f98bb86

Please sign in to comment.