Subject: bug#1260 closed by Stefan Monnier <[email-masked]> (Re: bug#1260: regex.c and RE_FRUGAL)

From: [email-masked] (Emacs bug Tracking System)

This is an automatic notification regarding your bug report
which was filed against the emacs package:

#1260: regex.c and RE_FRUGAL

It has been closed by Stefan Monnier <[email-masked]>.

Their explanation is attached below along with your original report.
If this explanation is unsatisfactory and you have not received a
better one in a separate message then please contact Stefan Monnier <[email-masked]> by
replying to this email.

-- 
1260: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=1260
Emacs Bug Tracking System
Contact [email-masked] with problems
>From [email-masked] Tue Oct 28 07:31:43 2008
From: Stefan Monnier <[email-masked]>
To: "Alexander V. Lukyanov" <[email-masked]>
Cc: [email-masked]
Subject: Re: bug#1260: regex.c and RE_FRUGAL
Date: Tue, 28 Oct 2008 10:31:29 -0400

>> > This bug report is not quite for emacs, but for its regex library.
>> > It features RE_FRUGAL flag (very useful), but it does not seem to work.
>> > I have tried this rather simple program and it prints 0-12 instead of
>> > expected 0-6.
>> 
>> IIRC you'll need to set RE_NO_POSIX_BACKTRACKING as well, otherwise the
>> match returned will always be the longest.

> Thank you! The flag RE_NO_POSIX_BACKTRACKING did the trick.

> Is there a reason for RE_SYNTAX_EMACS including RE_FRUGAL and not including
> RE_NO_POSIX_BACKTRACKING?

Emacs passes RE_NO_POSIX_BACKTRACKING explicitly depending on whether it
wants posix behavior or not (it has matching functions like
"string-match" and "posix-string-match").

        Stefan

>From [email-masked] Mon Oct 27 08:56:34 2008
Date: Mon, 27 Oct 2008 18:56:11 +0300
From: "Alexander V. Lukyanov" <[email-masked]>
To: [email-masked]
Subject: regex.c and RE_FRUGAL

Hello!

This bug report is not quite for emacs, but for its regex library.

It features RE_FRUGAL flag (very useful), but it does not seem to work.

I have tried this rather simple program and it prints 0-12 instead of expected 0-6.

Please advice.

#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "regex.h"
int main()
{
   const char *rexp="<.*?>";
   static struct re_pattern_buffer rexp_c;
   static struct re_registers regs;
   re_syntax_options = RE_FRUGAL;
   re_compile_pattern(rexp,strlen(rexp),&rexp_c);
   if(re_search(&rexp_c,"<html><head>",12,0,12,&regs)==-1) {
      printf("search failed\n");
      return 1;
   }
   printf("%d-%d\n",regs.start[0],regs.end[0]);
   return 0;
}

--
   Alexander.