Skip to content

Commit 6d5e368

Browse files
committed
all: super_batch7 fixes
1 parent 1d6b9b9 commit 6d5e368

10 files changed

Lines changed: 25 additions & 40 deletions

File tree

vlib/encoding/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
## Description
22

33
`encoding` is a namespace for different formats/protocols encoding/decoding,
4-
like `csv`, `utf8`, `base64`, and legacy text encodings such as `windows1252`.
4+
like `csv`, `utf8`, `base64` etc.

vlib/encoding/iconv/iconv.v

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module iconv
22

33
// Module iconv provides functions to convert between vstring(UTF8) and other encodings.
4-
import encoding.windows1252
54
import os
65

76
@[inline]
@@ -28,9 +27,6 @@ pub fn vstring_to_encoding(str string, tocode string) ![]u8 {
2827
encoding_name = 'UTF-8'
2928
}
3029
}
31-
if is_windows_1252_encoding(encoding_name) {
32-
return windows1252.encode(str)
33-
}
3430
return conv(encoding_name, 'UTF-8', str.str, str.len)
3531
}
3632

@@ -48,19 +44,11 @@ pub fn encoding_to_vstring(bytes []u8, fromcode string) !string {
4844
encoding_name = 'UTF-8'
4945
}
5046
}
51-
if is_windows_1252_encoding(encoding_name) {
52-
return windows1252.decode(bytes)
53-
}
5447
mut dst := conv('UTF-8', encoding_name, bytes.data, bytes.len)!
5548
dst << 0 // add a tail zero, to build a vstring
5649
return unsafe { cstring_to_vstring(dst.data) }
5750
}
5851

59-
@[inline]
60-
fn is_windows_1252_encoding(encoding_name string) bool {
61-
return encoding_name in ['CP1252', 'MS-ANSI', 'WINDOWS-1252', 'WINDOWS1252']!
62-
}
63-
6452
// create_utf_string_with_bom will create a utf8/utf16/utf32 string with BOM header
6553
// for utf8, it will prepend 0xEFBBBF to the `src`
6654
// for utf16le, it will prepend 0xFFFE to the `src`

vlib/encoding/iconv/iconv_test.v

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,6 @@ fn test_encoding_to_vstring() {
7878
}
7979
}
8080

