unsigned long xdiff_hash_string(const char *s, size_t len, long flags)
{
- return xdl_hash_record(&s, s + len, flags);
+ return xdl_hash_record((uint8_t const**)&s, (uint8_t const*)s + len, flags);
}
int xdiff_compare_lines(const char *l1, long s1,
static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_t const *xpp,
xdlclassifier_t *cf, xdfile_t *xdf) {
long bsize;
- unsigned long hav;
- char const *blk, *cur, *top, *prev;
+ uint64_t hav;
+ uint8_t const *blk, *cur, *top, *prev;
xrecord_t *crec;
xdf->rindex = NULL;
if (XDL_ALLOC_GROW(xdf->recs, xdf->nrec + 1, narec))
goto abort;
crec = &xdf->recs[xdf->nrec++];
- crec->ptr = (uint8_t const *)prev;
+ crec->ptr = prev;
crec->size = cur - prev;
crec->ha = hav;
if (xdl_classify_record(pass, cf, crec) < 0)
return 1;
}
-unsigned long xdl_hash_record_with_whitespace(char const **data,
- char const *top, long flags) {
- unsigned long ha = 5381;
- char const *ptr = *data;
- int cr_at_eol_only = (flags & XDF_WHITESPACE_FLAGS) == XDF_IGNORE_CR_AT_EOL;
+uint64_t xdl_hash_record_with_whitespace(uint8_t const **data,
+ uint8_t const *top, uint64_t flags) {
+ uint64_t ha = 5381;
+ uint8_t const *ptr = *data;
+ bool cr_at_eol_only = (flags & XDF_WHITESPACE_FLAGS) == XDF_IGNORE_CR_AT_EOL;
for (; ptr < top && *ptr != '\n'; ptr++) {
if (cr_at_eol_only) {
continue;
}
else if (XDL_ISSPACE(*ptr)) {
- const char *ptr2 = ptr;
- int at_eol;
+ const uint8_t *ptr2 = ptr;
+ bool at_eol;
while (ptr + 1 < top && XDL_ISSPACE(ptr[1])
&& ptr[1] != '\n')
ptr++;
else if (flags & XDF_IGNORE_WHITESPACE_CHANGE
&& !at_eol) {
ha += (ha << 5);
- ha ^= (unsigned long) ' ';
+ ha ^= (uint64_t) ' ';
}
else if (flags & XDF_IGNORE_WHITESPACE_AT_EOL
&& !at_eol) {
while (ptr2 != ptr + 1) {
ha += (ha << 5);
- ha ^= (unsigned long) *ptr2;
+ ha ^= (uint64_t) *ptr2;
ptr2++;
}
}
continue;
}
ha += (ha << 5);
- ha ^= (unsigned long) *ptr;
+ ha ^= (uint64_t) *ptr;
}
*data = ptr < top ? ptr + 1: ptr;
#define REASSOC_FENCE(x, y)
#endif
-unsigned long xdl_hash_record_verbatim(char const **data, char const *top) {
- unsigned long ha = 5381, c0, c1;
- char const *ptr = *data;
+uint64_t xdl_hash_record_verbatim(uint8_t const **data, uint8_t const *top) {
+ uint64_t ha = 5381, c0, c1;
+ uint8_t const *ptr = *data;
#if 0
/*
* The baseline form of the optimized loop below. This is the djb2
*/
for (; ptr < top && *ptr != '\n'; ptr++) {
ha += (ha << 5);
- ha += (unsigned long) *ptr;
+ ha += (uint64_t) *ptr;
}
*data = ptr < top ? ptr + 1: ptr;
#else
long xdl_guess_lines(mmfile_t *mf, long sample);
int xdl_blankline(const char *line, long size, long flags);
int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags);
-unsigned long xdl_hash_record_verbatim(char const **data, char const *top);
-unsigned long xdl_hash_record_with_whitespace(char const **data, char const *top, long flags);
-static inline unsigned long xdl_hash_record(char const **data, char const *top, long flags)
+uint64_t xdl_hash_record_verbatim(uint8_t const **data, uint8_t const *top);
+uint64_t xdl_hash_record_with_whitespace(uint8_t const **data, uint8_t const *top, uint64_t flags);
+static inline uint64_t xdl_hash_record(uint8_t const **data, uint8_t const *top, uint64_t flags)
{
if (flags & XDF_WHITESPACE_FLAGS)
return xdl_hash_record_with_whitespace(data, top, flags);