Algorithm 版 (精华区)
发信人: Lerry (想不开·撞树), 信区: Algorithm
标 题: parse.c
发信站: 哈工大紫丁香 (2002年06月09日21:28:17 星期天), 站内信件
/*
* NoseyParker, the search engine for FTP archives
* Copyright (C) 1993-96 by Jiri A. Randus
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* The author can be reached as follows:
* Internet: <Jiri.Randus@vslib.cz>
* Phone: ++42 48 5227374
* SnailMail: Jiri Randus
* KIN HF TU v Liberci
* Halkova 6
* 46117 Liberec
* Czech Republic
*/
#define PARSE_VERSION "2.0"
#include "parker.h"
char line[MAX];
int i,j;
char blank=0,headers;
char *ptr,*ptr2;
void main(void)
{
headers=1;
while(1)
{
fgets(line,MAX,stdin);
if(feof(stdin)) break;
if((ptr=strchr(line,'\n'))!=NULL) *ptr='\0';
if(!strlen(line)) {blank=1;headers=0;} else blank=0;
ptr=line;
if(headers) {
while(*ptr)
if(*ptr=='\"') {
ptr2=ptr+1;
while(*ptr2 && (*ptr2!='\"')) ptr2++;
if(*ptr2) ptr2++;
strcpy(ptr,ptr2);
ptr=line;
}
else if(*ptr=='\(') {
ptr2=ptr+1;
while(*ptr2 && (*ptr2!=')')) ptr2++;
if(*ptr2) ptr2++;
strcpy(ptr,ptr2);
ptr=line;
}
else ptr++;
if((ptr=strchr(line,':'))&&(ptr2=strchr(ptr,'<')))
{
while(*(ptr+1)==' ') ptr++;
ptr++;
strcpy(ptr,ptr2+1);
if(ptr2=strchr(ptr,'>')) *(ptr2)='\0';
}
}
fputs(line,stdout);
fputs("\n",stdout);
}
}
--
当一个女孩儿觉得她不太容易了解那个男人的时候,她会爱他。
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 天外飞仙]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.181毫秒