From 7009a1097a86f336caf029b7592d1188c4cb2b57 Mon Sep 17 00:00:00 2001 From: Robert Spalek Date: Thu, 27 Sep 2001 09:42:08 +0000 Subject: [PATCH] url_has_repeated_component() fully implemented and tested --- lib/url.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) 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; } -- 2.39.2