1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

do not allow casting a type to itself

This commit is contained in:
Alexander Medvednikov
2019-12-07 15:31:56 +03:00
parent a854d396ff
commit d7ccbba2c9
5 changed files with 17 additions and 12 deletions

View File

@@ -53,7 +53,8 @@ fn print_backtrace_skipping_top_frames_linux(skipframes int) bool {
nr_ptrs := C.backtrace(*voidptr(buffer), 100)
nr_actual_frames := nr_ptrs-skipframes
mut sframes := []string
csymbols := *byteptr(C.backtrace_symbols(*voidptr(&buffer[skipframes]), nr_actual_frames))
csymbols := C.backtrace_symbols(*voidptr(&buffer[skipframes]),
nr_actual_frames)
for i in 0..nr_actual_frames { sframes << tos2(csymbols[i]) }
for sframe in sframes {
executable := sframe.all_before('(')
@@ -72,7 +73,7 @@ fn print_backtrace_skipping_top_frames_linux(skipframes int) bool {
output += tos(buf, vstrlen(buf))
}
output = output.trim_space()+':'
if 0 != int(C.pclose(f)) {
if 0 != C.pclose(f) {
println(sframe) continue
}
if output in ['??:0:','??:?:'] { output = '' }

View File

@@ -155,7 +155,7 @@ fn utf8_len(c byte) int {
// Reads an utf8 character from standard input
pub fn utf8_getchar() int {
c := int(C.getchar())
c := C.getchar()
len := utf8_len(~c)
if c < 0 {
return 0
@@ -164,12 +164,12 @@ pub fn utf8_getchar() int {
} else if len == 1 {
return -1
} else {
mut uc := int(c & ((1 << (7 - len)) - 1))
mut uc := c & ((1 << (7 - len)) - 1)
for i := 0; i + 1 < len; i++ {
c2 := int(C.getchar())
c2 := C.getchar()
if c2 != -1 && (c2 >> 6) == 2 {
uc <<= 6
uc |= int((c2 & 63))
uc |= (c2 & 63)
} else if c2 == -1 {
return 0
} else {