rpms/driftnet/devel driftnet-64bit-spin.patch,NONE,1.1

Paul Wouters (pwouters) fedora-extras-commits at redhat.com
Tue Oct 23 00:14:12 UTC 2007


Author: pwouters

Update of /cvs/extras/rpms/driftnet/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1763

Added Files:
	driftnet-64bit-spin.patch 
Log Message:
driftnet-64bit-spin.patch by Bastien Nocera 


driftnet-64bit-spin.patch:

--- NEW FILE driftnet-64bit-spin.patch ---
--- driftnet-0.1.6/image.c	2002-07-09 20:26:41.000000000 +0100
+++ driftnet-0.1.6.new/image.c	2006-08-22 21:14:38.000000000 +0100
@@ -15,29 +15,20 @@ static const char rcsid[] = "$Id: image.
 
 /* memstr:
  * Locate needle, of length n_len, in haystack, of length h_len, returning NULL.
- * Uses the Boyer-Moore search algorithm. Cf.
- *  http://www-igm.univ-mlv.fr/~lecroq/string/node14.html */
-static unsigned char *memstr(const unsigned char *haystack, const size_t hlen,
-                             const unsigned char *needle, const size_t nlen) {
-    int skip[256], k;
-
-    if (nlen == 0) return (char*)haystack;
-
-    /* Set up the finite state machine we use. */
-    for (k = 0; k < 255; ++k) skip[k] = nlen;
-    for (k = 0; k < nlen - 1; ++k) skip[needle[k]] = nlen - k - 1;
-
-    /* Do the search. */
-    for (k = nlen - 1; k < hlen; k += skip[haystack[k]]) {
-        int i, j;
-        for (j = nlen - 1, i = k; j >= 0 && haystack[i] == needle[j]; j--) i--;
-        if (j == -1) return (unsigned char*)(haystack + i + 1);
-    }
-
-    return NULL;
+ */
+char *memstr(const unsigned char *haystack, const size_t hlen,
+		const unsigned char *needle, const size_t nlen)
+{
+	char *p;
+
+	for (p = haystack; p <= (haystack - nlen + hlen); p++)
+	{
+		if (memcmp(p, needle, nlen) == 0)
+			return p; /* found */
+	}
+	return NULL;
 }
 
-
 /* If we run out of space, put us back to the last candidate GIF header. */
 /*#define spaceleft       do { if (block > data + len) { printf("ran out of space\n"); return gifhdr; } } while (0)*/
 #define spaceleft       if (block > data + len) return gifhdr




More information about the fedora-extras-commits mailing list