diff --git a/.gitignore b/.gitignore index cb77d18a4b..aad7ae35e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.dSYM +*_test diff --git a/base64/base64.v b/base64/base64.v index 64448166a3..5c801a47d0 100644 --- a/base64/base64.v +++ b/base64/base64.v @@ -14,7 +14,7 @@ const ( 47, 48, 49, 50, 51] ) -fn decode(data string) string { +pub fn decode(data string) string { p := data.cstr() len := data.len mut pad := 0 @@ -25,7 +25,7 @@ fn decode(data string) string { str_len := L / 4 * 3 + pad mut str := malloc(str_len + 2) mut j := 0 - for i := 0; i < L; i += 4 { + for i := 0; i < L; i = i+4 { n := (Index[p[i]] << 18) | (Index[p[i + 1]] << 12) | (Index[p[i + 2]] << 6) | (Index[p[i + 3]]) str[j] = n >> 16 @@ -44,7 +44,7 @@ fn decode(data string) string { } } str[str_len + 1] = `\0` - return tos(str, str_len+2) + return tos(str, str_len+1) } const ( diff --git a/builtin/string.v b/builtin/string.v index 441234ba73..c7db31df53 100644 --- a/builtin/string.v +++ b/builtin/string.v @@ -143,7 +143,7 @@ fn (s string) int() int { } fn (s string) f32() f32 { - return C.atof(s.str) + return C.atof(s.str) } // == @@ -332,7 +332,7 @@ pub fn (s string) right(n int) string { // puts(substr.str) will print 'rivet' // Avoid using C functions with these substrs! pub fn (s string) substr(start, end int) string { - /* + /* if start > end || start >= s.len || end > s.len || start < 0 || end < 0 { panic('substr($start, $end) out of bounds (len=$s.len)') return '' diff --git a/builtin/string_test.v b/builtin/string_test.v index d650cab2d4..ca7937533f 100644 --- a/builtin/string_test.v +++ b/builtin/string_test.v @@ -289,4 +289,5 @@ fn test_all_after() { s := 'fn hello' q := s.all_after('fn ') assert q == 'hello' +} diff --git a/compiler/Makefile b/compiler/Makefile index 85b43544b1..4f4694a36a 100644 --- a/compiler/Makefile +++ b/compiler/Makefile @@ -8,7 +8,7 @@ v.c: curl -Os https://raw.githubusercontent.com/vlang/vc/master/v.c test: v - find .. -name '*_test.v' | xargs ./v {} + find .. -name '*_test.v' -print0 | xargs -0 -n1 ./v clean: -rm -f v.c v diff --git a/glm/glm.v b/glm/glm.v index 912da5608c..b3f8ebe74f 100644 --- a/glm/glm.v +++ b/glm/glm.v @@ -33,7 +33,7 @@ struct Vec3 { z f32 } -fn vec3(x, y, z f32) Vec3 { +pub fn vec3(x, y, z f32) Vec3 { res := Vec3 { x: x, y: y,