… | |
… | |
298 | } |
298 | } |
299 | |
299 | |
300 | \%pak |
300 | \%pak |
301 | } |
301 | } |
302 | |
302 | |
303 | sub read_arch($) { |
303 | sub read_arch($;$) { |
304 | my ($path) = @_; |
304 | my ($path, $toplevel) = @_; |
305 | |
305 | |
306 | my %arc; |
306 | my %arc; |
307 | my ($more, $prev); |
307 | my ($more, $prev); |
308 | |
308 | |
309 | open my $fh, "<:raw:perlio:utf8", $path |
309 | open my $fh, "<:raw:perlio:utf8", $path |
… | |
… | |
328 | } elsif (/^msg$/i) { |
328 | } elsif (/^msg$/i) { |
329 | while (<$fh>) { |
329 | while (<$fh>) { |
330 | last if /^endmsg\s*$/i; |
330 | last if /^endmsg\s*$/i; |
331 | $arc{msg} .= $_; |
331 | $arc{msg} .= $_; |
332 | } |
332 | } |
|
|
333 | } elsif (/^anim$/i) { |
|
|
334 | while (<$fh>) { |
|
|
335 | last if /^mina\s*$/i; |
|
|
336 | chomp; |
|
|
337 | push @{ $arc{anim} }, $_; |
|
|
338 | } |
333 | } elsif (/^(\S+)\s*(.*)$/) { |
339 | } elsif (/^(\S+)\s*(.*)$/) { |
334 | $arc{lc $1} = $2; |
340 | $arc{lc $1} = $2; |
335 | } elsif (/^\s*($|#)/) { |
341 | } elsif (/^\s*($|#)/) { |
336 | # |
342 | # |
337 | } else { |
343 | } else { |
… | |
… | |
366 | } else { |
372 | } else { |
367 | push @{ $arc{arch} }, $arc; |
373 | push @{ $arc{arch} }, $arc; |
368 | } |
374 | } |
369 | $prev = $arc; |
375 | $prev = $arc; |
370 | $more = undef; |
376 | $more = undef; |
|
|
377 | } elsif ($toplevel && /^(\S+)\s+(.*)$/) { |
|
|
378 | if ($1 eq "lev_array") { |
|
|
379 | while (<$fh>) { |
|
|
380 | last if /^endplst\s*$/; |
|
|
381 | push @{$toplevel->{lev_array}}, $_+0; |
|
|
382 | } |
|
|
383 | } else { |
|
|
384 | $toplevel->{$1} = $2; |
|
|
385 | } |
371 | } elsif (/^\s*($|#)/) { |
386 | } elsif (/^\s*($|#)/) { |
372 | # |
387 | # |
373 | } else { |
388 | } else { |
374 | warn "$path: unparseable top-level line '$_'"; |
389 | die "$path: unparseable top-level line '$_'"; |
375 | } |
390 | } |
376 | } |
391 | } |
377 | |
392 | |
378 | undef $parse_block; # work around bug in perl not freeing $fh etc. |
393 | undef $parse_block; # work around bug in perl not freeing $fh etc. |
379 | |
394 | |