Plan 9 from Bell Labs’s /usr/web/sources/plan9/sys/src/libc/port/cistrstr.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <u.h>
#include <libc.h>

char*
cistrstr(char *s, char *sub)
{
	int c, csub, n;

	csub = *sub;
	if(csub == '\0')
		return s;
	if(csub >= 'A' && csub <= 'Z')
		csub -= 'A' - 'a';
	sub++;
	n = strlen(sub);
	for(; c = *s; s++){
		if(c >= 'A' && c <= 'Z')
			c -= 'A' - 'a';
		if(c == csub && cistrncmp(s+1, sub, n) == 0)
			return s;
	}
	return nil;
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.