mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-17 23:08:40 +02:00
Use HashPJW for hasing user-defined function names and variable names.
All checks were successful
Remind unit tests / tests (push) Successful in 26s
All checks were successful
Remind unit tests / tests (push) Successful in 26s
This commit is contained in:
@@ -44,17 +44,17 @@ static void FSet (UserFunc *f);
|
|||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
unsigned int HashVal_nocase(char const *str)
|
unsigned int HashVal_nocase(char const *str)
|
||||||
{
|
{
|
||||||
register unsigned int i=0;
|
unsigned int h = 0, high;
|
||||||
register unsigned int j=1;
|
while(*str) {
|
||||||
register unsigned int len=0;
|
h = (h << 4) + (unsigned int) *str;
|
||||||
|
str++;
|
||||||
while(*str && len < VAR_NAME_LEN) {
|
high = h & 0xF0000000;
|
||||||
i += j * (*str);
|
if (high) {
|
||||||
str++;
|
h ^= (high >> 24);
|
||||||
len++;
|
}
|
||||||
j = 3-j;
|
h &= ~high;
|
||||||
}
|
}
|
||||||
return i;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
|
|||||||
20
src/var.c
20
src/var.c
@@ -461,17 +461,17 @@ static int time_sep_func(int do_set, Value *val)
|
|||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
unsigned int HashVal(char const *str)
|
unsigned int HashVal(char const *str)
|
||||||
{
|
{
|
||||||
register unsigned int i=0;
|
unsigned int h = 0, high;
|
||||||
register unsigned int j=1;
|
while(*str) {
|
||||||
register unsigned int len=0;
|
h = (h << 4) + (unsigned int) UPPER(*str);
|
||||||
|
str++;
|
||||||
while(*str && len < VAR_NAME_LEN) {
|
high = h & 0xF0000000;
|
||||||
i += j * (unsigned int) UPPER(*str);
|
if (high) {
|
||||||
str++;
|
h ^= (high >> 24);
|
||||||
len++;
|
}
|
||||||
j = 3-j;
|
h &= ~high;
|
||||||
}
|
}
|
||||||
return i;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
|
|||||||
258
tests/test.cmp
258
tests/test.cmp
@@ -2578,141 +2578,141 @@ wkdaynum(1993-12-27) => 1
|
|||||||
dump
|
dump
|
||||||
Variable Value
|
Variable Value
|
||||||
|
|
||||||
a017 29
|
|
||||||
a036 "bar"
|
|
||||||
a054b 11:22
|
|
||||||
a055 1
|
|
||||||
a074 "Tuesday, 5 May, 1992 In 444 days' time T"...
|
|
||||||
a093 0
|
|
||||||
a116 -4
|
|
||||||
a135 72:00
|
|
||||||
a008 "11:44"
|
|
||||||
a027 0
|
|
||||||
a046 "ies"
|
|
||||||
a065 1
|
|
||||||
a084 7
|
|
||||||
a107 3
|
|
||||||
a126 14:00
|
|
||||||
a018 1
|
|
||||||
a037 1991-02-15
|
|
||||||
a056 "SDFJHSDF KSJDFH KJSDFH KSJDFH"
|
|
||||||
a075 "05-05 Tuesday, May 5th, 1992 Tuesday, Ma"...
|
|
||||||
a094 0
|
|
||||||
a117 -3
|
|
||||||
a136 "FILE"
|
|
||||||
a028 1
|
|
||||||
a047 -1
|
|
||||||
a066 0
|
|
||||||
a085 7
|
|
||||||
a108 14
|
|
||||||
a127 04:30
|
|
||||||
a019 0
|
|
||||||
a038 33
|
|
||||||
a057 "SDFJHSDF KSJDFH KJSDFH KSJDFH"
|
|
||||||
a076 "S' 05 Th 05 Tuesday, 5th May, 1992 Tuesd"...
|
|
||||||
a095 -1
|
|
||||||
a118 0
|
|
||||||
a029 0
|
|
||||||
a048 "foo"
|
|
||||||
a067 "INT"
|
|
||||||
a086 4
|
|
||||||
a109 2012-01-01
|
|
||||||
a128 2018-02-03@16:45
|
|
||||||
a039 "February"
|
|
||||||
a058 "05.00.06"
|
|
||||||
a077 "1992 92\n"
|
|
||||||
a096 -4
|
|
||||||
a119 -1
|
|
||||||
a049 21
|
|
||||||
a068 "STRING"
|
|
||||||
a087 3
|
|
||||||
a129 2019-02-03@16:14
|
|
||||||
a059 "Saturday"
|
|
||||||
a078 1991-04-07
|
|
||||||
a097 -3
|
|
||||||
a069 "TIME"
|
|
||||||
a088 14
|
|
||||||
a079 1992-04-26
|
|
||||||
a098 0
|
|
||||||
a089 2012-01-01
|
|
||||||
a099 -1
|
|
||||||
a000 1
|
|
||||||
a010 12
|
a010 12
|
||||||
a001 1
|
|
||||||
a020 "../tests/test.rem"
|
|
||||||
a100 2010-09-03
|
|
||||||
a011 704
|
|
||||||
a030 1
|
|
||||||
a110 1991-02-16
|
|
||||||
a002 102
|
|
||||||
a021 "foo bar baz"
|
|
||||||
a040 2
|
|
||||||
a101 2010-09-03
|
|
||||||
a120 2010-09-03
|
|
||||||
a012 411
|
|
||||||
a031 "foobarbaz"
|
|
||||||
a111 -1
|
|
||||||
a130 1991-02-16
|
|
||||||
a003 1990
|
|
||||||
a022 11
|
|
||||||
a041 "3rd"
|
|
||||||
a060 6
|
|
||||||
a102 5000
|
|
||||||
a121 2010-09-03
|
|
||||||
a013 1992-02-02
|
|
||||||
a032 34
|
|
||||||
a070 "DATE"
|
|
||||||
a112 7
|
|
||||||
a131 00:00
|
|
||||||
a004 "B7BMB"
|
|
||||||
a023 1
|
|
||||||
a042 "4th"
|
|
||||||
a061 1991
|
|
||||||
a080 2027-05-02
|
|
||||||
a103 0
|
|
||||||
a122 5000
|
|
||||||
a033 "foo"
|
|
||||||
a052 03:07
|
|
||||||
a071 2
|
|
||||||
a090 1991-02-16
|
a090 1991-02-16
|
||||||
a113 15
|
a110 1991-02-16
|
||||||
a131b 00:00
|
a011 704
|
||||||
a132 1991-02-16@00:00
|
|
||||||
a005 "baz"
|
|
||||||
a024 0
|
|
||||||
a043 "UNIX"
|
|
||||||
a062 -19
|
|
||||||
a081 ""
|
|
||||||
a104 0
|
|
||||||
a123 0
|
|
||||||
a015 16
|
|
||||||
a034 1991-02-17
|
|
||||||
a053 1992-01-10
|
|
||||||
a072 0
|
|
||||||
a091 -1
|
a091 -1
|
||||||
a114 2
|
a111 -1
|
||||||
a133 16:00
|
a012 411
|
||||||
a006 "1"
|
a052 03:07
|
||||||
a025 4
|
a054b 11:22
|
||||||
a044 "s"
|
|
||||||
a063 0
|
|
||||||
a082 1991-03-13
|
|
||||||
a105 -1
|
|
||||||
a124 0
|
|
||||||
mltest "a b"
|
|
||||||
a016 28
|
|
||||||
a035 1
|
|
||||||
a054 11:22
|
|
||||||
a092 7
|
a092 7
|
||||||
|
a112 7
|
||||||
|
a013 1992-02-02
|
||||||
|
a053 1992-01-10
|
||||||
|
a093 0
|
||||||
|
a113 15
|
||||||
|
mltest "a b"
|
||||||
|
a054 11:22
|
||||||
|
a094 0
|
||||||
|
a114 2
|
||||||
|
a015 16
|
||||||
|
a055 1
|
||||||
|
a095 -1
|
||||||
a115 03:33
|
a115 03:33
|
||||||
a134 1991-02-13@16:00
|
a016 28
|
||||||
a007 "1991-02-16"
|
a056 "SDFJHSDF KSJDFH KJSDFH KSJDFH"
|
||||||
a026 7
|
a096 -4
|
||||||
a045 "iess"
|
a116 -4
|
||||||
|
a017 29
|
||||||
|
a057 "SDFJHSDF KSJDFH KJSDFH KSJDFH"
|
||||||
|
a097 -3
|
||||||
|
a117 -3
|
||||||
|
a018 1
|
||||||
|
a058 "05.00.06"
|
||||||
|
a098 0
|
||||||
|
a118 0
|
||||||
|
a019 0
|
||||||
|
a059 "Saturday"
|
||||||
|
a099 -1
|
||||||
|
a119 -1
|
||||||
|
a020 "../tests/test.rem"
|
||||||
|
a060 6
|
||||||
|
a120 2010-09-03
|
||||||
|
a021 "foo bar baz"
|
||||||
|
a061 1991
|
||||||
|
a121 2010-09-03
|
||||||
|
a022 11
|
||||||
|
a062 -19
|
||||||
|
a122 5000
|
||||||
|
a131b 00:00
|
||||||
|
a023 1
|
||||||
|
a063 0
|
||||||
|
a123 0
|
||||||
|
a024 0
|
||||||
a064 1
|
a064 1
|
||||||
a083 1991-03-24
|
a124 0
|
||||||
a106 4
|
a025 4
|
||||||
|
a065 1
|
||||||
a125 -1
|
a125 -1
|
||||||
|
a026 7
|
||||||
|
a066 0
|
||||||
|
a126 14:00
|
||||||
|
a027 0
|
||||||
|
a067 "INT"
|
||||||
|
a127 04:30
|
||||||
|
a028 1
|
||||||
|
a068 "STRING"
|
||||||
|
a128 2018-02-03@16:45
|
||||||
|
a029 0
|
||||||
|
a069 "TIME"
|
||||||
|
a129 2019-02-03@16:14
|
||||||
|
a030 1
|
||||||
|
a070 "DATE"
|
||||||
|
a130 1991-02-16
|
||||||
|
a031 "foobarbaz"
|
||||||
|
a071 2
|
||||||
|
a131 00:00
|
||||||
|
a032 34
|
||||||
|
a072 0
|
||||||
|
a132 1991-02-16@00:00
|
||||||
|
a033 "foo"
|
||||||
|
a133 16:00
|
||||||
|
a034 1991-02-17
|
||||||
|
a074 "Tuesday, 5 May, 1992 In 444 days' time T"...
|
||||||
|
a134 1991-02-13@16:00
|
||||||
|
a035 1
|
||||||
|
a075 "05-05 Tuesday, May 5th, 1992 Tuesday, Ma"...
|
||||||
|
a135 72:00
|
||||||
|
a036 "bar"
|
||||||
|
a076 "S' 05 Th 05 Tuesday, 5th May, 1992 Tuesd"...
|
||||||
|
a136 "FILE"
|
||||||
|
a037 1991-02-15
|
||||||
|
a077 "1992 92\n"
|
||||||
|
a038 33
|
||||||
|
a078 1991-04-07
|
||||||
|
a039 "February"
|
||||||
|
a079 1992-04-26
|
||||||
|
a000 1
|
||||||
|
a040 2
|
||||||
|
a080 2027-05-02
|
||||||
|
a100 2010-09-03
|
||||||
|
a001 1
|
||||||
|
a041 "3rd"
|
||||||
|
a081 ""
|
||||||
|
a101 2010-09-03
|
||||||
|
a002 102
|
||||||
|
a042 "4th"
|
||||||
|
a082 1991-03-13
|
||||||
|
a102 5000
|
||||||
|
a003 1990
|
||||||
|
a043 "UNIX"
|
||||||
|
a083 1991-03-24
|
||||||
|
a103 0
|
||||||
|
a004 "B7BMB"
|
||||||
|
a044 "s"
|
||||||
|
a084 7
|
||||||
|
a104 0
|
||||||
|
a005 "baz"
|
||||||
|
a045 "iess"
|
||||||
|
a085 7
|
||||||
|
a105 -1
|
||||||
|
a006 "1"
|
||||||
|
a046 "ies"
|
||||||
|
a086 4
|
||||||
|
a106 4
|
||||||
|
a007 "1991-02-16"
|
||||||
|
a047 -1
|
||||||
|
a087 3
|
||||||
|
a107 3
|
||||||
|
a008 "11:44"
|
||||||
|
a048 "foo"
|
||||||
|
a088 14
|
||||||
|
a108 14
|
||||||
|
a049 21
|
||||||
|
a089 2012-01-01
|
||||||
|
a109 2012-01-01
|
||||||
dump $
|
dump $
|
||||||
Variable Value
|
Variable Value
|
||||||
|
|
||||||
@@ -5688,7 +5688,7 @@ Barf
|
|||||||
DEBUG +s
|
DEBUG +s
|
||||||
# Don't want Remind to queue reminders
|
# Don't want Remind to queue reminders
|
||||||
EXIT
|
EXIT
|
||||||
Var hash: total = 141; maxlen = 8; avglen = 2.203
|
Var hash: total = 141; maxlen = 5; avglen = 2.203
|
||||||
Func hash: total = 15; maxlen = 3; avglen = 0.469
|
Func hash: total = 15; maxlen = 3; avglen = 0.469
|
||||||
Expression nodes allocated: 128
|
Expression nodes allocated: 128
|
||||||
Expression nodes high-water: 73
|
Expression nodes high-water: 73
|
||||||
|
|||||||
Reference in New Issue
Block a user