From: Robert Spalek Date: Thu, 27 Sep 2001 09:42:08 +0000 (+0000) Subject: url_has_repeated_component() fully implemented and tested X-Git-Tag: holmes-import~1468 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=7009a1097a86f336caf029b7592d1188c4cb2b57;p=libucw.git url_has_repeated_component() fully implemented and tested --- diff --git a/lib/url.c b/lib/url.c index 3920aa59..7b0548ca 100644 --- a/lib/url.c +++ b/lib/url.c @@ -580,8 +580,75 @@ int main(int argc, char **argv) #endif +struct component { + byte *start; + int length; + u32 hash; +}; + +static inline u32 +hashf(byte *start, int length) +{ + u32 hf = length; + while (length-- > 0) + hf = (hf << 8 | hf >> 24) ^ *start++; + return hf; +} + +static inline uns +repeat_count(struct component *comp, uns count, uns len) +{ + struct component *orig_comp = comp; + uns found = 0; + while (1) + { + uns i; + comp += len; + count -= len; + found++; + if (count < len) + return found; + for (i=0; i= url_min_repeat_count) + return comp_len; return 0; }