bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GNU Regex Library Problem


From: Adam T. Bowen
Subject: GNU Regex Library Problem
Date: Thu, 24 Oct 2002 10:33:05 +0100 (BST)

Hi,

        We have recently upgraded a few of our workstations to RedHat 8.0
which comes with gcc 3.2.  This upgrade has created some problems in our
code that uses the regex library.  I have stripped the code down to the
following :

#include <sys/types.h>
#include <regex.h>

int main(int argc, char **argv)
{
  regex_t RE;
  regmatch_t RM[10];
  char *Test_String="testing\ntesting\ntesting";
  int Pos=0;

  regcomp(&RE, "([^z]+z)", REG_EXTENDED|REG_NEWLINE);
  while(regexec(&RE, &Test_String[Pos], (size_t)1, RM, REG_NOTEOL) == 0) 
  {
    printf("Match from %ld to %ld\n",Pos+RM[0].rm_so,Pos+RM[0].rm_eo-1);
    Pos+=RM[0].rm_eo;
  }
  return 0;
}

The output of which is :

        Match from 0 to 7
        Match from 8 to 15

When I run the same code on an older workstation running RedHat 7.2 with 
the bizarre gcc3 redhat abortion command of version 3.0.4 I get no output, 
which I would expect as there are no 'z's in the string 
"testing\ntesting\ntesting".  Can you please let me know if I am going mad 
and there are indeed 'z's in the string or whether RedHat are playing 
there usual fiddling around with code and version number games, please?

Cheers

Adam Bowen





reply via email to

[Prev in Thread] Current Thread [Next in Thread]