81-
fn test_windows_1252_encoding_support() ! {
82-
pound := iconv.encoding_to_vstring([u8(0xa3)], 'WINDOWS-1252')!
83-
assert pound == '£'
84-
assert pound.runes() == [rune(0x00a3)]
85-
86-
smart_quotes := iconv.encoding_to_vstring([u8(0x93), 0x56, 0x94], 'CP1252')!
87-
assert smart_quotes == '“V”'
88-
assert iconv.vstring_to_encoding(smart_quotes, 'WINDOWS-1252')! == [u8(0x93), 0x56, 0x94]
89-
}
90-
9181
fn test_create_utf_string_with_bom() {
9282
// bug ? vfmt create strange format here
9383
// vfmt off

vlib/v/ast/ast.v

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3247,16 +3247,10 @@ pub fn (expr Expr) is_reference() bool {
32473247
}
32483248

32493249
// remove_par removes all parenthesis and gets the innermost Expr
3250-
pub fn (mut expr Expr) remove_par() Expr {
3250+
pub fn (expr Expr) remove_par() Expr {
32513251
mut e := expr
3252-
for {
3253-
mut next_expr := Expr(EmptyExpr{})
3254-
if mut e is ParExpr {
3255-
next_expr = e.expr
3256-
} else {
3257-
break
3258-
}
3259-
e = next_expr
3252+
for e is ParExpr {
3253+
e = (e as ParExpr).expr
32603254
}
32613255
return e
32623256
}

vlib/v/builder/cc.v

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,15 @@ fn (mut v Builder) setup_output_name() {
10751075
}
10761076

10771077
pub fn (mut v Builder) tcc_quoted_path(p string) string {
1078-
return os.quoted_path(v.tcc_windows_path(p))
1078+
wp := v.tcc_windows_path(p)
1079+
if v.ccoptions.cc == .tcc && !v.pref.no_rsp {
1080+
// tcc has a bug that prevents it from parsing names quoted with `'` in .rsp files,
1081+
// so force double-quoted, backslash-escaped paths for tcc rsp mode.
1082+
mut escaped := wp.replace('\\', '\\\\')
1083+
escaped = escaped.replace('"', '\\"')
1084+
return '"${escaped}"'
1085+
}
1086+
return os.quoted_path(wp)
10791087
}
10801088

10811089
fn looks_like_windows_path(value string) bool {
@@ -1496,6 +1504,10 @@ pub fn (mut v Builder) cc() {
14961504
if v.pref.ccompiler != '' && v.pref.ccompiler != ccompiler {
14971505
if v.pref.is_verbose {
14981506
eprintln('Compilation with tcc failed. Retrying with ${v.pref.ccompiler} ...')
1507+
} else {
1508+
$if macos {
1509+
eprintln(term.red('warning: tcc compilation failed, falling back to ${v.pref.ccompiler} (this is much slower)'))
1510+
}
14991511
}
15001512
continue
15011513
}

vlib/v/builder/cflags.v

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ fn (mut v Builder) get_os_cflags() []cflag.CFlag {
1212
ctimedefines << v.pref.compile_defines
1313
}
1414
for mut flag in v.table.cflags {
15-
if ext := os.file_ext(flag.value); ext in ['.o', '.obj'] {
15+
ext := os.file_ext(flag.value)
16+
if ext in ['.o', '.obj'] {
1617
flag.cached = v.pref.cache_manager.mod_postfix_with_key2cpath(flag.mod, ext,
1718
os.real_path(flag.value))
1819
}

vlib/v/checker/struct.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ fn (mut c Checker) struct_decl(mut node ast.StructDecl) {
143143
c.error('field ${err_desc} reference but default value ${val_desc} reference',
144144
default_pos)
145145
} else if field.default_expr is ast.StructInit
146-
|| (field.typ.is_ptr()
147-
&& (field.default_expr is ast.Ident || field.default_expr is ast.SelectorExpr)) {
146+
|| (field.typ.is_ptr() && (field.default_expr is ast.Ident
147+
|| field.default_expr is ast.SelectorExpr)) {
148148
c.error('reference field must be initialized with reference', default_pos)
149149
}
150150
}

vlib/v/gen/c/cgen.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8612,8 +8612,8 @@ fn (mut g Gen) cast_expr(node ast.CastExpr) {
86128612
return
86138613
}
86148614
use_dynamic_ptr_payload := node_typ.is_ptr() && expr_type.is_ptr()
8615-
&& final_expr_sym.kind == .sum_type
8616-
&& final_sym.kind !in [.sum_type, .interface] && final_sym.language == .c
8615+
&& final_expr_sym.kind == .sum_type && final_sym.kind !in [.sum_type, .interface]
8616+
&& final_sym.language == .c
86178617
if (g.pref.translated || g.file.is_translated) && sym.kind == .function {
86188618
// TODO: handle the type in fn casts, not just exprs
86198619
/*

vlib/v/tests/builtin_arrays/array_init_test.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ fn empty_array_from_generic_typ[T]() []T {
290290

291291
fn test_array_init_from_typeof_idx() {
292292
fixed := [1, 2, 3]!
293-
dyn := []typeof(fixed[0]).idx{}
293+
dyn := []typeof(fixed[0]).idx{}{}
294294
assert typeof(dyn).name == '[]int'
295295
assert dyn.len == 0
296296
}

vlib/v/tests/fns/fn_index_direct_call_test.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ fn add(a int, b int) int {
4141
}
4242

4343
fn test_parenthesized_fn_direct_call() {
44-
assert (add)(2, 4) == 6
44+
assert add(2, 4) == 6
4545
}

0 commit comments

Comments
 (0)