chiark / gitweb /
Error handling: Provide err and ddbl_only, and an internal spec
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 28 Dec 2019 00:26:16 +0000 (00:26 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 30 Dec 2019 11:35:15 +0000 (11:35 +0000)
No callers of these yet.  The spec is honoured in the breach.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
generate

index 4bc1e74eb712a3a799bb9ee19912189d58b91e08..84572edc2ef842e0ceffacd884aa306851518831 100755 (executable)
--- a/generate
+++ b/generate
@@ -19,6 +19,22 @@ print "$0 @ARGV\n" or die $!;
 
 our $srcdir='.';
 
+# error handling methods:
+#
+# Error in input file, while $err_file and $. set, eg in most of
+# process_input_mk:
+#         err "message";
+#
+# Other input or usage errors:
+#         die "$0: $file:$lno: problem\n";
+#         die "$0: some problem not locatable in that way\n";
+#
+# System call error (not ENOENT) accessing input/output files:
+#         die "description of problem eg maybe erbing noun: $!\n";
+#
+# Bug detedcted in `generate':
+#         die "internal error (some information)?"; # or similar
+
 while (@ARGV && $ARGV[0] =~ m/^-/) {
     $_ = shift @ARGV;
     last if $_ eq '--';
@@ -149,6 +165,19 @@ sub set_dir_vars ($) {
     $var_prefix = "${var_prefix_name}_";
 }
 
+our $err_file;
+
+sub err ($) {
+    my ($m) = @_;
+    die "$0: ${err_file}:$.: $m\n";
+}
+
+sub ddbl_only ($) {
+    my ($e) = @_;
+    return if $ddbl;
+    err "escape &$e is valid only during \$-doubling";
+}
+
 sub process_input_mk ($$$$);
 sub process_input_mk ($$$$) {
     my ($targets, $f, $esclitr, $enoent_ok) = @_;
@@ -170,6 +199,8 @@ sub process_input_mk ($$$$) {
     }
     $input_files{$f}++;
 
+    local $err_file=$f;
+
     my %srcdirmap = (
                  '^' => "\$(top_srcdir)${dir_suffix}",
                  '~' => "\$(top_srcdir)",