head	1.3;
access;
symbols
	bobbase:1.3
	bob:1.3
	r2_1:1.3
	r2_0:1.3
	r1_1_beta:1.3
	r1_1_alpha:1.2
	r1_0:1.2
	r0_11:1.1
	r0_10:1.1;
locks; strict;
comment	@# @;


1.3
date	94.07.25.17.26.39;	author thoth;	state Exp;
branches;
next	1.2;

1.2
date	94.05.17.12.57.27;	author thoth;	state Exp;
branches;
next	1.1;

1.1
date	94.01.31.16.50.30;	author thoth;	state Exp;
branches;
next	;


desc
@perl script to replace instances of Image<P,T> with CoreImage<P,T>
if P and T don't match the arguments.
Used in generation of *ImageOps.[ch]
@


1.3
log
@Name sanitization
@
text
@#!/local/bin/perl

sub usage {
    print STDERR <<EOF
  Usage: $0 native-point native-type
Replaces instances of IA_Image<P,T> with IA_CoreImage<P,T> if
P!=native-point or T!=native-type.  This is necessary because CFront
does not yet allow forward declaration of template specializations and
because various IA_Image<P,T> specializations have intertwining
references.
EOF
;
    exit 1;
}

sub convert {
    local($P,$T) = @@_;
    $P =~ s/\s+//g;
    $T =~ s/\s+//g;
    local ($rval);
    $rval =  ( ($P ne $point || $T ne $type) ? "IA_CoreImage" : "IA_Image" )
	. "<" . $P . ", " . $T . ">";
#    print STDERR "Checking $P=$point $T=$type: $rval\n";
    return $rval;
}


&usage if @@ARGV < 2;
$point = shift;
$type = shift;

$point =~ s/\s+//g;
$type =~ s/\s+//g;

while (<>) {
# this is NOT pretty, but it's the best we can do without a real parser.
    s/IA_Image\s*<\s*(\w+(<[^>]+>|))\s*,\s*(\w+(<[^>]+>|))\s*>/&convert($1,$3)/ge;
    print;
}
@


1.2
log
@It can now be used with perl's -i flag.
@
text
@d18 4
a21 1
    return ( ($P ne $point || $T ne $type) ? "IA_CoreImage" : "IA_Image" )
d23 2
d32 3
d36 2
a37 1
    s/IA_Image\s*<\s*(\w+)\s*,\s*(\w+)\s*>/&convert($1,$2)/ge;
@


1.1
log
@Initial revision
@
text
@d23 3
a25 2
($point, $type, @@rest) = @@ARGV;
&usage if @@ARGV != 2;
d27 1
a27 1
while (<STDIN>) {
@
