free (line);
main (int argc, char **argv){  int ret = 0;  char *line = NULL;  size_t line_len = 0;  ssize_t len;  FILE *f;  static int test_utf8 = 0;  static const struct option options[] =    {      {"utf8",	no_argument,	&test_utf8,	1},      {NULL,	0,		NULL,		0 }    };  while (getopt_long (argc, argv, "", options, NULL) >= 0);  if (optind + 1 != argc)    {      fprintf (stderr, "Missing test filename\n");      return 1;    }  f = fopen (argv[optind], "r");  if (f == NULL)    {      fprintf (stderr, "Couldn't open %s\n", argv[optind]);      return 1;    }  while ((len = getline (&line, &line_len, f)) > 0)    {      char *pattern, *flagstr, *string, *expect, *matches, *p;      int cflags = REG_EXTENDED, eflags = 0, try_bre_ere = 0;      if (line[len - 1] == '\n')        line[len - 1] = '\0';      /* Skip comments and empty lines.  */      if (*line == '#' || *line == '\0')	continue;      puts (line);      fflush (stdout);      pattern = strtok (line, "\t");      if (pattern == NULL)        continue;      if (strcmp (pattern, "\"\"") == 0)	pattern += 2;      flagstr = strtok (NULL, "\t");      if (flagstr == NULL)        continue;      string = strtok (NULL, "\t");      if (string == NULL)        continue;      if (strcmp (string, "\"\"") == 0)	string += 2;      for (p = flagstr; *p; ++p)	switch (*p)	  {	  case '-':	    break;	  case 'b':	    cflags &= ~REG_EXTENDED;	    break;	  case '&':	    try_bre_ere = 1;	    break;	  case 'C':	    eflags = -1;	    break;	  case 'i':	    cflags |= REG_ICASE;	    break;	  case 's':	    cflags |= REG_NOSUB;	    break;	  case 'n':	    cflags |= REG_NEWLINE;	    break;	  case '^':	    eflags |= REG_NOTBOL;	    break;	  case '$':	    eflags |= REG_NOTEOL;	    break;	  case 'm':	  case 'p':	  case '#':	    /* Not supported.  */	    flagstr = NULL;	    break;	  }      if (flagstr == NULL)	continue;      replace_special_chars (pattern);      glibc_re_syntax (pattern);      if (eflags != -1)        replace_special_chars (string);      expect = strtok (NULL, "\t");      matches = NULL;      if (expect != NULL)        {	  replace_special_chars (expect);	  matches = strtok (NULL, "\t");	  if (matches != NULL)	    replace_special_chars (matches);        }      setlocale (LC_ALL, "C");      if (test (pattern, cflags, string, eflags, expect, matches, "FAIL")	  || (try_bre_ere	      && test (pattern, cflags & ~REG_EXTENDED, string, eflags,		       expect, matches, "FAIL")))	ret = 1;      else if (test_utf8)	{	  setlocale (LC_ALL, "cs_CZ.UTF-8");	  if (test (pattern, cflags, string, eflags, expect, matches,		    "UTF-8 FAIL")	      || (try_bre_ere		  && test (pattern, cflags & ~REG_EXTENDED, string, eflags,			   expect, matches, "UTF-8 FAIL")))	    ret = 1;	  else if (mb_tests (pattern, cflags, string, eflags, expect, matches)		   || (try_bre_ere		       && mb_tests (pattern, cflags & ~REG_EXTENDED, string,				    eflags, expect, matches)))	    ret = 1;	}    }  fclose (f);  return ret;}