ci: remove some tests from skip_with_werror in `v test-self`

pull/9732/head
Delyan Angelov 2021-04-14 12:47:24 +03:00
parent 980521824f
commit 3e297bced4
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
16 changed files with 59 additions and 70 deletions

View File

@ -32,24 +32,7 @@ const (
skip_with_werror = [ skip_with_werror = [
'vlib/clipboard/clipboard_test.v', 'vlib/clipboard/clipboard_test.v',
'vlib/eventbus/eventbus_test.v', 'vlib/eventbus/eventbus_test.v',
'vlib/gx/color_test.v',
'vlib/json/json_test.v',
'vlib/math/big/big_test.v',
'vlib/net/ftp/ftp_test.v',
'vlib/net/http/cookie_test.v',
'vlib/net/http/http_httpbin_test.v',
'vlib/net/http/header_test.v',
'vlib/net/tcp_test.v',
'vlib/net/tcp_simple_client_server_test.v',
'vlib/net/smtp/smtp_test.v',
'vlib/net/udp_test.v',
'vlib/net/unix/unix_test.v',
'vlib/net/http/http_test.v',
'vlib/net/http/status_test.v',
'vlib/orm/orm_test.v', 'vlib/orm/orm_test.v',
'vlib/os/os_test.v',
'vlib/rand/mt19937/mt19937_test.v',
'vlib/readline/readline_test.v',
'vlib/regex/regex_test.v', 'vlib/regex/regex_test.v',
'vlib/sqlite/sqlite_test.v', 'vlib/sqlite/sqlite_test.v',
'vlib/strconv/atof_test.v', 'vlib/strconv/atof_test.v',

View File

@ -51,7 +51,7 @@ pub fn (s &C.FONScontext) reset_atlas(width int, height int) int {
// Add fonts // Add fonts
[inline] [inline]
pub fn (s &C.FONScontext) get_font_by_name(name byteptr) int { pub fn (s &C.FONScontext) get_font_by_name(name &char) int {
return C.fonsGetFontByName(s, name) return C.fonsGetFontByName(s, name)
} }
@ -61,7 +61,7 @@ pub fn (s &C.FONScontext) add_fallback_font(base int, fallback int) int {
} }
[inline] [inline]
pub fn (s &C.FONScontext) add_font_mem(name byteptr, data byteptr, data_size int, free_data int) int { pub fn (s &C.FONScontext) add_font_mem(name &char, data &byte, data_size int, free_data int) int {
return C.fonsAddFontMem(s, name, data, data_size, free_data) return C.fonsAddFontMem(s, name, data, data_size, free_data)
} }
@ -114,13 +114,13 @@ pub fn (s &C.FONScontext) set_font(font int) {
// Draw text // Draw text
[inline] [inline]
pub fn (s &C.FONScontext) draw_text(x f32, y f32, str byteptr, end byteptr) f32 { pub fn (s &C.FONScontext) draw_text(x f32, y f32, str &char, end &char) f32 {
return C.fonsDrawText(s, x, y, str, end) return C.fonsDrawText(s, x, y, str, end)
} }
// Measure text // Measure text
[inline] [inline]
pub fn (s &C.FONScontext) text_bounds(x f32, y f32, str byteptr, end byteptr, bounds &f32) f32 { pub fn (s &C.FONScontext) text_bounds(x f32, y f32, str &char, end &char, bounds &f32) f32 {
return C.fonsTextBounds(s, x, y, str, end, bounds) return C.fonsTextBounds(s, x, y, str, end, bounds)
} }
@ -136,7 +136,7 @@ pub fn (s &C.FONScontext) vert_metrics(ascender &f32, descender &f32, lineh &f32
// Text iterator // Text iterator
[inline] [inline]
pub fn (s &C.FONScontext) text_iter_init(iter &C.FONStextIter, x f32, y f32, str byteptr, end byteptr) int { pub fn (s &C.FONScontext) text_iter_init(iter &C.FONStextIter, x f32, y f32, str &char, end &char) int {
return C.fonsTextIterInit(s, iter, x, y, str, end) return C.fonsTextIterInit(s, iter, x, y, str, end)
} }
@ -147,8 +147,8 @@ pub fn (s &C.FONScontext) text_iter_next(iter &C.FONStextIter, quad &C.FONSquad)
// Pull texture changes // Pull texture changes
[inline] [inline]
pub fn (s &C.FONScontext) get_texture_data(width &int, height &int) byteptr { pub fn (s &C.FONScontext) get_texture_data(width &int, height &int) &byte {
return C.fonsGetTextureData(s, width, height) return &byte(C.fonsGetTextureData(s, width, height))
} }
[inline] [inline]

View File

@ -4,18 +4,21 @@ module fontstash
fn C.fonsCreateInternal(params &C.FONSparams) &C.FONScontext fn C.fonsCreateInternal(params &C.FONSparams) &C.FONScontext
fn C.fonsDeleteInternal(s &C.FONScontext) fn C.fonsDeleteInternal(s &C.FONScontext)
fn C.fonsSetErrorCallback(s &C.FONScontext, callback fn(uptr voidptr, error int, val int), uptr voidptr) fn C.fonsSetErrorCallback(s &C.FONScontext, callback fn (voidptr, int, int), uptr voidptr)
// Returns current atlas size. // Returns current atlas size.
fn C.fonsGetAtlasSize(s &C.FONScontext, width &int, height &int) fn C.fonsGetAtlasSize(s &C.FONScontext, width &int, height &int)
// Expands the atlas size. // Expands the atlas size.
fn C.fonsExpandAtlas(s &C.FONScontext, width int, height int) int fn C.fonsExpandAtlas(s &C.FONScontext, width int, height int) int
// Resets the whole stash. // Resets the whole stash.
fn C.fonsResetAtlas(s &C.FONScontext, width int, height int) int fn C.fonsResetAtlas(s &C.FONScontext, width int, height int) int
// Add fonts // Add fonts
fn C.fonsGetFontByName(s &C.FONScontext, name byteptr) int fn C.fonsGetFontByName(s &C.FONScontext, name &char) int
fn C.fonsAddFallbackFont(s &C.FONScontext, base int, fallback int) int fn C.fonsAddFallbackFont(s &C.FONScontext, base int, fallback int) int
fn C.fonsAddFontMem(s &C.FONScontext, name byteptr, data byteptr, dataSize int, freeData int) int fn C.fonsAddFontMem(s &C.FONScontext, name &char, data &byte, dataSize int, freeData int) int
// State handling // State handling
fn C.fonsPushState(s &C.FONScontext) fn C.fonsPushState(s &C.FONScontext)
@ -31,19 +34,19 @@ fn C.fonsSetAlign(s &C.FONScontext, align int)
fn C.fonsSetFont(s &C.FONScontext, font int) fn C.fonsSetFont(s &C.FONScontext, font int)
// Draw text // Draw text
fn C.fonsDrawText(s &C.FONScontext, x f32, y f32, str byteptr, end byteptr) f32 fn C.fonsDrawText(s &C.FONScontext, x f32, y f32, str &char, end &char) f32
// Measure text // Measure text
fn C.fonsTextBounds(s &C.FONScontext, x f32, y f32, str byteptr, end byteptr, bounds &f32) f32 fn C.fonsTextBounds(s &C.FONScontext, x f32, y f32, str &char, end &char, bounds &f32) f32
fn C.fonsLineBounds(s &C.FONScontext, y f32, miny &f32, maxy &f32) fn C.fonsLineBounds(s &C.FONScontext, y f32, miny &f32, maxy &f32)
fn C.fonsVertMetrics(s &C.FONScontext, ascender &f32, descender &f32, lineh &f32) fn C.fonsVertMetrics(s &C.FONScontext, ascender &f32, descender &f32, lineh &f32)
// Text iterator // Text iterator
fn C.fonsTextIterInit(s &C.FONScontext, iter &C.FONStextIter, x f32, y f32, str byteptr, end byteptr) int fn C.fonsTextIterInit(s &C.FONScontext, iter &C.FONStextIter, x f32, y f32, str &char, end &char) int
fn C.fonsTextIterNext(s &C.FONScontext, iter &C.FONStextIter, quad &C.FONSquad) int fn C.fonsTextIterNext(s &C.FONScontext, iter &C.FONStextIter, quad &C.FONSquad) int
// Pull texture changes // Pull texture changes
fn C.fonsGetTextureData(s &C.FONScontext, width &int, height &int) byteptr fn C.fonsGetTextureData(s &C.FONScontext, width &int, height &int) &char
fn C.fonsValidateTexture(s &C.FONScontext, dirty &int) int fn C.fonsValidateTexture(s &C.FONScontext, dirty &int) int
// Draws the stash texture for debugging // Draws the stash texture for debugging

View File

@ -11,7 +11,7 @@ module json
struct C.cJSON { struct C.cJSON {
valueint int valueint int
valuedouble f32 valuedouble f32
valuestring charptr valuestring &char
} }
fn C.cJSON_IsTrue(&C.cJSON) bool fn C.cJSON_IsTrue(&C.cJSON) bool
@ -20,13 +20,13 @@ fn C.cJSON_CreateNumber(int) &C.cJSON
fn C.cJSON_CreateBool(bool) &C.cJSON fn C.cJSON_CreateBool(bool) &C.cJSON
fn C.cJSON_CreateString(charptr) &C.cJSON fn C.cJSON_CreateString(&char) &C.cJSON
fn C.cJSON_Parse(charptr) &C.cJSON fn C.cJSON_Parse(&char) &C.cJSON
fn C.cJSON_PrintUnformatted(&C.cJSON) charptr fn C.cJSON_PrintUnformatted(&C.cJSON) &char
fn C.cJSON_Print(&C.cJSON) charptr fn C.cJSON_Print(&C.cJSON) &char
pub fn decode(typ voidptr, s string) ?voidptr { pub fn decode(typ voidptr, s string) ?voidptr {
// compiler implementation // compiler implementation
@ -122,7 +122,7 @@ fn decode_string(root &C.cJSON) string {
} }
// println('decode string valuestring="$root.valuestring"') // println('decode string valuestring="$root.valuestring"')
// return tos(root.valuestring, _strlen(root.valuestring)) // return tos(root.valuestring, _strlen(root.valuestring))
return unsafe { tos_clone(byteptr(root.valuestring)) } // , _strlen(root.valuestring)) return unsafe { tos_clone(&byte(root.valuestring)) } // , _strlen(root.valuestring))
} }
fn decode_bool(root &C.cJSON) bool { fn decode_bool(root &C.cJSON) bool {
@ -190,12 +190,12 @@ fn json_parse(s string) &C.cJSON {
// json_string := json_print(encode_User(user)) // json_string := json_print(encode_User(user))
fn json_print(json &C.cJSON) string { fn json_print(json &C.cJSON) string {
s := C.cJSON_PrintUnformatted(json) s := C.cJSON_PrintUnformatted(json)
return unsafe { tos(byteptr(s), C.strlen(&char(s))) } return unsafe { tos(&byte(s), C.strlen(&char(s))) }
} }
fn json_print_pretty(json &C.cJSON) string { fn json_print_pretty(json &C.cJSON) string {
s := C.cJSON_Print(json) s := C.cJSON_Print(json)
return unsafe { tos(byteptr(s), C.strlen(&char(s))) } return unsafe { tos(&byte(s), C.strlen(&char(s))) }
} }
// / cjson wrappers // / cjson wrappers

View File

@ -19,9 +19,9 @@ fn C.bignum_from_int(n &Number, i u64)
fn C.bignum_to_int(n &Number) int fn C.bignum_to_int(n &Number) int
fn C.bignum_from_string(n &Number, s &byte, nbytes int) fn C.bignum_from_string(n &Number, s &char, nbytes int)
fn C.bignum_to_string(n &Number, s &byte, maxsize int) fn C.bignum_to_string(n &Number, s &char, maxsize int)
// c = a + b // c = a + b
fn C.bignum_add(a &Number, b &Number, c &Number) fn C.bignum_add(a &Number, b &Number, c &Number)
@ -104,7 +104,7 @@ pub fn from_hex_string(input string) Number {
padding := '0'.repeat((8 - s.len % 8) % 8) padding := '0'.repeat((8 - s.len % 8) % 8)
s = padding + s s = padding + s
n := Number{} n := Number{}
C.bignum_from_string(&n, s.str, s.len) C.bignum_from_string(&n, &char(s.str), s.len)
return n return n
} }
@ -151,7 +151,7 @@ pub fn (n Number) hexstr() string {
unsafe { unsafe {
bp := &buf[0] bp := &buf[0]
// NB: C.bignum_to_string(), returns the HEXADECIMAL representation of the bignum n // NB: C.bignum_to_string(), returns the HEXADECIMAL representation of the bignum n
C.bignum_to_string(&n, bp, 8192) C.bignum_to_string(&n, &char(bp), 8192)
s = tos_clone(bp) s = tos_clone(bp)
} }
if s.len == 0 { if s.len == 0 {

View File

@ -115,7 +115,7 @@ fn test_str() {
assert big.from_u64(1024).str() == '1024' assert big.from_u64(1024).str() == '1024'
assert big.from_u64(4294967295).str() == '4294967295' assert big.from_u64(4294967295).str() == '4294967295'
assert big.from_u64(4398046511104).str() == '4398046511104' assert big.from_u64(4398046511104).str() == '4398046511104'
assert big.from_int(4294967295).str() == '18446744073709551615' assert big.from_int(int(4294967295)).str() == '18446744073709551615'
assert big.from_int(-1).str() == '18446744073709551615' assert big.from_int(-1).str() == '18446744073709551615'
assert big.from_hex_string('e'.repeat(80)).str() == '1993587900192849410235353592424915306962524220866209251950572167300738410728597846688097947807470' assert big.from_hex_string('e'.repeat(80)).str() == '1993587900192849410235353592424915306962524220866209251950572167300738410728597846688097947807470'
} }

View File

@ -72,9 +72,10 @@ pub fn resolve_addr(addr string, family SocketFamily, typ SocketType) ?Addr {
// This might look silly but is recommended by MSDN // This might look silly but is recommended by MSDN
$if windows { $if windows {
socket_error(0 - C.getaddrinfo(address.str, sport.str, &hints, &info)) ? socket_error(0 - C.getaddrinfo(&char(address.str), &char(sport.str), &hints,
&info)) ?
} $else { } $else {
x := C.getaddrinfo(address.str, sport.str, &hints, &info) x := C.getaddrinfo(&char(address.str), &char(sport.str), &hints, &info)
wrap_error(x) ? wrap_error(x) ?
} }

View File

@ -12,7 +12,7 @@ const (
fn (req &Request) ssl_do(port int, method Method, host_name string, path string) ?Response { fn (req &Request) ssl_do(port int, method Method, host_name string, path string) ?Response {
// ssl_method := C.SSLv23_method() // ssl_method := C.SSLv23_method()
ctx := C.SSL_CTX_new(C.TLSv1_2_method()) ctx := C.SSL_CTX_new(C.TLS_method())
C.SSL_CTX_set_verify_depth(ctx, 4) C.SSL_CTX_set_verify_depth(ctx, 4)
flags := C.SSL_OP_NO_SSLv2 | C.SSL_OP_NO_SSLv3 | C.SSL_OP_NO_COMPRESSION flags := C.SSL_OP_NO_SSLv2 | C.SSL_OP_NO_SSLv3 | C.SSL_OP_NO_COMPRESSION
C.SSL_CTX_set_options(ctx, flags) C.SSL_CTX_set_options(ctx, flags)
@ -23,7 +23,7 @@ fn (req &Request) ssl_do(port int, method Method, host_name string, path string)
ssl := &openssl.SSL(0) ssl := &openssl.SSL(0)
C.BIO_get_ssl(web, &ssl) C.BIO_get_ssl(web, &ssl)
preferred_ciphers := 'HIGH:!aNULL:!kRSA:!PSK:!SRP:!MD5:!RC4' preferred_ciphers := 'HIGH:!aNULL:!kRSA:!PSK:!SRP:!MD5:!RC4'
res = C.SSL_set_cipher_list(voidptr(ssl), preferred_ciphers.str) res = C.SSL_set_cipher_list(voidptr(ssl), &char(preferred_ciphers.str))
if res != 1 { if res != 1 {
println('http: openssl: cipher failed') println('http: openssl: cipher failed')
} }
@ -41,7 +41,7 @@ fn (req &Request) ssl_do(port int, method Method, host_name string, path string)
eprintln('> $req_headers') eprintln('> $req_headers')
} }
// println(req_headers) // println(req_headers)
C.BIO_puts(web, req_headers.str) C.BIO_puts(web, &char(req_headers.str))
mut content := strings.new_builder(100) mut content := strings.new_builder(100)
mut buff := [bufsize]byte{} mut buff := [bufsize]byte{}
bp := &buff[0] bp := &buff[0]

View File

@ -159,7 +159,7 @@ pub fn (c &TcpConn) peer_addr() ?Addr {
} }
pub fn (c &TcpConn) peer_ip() ?string { pub fn (c &TcpConn) peer_ip() ?string {
buf := [44]byte{} buf := [44]char{}
peeraddr := C.sockaddr_in{} peeraddr := C.sockaddr_in{}
speeraddr := sizeof(peeraddr) speeraddr := sizeof(peeraddr)
socket_error(C.getpeername(c.sock.handle, unsafe { &C.sockaddr(&peeraddr) }, &speeraddr)) ? socket_error(C.getpeername(c.sock.handle, unsafe { &C.sockaddr(&peeraddr) }, &speeraddr)) ?

View File

@ -41,7 +41,8 @@ fn error_code() int {
} }
fn new_stream_socket() ?StreamSocket { fn new_stream_socket() ?StreamSocket {
sockfd := net.socket_error(C.socket(net.SocketFamily.unix, net.SocketType.stream, 0)) ? sockfd := net.socket_error(C.socket(net.SocketFamily.unix, net.SocketType.stream,
0)) ?
mut s := StreamSocket{ mut s := StreamSocket{
handle: sockfd handle: sockfd
} }
@ -64,7 +65,7 @@ fn (mut s StreamSocket) connect(a string) ? {
mut addr := C.sockaddr_un{} mut addr := C.sockaddr_un{}
unsafe { C.memset(&addr, 0, sizeof(C.sockaddr_un)) } unsafe { C.memset(&addr, 0, sizeof(C.sockaddr_un)) }
addr.sun_family = C.AF_UNIX addr.sun_family = C.AF_UNIX
unsafe { C.strncpy(&addr.sun_path[0], a.str, max_sun_path) } unsafe { C.strncpy(&addr.sun_path[0], &char(a.str), max_sun_path) }
size := C.SUN_LEN(&addr) size := C.SUN_LEN(&addr)
sockaddr := unsafe { &C.sockaddr(&addr) } sockaddr := unsafe { &C.sockaddr(&addr) }
res := C.connect(s.handle, sockaddr, size) res := C.connect(s.handle, sockaddr, size)
@ -97,7 +98,7 @@ pub fn listen_stream(sock string) ?&StreamListener {
mut addr := C.sockaddr_un{} mut addr := C.sockaddr_un{}
unsafe { C.memset(&addr, 0, sizeof(C.sockaddr_un)) } unsafe { C.memset(&addr, 0, sizeof(C.sockaddr_un)) }
addr.sun_family = C.AF_UNIX addr.sun_family = C.AF_UNIX
unsafe { C.strncpy(&addr.sun_path[0], sock.str, max_sun_path) } unsafe { C.strncpy(&addr.sun_path[0], &char(sock.str), max_sun_path) }
size := C.SUN_LEN(&addr) size := C.SUN_LEN(&addr)
sockaddr := unsafe { &C.sockaddr(&addr) } sockaddr := unsafe { &C.sockaddr(&addr) }
net.socket_error(C.bind(s.handle, sockaddr, size)) ? net.socket_error(C.bind(s.handle, sockaddr, size)) ?
@ -170,14 +171,14 @@ pub fn (mut c StreamConn) close() ? {
} }
// write_ptr blocks and attempts to write all data // write_ptr blocks and attempts to write all data
pub fn (mut c StreamConn) write_ptr(b byteptr, len int) ?int { pub fn (mut c StreamConn) write_ptr(b &byte, len int) ?int {
$if trace_unix ? { $if trace_unix ? {
eprintln( eprintln(
'>>> StreamConn.write_ptr | c.sock.handle: $c.sock.handle | b: ${ptr_str(b)} len: $len |\n' + '>>> StreamConn.write_ptr | c.sock.handle: $c.sock.handle | b: ${ptr_str(b)} len: $len |\n' +
unsafe { b.vstring_with_len(len) }) unsafe { b.vstring_with_len(len) })
} }
unsafe { unsafe {
mut ptr_base := byteptr(b) mut ptr_base := &byte(b)
mut total_sent := 0 mut total_sent := 0
for total_sent < len { for total_sent < len {
ptr := ptr_base + total_sent ptr := ptr_base + total_sent
@ -214,7 +215,7 @@ pub fn (mut c StreamConn) write_string(s string) ?int {
return c.write_ptr(s.str, s.len) return c.write_ptr(s.str, s.len)
} }
pub fn (mut c StreamConn) read_ptr(buf_ptr byteptr, len int) ?int { pub fn (mut c StreamConn) read_ptr(buf_ptr &byte, len int) ?int {
mut res := wrap_read_result(C.recv(c.sock.handle, buf_ptr, len, 0)) ? mut res := wrap_read_result(C.recv(c.sock.handle, buf_ptr, len, 0)) ?
$if trace_unix ? { $if trace_unix ? {
eprintln('<<< StreamConn.read_ptr | c.sock.handle: $c.sock.handle | buf_ptr: ${ptr_str(buf_ptr)} len: $len | res: $res') eprintln('<<< StreamConn.read_ptr | c.sock.handle: $c.sock.handle | buf_ptr: ${ptr_str(buf_ptr)} len: $len | res: $res')

View File

@ -17,7 +17,7 @@ const (
fn mt19937_basic_test() { fn mt19937_basic_test() {
mut rng := mt19937.MT19937RNG{} mut rng := mt19937.MT19937RNG{}
rng.seed([u32(0xdeadbeef)]) rng.seed([u32(0xdeadbeef)])
target := [956529277, 3842322136, 3319553134, 1843186657, 2704993644, 595827513, 938518626, target := [u32(956529277), 3842322136, 3319553134, 1843186657, 2704993644, 595827513, 938518626,
1676224337, 3221315650, 1819026461] 1676224337, 3221315650, 1819026461]
for i := 0; i < 10; i++ { for i := 0; i < 10; i++ {
assert target[i] == rng.u32() assert target[i] == rng.u32()

View File

@ -8,6 +8,8 @@
module readline module readline
// Termios stores the terminal options on Linux. // Termios stores the terminal options on Linux.
struct C.termios {}
struct Termios { struct Termios {
mut: mut:
c_iflag int c_iflag int
@ -32,7 +34,7 @@ mut:
is_raw bool is_raw bool
orig_termios Termios // Linux orig_termios Termios // Linux
current ustring // Line being edited current ustring // Line being edited
cursor int // Cursor position cursor int // Cursor position
overwrite bool overwrite bool
cursor_row_offset int cursor_row_offset int
prompt string prompt string

View File

@ -13,9 +13,9 @@ import os
#include <termios.h> #include <termios.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
fn C.tcgetattr(fd int, termios_p &Termios) int fn C.tcgetattr(fd int, termios_p &C.termios) int
fn C.tcsetattr(fd int, optional_actions int, termios_p &Termios) int fn C.tcsetattr(fd int, optional_actions int, termios_p &C.termios) int
fn C.raise(sig int) fn C.raise(sig int)
@ -47,18 +47,18 @@ enum Action {
// Please note that `enable_raw_mode` catches the `SIGUSER` (CTRL + C) signal. // Please note that `enable_raw_mode` catches the `SIGUSER` (CTRL + C) signal.
// For a method that does please see `enable_raw_mode_nosig`. // For a method that does please see `enable_raw_mode_nosig`.
pub fn (mut r Readline) enable_raw_mode() { pub fn (mut r Readline) enable_raw_mode() {
if C.tcgetattr(0, &r.orig_termios) == -1 { if C.tcgetattr(0, unsafe { &C.termios(&r.orig_termios) }) == -1 {
r.is_tty = false r.is_tty = false
r.is_raw = false r.is_raw = false
return return
} }
mut raw := r.orig_termios mut raw := r.orig_termios
raw.c_iflag &= ~(C.BRKINT | C.ICRNL | C.INPCK | C.ISTRIP | C.IXON) raw.c_iflag &= ~(C.BRKINT | C.ICRNL | C.INPCK | C.ISTRIP | C.IXON)
raw.c_cflag |= (C.CS8) raw.c_cflag |= C.CS8
raw.c_lflag &= ~(C.ECHO | C.ICANON | C.IEXTEN | C.ISIG) raw.c_lflag &= ~(C.ECHO | C.ICANON | C.IEXTEN | C.ISIG)
raw.c_cc[C.VMIN] = 1 raw.c_cc[C.VMIN] = 1
raw.c_cc[C.VTIME] = 0 raw.c_cc[C.VTIME] = 0
C.tcsetattr(0, C.TCSADRAIN, &raw) C.tcsetattr(0, C.TCSADRAIN, unsafe { &C.termios(&raw) })
r.is_raw = true r.is_raw = true
r.is_tty = true r.is_tty = true
} }
@ -68,18 +68,18 @@ pub fn (mut r Readline) enable_raw_mode() {
// Please note that `enable_raw_mode_nosig` does not catch the `SIGUSER` (CTRL + C) signal // Please note that `enable_raw_mode_nosig` does not catch the `SIGUSER` (CTRL + C) signal
// as opposed to `enable_raw_mode`. // as opposed to `enable_raw_mode`.
pub fn (mut r Readline) enable_raw_mode_nosig() { pub fn (mut r Readline) enable_raw_mode_nosig() {
if C.tcgetattr(0, &r.orig_termios) == -1 { if C.tcgetattr(0, unsafe { &C.termios(&r.orig_termios) }) == -1 {
r.is_tty = false r.is_tty = false
r.is_raw = false r.is_raw = false
return return
} }
mut raw := r.orig_termios mut raw := r.orig_termios
raw.c_iflag &= ~(C.BRKINT | C.ICRNL | C.INPCK | C.ISTRIP | C.IXON) raw.c_iflag &= ~(C.BRKINT | C.ICRNL | C.INPCK | C.ISTRIP | C.IXON)
raw.c_cflag |= (C.CS8) raw.c_cflag |= C.CS8
raw.c_lflag &= ~(C.ECHO | C.ICANON | C.IEXTEN) raw.c_lflag &= ~(C.ECHO | C.ICANON | C.IEXTEN)
raw.c_cc[C.VMIN] = 1 raw.c_cc[C.VMIN] = 1
raw.c_cc[C.VTIME] = 0 raw.c_cc[C.VTIME] = 0
C.tcsetattr(0, C.TCSADRAIN, &raw) C.tcsetattr(0, C.TCSADRAIN, unsafe { &C.termios(&raw) })
r.is_raw = true r.is_raw = true
r.is_tty = true r.is_tty = true
} }
@ -88,7 +88,7 @@ pub fn (mut r Readline) enable_raw_mode_nosig() {
// For a description of raw mode please see the `enable_raw_mode` method. // For a description of raw mode please see the `enable_raw_mode` method.
pub fn (mut r Readline) disable_raw_mode() { pub fn (mut r Readline) disable_raw_mode() {
if r.is_raw { if r.is_raw {
C.tcsetattr(0, C.TCSADRAIN, &r.orig_termios) C.tcsetattr(0, C.TCSADRAIN, unsafe { &C.termios(&r.orig_termios) })
r.is_raw = false r.is_raw = false
} }
} }

View File

@ -47,7 +47,7 @@ fn test_atof() {
// test C.atof // test C.atof
n1 := x.strsci(18) n1 := x.strsci(18)
n2 := f64(C.atof(src_num_str[c].str)).strsci(18) n2 := f64(C.atof(&char(src_num_str[c].str))).strsci(18)
//println("$n1 $n2") //println("$n1 $n2")
assert n1 == n2 assert n1 == n2
} }

View File

@ -328,7 +328,6 @@ fn (mut g Gen) gen_map_equality_fn(left ast.Type) string {
fn_builder.writeln('\t\tif (*(voidptr*)map_get(&b, k, &(voidptr[]){ 0 }) != v) {') fn_builder.writeln('\t\tif (*(voidptr*)map_get(&b, k, &(voidptr[]){ 0 }) != v) {')
} }
else { else {
println(kind)
fn_builder.writeln('\t\tif (*($ptr_value_typ*)map_get(&b, k, &($ptr_value_typ[]){ 0 }) != v) {') fn_builder.writeln('\t\tif (*($ptr_value_typ*)map_get(&b, k, &($ptr_value_typ[]){ 0 }) != v) {')
} }
} }

View File

@ -127,7 +127,7 @@ fn (mut g Gen) gen_struct_enc_dec(type_info ast.TypeInfo, styp string, mut enc s
field_sym := g.table.get_type_symbol(field.typ) field_sym := g.table.get_type_symbol(field.typ)
// First generate decoding // First generate decoding
if field.attrs.contains('raw') { if field.attrs.contains('raw') {
dec.writeln('\tres.${c_name(field.name)} = tos4(cJSON_PrintUnformatted(' + dec.writeln('\tres.${c_name(field.name)} = tos5(cJSON_PrintUnformatted(' +
'js_get(root, "$name")));') 'js_get(root, "$name")));')
} else { } else {
// Now generate decoders for all field types in this struct // Now generate decoders for all field types in this struct