summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Prymmer <PPrymmer@factset.com>2001-06-14 09:25:33 -0700
committerJarkko Hietaniemi <jhi@iki.fi>2001-06-15 13:49:55 +0000
commitb7bcf49446150838af3c7cd1dec335ba45a2fc6b (patch)
tree73555e583d3a9108aaf921a40707eea8961efc8c
parent8999201bab63458618adf26ec16c87a4d7bec076 (diff)
downloadperl-b7bcf49446150838af3c7cd1dec335ba45a2fc6b.tar.gz
handle tri graphs in h2ph.PL -> h2ph*
Message-ID: <Pine.OSF.4.10.10106141608080.110974-100000@aspara.forte.com> p4raw-id: //depot/perl@10605
-rw-r--r--t/lib/h2ph.h16
-rw-r--r--t/lib/h2ph.pht12
-rwxr-xr-xt/lib/h2ph.t30
-rw-r--r--utils/h2ph.PL14
4 files changed, 58 insertions, 14 deletions
diff --git a/t/lib/h2ph.h b/t/lib/h2ph.h
index 128ec5f1ae..9fd535d34e 100644
--- a/t/lib/h2ph.h
+++ b/t/lib/h2ph.h
@@ -82,4 +82,20 @@ typedef struct a_struct {
typedef enum _days_of_week { sun, mon, tue, wed, thu, fri, sat, Sun=0, Mon,
Tue, Wed, Thu, Fri, Sat } days_of_week;
+/*
+ * Some moderate flexing of tri-graph pre substitution.
+ */
+??=ifndef _SOMETHING_TRIGRAPHIC
+??=define _SOMETHING_TRIGRAPHIC
+??= define SOMETHING_ELSE_TRIGRAPHIC_0 "??!" /* | ??!| || */
+ ??=define SOMETHING_ELSE_TRIGRAPHIC_1 "??'" /* | ??'| ^| */
+??= define SOMETHING_ELSE_TRIGRAPHIC_2 "??(" /* | ??(| [| */
+ ??= define SOMETHING_ELSE_TRIGRAPHIC_3 "??)" /* | ??)| ]| */
+??=define SOMETHING_ELSE_TRIGRAPHIC_4 "??-0" /* | ??-| ~| */
+ ??= define SOMETHING_ELSE_TRIGRAPHIC_5 "??/ " /* | ??/| \| */
+??= define SOMETHING_ELSE_TRIGRAPHIC_6 "??<" /* | ??<| {| */
+??=define SOMETHING_ELSE_TRIGRAPHIC_7 "??=" /* | ??=| #| */
+??= define SOMETHING_ELSE_TRIGRAPHIC_8 "??>" /* | ??>| }| */
+ ??=endif
+
#endif /* _H2PH_H_ */
diff --git a/t/lib/h2ph.pht b/t/lib/h2ph.pht
index e8868dcb4a..07b9470e70 100644
--- a/t/lib/h2ph.pht
+++ b/t/lib/h2ph.pht
@@ -67,5 +67,17 @@ unless(defined(&_H2PH_H_)) {
eval("sub Thu () { 4; }") unless defined(&Thu);
eval("sub Fri () { 5; }") unless defined(&Fri);
eval("sub Sat () { 6; }") unless defined(&Sat);
+ unless(defined(&_SOMETHING_TRIGRAPHIC)) {
+ eval 'sub _SOMETHING_TRIGRAPHIC () {1;}' unless defined(&_SOMETHING_TRIGRAPHIC);
+ eval 'sub SOMETHING_ELSE_TRIGRAPHIC_0 () {"|";}' unless defined(&SOMETHING_ELSE_TRIGRAPHIC_0);
+ eval 'sub SOMETHING_ELSE_TRIGRAPHIC_1 () {"^";}' unless defined(&SOMETHING_ELSE_TRIGRAPHIC_1);
+ eval 'sub SOMETHING_ELSE_TRIGRAPHIC_2 () {"[";}' unless defined(&SOMETHING_ELSE_TRIGRAPHIC_2);
+ eval 'sub SOMETHING_ELSE_TRIGRAPHIC_3 () {"]";}' unless defined(&SOMETHING_ELSE_TRIGRAPHIC_3);
+ eval 'sub SOMETHING_ELSE_TRIGRAPHIC_4 () {"~0";}' unless defined(&SOMETHING_ELSE_TRIGRAPHIC_4);
+ eval 'sub SOMETHING_ELSE_TRIGRAPHIC_5 () {"\\ ";}' unless defined(&SOMETHING_ELSE_TRIGRAPHIC_5);
+ eval 'sub SOMETHING_ELSE_TRIGRAPHIC_6 () {"{";}' unless defined(&SOMETHING_ELSE_TRIGRAPHIC_6);
+ eval 'sub SOMETHING_ELSE_TRIGRAPHIC_7 () {"#";}' unless defined(&SOMETHING_ELSE_TRIGRAPHIC_7);
+ eval 'sub SOMETHING_ELSE_TRIGRAPHIC_8 () {"}";}' unless defined(&SOMETHING_ELSE_TRIGRAPHIC_8);
+ }
}
1;
diff --git a/t/lib/h2ph.t b/t/lib/h2ph.t
index 15dc2b52c2..7b339b3927 100755
--- a/t/lib/h2ph.t
+++ b/t/lib/h2ph.t
@@ -8,6 +8,13 @@ BEGIN {
@INC = '../lib';
}
+my $extracted_program = '../utils/h2ph'; # unix, nt, ...
+if ($^O eq 'VMS') { $extracted_program = '[-.utils]h2ph.com'; }
+if (!(-e $extracted_program)) {
+ print "1..0 # Skip: $extracted_program was not built\n";
+ exit 0;
+}
+
print "1..2\n";
# quickly compare two text files
@@ -17,19 +24,14 @@ sub txt_compare {
$A cmp $B;
}
-unless(-e '../utils/h2ph') {
- print("ok 1\nok 2\n");
- # i'll probably get in trouble for this :)
-} else {
- # does it run?
- $ok = system("./perl -I../lib ../utils/h2ph -d. -Q lib/h2ph.h");
- print(($ok == 0 ? "" : "not "), "ok 1\n");
+# does it run?
+$ok = system("$^X \"-I../lib\" $extracted_program -d. \"-Q\" lib/h2ph.h");
+print(($ok == 0 ? "" : "not "), "ok 1\n");
- # does it work? well, does it do what we expect? :-)
- $ok = txt_compare("lib/h2ph.ph", "lib/h2ph.pht");
- print(($ok == 0 ? "" : "not "), "ok 2\n");
+# does it work? well, does it do what we expect? :-)
+$ok = txt_compare("lib/h2ph.ph", "lib/h2ph.pht");
+print(($ok == 0 ? "" : "not "), "ok 2\n");
- # cleanup - should this be in an END block?
- unlink("lib/h2ph.ph");
- unlink("_h2ph_pre.ph");
-}
+# cleanup - should this be in an END block?
+unlink("lib/h2ph.ph");
+unlink("_h2ph_pre.ph");
diff --git a/utils/h2ph.PL b/utils/h2ph.PL
index d852fc2422..f647831a53 100644
--- a/utils/h2ph.PL
+++ b/utils/h2ph.PL
@@ -401,6 +401,7 @@ sub expr {
sub next_line
{
my ($in, $out);
+ my $pre_sub_tri_graphs = 1;
READ: while (not eof IN) {
$in .= <IN>;
@@ -408,6 +409,19 @@ sub next_line
next unless length $in;
while (length $in) {
+ if ($pre_sub_tri_graphs) {
+ # Preprocess all tri-graphs
+ # including things stuck in quoted string constants.
+ $in =~ s/\?\?=/#/g; # | ??=| #|
+ $in =~ s/\?\?\!/|/g; # | ??!| ||
+ $in =~ s/\?\?'/^/g; # | ??'| ^|
+ $in =~ s/\?\?\(/[/g; # | ??(| [|
+ $in =~ s/\?\?\)/]/g; # | ??)| ]|
+ $in =~ s/\?\?\-/~/g; # | ??-| ~|
+ $in =~ s/\?\?\//\\/g; # | ??/| \|
+ $in =~ s/\?\?</{/g; # | ??<| {|
+ $in =~ s/\?\?>/}/g; # | ??>| }|
+ }
if ($in =~ s/\\$//) { # \-newline
$out .= ' ';
next READ;