提交 69e2b8d6 编写于 作者: R Rich Salz

Revise and cleanup; use strict,warnings

Use shorter names for some defines, so also had to change the .c file
that used them.
Reviewed-by: NRichard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5669)
上级 8a5ed9dc
......@@ -558,7 +558,7 @@ static int str_copy(CONF *conf, char *section, char **pto, char *from)
s++;
cp = section;
e = np = s;
while (IS_ALPHA_NUMERIC(conf, *e))
while (IS_ALNUM(conf, *e))
e++;
if ((e[0] == ':') && (e[1] == ':')) {
cp = np;
......@@ -567,7 +567,7 @@ static int str_copy(CONF *conf, char *section, char **pto, char *from)
*rrp = '\0';
e += 2;
np = e;
while (IS_ALPHA_NUMERIC(conf, *e))
while (IS_ALNUM(conf, *e))
e++;
}
r = *e;
......@@ -759,7 +759,7 @@ static char *eat_alpha_numeric(CONF *conf, char *p)
p = scan_esc(conf, p);
continue;
}
if (!IS_ALPHA_NUMERIC_PUNCT(conf, *p))
if (!IS_ALNUM_PUNCT(conf, *p))
return p;
p++;
}
......
......@@ -13,7 +13,7 @@
#define CONF_UPPER 2
#define CONF_LOWER 4
#define CONF_UNDER 256
#define CONF_PUNCTUATION 512
#define CONF_PUNCT 512
#define CONF_WS 16
#define CONF_ESC 32
#define CONF_QUOTE 64
......@@ -23,40 +23,28 @@
#define CONF_EOF 8
#define CONF_HIGHBIT 4096
#define CONF_ALPHA (CONF_UPPER|CONF_LOWER)
#define CONF_ALPHA_NUMERIC (CONF_ALPHA|CONF_NUMBER|CONF_UNDER)
#define CONF_ALPHA_NUMERIC_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER| \
CONF_PUNCTUATION)
#define CONF_ALNUM (CONF_ALPHA|CONF_NUMBER|CONF_UNDER)
#define CONF_ALNUM_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER|CONF_PUNCT)
#define KEYTYPES(c) ((const unsigned short *)((c)->meth_data))
#ifndef CHARSET_EBCDIC
# define IS_COMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_COMMENT)
# define IS_FCOMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_FCOMMENT)
# define IS_EOF(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_EOF)
# define IS_ESC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ESC)
# define IS_NUMBER(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_NUMBER)
# define IS_WS(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_WS)
# define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC)
# define IS_ALPHA_NUMERIC_PUNCT(c,a) \
(KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC_PUNCT)
# define IS_QUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_QUOTE)
# define IS_DQUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_DQUOTE)
# define IS_HIGHBIT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_HIGHBIT)
#else /* CHARSET_EBCDIC */
#ifndef CHARSET_EBCDIC
# define CVT(a) ((a) & 0xFF)
#else
# define CVT(a) os_toascci[(a) & 0FF]
#endif
# define IS_COMMENT(c,a) (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_COMMENT)
# define IS_FCOMMENT(c,a) (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_FCOMMENT)
# define IS_EOF(c,a) (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_EOF)
# define IS_ESC(c,a) (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_ESC)
# define IS_NUMBER(c,a) (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_NUMBER)
# define IS_WS(c,a) (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_WS)
# define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_ALPHA_NUMERIC)
# define IS_ALPHA_NUMERIC_PUNCT(c,a) \
(KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_ALPHA_NUMERIC_PUNCT)
# define IS_QUOTE(c,a) (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_QUOTE)
# define IS_DQUOTE(c,a) (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_DQUOTE)
# define IS_HIGHBIT(c,a) (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_HIGHBIT)
#endif /* CHARSET_EBCDIC */
#define IS_COMMENT(c,a) (KEYTYPES(c)[CVT(a)] & CONF_COMMENT)
#define IS_FCOMMENT(c,a) (KEYTYPES(c)[CVT(a)] & CONF_FCOMMENT)
#define IS_EOF(c,a) (KEYTYPES(c)[CVT(a)] & CONF_EOF)
#define IS_ESC(c,a) (KEYTYPES(c)[CVT(a)] & CONF_ESC)
#define IS_NUMBER(c,a) (KEYTYPES(c)[CVT(a)] & CONF_NUMBER)
#define IS_WS(c,a) (KEYTYPES(c)[CVT(a)] & CONF_WS)
#define IS_ALNUM(c,a) (KEYTYPES(c)[CVT(a)] & CONF_ALNUM)
#define IS_ALNUM_PUNCT(c,a) (KEYTYPES(c)[CVT(a)] & CONF_ALNUM_PUNCT)
#define IS_QUOTE(c,a) (KEYTYPES(c)[CVT(a)] & CONF_QUOTE)
#define IS_DQUOTE(c,a) (KEYTYPES(c)[CVT(a)] & CONF_DQUOTE)
#define IS_HIGHBIT(c,a) (KEYTYPES(c)[CVT(a)] & CONF_HIGHBIT)
static const unsigned short CONF_type_default[256] = {
0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
......
......@@ -6,59 +6,60 @@
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
$NUMBER=0x01;
$UPPER=0x02;
$LOWER=0x04;
$UNDER=0x100;
$PUNCTUATION=0x200;
$WS=0x10;
$ESC=0x20;
$QUOTE=0x40;
$DQUOTE=0x400;
$COMMENT=0x80;
$FCOMMENT=0x800;
$EOF=0x08;
$HIGHBIT=0x1000;
foreach (0 .. 255)
{
$v=0;
$c=sprintf("%c",$_);
$v|=$NUMBER if ($c =~ /[0-9]/);
$v|=$UPPER if ($c =~ /[A-Z]/);
$v|=$LOWER if ($c =~ /[a-z]/);
$v|=$UNDER if ($c =~ /_/);
$v|=$PUNCTUATION if ($c =~ /[!\.%&\*\+,\/;\?\@\^\~\|-]/);
$v|=$WS if ($c =~ /[ \t\r\n]/);
$v|=$ESC if ($c =~ /\\/);
$v|=$QUOTE if ($c =~ /['`"]/); # for emacs: "`'}/)
$v|=$COMMENT if ($c =~ /\#/);
$v|=$EOF if ($c =~ /\0/);
$v|=$HIGHBIT if ($c =~/[\x80-\xff]/);
push(@V_def,$v);
}
foreach (0 .. 255)
{
$v=0;
$c=sprintf("%c",$_);
$v|=$NUMBER if ($c =~ /[0-9]/);
$v|=$UPPER if ($c =~ /[A-Z]/);
$v|=$LOWER if ($c =~ /[a-z]/);
$v|=$UNDER if ($c =~ /_/);
$v|=$PUNCTUATION if ($c =~ /[!\.%&\*\+,\/;\?\@\^\~\|-]/);
$v|=$WS if ($c =~ /[ \t\r\n]/);
$v|=$DQUOTE if ($c =~ /["]/); # for emacs: "}/)
$v|=$FCOMMENT if ($c =~ /;/);
$v|=$EOF if ($c =~ /\0/);
$v|=$HIGHBIT if ($c =~/[\x80-\xff]/);
push(@V_w32,$v);
}
use strict;
use warnings;
my $NUMBER = 0x0001;
my $UPPER = 0x0002;
my $LOWER = 0x0004;
my $UNDER = 0x0100;
my $PUNCTUATION = 0x0200;
my $WS = 0x0010;
my $ESC = 0x0020;
my $QUOTE = 0x0040;
my $DQUOTE = 0x0400;
my $COMMENT = 0x0080;
my $FCOMMENT = 0x0800;
my $EOF = 0x0008;
my $HIGHBIT = 0x1000;
my @V_def;
my @V_w32;
my $v;
my $c;
foreach (0 .. 255) {
$c = sprintf("%c", $_);
$v = 0;
$v |= $NUMBER if $c =~ /[0-9]/;
$v |= $UPPER if $c =~ /[A-Z]/;
$v |= $LOWER if $c =~ /[a-z]/;
$v |= $UNDER if $c =~ /_/;
$v |= $PUNCTUATION if $c =~ /[!\.%&\*\+,\/;\?\@\^\~\|-]/;
$v |= $WS if $c =~ /[ \t\r\n]/;
$v |= $ESC if $c =~ /\\/;
$v |= $QUOTE if $c =~ /['`"]/; # for emacs: "`'
$v |= $COMMENT if $c =~ /\#/;
$v |= $EOF if $c =~ /\0/;
$v |= $HIGHBIT if $c =~ /[\x80-\xff]/;
push(@V_def, $v);
$v = 0;
$v |= $NUMBER if $c =~ /[0-9]/;
$v |= $UPPER if $c =~ /[A-Z]/;
$v |= $LOWER if $c =~ /[a-z]/;
$v |= $UNDER if $c =~ /_/;
$v |= $PUNCTUATION if $c =~ /[!\.%&\*\+,\/;\?\@\^\~\|-]/;
$v |= $WS if $c =~ /[ \t\r\n]/;
$v |= $DQUOTE if $c =~ /["]/; # for emacs: "
$v |= $FCOMMENT if $c =~ /;/;
$v |= $EOF if $c =~ /\0/;
$v |= $HIGHBIT if $c =~ /[\x80-\xff]/;
push(@V_w32, $v);
}
# Output year depends on the year of the script.
my $YEAR = [localtime([stat($0)]->[9])]->[5] + 1900;
print <<"EOF";
/*
* WARNING: do not edit!
......@@ -75,7 +76,7 @@ print <<"EOF";
#define CONF_UPPER $UPPER
#define CONF_LOWER $LOWER
#define CONF_UNDER $UNDER
#define CONF_PUNCTUATION $PUNCTUATION
#define CONF_PUNCT $PUNCTUATION
#define CONF_WS $WS
#define CONF_ESC $ESC
#define CONF_QUOTE $QUOTE
......@@ -85,59 +86,43 @@ print <<"EOF";
#define CONF_EOF $EOF
#define CONF_HIGHBIT $HIGHBIT
#define CONF_ALPHA (CONF_UPPER|CONF_LOWER)
#define CONF_ALPHA_NUMERIC (CONF_ALPHA|CONF_NUMBER|CONF_UNDER)
#define CONF_ALPHA_NUMERIC_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER| \\
CONF_PUNCTUATION)
#define CONF_ALNUM (CONF_ALPHA|CONF_NUMBER|CONF_UNDER)
#define CONF_ALNUM_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER|CONF_PUNCT)
#define KEYTYPES(c) ((const unsigned short *)((c)->meth_data))
#ifndef CHARSET_EBCDIC
# define IS_COMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_COMMENT)
# define IS_FCOMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_FCOMMENT)
# define IS_EOF(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_EOF)
# define IS_ESC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ESC)
# define IS_NUMBER(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_NUMBER)
# define IS_WS(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_WS)
# define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC)
# define IS_ALPHA_NUMERIC_PUNCT(c,a) \\
(KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC_PUNCT)
# define IS_QUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_QUOTE)
# define IS_DQUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_DQUOTE)
# define IS_HIGHBIT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_HIGHBIT)
#else /* CHARSET_EBCDIC */
# define IS_COMMENT(c,a) (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_COMMENT)
# define IS_FCOMMENT(c,a) (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_FCOMMENT)
# define IS_EOF(c,a) (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_EOF)
# define IS_ESC(c,a) (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_ESC)
# define IS_NUMBER(c,a) (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_NUMBER)
# define IS_WS(c,a) (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_WS)
# define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_ALPHA_NUMERIC)
# define IS_ALPHA_NUMERIC_PUNCT(c,a) \\
(KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_ALPHA_NUMERIC_PUNCT)
# define IS_QUOTE(c,a) (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_QUOTE)
# define IS_DQUOTE(c,a) (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_DQUOTE)
# define IS_HIGHBIT(c,a) (KEYTYPES(c)[os_toascii[a & 0xff]]&CONF_HIGHBIT)
#endif /* CHARSET_EBCDIC */
#ifndef CHARSET_EBCDIC
# define CVT(a) ((a) & 0xFF)
#else
# define CVT(a) os_toascci[(a) & 0FF]
#endif
#define IS_COMMENT(c,a) (KEYTYPES(c)[CVT(a)] & CONF_COMMENT)
#define IS_FCOMMENT(c,a) (KEYTYPES(c)[CVT(a)] & CONF_FCOMMENT)
#define IS_EOF(c,a) (KEYTYPES(c)[CVT(a)] & CONF_EOF)
#define IS_ESC(c,a) (KEYTYPES(c)[CVT(a)] & CONF_ESC)
#define IS_NUMBER(c,a) (KEYTYPES(c)[CVT(a)] & CONF_NUMBER)
#define IS_WS(c,a) (KEYTYPES(c)[CVT(a)] & CONF_WS)
#define IS_ALNUM(c,a) (KEYTYPES(c)[CVT(a)] & CONF_ALNUM)
#define IS_ALNUM_PUNCT(c,a) (KEYTYPES(c)[CVT(a)] & CONF_ALNUM_PUNCT)
#define IS_QUOTE(c,a) (KEYTYPES(c)[CVT(a)] & CONF_QUOTE)
#define IS_DQUOTE(c,a) (KEYTYPES(c)[CVT(a)] & CONF_DQUOTE)
#define IS_HIGHBIT(c,a) (KEYTYPES(c)[CVT(a)] & CONF_HIGHBIT)
EOF
print "static const unsigned short CONF_type_default[256] = {";
my $i;
for ($i=0; $i<256; $i++)
{
print "static const unsigned short CONF_type_default[256] = {";
for ($i = 0; $i < 256; $i++) {
print "\n " if ($i % 8) == 0;
printf " 0x%04X,",$V_def[$i];
}
printf " 0x%04X,", $V_def[$i];
}
print "\n};\n\n";
print "static const unsigned short CONF_type_win32[256] = {";
for ($i=0; $i<256; $i++)
{
for ($i = 0; $i < 256; $i++) {
print "\n " if ($i % 8) == 0;
printf " 0x%04X,",$V_w32[$i];
}
printf " 0x%04X,", $V_w32[$i];
}
print "\n};\n";
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册