Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 1 | #!/usr/bin/perl |
| 2 | use strict; |
| 3 | use Text::Tabs; |
| 4 | |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 5 | my $debug = 0; |
| 6 | |
Mauro Carvalho Chehab | bcec7c2 | 2016-08-31 06:41:40 -0300 | [diff] [blame] | 7 | while ($ARGV[0] =~ m/^-(.*)/) { |
| 8 | my $cmd = shift @ARGV; |
| 9 | if ($cmd eq "--debug") { |
| 10 | require Data::Dumper; |
| 11 | $debug = 1; |
| 12 | next; |
| 13 | } |
| 14 | die "argument $cmd unknown"; |
| 15 | } |
| 16 | |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 17 | if (scalar @ARGV < 2 || scalar @ARGV > 3) { |
| 18 | die "Usage:\n\t$0 <file in> <file out> [<exceptions file>]\n"; |
| 19 | } |
| 20 | |
| 21 | my ($file_in, $file_out, $file_exceptions) = @ARGV; |
| 22 | |
| 23 | my $data; |
| 24 | my %ioctls; |
| 25 | my %defines; |
| 26 | my %typedefs; |
| 27 | my %enums; |
| 28 | my %enum_symbols; |
| 29 | my %structs; |
| 30 | |
| 31 | # |
| 32 | # read the file and get identifiers |
| 33 | # |
| 34 | |
| 35 | my $is_enum = 0; |
Mauro Carvalho Chehab | 034e6c8 | 2016-07-07 14:13:12 -0300 | [diff] [blame] | 36 | my $is_comment = 0; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 37 | open IN, $file_in or die "Can't open $file_in"; |
| 38 | while (<IN>) { |
| 39 | $data .= $_; |
| 40 | |
Mauro Carvalho Chehab | 034e6c8 | 2016-07-07 14:13:12 -0300 | [diff] [blame] | 41 | my $ln = $_; |
| 42 | if (!$is_comment) { |
| 43 | $ln =~ s,/\*.*(\*/),,g; |
| 44 | |
| 45 | $is_comment = 1 if ($ln =~ s,/\*.*,,); |
| 46 | } else { |
| 47 | if ($ln =~ s,^(.*\*/),,) { |
| 48 | $is_comment = 0; |
| 49 | } else { |
| 50 | next; |
| 51 | } |
| 52 | } |
| 53 | |
Mauro Carvalho Chehab | 9c80c74 | 2016-07-07 07:06:05 -0300 | [diff] [blame] | 54 | if ($is_enum && $ln =~ m/^\s*([_\w][\w\d_]+)\s*[\,=]?/) { |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 55 | my $s = $1; |
| 56 | my $n = $1; |
| 57 | $n =~ tr/A-Z/a-z/; |
| 58 | $n =~ tr/_/-/; |
| 59 | |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 60 | $enum_symbols{$s} = "\\ :ref:`$s <$n>`\\ "; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 61 | |
| 62 | $is_enum = 0 if ($is_enum && m/\}/); |
| 63 | next; |
| 64 | } |
| 65 | $is_enum = 0 if ($is_enum && m/\}/); |
| 66 | |
Mauro Carvalho Chehab | 9c80c74 | 2016-07-07 07:06:05 -0300 | [diff] [blame] | 67 | if ($ln =~ m/^\s*#\s*define\s+([_\w][\w\d_]+)\s+_IO/) { |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 68 | my $s = $1; |
| 69 | my $n = $1; |
| 70 | $n =~ tr/A-Z/a-z/; |
| 71 | |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 72 | $ioctls{$s} = "\\ :ref:`$s <$n>`\\ "; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 73 | next; |
| 74 | } |
| 75 | |
Mauro Carvalho Chehab | 9c80c74 | 2016-07-07 07:06:05 -0300 | [diff] [blame] | 76 | if ($ln =~ m/^\s*#\s*define\s+([_\w][\w\d_]+)\s+/) { |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 77 | my $s = $1; |
| 78 | my $n = $1; |
| 79 | $n =~ tr/A-Z/a-z/; |
| 80 | $n =~ tr/_/-/; |
| 81 | |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 82 | $defines{$s} = "\\ :ref:`$s <$n>`\\ "; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 83 | next; |
| 84 | } |
| 85 | |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 86 | if ($ln =~ m/^\s*typedef\s+([_\w][\w\d_]+)\s+(.*)\s+([_\w][\w\d_]+);/) { |
| 87 | my $s = $2; |
| 88 | my $n = $3; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 89 | |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 90 | $typedefs{$n} = "\\ :c:type:`$n <$s>`\\ "; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 91 | next; |
| 92 | } |
Mauro Carvalho Chehab | 9c80c74 | 2016-07-07 07:06:05 -0300 | [diff] [blame] | 93 | if ($ln =~ m/^\s*enum\s+([_\w][\w\d_]+)\s+\{/ |
Mauro Carvalho Chehab | 6c4c7da | 2016-07-07 07:20:27 -0300 | [diff] [blame] | 94 | || $ln =~ m/^\s*enum\s+([_\w][\w\d_]+)$/ |
| 95 | || $ln =~ m/^\s*typedef\s*enum\s+([_\w][\w\d_]+)\s+\{/ |
| 96 | || $ln =~ m/^\s*typedef\s*enum\s+([_\w][\w\d_]+)$/) { |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 97 | my $s = $1; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 98 | |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 99 | $enums{$s} = "enum :c:type:`$s`\\ "; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 100 | |
| 101 | $is_enum = $1; |
| 102 | next; |
| 103 | } |
Mauro Carvalho Chehab | 9c80c74 | 2016-07-07 07:06:05 -0300 | [diff] [blame] | 104 | if ($ln =~ m/^\s*struct\s+([_\w][\w\d_]+)\s+\{/ |
Mauro Carvalho Chehab | 6c4c7da | 2016-07-07 07:20:27 -0300 | [diff] [blame] | 105 | || $ln =~ m/^\s*struct\s+([[_\w][\w\d_]+)$/ |
| 106 | || $ln =~ m/^\s*typedef\s*struct\s+([_\w][\w\d_]+)\s+\{/ |
| 107 | || $ln =~ m/^\s*typedef\s*struct\s+([[_\w][\w\d_]+)$/ |
| 108 | ) { |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 109 | my $s = $1; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 110 | |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 111 | $structs{$s} = "struct :c:type:`$s`\\ "; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 112 | next; |
| 113 | } |
| 114 | } |
| 115 | close IN; |
| 116 | |
| 117 | # |
| 118 | # Handle multi-line typedefs |
| 119 | # |
| 120 | |
Mauro Carvalho Chehab | 4ff916a | 2016-07-07 08:09:37 -0300 | [diff] [blame] | 121 | my @matches = ($data =~ m/typedef\s+struct\s+\S+?\s*\{[^\}]+\}\s*(\S+)\s*\;/g, |
| 122 | $data =~ m/typedef\s+enum\s+\S+?\s*\{[^\}]+\}\s*(\S+)\s*\;/g,); |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 123 | foreach my $m (@matches) { |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 124 | my $s = $m; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 125 | |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 126 | $typedefs{$s} = "\\ :c:type:`$s`\\ "; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 127 | next; |
| 128 | } |
| 129 | |
| 130 | # |
| 131 | # Handle exceptions, if any |
| 132 | # |
| 133 | |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 134 | my %def_reftype = ( |
| 135 | "ioctl" => ":ref", |
| 136 | "define" => ":ref", |
| 137 | "symbol" => ":ref", |
| 138 | "typedef" => ":c:type", |
| 139 | "enum" => ":c:type", |
| 140 | "struct" => ":c:type", |
| 141 | ); |
| 142 | |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 143 | if ($file_exceptions) { |
| 144 | open IN, $file_exceptions or die "Can't read $file_exceptions"; |
| 145 | while (<IN>) { |
| 146 | next if (m/^\s*$/ || m/^\s*#/); |
| 147 | |
| 148 | # Parsers to ignore a symbol |
| 149 | |
| 150 | if (m/^ignore\s+ioctl\s+(\S+)/) { |
| 151 | delete $ioctls{$1} if (exists($ioctls{$1})); |
| 152 | next; |
| 153 | } |
| 154 | if (m/^ignore\s+define\s+(\S+)/) { |
| 155 | delete $defines{$1} if (exists($defines{$1})); |
| 156 | next; |
| 157 | } |
| 158 | if (m/^ignore\s+typedef\s+(\S+)/) { |
| 159 | delete $typedefs{$1} if (exists($typedefs{$1})); |
| 160 | next; |
| 161 | } |
| 162 | if (m/^ignore\s+enum\s+(\S+)/) { |
| 163 | delete $enums{$1} if (exists($enums{$1})); |
| 164 | next; |
| 165 | } |
| 166 | if (m/^ignore\s+struct\s+(\S+)/) { |
| 167 | delete $structs{$1} if (exists($structs{$1})); |
| 168 | next; |
| 169 | } |
Mauro Carvalho Chehab | 526b884 | 2016-07-07 14:26:51 -0300 | [diff] [blame] | 170 | if (m/^ignore\s+symbol\s+(\S+)/) { |
| 171 | delete $enum_symbols{$1} if (exists($enum_symbols{$1})); |
| 172 | next; |
| 173 | } |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 174 | |
| 175 | # Parsers to replace a symbol |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 176 | my ($type, $old, $new, $reftype); |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 177 | |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 178 | if (m/^replace\s+(\S+)\s+(\S+)\s+(\S+)/) { |
| 179 | $type = $1; |
| 180 | $old = $2; |
| 181 | $new = $3; |
| 182 | } else { |
| 183 | die "Can't parse $file_exceptions: $_"; |
| 184 | } |
| 185 | |
| 186 | if ($new =~ m/^\:c\:(data|func|macro|type)\:\`(.+)\`/) { |
| 187 | $reftype = ":c:$1"; |
| 188 | $new = $2; |
| 189 | } elsif ($new =~ m/\:ref\:\`(.+)\`/) { |
| 190 | $reftype = ":ref"; |
| 191 | $new = $1; |
| 192 | } else { |
| 193 | $reftype = $def_reftype{$type}; |
| 194 | } |
| 195 | $new = "$reftype:`$old <$new>`"; |
| 196 | |
| 197 | if ($type eq "ioctl") { |
| 198 | $ioctls{$old} = $new if (exists($ioctls{$old})); |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 199 | next; |
| 200 | } |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 201 | if ($type eq "define") { |
| 202 | $defines{$old} = $new if (exists($defines{$old})); |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 203 | next; |
| 204 | } |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 205 | if ($type eq "symbol") { |
| 206 | $enum_symbols{$old} = $new if (exists($enum_symbols{$old})); |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 207 | next; |
| 208 | } |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 209 | if ($type eq "typedef") { |
| 210 | $typedefs{$old} = $new if (exists($typedefs{$old})); |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 211 | next; |
| 212 | } |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 213 | if ($type eq "enum") { |
| 214 | $enums{$old} = $new if (exists($enums{$old})); |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 215 | next; |
| 216 | } |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 217 | if ($type eq "struct") { |
| 218 | $structs{$old} = $new if (exists($structs{$old})); |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 219 | next; |
| 220 | } |
| 221 | |
| 222 | die "Can't parse $file_exceptions: $_"; |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | if ($debug) { |
| 227 | print Data::Dumper->Dump([\%ioctls], [qw(*ioctls)]) if (%ioctls); |
| 228 | print Data::Dumper->Dump([\%typedefs], [qw(*typedefs)]) if (%typedefs); |
| 229 | print Data::Dumper->Dump([\%enums], [qw(*enums)]) if (%enums); |
| 230 | print Data::Dumper->Dump([\%structs], [qw(*structs)]) if (%structs); |
| 231 | print Data::Dumper->Dump([\%defines], [qw(*defines)]) if (%defines); |
| 232 | print Data::Dumper->Dump([\%enum_symbols], [qw(*enum_symbols)]) if (%enum_symbols); |
| 233 | } |
| 234 | |
| 235 | # |
| 236 | # Align block |
| 237 | # |
| 238 | $data = expand($data); |
| 239 | $data = " " . $data; |
| 240 | $data =~ s/\n/\n /g; |
| 241 | $data =~ s/\n\s+$/\n/g; |
| 242 | $data =~ s/\n\s+\n/\n\n/g; |
| 243 | |
| 244 | # |
| 245 | # Add escape codes for special characters |
| 246 | # |
Mauro Carvalho Chehab | 999d998 | 2016-08-16 13:25:41 -0300 | [diff] [blame] | 247 | $data =~ s,([\_\`\*\<\>\&\\\\:\/\|\%\$\#\{\}\~\^]),\\$1,g; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 248 | |
Mauro Carvalho Chehab | 7d95fa8 | 2016-07-07 06:31:21 -0300 | [diff] [blame] | 249 | $data =~ s,DEPRECATED,**DEPRECATED**,g; |
| 250 | |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 251 | # |
| 252 | # Add references |
| 253 | # |
| 254 | |
Mauro Carvalho Chehab | 6fe79d1 | 2016-07-07 06:27:54 -0300 | [diff] [blame] | 255 | my $start_delim = "[ \n\t\(\=\*\@]"; |
| 256 | my $end_delim = "(\\s|,|\\\\=|\\\\:|\\;|\\\)|\\}|\\{)"; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 257 | |
| 258 | foreach my $r (keys %ioctls) { |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 259 | my $s = $ioctls{$r}; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 260 | |
| 261 | $r =~ s,([\_\`\*\<\>\&\\\\:\/]),\\\\$1,g; |
| 262 | |
| 263 | print "$r -> $s\n" if ($debug); |
| 264 | |
Mauro Carvalho Chehab | 6fe79d1 | 2016-07-07 06:27:54 -0300 | [diff] [blame] | 265 | $data =~ s/($start_delim)($r)$end_delim/$1$s$3/g; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | foreach my $r (keys %defines) { |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 269 | my $s = $defines{$r}; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 270 | |
| 271 | $r =~ s,([\_\`\*\<\>\&\\\\:\/]),\\\\$1,g; |
| 272 | |
| 273 | print "$r -> $s\n" if ($debug); |
| 274 | |
Mauro Carvalho Chehab | 6fe79d1 | 2016-07-07 06:27:54 -0300 | [diff] [blame] | 275 | $data =~ s/($start_delim)($r)$end_delim/$1$s$3/g; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | foreach my $r (keys %enum_symbols) { |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 279 | my $s = $enum_symbols{$r}; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 280 | |
| 281 | $r =~ s,([\_\`\*\<\>\&\\\\:\/]),\\\\$1,g; |
| 282 | |
| 283 | print "$r -> $s\n" if ($debug); |
| 284 | |
Mauro Carvalho Chehab | 6fe79d1 | 2016-07-07 06:27:54 -0300 | [diff] [blame] | 285 | $data =~ s/($start_delim)($r)$end_delim/$1$s$3/g; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | foreach my $r (keys %enums) { |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 289 | my $s = $enums{$r}; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 290 | |
| 291 | $r =~ s,([\_\`\*\<\>\&\\\\:\/]),\\\\$1,g; |
| 292 | |
| 293 | print "$r -> $s\n" if ($debug); |
| 294 | |
Mauro Carvalho Chehab | 6fe79d1 | 2016-07-07 06:27:54 -0300 | [diff] [blame] | 295 | $data =~ s/enum\s+($r)$end_delim/$s$2/g; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | foreach my $r (keys %structs) { |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 299 | my $s = $structs{$r}; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 300 | |
| 301 | $r =~ s,([\_\`\*\<\>\&\\\\:\/]),\\\\$1,g; |
| 302 | |
| 303 | print "$r -> $s\n" if ($debug); |
| 304 | |
Mauro Carvalho Chehab | 6fe79d1 | 2016-07-07 06:27:54 -0300 | [diff] [blame] | 305 | $data =~ s/struct\s+($r)$end_delim/$s$2/g; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | foreach my $r (keys %typedefs) { |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 309 | my $s = $typedefs{$r}; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 310 | |
| 311 | $r =~ s,([\_\`\*\<\>\&\\\\:\/]),\\\\$1,g; |
| 312 | |
| 313 | print "$r -> $s\n" if ($debug); |
Mauro Carvalho Chehab | 6fe79d1 | 2016-07-07 06:27:54 -0300 | [diff] [blame] | 314 | $data =~ s/($start_delim)($r)$end_delim/$1$s$3/g; |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 315 | } |
| 316 | |
Mauro Carvalho Chehab | 22c4003 | 2016-08-31 06:44:21 -0300 | [diff] [blame^] | 317 | $data =~ s/\\ ([\n\s])/\1/g; |
Mauro Carvalho Chehab | fb6fc6c | 2016-07-09 09:35:34 -0300 | [diff] [blame] | 318 | |
Mauro Carvalho Chehab | dabf8be | 2016-07-06 22:58:54 -0300 | [diff] [blame] | 319 | # |
| 320 | # Generate output file |
| 321 | # |
| 322 | |
| 323 | my $title = $file_in; |
| 324 | $title =~ s,.*/,,; |
| 325 | |
| 326 | open OUT, "> $file_out" or die "Can't open $file_out"; |
| 327 | print OUT ".. -*- coding: utf-8; mode: rst -*-\n\n"; |
| 328 | print OUT "$title\n"; |
| 329 | print OUT "=" x length($title); |
| 330 | print OUT "\n\n.. parsed-literal::\n\n"; |
| 331 | print OUT $data; |
| 332 | close OUT; |