Back to index

glibc  2.9
Functions | Variables
bug-regex12.c File Reference
#include <sys/types.h>
#include <mcheck.h>
#include <regex.h>
#include <stdio.h>
#include <stdlib.h>

Go to the source code of this file.

Functions

int main (void)

Variables

struct {
const char * pattern
const char * string
int flags
int nmatch
tests []

Function Documentation

int main ( void  )

Definition at line 41 of file bug-regex12.c.

{
  regex_t re;
  regmatch_t rm[4];
  size_t i;
  int n, ret = 0;

  mtrace ();

  for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
    {
      n = regcomp (&re, tests[i].pattern, tests[i].flags);
      if (n != 0)
       {
         char buf[500];
         regerror (n, &re, buf, sizeof (buf));
         printf ("regcomp %zd failed: %s\n", i, buf);
         ret = 1;
         continue;
       }

      if (! regexec (&re, tests[i].string, tests[i].nmatch,
                   tests[i].nmatch ? rm : NULL, 0))
       {
         printf ("regexec %zd incorrectly matched\n", i);
         ret = 1;
       }

      regfree (&re);
    }

  return ret;
}

Here is the call graph for this function:


Variable Documentation

struct { ... } tests[]