@@ -217,35 +217,40 @@ impl<'a> TokenStream<'a> {
217
217
}
218
218
}
219
219
fn skip_whitespace ( & mut self ) {
220
- let num = {
221
- let mut iter = self . buf [ self . off ..] . char_indices ( ) ;
222
- loop {
223
- let ( idx, cur_char) = match iter. next ( ) {
224
- Some ( pair) => pair,
225
- None => break ( self . buf . len ( ) - self . off ) ,
226
- } ;
227
- match cur_char {
228
- '\u{feff}' | '\t' | ' ' |
229
- '\r' | '\n' |
230
- // comma is also entirely ignored in spec
231
- ',' => continue ,
232
- //comment
233
- '#' => {
234
- while let Some ( ( _, cur_char) ) = iter. next ( ) {
235
- // TODO(tailhook) ensure SourceCharacter
236
- if cur_char == '\r' || cur_char == '\n' {
237
- break ;
238
- }
220
+ let mut iter = self . buf [ self . off ..] . char_indices ( ) ;
221
+ let idx = loop {
222
+ let ( idx, cur_char) = match iter. next ( ) {
223
+ Some ( pair) => pair,
224
+ None => break self . buf . len ( ) - self . off ,
225
+ } ;
226
+ match cur_char {
227
+ '\u{feff}' | '\r' => continue ,
228
+ '\t' => self . position . column += 8 ,
229
+ '\n' => {
230
+ self . position . column = 1 ;
231
+ self . position . line += 1 ;
232
+ }
233
+ // comma is also entirely ignored in spec
234
+ ' ' | ',' => {
235
+ self . position . column += 1 ;
236
+ continue ;
237
+ }
238
+ //comment
239
+ '#' => {
240
+ while let Some ( ( _, cur_char) ) = iter. next ( ) {
241
+ // TODO(tailhook) ensure SourceCharacter
242
+ if cur_char == '\r' || cur_char == '\n' {
243
+ self . position . column = 1 ;
244
+ self . position . line += 1 ;
245
+ break ;
239
246
}
240
- continue ;
241
247
}
242
- _ => break idx ,
248
+ continue ;
243
249
}
250
+ _ => break idx,
244
251
}
245
252
} ;
246
- if num > 0 {
247
- self . update_position ( num) ;
248
- }
253
+ self . off += idx;
249
254
}
250
255
fn update_position ( & mut self , len : usize ) {
251
256
let val = & self . buf [ self . off ..] [ ..len] ;
0 commit comments