diff --git a/vlib/builtin/cdefs.v b/vlib/builtin/cfns.v similarity index 100% rename from vlib/builtin/cdefs.v rename to vlib/builtin/cfns.v diff --git a/vlib/compiler/gen_c.v b/vlib/compiler/gen_c.v index 87467c0e8e..032d870fd4 100644 --- a/vlib/compiler/gen_c.v +++ b/vlib/compiler/gen_c.v @@ -247,7 +247,9 @@ fn (table mut Table) fn_gen_name(f &Fn) string { return name } -fn (p mut Parser) gen_method_call(receiver_type, ftyp string, cgen_name string, receiver Var,method_ph int) { +fn (p mut Parser) gen_method_call(receiver_type, ftyp string, cgen_name string, + receiver Var,method_ph int) +{ //mut cgen_name := p.table.fn_gen_name(f) mut method_call := cgen_name + '(' // if receiver is key_mut or a ref (&), generate & for the first arg diff --git a/vlib/compiler/gen_js.v b/vlib/compiler/gen_js.v index 06dc895745..9323afd000 100644 --- a/vlib/compiler/gen_js.v +++ b/vlib/compiler/gen_js.v @@ -91,7 +91,9 @@ fn (table &Table) fn_gen_name(f &Fn) string { return name } -fn (p mut Parser) gen_method_call(receiver_type, ftyp string, cgen_name string, receiver Var,method_ph int) { +fn (p mut Parser) gen_method_call(receiver_type, ftyp string, + cgen_name string, receiver Var,method_ph int) +{ //mut cgen_name := p.table.fn_gen_name(f) //mut method_call := cgen_name + '(' p.gen('.' + cgen_name.all_after('_') + '(') diff --git a/vlib/net/urllib/urllib.v b/vlib/net/urllib/urllib.v index 0e62de337f..e22fe7a4b7 100644 --- a/vlib/net/urllib/urllib.v +++ b/vlib/net/urllib/urllib.v @@ -55,48 +55,56 @@ fn should_escape(c byte, mode EncodingMode) bool { // we could possibly allow, and parse will reject them if we // escape them (because hosts can`t use %-encoding for // ASCII bytes). - switch c { - case `!`, `$`, `&`, `\\`, `(`, `)`, `*`, `+`, `,`, `;`, `=`, `:`, `[`, `]`, `<`, `>`, `"`: + if c in [`!`, `$`, `&`, `\\`, `(`, `)`, `*`, `+`, `,`, `;`, `=`, + `:`, `[`, `]`, `<`, `>`, `"`] + { return false } } - switch c { - case `-`, `_`, `.`, `~`: // §2.3 Unreserved characters (mark) - return false + match c { + `-`, `_`, `.`, `~` { // §2.3 Unreserved characters (mark) + return false + } - case `$`, `&`, `+`, `,`, `/`, `:`, `;`, `=`, `?`, `@`: // §2.2 Reserved characters (reserved) + `$`, `&`, `+`, `,`, `/`, `:`, `;`, `=`, `?`, `@` { // §2.2 Reserved characters (reserved) // Different sections of the URL allow a few of // the reserved characters to appear unescaped. - switch mode { - case EncodingMode.encode_path: // §3.3 + match mode { + .encode_path { // §3.3 // The RFC allows : @ & = + $ but saves / ; , for assigning // meaning to individual path segments. This package // only manipulates the path as a whole, so we allow those // last three as well. That leaves only ? to escape. return c == `?` + } - case EncodingMode.encode_path_segment: // §3.3 + .encode_path_segment { // §3.3 // The RFC allows : @ & = + $ but saves / ; , for assigning // meaning to individual path segments. return c == `/` || c == `;` || c == `,` || c == `?` + } - case EncodingMode.encode_user_password: // §3.2.1 + .encode_user_password { // §3.2.1 // The RFC allows `;`, `:`, `&`, `=`, `+`, `$`, and `,` in // userinfo, so we must escape only `@`, `/`, and `?`. // The parsing of userinfo treats `:` as special so we must escape // that too. return c == `@` || c == `/` || c == `?` || c == `:` + } - case EncodingMode.encode_query_component: // §3.4 + .encode_query_component { // §3.4 // The RFC reserves (so we must escape) everything. return true + } - case EncodingMode.encode_fragment: // §4.1 + .encode_fragment { // §4.1 // The RFC text is silent but the grammar allows // everything, so escape nothing. return false } + } + } } if mode == .encode_fragment {