scanner: minor cleanup of scanner.v (#7467)

pull/7465/head
yuyi 2020-12-22 17:56:29 +08:00 committed by GitHub
parent a8447398f5
commit c11928260d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 6 deletions

View File

@ -1170,10 +1170,7 @@ fn (mut s Scanner) ident_char() string {
[inline]
fn (s &Scanner) expect(want string, start_pos int) bool {
end_pos := start_pos + want.len
if start_pos < 0 || start_pos >= s.text.len {
return false
}
if end_pos < 0 || end_pos > s.text.len {
if start_pos < 0 || end_pos < 0 || start_pos >= s.text.len || end_pos > s.text.len {
return false
}
for pos in start_pos .. end_pos {
@ -1273,8 +1270,7 @@ pub fn (mut s Scanner) error(msg string) {
}
fn (mut s Scanner) vet_error(msg string) {
eline := '$s.file_path:$s.line_nr: $msg'
s.vet_errors << eline
s.vet_errors << '$s.file_path:$s.line_nr: $msg'
}
pub fn verror(s string) {