-#!/usr/bin/env perl -w
+#!/usr/bin/env perl
#############################################################################
# Name: regex.pl
# Purpose: Generate test code for wxRegEx from 'reg.test'
# Author: Mike Wetherell
# RCS-ID: $Id$
# Copyright: (c) Mike Wetherell
-# Licence: wxWidgets licence
+# Licence: wxWindows licence
#############################################################################
#
#
use strict;
+use warnings;
use File::Basename;
#use encoding "UTF-8"; # enable in the future when perl 5.6.x is just a memory
"\013" => "v", '"' => '"', "\\" => "\\" );
# working around lack of 'use encoding'
- $_ = pack "U0C*", unpack "C*", $_;
- use utf8;
+ if (!$utf) {
+ $_ = pack "U0C*", unpack "C*", $_;
+ use utf8;
+ }
s/[\000-\037"\\\177-\x{ffff}]/
if ($esc{$&}) {
"\\$esc{$&}";
- } elsif (ord($&) > 0x9f) {
- if ($utf) {
- $&;
- } else {
- sprintf "\\u%04x", ord($&);
- }
+ } elsif (ord($&) > 0x9f && !$utf) {
+ sprintf "\\u%04x", ord($&);
} else {
sprintf "\\%03o", ord($&);
}
/ge;
# working around lack of 'use encoding'
- no utf8;
- $_ = pack "C*", unpack "C*", $_;
+ if (!$utf) {
+ no utf8;
+ $_ = pack "C*", unpack "C*", $_;
+ }
return ($utf ? '"' : 'L"') . $_ . '"'
}
Input files should be in UTF-8. If no input files are specified input is
read from stdin. If no output file is specified output is written to stdout.
-See the comments in reg.test (in src/regex) for details of the input file
-format.
+See the comments in reg.test for details of the input file format.
EOT
exit 0;
}
my $results = $opts =~ /-inline/ && $test ne 'f' ? $extras[$i+2] : '';
# get them all in the right order and print
- unshift @args, $test, parsetcl($id), '-';
+ unshift @args, $test, parsetcl($id), $results ? '-' : 'o';
push @args, parsetcl(parsetcl($results)) if $results;
handle_test @args;
}