www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/10/04:59:07

Date: Wed, 10 Sep 1997 11:58:51 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Michael Mauch <mauch AT uni-duisburg DOT de>
cc: djgpp AT delorie DOT com
Subject: Re: DJGPP regex - how does it work?
In-Reply-To: <5und1g$l9o$2@news-hrz.uni-duisburg.de>
Message-ID: <Pine.SUN.3.91.970910115809.9494I-100000@is>
MIME-Version: 1.0

On Fri, 5 Sep 1997, Michael Mauch wrote:

> I tried to use the functions regcomp() and regexec() from DJGPP's
> regex.h, but obviously I'm plain too dumb to get these things to
> work.

Not dumb, just plain tired (judging by the hour you've written your
message).

> I include my test program below. It always prints "Matching", even if I
> match the RE "a" against the string "b".

Here's the line that gives you the trouble:

>   r = regexec(&regex,strRegex,1,pMatch,eFlags | REG_TRACE);
                       ^^^^^^^^
You should have passed strString, not strRegex, to `regexec'!
Otherwise, you are matching the pattern against itself, which will
almost always succeed (at least for simple patterns).

> BTW: Searching for an example program using "regex.h", I found the file
> DJGPP\TESTS\LIBC\POSIX\REGEX\r1.c which seems to be rather
> incomplete/broken - is this only on my machine or is there another
> secret behind it?

Yes, r1.c seems to be corrupted.  Please report this to DJ Delorie
<dj AT delorie DOT com>.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019