Make generated copyright year be "now"
[openssl.git] / crypto / objects / objxref.pl
index 1913b9d133c24b05c56c68b9eb98e4589abf6313..01ecf438f0b6b38416ffa55277d54a4772d03d5d 100644 (file)
@@ -1,4 +1,11 @@
-#!/usr/local/bin/perl
+#! /usr/bin/env perl
+# Copyright 1998-2019 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the Apache License 2.0 (the "License").  You may not use
+# this file except in compliance with the License.  You can obtain a copy
+# in the file LICENSE in the source distribution or at
+# https://www.openssl.org/source/license.html
+
 
 use strict;
 
@@ -7,25 +14,28 @@ my %oid_tbl;
 
 my ($mac_file, $xref_file) = @ARGV;
 
-open(IN, $mac_file) || die "Can't open $mac_file";
+# The year the output file is generated.
+my $YEAR = [localtime()]->[5] + 1900;
+
+open(IN, $mac_file) || die "Can't open $mac_file, $!\n";
 
 # Read in OID nid values for a lookup table.
 
 while (<IN>)
        {
-       chomp;
+       s|\R$||;                # Better chomp
        my ($name, $num) = /^(\S+)\s+(\S+)$/;
        $oid_tbl{$name} = $num;
        }
 close IN;
 
-open(IN, $xref_file) || die "Can't open $xref_file";
+open(IN, $xref_file) || die "Can't open $xref_file, $!\n";
 
 my $ln = 1;
 
 while (<IN>)
        {
-       chomp;
+       s|\R$||;                # Better chomp
        s/#.*$//;
        next if (/^\S*$/);
        my ($xr, $p1, $p2) = /^(\S+)\s+(\S+)\s+(\S+)/;
@@ -57,11 +67,21 @@ my @srt2 = sort
        } @xrkeys;
 
 my $pname = $0;
-
-$pname =~ s|^.[^/]/||;
+$pname =~ s|.*/||;
 
 print <<EOF;
-/* AUTOGENERATED BY $pname, DO NOT EDIT */
+/*
+ * WARNING: do not edit!
+ * Generated by $pname
+ *
+ * Copyright 1998-$YEAR The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License").  You may not use
+ * this file except in compliance with the License.  You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
 
 typedef struct {
     int sign_id;
@@ -69,6 +89,8 @@ typedef struct {
     int pkey_id;
 } nid_triple;
 
+DEFINE_STACK_OF(nid_triple)
+
 static const nid_triple sigoid_srt[] = {
 EOF
 
@@ -111,6 +133,6 @@ sub check_oid
        my ($chk) = @_;
        if (!exists $oid_tbl{$chk})
                {
-               die "Not Found \"$chk\"\n";
+               die "Can't find \"$chk\"\n";
                }
        }