Date: Wed, 10 Sep 1997 11:58:51 +0300 (IDT) From: Eli Zaretskii To: Michael Mauch 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: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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(®ex,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 .