summaryrefslogtreecommitdiff
path: root/Porting
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-01-23 21:03:05 +0000
committerNicholas Clark <nick@ccl4.org>2011-01-23 21:08:46 +0000
commit8770da0e36c1d16484eea6e86a2d0eeafad07f30 (patch)
tree7a1da4e804e3ffb71c0c3d0ca1e594de8164d8c5 /Porting
parentc21ebed2b0d42104e83548e11b188182a597806e (diff)
downloadperl-8770da0e36c1d16484eea6e86a2d0eeafad07f30.tar.gz
Convert regcharclass.pl to use regen_lib.pl
This results in small changes to the formatting of the generated comments in regcharclass.h
Diffstat (limited to 'Porting')
-rwxr-xr-xPorting/regcharclass.pl50
1 files changed, 13 insertions, 37 deletions
diff --git a/Porting/regcharclass.pl b/Porting/regcharclass.pl
index 5bafcc9b26..c3ea8a62b0 100755
--- a/Porting/regcharclass.pl
+++ b/Porting/regcharclass.pl
@@ -1,5 +1,6 @@
package CharClass::Matcher;
use strict;
+use 5.008;
use warnings;
use warnings FATAL => 'all';
use Text::Wrap qw(wrap);
@@ -8,6 +9,8 @@ use Data::Dumper;
$Data::Dumper::Useqq= 1;
our $hex_fmt= "0x%02X";
+require 'regen/regen_lib.pl';
+
=head1 NAME
CharClass::Matcher -- Generate C macros that match character classes efficiently
@@ -612,45 +615,17 @@ sub make_macro {
# be the path of the file to output to, if the arg is '-' outputs
# to STDOUT.
if ( !caller ) {
-
-
-
$|++;
- my $path= shift @ARGV;
-
- if ( !$path ) {
- $path= "regcharclass.h";
- if ( !-e $path ) { $path= "../$path" }
- if ( !-e $path ) { die "Can't find '$path' to update!\n" }
- }
+ my $path= shift @ARGV || "regcharclass.h";
my $out_fh;
if ( $path eq '-' ) {
$out_fh= \*STDOUT;
} else {
- rename $path, "$path.bak";
- open $out_fh, ">", $path
- or die "Can't write to '$path':$!";
- binmode $out_fh; # want unix line endings even when run on win32.
+ $out_fh = safer_open( "$path-new", $path );
}
- my ( $zero )= $0 =~ /([^\\\/]+)$/;
- print $out_fh <<"HEADER";
-/* -*- buffer-read-only: t -*-
- *
- * regcharclass.h
- *
- * Copyright (C) 2007, by Larry Wall and others
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
- * This file is built by Porting/$zero.
- *
- * Any changes made here will be lost!
- *
- */
-
-HEADER
+ print $out_fh read_only_top( lang => 'C', by => $0,
+ file => 'regcharclass.h', style => '*',
+ copyright => [2007] );
my ( $op, $title, @txt, @types, @mods );
my $doit= sub {
@@ -693,8 +668,11 @@ HEADER
}
}
$doit->();
- print $out_fh "/* ex: set ro: */\n";
- print "updated $path\n" if $path ne '-';
+ if($path eq '-') {
+ print $out_fh "/* ex: set ro: */\n";
+ } else {
+ read_only_bottom_close_and_rename($out_fh)
+ }
}
#
@@ -756,5 +734,3 @@ TRICKYFOLD: Problematic fold case letters.
0x00DF # LATIN1 SMALL LETTER SHARP S
0x0390 # GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
0x03B0 # GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
-
-