⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 memlook.c

📁 harvest是一个下载html网页得机器人
💻 C
字号:
/* Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal.  All Rights Reserved. *//* ./glimpse/index/memlook.c *//* ------------------------------------------------------------------------   this is a brute-force string matching function.   it's used for short text, or the matching place is expected to be   not far from the beginning.   the function returns the position where the pattern first matches.------------------------------------------------------------------------*/#include <stdio.h>int memlook(pattern, text, length)unsigned char *pattern;unsigned char *text;int  length;{	unsigned char *text_end = text+length;	unsigned char *text_begin = text;	register unsigned char pat_0=pattern[0];	register unsigned char *px, *tx;	if(pat_0 == '\n') {		if(strncmp((char *)pattern+1, text, strlen((char *)pattern) -1) == 0) {			return(0);		}	}	/* this is a special case when the pattern is to begin of a line 	   while the text match the pattern right at the beginning, in	   which case, '\n' won't be matched.	*/	pattern++;	*text_end = pat_0 ;	while(text < text_end) {		while(*text++ != pat_0);		if(text < text_end) {			px = pattern; 			tx = text;			while(*px == *tx) {				px++; tx++;			};			if(*px == '\0') {				/*				printf("begin matched\n");				*/				return(text - text_begin);			}		}	}	return(-2);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -