--- Begin Message ---
Subject: |
regex.c and RE_FRUGAL |
Date: |
Mon, 27 Oct 2008 18:56:11 +0300 |
User-agent: |
Mutt/1.5.11 |
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,®s)==-1) {
printf("search failed\n");
return 1;
}
printf("%d-%d\n",regs.start[0],regs.end[0]);
return 0;
}
--
Alexander.
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#1260: regex.c and RE_FRUGAL |
Date: |
Tue, 28 Oct 2008 10:31:29 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
>> > 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
--- End Message ---