/[pcre]/code/branches/pcre16/perltest.pl
ViewVC logotype

Diff of /code/branches/pcre16/perltest.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

code/trunk/perltest revision 63 by nigel, Sat Feb 24 21:40:03 2007 UTC code/trunk/perltest.pl revision 459 by ph10, Sun Oct 4 09:21:39 2009 UTC
# Line 1  Line 1 
1  #! /usr/bin/perl  #! /usr/bin/env perl
2    
3  # Program for testing regular expressions with perl to check that PCRE handles  # Program for testing regular expressions with perl to check that PCRE handles
4  # them the same. This is the version that supports /8 for UTF-8 testing. As it  # them the same. This is the version that supports /8 for UTF-8 testing. As it
5  # stands, it requires at least Perl 5.8 for UTF-8 support. For Perl 5.6, it  # stands, it requires at least Perl 5.8 for UTF-8 support. However, it needs to
6  # can be used as is for non-UTF-8 testing, but you have to uncomment the  # have "use utf8" at the start for running the UTF-8 tests, but *not* for the
7  # "use utf8" lines in order to to UTF-8 stuff (and you mustn't uncomment them  # other tests. The only way I've found for doing this is to cat this line in
8  # for non-UTF-8 use).  # explicitly in the RunPerlTest script.
9    
10    # use locale;  # With this included, \x0b matches \s!
11    
12  # Function for turning a string into a string of printing chars. There are  # Function for turning a string into a string of printing chars. There are
13  # currently problems with UTF-8 strings; this fudges round them.  # currently problems with UTF-8 strings; this fudges round them.
# Line 16  my($t) = ""; Line 17  my($t) = "";
17    
18  if ($utf8)  if ($utf8)
19    {    {
 #  use utf8;                    <=============== For UTF-8 in Perl 5.6  
20    @p = unpack('U*', $_[0]);    @p = unpack('U*', $_[0]);
21    foreach $c (@p)    foreach $c (@p)
22      {      {
# Line 38  $t; Line 38  $t;
38  }  }
39    
40    
   
41  # Read lines from named file or stdin and write to named file or stdout; lines  # Read lines from named file or stdin and write to named file or stdout; lines
42  # consist of a regular expression, in delimiters and optionally followed by  # consist of a regular expression, in delimiters and optionally followed by
43  # options, followed by a set of test data, terminated by an empty line.  # options, followed by a set of test data, terminated by an empty line.
# Line 88  for (;;) Line 87  for (;;)
87    
88    $showrest = ($pattern =~ s/\+(?=[a-z]*$)//);    $showrest = ($pattern =~ s/\+(?=[a-z]*$)//);
89    
90    # The private /8 modifier means "operate in UTF-8". Currently, Perl    # Remove /8 from a UTF-8 pattern.
   # has bugs that we try to work around using this flag.  
91    
92    $utf8 = ($pattern =~ s/8(?=[a-z]*$)//);    $utf8 = $pattern =~ s/8(?=[a-z]*$)//;
93    
94      # Remove /J from a pattern with duplicate names.
95    
96      $pattern =~ s/J(?=[a-z]*$)//;
97    
98    # Check that the pattern is valid    # Check that the pattern is valid
99    
100    if ($utf8)    eval "\$_ =~ ${pattern}";
     {  
 #    use utf8;                    <=============== For UTF-8 in Perl 5.6  
     eval "\$_ =~ ${pattern}";  
     }  
   else  
     {  
     eval "\$_ =~ ${pattern}";  
     }  
   
101    if ($@)    if ($@)
102      {      {
103      printf $outfile "Error: $@";      printf $outfile "Error: $@";
# Line 138  for (;;) Line 131  for (;;)
131      s/^\s+//;      s/^\s+//;
132    
133      last if ($_ eq "");      last if ($_ eq "");
   
134      $x = eval "\"$_\"";   # To get escapes processed      $x = eval "\"$_\"";   # To get escapes processed
135    
136      # Empty array for holding results, then do the matching.      # Empty array for holding results, then do the matching.
# Line 164  for (;;) Line 156  for (;;)
156           "push \@subs,\$16;" .           "push \@subs,\$16;" .
157           "push \@subs,\$'; }";           "push \@subs,\$'; }";
158    
159      if ($utf8)      eval "${cmd} (\$x =~ ${pattern}) {" . $pushes;
       {  
 #      use utf8;                    <=============== For UTF-8 in Perl 5.6  
       eval "${cmd} (\$x =~ ${pattern}) {" . $pushes;  
       }  
     else  
       {  
       eval "${cmd} (\$x =~ ${pattern}) {" . $pushes;  
       }  
160    
161      if ($@)      if ($@)
162        {        {
# Line 206  for (;;) Line 190  for (;;)
190      }      }
191    }    }
192    
193  printf $outfile "\n";  # printf $outfile "\n";
194    
195  # End  # End

Legend:
Removed from v.63  
changed lines
  Added in v.459

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12