Back to index

glibc  2.9
Functions
bug-regex8.c File Reference
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <regex.h>

Go to the source code of this file.

Functions

int main (void)

Function Documentation

int main ( void  )

Definition at line 30 of file bug-regex8.c.

{
  struct re_pattern_buffer regex;
  const char *s;
  int match[4];

  memset (&regex, '\0', sizeof (regex));

  s = re_compile_pattern ("xy$", 3, &regex);
  if (s != NULL)
    {
      puts ("failed to compile pattern \"xy$\"");
      return 1;
    }
  else
    match[0] = re_match_2(&regex,"xyz",3,NULL,0,0,NULL,2);

  free (regex.buffer);
  memset (&regex, '\0', sizeof (regex));

  s = re_compile_pattern ("xy\\>", 4, &regex);
  if (s != NULL)
    {
      puts ("failed to compile pattern \"xy\\>\"");
      return 1;
    }
  else
    match[1] = re_search_2(&regex,"xyz",3,NULL,0,0,2,NULL,2);

  free (regex.buffer);
  memset (&regex, '\0', sizeof (regex));

  s = re_compile_pattern ("xy \\<", 5, &regex);
  if (s != NULL)
    {
      puts ("failed to compile pattern \"xy \\<\"");
      return 1;
    }
  else
    {
      match[2] = re_match_2(&regex,"xy  ",4,NULL,0,0,NULL,3);
      match[3] = re_match_2(&regex,"xy z",4,NULL,0,0,NULL,3);
    }

  if (match[0] != -1 || match[1] != -1 || match[2] != -1 || match[3] != 3)
    {
      printf ("re_{match,search}_2 returned %d,%d,%d,%d, expected -1,-1,-1,3\n",
              match[0], match[1], match[2], match[3]);
      return 1;
    }

  puts (" -> OK");

  return 0;
}

Here is the call graph for this function: