@@ -236,6 +236,22 @@ where
236
236
break ;
237
237
}
238
238
239
+ if next_atom. ident != DATA_ATOM_IDENT {
240
+ if parsing_mode == ParsingMode :: Strict {
241
+ err ! ( BadAtom ( "Expected atom \" data\" to follow name" ) )
242
+ }
243
+
244
+ log:: warn!(
245
+ "Skipping unexpected atom {actual_ident:?}, expected {expected_ident:?}" ,
246
+ actual_ident = next_atom. ident,
247
+ expected_ident = DATA_ATOM_IDENT
248
+ ) ;
249
+
250
+ pos += next_atom. len ;
251
+ skip_unneeded ( reader, next_atom. extended , next_atom. len ) ?;
252
+ continue ;
253
+ }
254
+
239
255
let Some ( data_type) = parse_type_indicator ( reader, parsing_mode) ? else {
240
256
log:: warn!( "Skipping atom with unknown type set" ) ;
241
257
let remaining_atom_len = next_atom. len - ( ATOM_HEADER_LEN + 1 ) ;
@@ -248,31 +264,13 @@ where
248
264
// We don't care about the locale
249
265
reader. seek ( SeekFrom :: Current ( 4 ) ) ?;
250
266
251
- match next_atom. ident {
252
- DATA_ATOM_IDENT => {
253
- let content_len = ( next_atom. len - 16 ) as usize ;
254
- if content_len > 0 {
255
- let mut content = try_vec ! [ 0 ; content_len] ;
256
- reader. read_exact ( & mut content) ?;
257
- ret. push ( ( data_type, content) ) ;
258
- } else {
259
- log:: warn!( "Skipping empty \" data\" atom" ) ;
260
- }
261
- } ,
262
- _ => match parsing_mode {
263
- ParsingMode :: Strict => {
264
- err ! ( BadAtom ( "Expected atom \" data\" to follow name" ) )
265
- } ,
266
- ParsingMode :: BestAttempt | ParsingMode :: Relaxed => {
267
- log:: warn!(
268
- "Skipping unexpected atom {actual_ident:?}, expected {expected_ident:?}" ,
269
- actual_ident = next_atom. ident,
270
- expected_ident = DATA_ATOM_IDENT
271
- ) ;
272
-
273
- reader. seek ( SeekFrom :: Current ( ( next_atom. len - 16 ) as i64 ) ) ?;
274
- } ,
275
- } ,
267
+ let content_len = ( next_atom. len - 16 ) as usize ;
268
+ if content_len > 0 {
269
+ let mut content = try_vec ! [ 0 ; content_len] ;
270
+ reader. read_exact ( & mut content) ?;
271
+ ret. push ( ( data_type, content) ) ;
272
+ } else {
273
+ log:: warn!( "Skipping empty \" data\" atom" ) ;
276
274
}
277
275
278
276
pos += next_atom. len ;
0 commit comments