[MPlayer-dev-eng] [PATCH] SAMI subtitle files (subreader.c) NOVIRUS

Moritz Bunkus moritz at bunkus.org
Sun Aug 24 11:32:36 CEST 2003


Hi.

> +static char *stristr(const char *haystack, const char *needle) {
> +    int len = 0;
> +    const char *p = haystack;
> +
> +    if (!(haystack && needle)) return NULL;
> +
> +    len=strlen(needle);
> +    while (*p != '\0' && *(p+len-1) != '\0') {
> +	if (strncasecmp(p, needle, len) == 0) return (char*)p;

why not something like...
  const char *endp;
  endp = haystack + strlen(haystack);
  while ((endp - p) >= len) {
... 
or something that looks more like 'while (enough data left to compare)'?
  :)

Rest looks fine to me.

-- 
 ==> Ciao, Mosu (Moritz Bunkus)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20030824/4d940776/attachment.pgp>


More information about the MPlayer-dev-eng mailing list