scanner: allow escape on null character (#6404)
							parent
							
								
									a1e127ae46
								
							
						
					
					
						commit
						99574e465d
					
				|  | @ -0,0 +1,5 @@ | |||
| vlib/v/checker/tests/string_char_null_err.vv:2:31: error: 0 character in a string literal | ||||
|     1 | fn main() { | ||||
|     2 |     println('Null character: \0') | ||||
|       |                               ^ | ||||
|     3 | } | ||||
|  | @ -0,0 +1,3 @@ | |||
| fn main() { | ||||
|     println('Null character: \0') | ||||
| } | ||||
|  | @ -1216,14 +1216,15 @@ fn (mut s Scanner) ident_string() string { | |||
| 		} | ||||
| 		// Don't allow \0
 | ||||
| 		if c == `0` && s.pos > 2 && s.text[s.pos - 1] == slash { | ||||
| 			if s.pos < s.text.len - 1 && s.text[s.pos + 1].is_digit() { | ||||
| 			if (s.pos < s.text.len - 1 && s.text[s.pos + 1].is_digit()) || s.count_symbol_before(s.pos - 1, slash) % 2 == 0 { | ||||
| 			} else if !is_cstr { | ||||
| 				s.error('0 character in a string literal') | ||||
| 			} | ||||
| 		} | ||||
| 		// Don't allow \x00
 | ||||
| 		if c == `0` && s.pos > 5 && s.expect('\\x0', s.pos - 3) { | ||||
| 			if !is_cstr { | ||||
| 			if s.count_symbol_before(s.pos - 3, slash) % 2 == 0 { | ||||
| 			} else if !is_cstr { | ||||
| 				s.error('0 character in a string literal') | ||||
| 			} | ||||
| 		} | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue