Skip to content

Commit d39b5ff

Browse files
committed
all: super_batch7 fixes
1 parent 1d6b9b9 commit d39b5ff

13 files changed

Lines changed: 48 additions & 40 deletions

File tree

vlib/builtin/array_notd_gcboehm_opt.v

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44

55
module builtin
66

7+
// these are needed for calls inside `$if gcboehm_opt ? { ... }` in array.v
8+
fn alloc_array_data_noscan(total_size u64) voidptr {
9+
return alloc_array_data(total_size)
10+
}
11+
12+
fn alloc_array_data_noscan_uninit(total_size u64) voidptr {
13+
return alloc_array_data_uninit(total_size)
14+
}
15+
716
// this is needed in `string.v`
817
fn __new_array_noscan(mylen int, cap int, elm_size int) array {
918
return __new_array(mylen, cap, elm_size)

vlib/builtin/builtin_nix.c.v

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,10 @@ pub fn panic_lasterr(base string) {
2525
// TODO: use strerror_r and errno
2626
panic(base + ' unknown')
2727
}
28+
29+
// write_buf_to_console is a Windows-only helper; on non-Windows platforms
30+
// it is a no-op stub so that callers guarded by `$if windows { ... }` still
31+
// type-check on other targets.
32+
fn write_buf_to_console(fd int, buf &u8, buf_len int) bool {
33+
return false
34+
}

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/os/os_nix.c.v

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ module os
99
#include <utime.h>
1010
#insert "@VEXEROOT/vlib/os/execute_capture_nix.h"
1111

12+
// short_path is a Windows-only helper that returns the DOS 8.3 short path.
13+
// On non-Windows platforms it simply returns the given path unchanged,
14+
// so that callers guarded by `$if windows { ... }` type-check on other targets.
15+
pub fn short_path(path string) string {
16+
return path
17+
}
18+
1219
// path_separator is the platform specific separator string, used between the folders and filenames in a path. It is '/' on POSIX, and '\\' on Windows.
1320
pub const path_separator = '/'
1421

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
}

0 commit comments

Comments
 (0)