v.scanner: fix error line numbers when comments end with CRLF
							parent
							
								
									84b8e0a7e4
								
							
						
					
					
						commit
						47f59d3fb6
					
				| 
						 | 
				
			
			@ -0,0 +1,2 @@
 | 
			
		|||
*_crlf_*  binary
 | 
			
		||||
*_lf_*    binary
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
vlib/v/checker/tests/error_with_comment_with_crlf_ending.vv:2:6: error: unexpected name `should`
 | 
			
		||||
    1 | // Empty lines don't cause an issue but as soon as there's a comment with a CRLF ending, it fails
 | 
			
		||||
    2 | This should cause an error!
 | 
			
		||||
      |      ~~~~~~
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,2 @@
 | 
			
		|||
// Empty lines don't cause an issue but as soon as there's a comment with a CRLF ending, it fails
 | 
			
		||||
This should cause an error!
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
vlib/v/checker/tests/error_with_comment_with_lf_ending.vv:2:6: error: unexpected name `should`
 | 
			
		||||
    1 | // Empty lines don't cause an issue but as soon as there's a comment with a CRLF ending, it fails
 | 
			
		||||
    2 | This should cause an error!
 | 
			
		||||
      |      ~~~~~~
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,2 @@
 | 
			
		|||
// Empty lines don't cause an issue but as soon as there's a comment with a CRLF ending, it fails
 | 
			
		||||
This should cause an error!
 | 
			
		||||
| 
						 | 
				
			
			@ -1092,10 +1092,14 @@ fn (mut s Scanner) text_scan() token.Token {
 | 
			
		|||
				if nextc == `/` {
 | 
			
		||||
					start := s.pos + 1
 | 
			
		||||
					s.ignore_line()
 | 
			
		||||
					comment_line_end := s.pos
 | 
			
		||||
					s.pos--
 | 
			
		||||
					// fix line_nr, \n was read; the comment is marked on the next line
 | 
			
		||||
					s.line_nr--
 | 
			
		||||
					mut comment_line_end := s.pos
 | 
			
		||||
					if s.text[s.pos-1] == `\r` {
 | 
			
		||||
						comment_line_end--
 | 
			
		||||
					} else {
 | 
			
		||||
						// fix line_nr, \n was read; the comment is marked on the next line
 | 
			
		||||
						s.pos--
 | 
			
		||||
						s.line_nr--
 | 
			
		||||
					}                    
 | 
			
		||||
					if s.should_parse_comment() {
 | 
			
		||||
						s.line_comment = s.text[start + 1..comment_line_end]
 | 
			
		||||
						mut comment := s.line_comment.trim_space()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue