Harmen Stoppels | a54f160 | 2021-02-25 11:31:42 +0100 | [diff] [blame] | 1 | #!/usr/bin/env perl |
Douglas Gregor | 7a1095f | 2009-06-13 06:06:53 +0000 | [diff] [blame] | 2 | # |
| 3 | # Simple little Perl script that takes the cxx-sections.data file as |
| 4 | # input and generates a directory structure that mimics the standard's |
| 5 | # structure. |
| 6 | use English; |
Harmen Stoppels | a54f160 | 2021-02-25 11:31:42 +0100 | [diff] [blame] | 7 | use warnings; |
Douglas Gregor | 7a1095f | 2009-06-13 06:06:53 +0000 | [diff] [blame] | 8 | |
| 9 | $current_indent_level = -4; |
| 10 | while ($line = <STDIN>) { |
| 11 | $line =~ /^\s*/; |
| 12 | $next_indent_level = length($MATCH); |
| 13 | if ($line =~ /\[([^\]]*)\]/) { |
| 14 | my $section = $1; |
| 15 | while ($next_indent_level < $current_indent_level) { |
| 16 | chdir(".."); |
| 17 | $current_indent_level -= 4; |
| 18 | } |
| 19 | |
| 20 | if ($next_indent_level == $current_indent_level) { |
| 21 | chdir(".."); |
| 22 | } else { |
| 23 | $current_indent_level = $next_indent_level; |
| 24 | } |
| 25 | mkdir($section); |
| 26 | chdir($section); |
| 27 | } |
| 28 | } |