提交 6c8abdd7 编写于 作者: D Dr. Stephen Henson

New err_code.pl script to retain old error codes. This should allow the use

of 'make errors' without causing huge re-organisations of files when a new
code is added.
上级 4a66b7e0
......@@ -5,6 +5,16 @@
Changes between 0.9.1c and 0.9.2
*) Changes to the error generation code. The perl script err-code.pl
now reads in the old error codes and retains the old numbers, only
adding new ones if necessary. It also only changes the .err files if new
codes are added. The makefiles have been modified to only insert errors
when needed (to avoid needlessly modifying header files). This is done
by only inserting errors if the .err file is newer than the auto generated
C file. To rebuild all the error codes from scratch (the old behaviour)
either modify crypto/Makefile.ssl to pass the -regen flag to err_code.pl
or delete all the .err files.
*) CAST-128 was incorrectly implemented for short keys. The C version has
been fixed, but is untested. The assembler versions are also fixed, but
new assembler HAS NOT BEEN GENERATED FOR WIN32 - the Makefile needs fixing
......
......@@ -15,10 +15,6 @@ MAKEFILE= Makefile.ssl
RM= /bin/rm -f
AR= ar r
MAKE= make -f Makefile.ssl
MAKEDEPEND= makedepend -f Makefile.ssl
MAKEFILE= Makefile.ssl
PEX_LIBS=
EX_LIBS=
......@@ -148,14 +144,19 @@ dclean:
$(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' dclean ); \
done;
errors:
perl ./err/err_code.pl -conf err/ssleay.ec *.c */*.c ../ssl/*.c ../rsaref/*.c
errors: errgen $(ERRC).c
$(ERRC).c: $(ERR).err
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
perl err/err_genc.pl -s $(ERR).h $(ERRC).c
errgen:
perl ./err/err_code.pl -conf err/ssleay.ec *.c */*.c ../ssl/*.c ../rsaref/*.c
@for i in $(SDIRS) ;\
do \
(cd $$i; echo "making errors in $$i..."; \
$(MAKE) errors ); \
done;
# DO NOT DELETE THIS LINE -- make depend depends on it.
......@@ -113,7 +113,9 @@ dclean:
clean:
/bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
errors:
errors: $(ERRC).c
$(ERRC).c: $(ERR).err
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
......
......@@ -85,7 +85,9 @@ dclean:
clean:
/bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
errors:
errors: $(ERRC).c
$(ERRC).c: $(ERR).err
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
......
......@@ -149,7 +149,9 @@ dclean:
clean:
/bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff bn_asm.s
errors:
errors: $(ERRC).c
$(ERRC).c: $(ERR).err
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).org # special case .org
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
......
......@@ -77,7 +77,9 @@ dclean:
clean:
/bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
errors:
errors: $(ERRC).c
$(ERRC).c: $(ERR).err
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
......
......@@ -80,7 +80,15 @@ dclean:
clean:
/bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
errors:
# This is a dummy to create comp.err: remove if we add any real errors to this
# stuff.
comp.err:
touch comp.err
errors: $(ERRC).c
$(ERRC).c: $(ERR).err
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
......
......@@ -78,7 +78,9 @@ dclean:
clean:
/bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
errors:
errors: $(ERRC).c
$(ERRC).c: $(ERR).err
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
......
......@@ -77,7 +77,9 @@ dclean:
clean:
/bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
errors:
errors: $(ERRC).c
$(ERRC).c: $(ERR).err
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
......
......@@ -77,7 +77,9 @@ dclean:
clean:
/bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
errors:
errors: $(ERRC).c
$(ERRC).c: $(ERR).err
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
......
#!/usr/local/bin/perl
#!/usr/local/bin/perl -w
# Modified by Steve Henson. It should now read in the .err
# file and only add new error codes, retaining the old
# numbers.
# Before it re-sorted new codes and re-ordered the whole thing.
# This is the motivation for the change: the re numbering caused large
# patch files even if only one error or reason code was added.
# To force regeneration of all error codes (the old behaviour) use the
# -regen flag.
$regen = 0;
while (@ARGV)
{
......@@ -23,6 +35,11 @@ while (@ARGV)
close(IN);
next;
}
elsif ($in =~ /^-regen/)
{
$regen = 1;
next;
}
open(IN,"<$in") || die "unable to open '$in'\n";
$last="";
......@@ -30,13 +47,14 @@ while (@ARGV)
{
if (/err\(([A-Z0-9]+_F_[0-9A-Z_]+)\s*,\s*([0-9A-Z]+_R_[0-9A-Z_]+)\s*\)/)
{
if ($1 != $last)
{
if ($function{$1} == 0)
{
printf STDERR "$. $1 is bad\n";
}
}
# Not sure what this was supposed to be for: it's broken anyway [steve]
# if ($1 != $last)
# {
# if ($function{$1} == 0)
# {
# printf STDERR "$. $1 is bad\n";
# }
# }
$function{$1}++;
$last=$1;
$reason{$2}++;
......@@ -55,47 +73,74 @@ foreach (keys %function,keys %reason)
@R=sort keys %reason;
foreach $j (sort keys %prefix)
{
next if !defined $errfile{$j};
next if $errfile{$j} eq "NONE";
printf STDERR "doing %-6s - ",$j;
@f=grep(/^${j}_/,@F);
@r=grep(/^${j}_/,@R);
if (defined($errfile{$j}))
{
read_errcodes($errfile{$j});
# Check to see if any new codes: if not ignore.
$new_codes = 0;
foreach (@f) {
if(!exists $func_codes{$_}) {
$new_codes = 1;
last;
}
}
if(!$new_codes) {
foreach (@r) {
if(!exists $reason_codes{$_}) {
$new_codes = 1;
last;
}
}
}
if(!$new_codes) {
print STDERR "No New Codes\n";
next;
}
open(OUT,">$errfile{$j}") ||
die "unable to open '$errfile{$j}':$!\n";
$close_file=1;
}
else
{
$min_func = 100;
$min_reason = 100;
*OUT=*STDOUT;
$close=0;
$close_file=0;
}
@f=grep(/^${j}_/,@F);
@r=grep(/^${j}_/,@R);
$num=100;
$num=$min_func;
print OUT "/* Error codes for the $j functions. */\n\n";
print OUT "/* Function codes. */\n";
$f_count=0;
foreach $i (@f)
{
$z=6-int(length($i)/8);
printf OUT "#define $i%s $num\n","\t" x $z;
$num++;
if(exists $func_codes{$i}) {
printf OUT "#define $i%s $func_codes{$i}\n","\t" x $z;
} else {
printf OUT "#define $i%s $num\n","\t" x $z;
$num++;
}
$f_count++;
}
$num=100;
$num=$min_reason;
print OUT "\n/* Reason codes. */\n";
$r_count=0;
foreach $i (@r)
{
$z=6-int(length($i)/8);
if (defined($r_value{$i}))
{
if (exists $reason_codes{$i}) {
printf OUT "#define $i%s $reason_codes{$i}\n","\t" x $z;
} elsif (exists $r_value{$i}) {
printf OUT "#define $i%s $r_value{$i}\n","\t" x $z;
}
else
{
} else {
printf OUT "#define $i%s $num\n","\t" x $z;
$num++;
}
}
$r_count++;
}
close(OUT) if $close_file;
......@@ -103,3 +148,33 @@ foreach $j (sort keys %prefix)
printf STDERR "%3d functions, %3d reasons\n",$f_count,$r_count;
}
# Read in the error codes and populate %function and %reason with the
# old codes. Also define $min_func and $min_reason with the smallest
# unused function and reason codes. Care is needed because the
# config file can define larger reason codes and these should be
# ignored.
sub read_errcodes {
$file = $_[0];
$min_func = 100;
$min_reason = 100;
undef %func_codes;
undef %reason_codes;
return if ($regen);
if (open IN, $file) {
while(<IN>) {
if(/^#define\s*(\S*)\s*(\S*)/) {
if (exists $function{$1} ) {
if($2 >= $min_func) {$min_func = $2 + 1;}
$func_codes{$1} = $2;
} elsif ((defined %reason) && exists $reason{$1}) {
$reason_codes{$1} = $2;
if( !(exists $r_value{$1}) &&
($2 >= $min_reason))
{$min_reason = $2 + 1;}
}
}
}
close IN;
}
}
......@@ -104,7 +104,9 @@ dclean:
clean:
/bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
errors:
errors: $(ERRC).c
$(ERRC).c: $(ERR).err
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
......
......@@ -20,7 +20,7 @@ TEST=md2test.c
APPS=
LIB=$(TOP)/libcrypto.a
LIBSRC=md2_dgst.c md5_one.c
LIBSRC=md2_dgst.c md2_one.c
LIBOBJ=md2_dgst.o md2_one.o
SRC= $(LIBSRC)
......
......@@ -80,7 +80,9 @@ dclean:
clean:
/bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
errors:
errors: $(ERRC).c
$(ERRC).c: $(ERR).err
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
......
......@@ -56,7 +56,7 @@ lib: $(LIBOBJ)
files:
perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links:
links: $(EXHEADER)
/bin/rm -f Makefile
$(TOP)/util/point.sh Makefile.ssl Makefile ;
$(TOP)/util/mklink.sh ../../include $(EXHEADER)
......@@ -88,7 +88,9 @@ dclean:
clean:
/bin/rm -f $(CTX_SIZE) *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
errors:
errors: $(ERRC).c
$(ERRC).c: $(ERR).err
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).org # SPECIAL CASE .org
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
......
......@@ -79,7 +79,9 @@ dclean:
clean:
/bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
errors:
errors: $(ERRC).c
$(ERRC).c: $(ERR).err
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
......
......@@ -79,7 +79,9 @@ dclean:
clean:
/bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
errors:
errors: $(ERRC).c
$(ERRC).c: $(ERR).err
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
......
......@@ -89,7 +89,9 @@ dclean:
clean:
/bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
errors:
errors: $(ERRC).c
$(ERRC).c: $(ERR).err
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
......
......@@ -78,7 +78,9 @@ dclean:
clean:
/bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
errors:
errors: $(ERRC).c
$(ERRC).c: $(ERR).err
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
perl ../crypto/err/err_genc.pl -s $(ERR).h $(ERRC).c
......
......@@ -93,7 +93,9 @@ dclean:
clean:
/bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
errors:
errors: $(ERRC).c
$(ERRC).c: $(ERR).err
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
perl ../crypto/err/err_genc.pl -s $(ERR).h $(ERRC).c
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册