update all index() uses
parent
2651b8957a
commit
a23a4ed98a
|
@ -187,7 +187,11 @@ fn print_output(s os.Result) {
|
|||
for line in lines {
|
||||
if line.starts_with('.vrepl_temp.v') {
|
||||
// Hide the temporary file name
|
||||
println(line[line.index(' ') + 1 .. ])
|
||||
idx := line.index(' ') or {
|
||||
println(line)
|
||||
return
|
||||
}
|
||||
println(line[idx+1..])
|
||||
} else {
|
||||
println(line)
|
||||
}
|
||||
|
|
|
@ -21,8 +21,10 @@ fn test_flag_parsing() {
|
|||
|
||||
// Which ever one of these is lowest we use
|
||||
// TODO: we really shouldnt support all of these cmon
|
||||
mut lowest := base.index('-')
|
||||
for x in [base.index(' '), base.index(',')] {
|
||||
mut lowest := base.index('-') or { -1 }
|
||||
a := base.index(' ') or { -1 }
|
||||
b := base.index(',') or { -1 }
|
||||
for x in [a, b] {
|
||||
if (x < lowest && x != -1) || lowest == -1 {
|
||||
lowest = x
|
||||
}
|
||||
|
|
|
@ -113,8 +113,7 @@ fn (r mut Reader) read_record() ?[]string {
|
|||
for {
|
||||
// not quoted
|
||||
if line[0] != `"` {
|
||||
i = line.index(r.delimiter.str())
|
||||
if i == -1 {
|
||||
i = line.index(r.delimiter.str()) or {
|
||||
// last
|
||||
break
|
||||
}
|
||||
|
@ -125,8 +124,7 @@ fn (r mut Reader) read_record() ?[]string {
|
|||
// quoted
|
||||
else {
|
||||
line = line[1..]
|
||||
i = line.index('"')
|
||||
if i != -1 {
|
||||
if i := line.index('"') {
|
||||
if i+1 == line.len {
|
||||
// last record
|
||||
fields << line[..i]
|
||||
|
@ -145,7 +143,6 @@ fn (r mut Reader) read_record() ?[]string {
|
|||
return err_invalid_delim
|
||||
}
|
||||
}
|
||||
|
||||
return fields
|
||||
}
|
||||
|
||||
|
|
|
@ -185,15 +185,14 @@ fn parse_response(resp string) Response {
|
|||
break
|
||||
}
|
||||
i++
|
||||
pos := h.index(':')
|
||||
if pos == -1 {
|
||||
pos := h.index(':') or {
|
||||
continue
|
||||
}
|
||||
//if h.contains('Content-Type') {
|
||||
//continue
|
||||
//}
|
||||
key := h[..pos]
|
||||
val := h[pos + 2..]
|
||||
val := h[pos+2..]
|
||||
headers[key] = val.trim_space()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue