Regular expressions, C++ kai linux

Dimitris Stasinopoulos dimitris at linea.gr
Tue Jun 25 15:08:02 EEST 2002


On Τρι 25 Ιουν 2002 12:45, Nikos Mavroyanopoulos wrote:
> On Tue, Jun 25, 2002 at 11:45:25AM +0300, Dimitris Stasinopoulos wrote:
> >
> > Gelio: Bazo ena char[32] prin tin dilosi "regex_t preg;" kai allo ena
> > meta. Apotelesma 1): Den crasharei pleon.
>
> Είναι τυχαίο. Αν σε άλλο μηχάνημα έχεις άλλη κατανομή μνήμης θα
> σπάσει εκεί. Επειδή μόνο εικασίες μπορούμε να κάνουμε το καλύτερο που
> μπορεις να κάνεις είναι να στείλεις το μικρότερο κομμάτι εκείνο του κώδικα
> που έχει το πρόβλημα.

char * cc_strstr_nocase(char * haystack, char * needle)
{
regex_t preg;
regmatch_t pmatch;
int err_no=0;
int offset=0;

    if(haystack==NULL)
    return NULL;

    if(needle==NULL)
    return haystack;

err_no=regcomp(&preg, needle, REG_ICASE);
    if(err_no)
    return NULL;

err_no=regexec(&preg, haystack, 1, &pmatch, 0);
    if(err_no)
    {
    regfree(&preg);
    return NULL;
    }

offset=pmatch.rm_so;
regfree(&preg);
return haystack+offset;
}

>
> > > p.s. To kaneis compile me g++ h gcc ? (moy'xe tyxei kapote tetoio prob)
> >
> > g++. Sample compile line:
> > g++ -DHAVE_CONFIG_H -I. -I. -I.. -O2 -fno-exceptions -fno-check-new -c -o
> > helpfunc.o `test -f helpfunc.cpp || echo './'`helpfunc.cpp
>
> Ξέχασες το -Wall. Ειδικά στο development χρειάζονται οι -g (ή -ggdb3)
> και η -O0, αλλιώς το debugging είναι εφιάλτης.

Sostos. Thanks.

-- 
Dimitris Stasinopoulos

I am but a small signature
At the down down of the writing
If you don't read me
It will become the come and see.



More information about the Linux-greek-users mailing list