Re: c regex example
- From: gert <gert.cuykens@xxxxxxxxx>
- Date: Sat, 21 Jul 2007 18:46:16 -0000
On Jul 21, 8:39 pm, gert <gert.cuyk...@xxxxxxxxx> wrote:
On Jul 21, 9:21 am, Ico <use...@xxxxxxx> wrote:
Save the return value of regcomp() and use regerror() to convert the
error code into a readable string when not zero
Ok that i did and figured out the regex was invalid aldo it isn't some
how it doesn't understand (?
also memcpy is not copying what i expect and it gets stuck in a
infinitive loop also :)
http://dfo.svn.sourceforge.net/viewvc/dfo/trunk/cgi/csv.c?view=markup
void
csv(char *buffer,PAGE *page)
{
char *line;
char errbuf[100];
int errcode;
regex_t re;
regmatch_t rm;
errcode=regcomp(&re,"test", REG_EXTENDED);
//csv regex ",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))"
//csv regex ,(?=(?:[^ "]* "[^ "]* ")*(?![^ "]* "))
if(errcode==0)errcode=regexec(&re, &buffer[0], 1, &rm, 0);
while(errcode==0)
{
memcpy(line, &buffer[rm.rm_so], rm.rm_eo-rm.rm_so);
page->add(page,line);
errcode=regexec(&re, &buffer[rm.rm_eo], 1, &rm, 0);
}
regerror(errcode,&re,errbuf,100);
if(errbuf)printf("%s\n",errbuf);
regfree(&re);
}
Doh the memcpy doesnt work because i forgot to alocate memory first,
still need a answer for infinitive loop and the csv regex that is
invalid :)
.
- Follow-Ups:
- Re: c regex example
- From: Logan Shaw
- Re: c regex example
- References:
- c regex example
- From: gert
- Re: c regex example
- From: Ico
- Re: c regex example
- From: gert
- c regex example
- Prev by Date: Re: c regex example
- Next by Date: Saving AJAX responseText to a variable
- Previous by thread: Re: c regex example
- Next by thread: Re: c regex example
- Index(es):
Relevant Pages
|