File: strstr.c

package info (click to toggle)
html-xml-utils 7.7-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 2,488 kB
  • sloc: ansic: 11,213; sh: 7,996; lex: 243; makefile: 193; yacc: 125
file content (24 lines) | stat: -rwxr-xr-x 635 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * Copyright © 1994-2000 World Wide Web Consortium
 * See http://www.w3.org/Consortium/Legal/copyright-software
 *
 * Author: Bert Bos <bert@w3.org>
 * Created: 31 Mar 2000
 * Version: $Id: strstr.c,v 1.4 2017/11/24 09:50:25 bbos Exp $
 **/
#include "config.h"
#include "export.h"

#ifndef HAVE_STRSTR
EXPORT char *strstr(const char *haystack, const char *needle)
{
  char *s, *t, *u;

  if (! needle) return haystack;		/* No needle */
  for (s = haystack; *s; s++) {
    for (t = needle, u = s; *t == *u && *t; t++, u++);
    if (! *t) return s;				/* Found it */
  }
  return NULL;					/* Not found */
}
#endif /* HAVE_STRSTR */