This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Bug in Glibc Regex


Ulrich Drepper wrote:
> 
> Andreas Pour <pour@mieterra.com> writes:
> 
> > The attached file outputs:
> 
> There is no attached file.

Dohhh!  Got it now.

Ciao,

Andreas Pour

http://www.kde.com/ :  Everything KDE
http://apps.kde.com/:  The Latest in KDE Applications
#include <stdio.h>
#include <regex.h>

main()
{
  regex_t preg;
  const char *text = "\\{test\\}";
  const char *string = "search for {test}";
  char errMsg[512];
  regmatch_t pmatch[5];
  int ctr, errCode;
  
  if ((errCode = regcomp(&preg, text, REG_EXTENDED)) != 0)
  {
    regerror(errCode, &preg, errMsg, 512);
    fprintf(stderr, "Compilation of regex '%s' failed, error '%s'.\n", text, errMsg);
    exit();
  }

  if (regexec(&preg, string, 5, pmatch, 0) == REG_NOMATCH)
    printf("No match.\n");
  else
  {
    printf("Matches:\n");
    for (ctr = 0; ctr < 5; ctr++)
      if (pmatch[ctr].rm_so <= 0)
        break;
      else
        printf("\tPosition %d - %d\n", pmatch[ctr].rm_so, pmatch[ctr].rm_eo);
  }
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]