Back to index

glibc  2.9
Functions | Variables
bug-regex18.c File Reference
#include <sys/types.h>
#include <mcheck.h>
#include <regex.h>
#include <stdio.h>
#include <stdlib.h>
#include <locale.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
regmatch_t rm [5]
tests []

Function Documentation

int main ( void  )

Definition at line 56 of file bug-regex18.c.

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

  setlocale (LC_ALL, "tr_TR.UTF-8");
  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, rm, 0))
       {
         printf ("regexec %zd failed\n", i);
         ret = 1;
         regfree (&re);
         continue;
       }

      for (n = 0; n < tests[i].nmatch; ++n)
       if (rm[n].rm_so != tests[i].rm[n].rm_so
              || rm[n].rm_eo != tests[i].rm[n].rm_eo)
         {
           if (tests[i].rm[n].rm_so == -1 && tests[i].rm[n].rm_eo == -1)
             break;
           printf ("regexec match failure rm[%d] %d..%d\n",
                  n, rm[n].rm_so, rm[n].rm_eo);
           ret = 1;
           break;
         }

      regfree (&re);
    }

  return ret;
}

Here is the call graph for this function:


Variable Documentation

struct { ... } tests[]