Skip to content

Commit

Permalink
CHANGE: renaming CRC_Table to CRC24_Table
Browse files Browse the repository at this point in the history
So it has same naming as CRC32_Table.
  • Loading branch information
Oldes committed Feb 28, 2020
1 parent 89e3158 commit 6512190
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/core/n-strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ static struct digest {
i = Hash_String(data, len) % sum;
}
else {
i = Compute_CRC(data, len);
i = Compute_CRC24(data, len);
}

DS_RET_INT(i);
Expand Down
20 changes: 10 additions & 10 deletions src/core/s-crc.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
#define PRZCRC 0x864cfb /* PRZ's 24-bit CRC generator polynomial */
#define CRCINIT 0xB704CE /* Init value for CRC accumulator */

static REBCNT *CRC_Table;
static REBCNT *CRC24_Table;
static REBCNT *CRC32_Table = 0;

/***********************************************************************
**
*/ static REBCNT Generate_CRC(REBYTE ch, REBCNT poly, REBCNT accum)
*/ static REBCNT Generate_CRC24(REBYTE ch, REBCNT poly, REBCNT accum)
/*
** Simulates CRC hardware circuit. Generates true CRC
** directly, without requiring extra NULL bytes to be appended
Expand Down Expand Up @@ -96,7 +96,7 @@ static REBCNT *CRC32_Table = 0;

/***********************************************************************
**
*/ static void Make_CRC_Table(REBCNT poly)
*/ static void Make_CRC24_Table(REBCNT poly)
/*
** Derives a CRC lookup table from the CRC polynomial.
** The table is used later by crcupdate function given below.
Expand All @@ -106,13 +106,13 @@ static REBCNT *CRC32_Table = 0;
{
REBINT i;

FOREACH (i, 256) CRC_Table[i] = Generate_CRC((REBYTE) i, poly, 0);
FOREACH (i, 256) CRC24_Table[i] = Generate_CRC24((REBYTE) i, poly, 0);
}


/***********************************************************************
**
*/ REBINT Compute_CRC(REBYTE *str, REBCNT len)
*/ REBINT Compute_CRC24(REBYTE *str, REBCNT len)
/*
***********************************************************************/
{
Expand All @@ -121,7 +121,7 @@ static REBCNT *CRC32_Table = 0;

for (; len > 0; len--) {
n = (REBYTE)((crc >> CRCSHIFTS) ^ (REBYTE)(*str++));
crc = MASK_CRC(crc << 8) ^ (REBINT)CRC_Table[n];
crc = MASK_CRC(crc << 8) ^ (REBINT)CRC24_Table[n];
}

return crc;
Expand All @@ -142,7 +142,7 @@ static REBCNT *CRC32_Table = 0;

for (; len > 0; len--) {
n = (REBYTE)((hash >> CRCSHIFTS) ^ (REBYTE)LO_CASE(*str++));
hash = MASK_CRC(hash << 8) ^ (REBINT)CRC_Table[n];
hash = MASK_CRC(hash << 8) ^ (REBINT)CRC24_Table[n];
}

return hash;
Expand Down Expand Up @@ -172,7 +172,7 @@ static REBCNT *CRC32_Table = 0;
if (n > 127 && NZ(m = Decode_UTF8_Char(&str, &ulen))) n = m; // mods str, ulen
if (n < UNICODE_CASES) n = LO_CASE(n);
n = (REBYTE)((hash >> CRCSHIFTS) ^ (REBYTE)n); // drop upper 8 bits
hash = MASK_CRC(hash << 8) ^ (REBINT)CRC_Table[n];
hash = MASK_CRC(hash << 8) ^ (REBINT)CRC24_Table[n];
}

return hash;
Expand Down Expand Up @@ -324,8 +324,8 @@ static REBCNT *CRC32_Table = 0;
/*
***********************************************************************/
{
CRC_Table = Make_Mem(sizeof(REBCNT) * 256);
Make_CRC_Table(PRZCRC);
CRC24_Table = Make_Mem(sizeof(REBCNT) * 256);
Make_CRC24_Table(PRZCRC);
}


Expand Down
2 changes: 1 addition & 1 deletion src/core/t-string.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ static REBSER *make_binary(REBVAL *arg, REBOOL make)
case A_RANDOM:
if(IS_PROTECT_SERIES(VAL_SERIES(value))) Trap0(RE_PROTECTED);
if (D_REF(2)) { // seed
Set_Random(Compute_CRC(VAL_BIN_DATA(value), VAL_LEN(value)));
Set_Random(Compute_CRC24(VAL_BIN_DATA(value), VAL_LEN(value)));
return R_UNSET;
}
if (D_REF(4)) { // /only
Expand Down

0 comments on commit 6512190

Please sign in to comment.