Commit 48c1cc8c authored by Oswald Buddenhagen's avatar Oswald Buddenhagen
Browse files

better error reporting

parent 27065239
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
use strict; use strict;
@ARGV == 1 or die "usage: $0 <qdoc-file>\n";
my $file = $ARGV[0]; my $file = $ARGV[0];
open FILE, $file or die "File $file cannot be opened."; open FILE, $file or die "File $file cannot be opened.\n";
my @toc = (); my @toc = ();
my %title2page = (); my %title2page = ();
my $doctitle = ""; my $doctitle = "";
...@@ -17,7 +18,7 @@ while (<FILE>) { ...@@ -17,7 +18,7 @@ while (<FILE>) {
$curpage = $1; $curpage = $1;
} elsif (/^\h*\\title\h+(.+)$/) { } elsif (/^\h*\\title\h+(.+)$/) {
if ($curpage eq "") { if ($curpage eq "") {
die "Title '$1' appears in no \\page\n"; die "Title '$1' appears in no \\page.\n";
} }
$title2page{$1} = $curpage; $title2page{$1} = $curpage;
$doctitle = $1 if (!$doctitle); $doctitle = $1 if (!$doctitle);
...@@ -42,8 +43,8 @@ for my $title (@toc) { ...@@ -42,8 +43,8 @@ for my $title (@toc) {
$last = $title; $last = $title;
} }
open IN, $file or die "File $file cannot be opened a second time?!"; open IN, $file or die "File $file cannot be opened a second time?!\n";
open OUT, '>'.$file.".out" or die "File $file.out cannot be created."; open OUT, '>'.$file.".out" or die "File $file.out cannot be created.\n";
my $cutting = 0; my $cutting = 0;
while (<IN>) { while (<IN>) {
if (!$cutting) { if (!$cutting) {
...@@ -66,4 +67,4 @@ while (<IN>) { ...@@ -66,4 +67,4 @@ while (<IN>) {
close OUT; close OUT;
close IN; close IN;
rename($file.".out", $file) or die "Cannot replace $file with new version."; rename($file.".out", $file) or die "Cannot replace $file with new version.\n";
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment