}
}
+static int match_fragment(const char *buf, unsigned long size,
+ unsigned long try,
+ const char *fragment, unsigned long fragsize)
+{
+ if (try + fragsize > size)
+ return 0;
+ if (memcmp(buf + try, fragment, fragsize))
+ return 0;
+ return 1;
+}
+
static int find_offset(const char *buf, unsigned long size,
const char *fragment, unsigned long fragsize,
int line, int *lines)
}
/* Exact line number? */
- if ((start + fragsize <= size) &&
- !memcmp(buf + start, fragment, fragsize))
+ if (match_fragment(buf, size, start, fragment, fragsize))
return start;
/*
try = forwards;
}
- if (try + fragsize > size)
- continue;
- if (memcmp(buf + try, fragment, fragsize))
+ if (!match_fragment(buf, size, try, fragment, fragsize))
continue;
n = (i >> 1)+1;
if (i & 1)