From: Sam H. v. a. <we...@ma...> - 2005-07-05 22:01:56
|
Log Message: ----------- chech tthPreamble path and mtime to deal with changes to the file=20 between runs. this is necessary now that dangerousMacros.pl is cached.=20 Closes bug #798. Modified Files: -------------- pg/macros: dangerousMacros.pl Revision Data ------------- Index: dangerousMacros.pl =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /webwork/cvs/system/pg/macros/dangerousMacros.pl,v retrieving revision 1.34 retrieving revision 1.35 diff -Lmacros/dangerousMacros.pl -Lmacros/dangerousMacros.pl -u -r1.34 -r= 1.35 --- macros/dangerousMacros.pl +++ macros/dangerousMacros.pl @@ -436,21 +436,35 @@ # Global macros: # None =20 -my ($tthPreambleFile, $tthPreambleContents); # the contents of this file= will not change during problem compilation - # it only needs to be read = once +# the contents of this file will not change during problem compilation i= t +# only needs to be read once. however, the contents of the file may chan= ge, +# and indeed the file refered to may change, between rendering passes. t= hus, +# we need to keep track of the file name and the mtime as well. +my ($tthPreambleFile, $tthPreambleMtime, $tthPreambleContents); + sub tth { my $inputString =3D shift; - - # read the contents of the tthPreamble.tex file, unless it has already = been read - unless ( defined( $tthPreambleContents) ) { - $tthPreambleFile =3D "${templateDirectory}tthPreamble.tex" if ( -r "${= templateDirectory}tthPreamble.tex" ); - if ( defined($tthPreambleFile) ) { +=09 + my $thisFile =3D "${templateDirectory}tthPreamble.tex" if -r "${templat= eDirectory}tthPreamble.tex"; +=09 + if (defined $thisFile) { + my $thisMtime =3D (stat $thisFile)[9]; + my $load =3D=20 + # load preamble if we haven't loaded it ever + (not defined $tthPreambleFile or not defined $tthPreambleMtime or not= defined $tthPreambleContents) + || + # load if the file path has changed + ($tthPreambleFile ne $thisFile) + || + # load if the file has been modified + ($tthPreambleMtime < $thisMtime); + =09 + if ($load) { local(*TTHIN); open (TTHIN, "${templateDirectory}tthPreamble.tex") || die "Can't ope= n file ${templateDirectory}tthPreamble.tex"; - #my @tthPreambleArray =3D <TTHIN>; local($/); $/ =3D undef; - $tthPreambleContents =3D <TTHIN>;#join("",@tthPreambleArray); + $tthPreambleContents =3D <TTHIN>; close(TTHIN); =20 $tthPreambleContents =3D~ s/(.)\n/$1%\n/g; # thanks to Jim Martino @@ -459,12 +473,11 @@ # adding supurious paragrap= hs to output. =20 $tthPreambleContents .=3D"%\n"; # solves the problem if t= he file doesn't end with a return. - - } else { - $tthPreambleContents =3D ""; } + } else { + $tthPreambleContents =3D ""; } - +=09 $inputString =3D $tthPreambleContents . $inputString; $inputString =3D "<<END_OF_TTH_INPUT_STRING;\n\n\n" . $inputStrin= g . "\nEND_OF_TTH_INPUT_STRING\necho \"\" >/dev/null"; #it's not clear wh= y another command is needed. =20 @@ -496,25 +509,25 @@ $string =3D~ s/\x5C/\\/g; #\ 92 \ $string =3D~ s/\x7B/\{/g; #{ 123 {= ; $string =3D~ s/\x7D/\}/g; #} 125 }= ; - $string =3D~ s/\xE7/\Á/g; #=E7 231 = 93; - $string =3D~ s/\xE6/\Ê/g; #=E6 230 = 02; - $string =3D~ s/\xE8/\Ë/g; #=E8 232 = 03; - $string =3D~ s/\xF3/\Û/g; #=F3 243 = 19; - $string =3D~ s/\xA5/\•/g; #=A5 165 &bu= ll; - $string =3D~ s/\xB2/\≤/g; #=B2 178 ≤ - $string =3D~ s/\xB3/\≥/g; #=B3 179 ≥ - $string =3D~ s/\xB6/\∂/g; #=B6 182 &pa= rt; - $string =3D~ s/\xCE/\Œ/g; #=CE 206 = 38; - $string =3D~ s/\xD6/\˜/g; #=D6 214 = 32; - $string =3D~ s/\xD9/\Ÿ/g; #=D9 217 &Yu= ml; - $string =3D~ s/\xDA/\⁄/g; #=DA 218 &f= rasl; - $string =3D~ s/\xF5/\ı/g; #=F5 245 = 05 - $string =3D~ s/\xF6/\ˆ/g; #=F6 246 = 10; - $string =3D~ s/\xF7/\Á/g; #=F7 247 = 93; - $string =3D~ s/\xF8/\¯/g; #=F8 248 = 75; - $string =3D~ s/\xF9/\˘/g; #=F9 249 = 28; - $string =3D~ s/\xFA/\˙/g; #=FA 250 = 29; - $string =3D~ s/\xFB/\˚;/g; #=FB 251 &#= 730; + $string =3D~ s/\xE7/\Á/g; #=C1 231 = 93; + $string =3D~ s/\xE6/\Ê/g; #=CA 230 = 02; + $string =3D~ s/\xE8/\Ë/g; #=CB 232 = 03; + $string =3D~ s/\xF3/\Û/g; #=DB 243 = 19; + $string =3D~ s/\xA5/\•/g; #=80 165 &bu= ll; + $string =3D~ s/\xB2/\≤/g; #=BE 178 ≤ + $string =3D~ s/\xB3/\≥/g; #=84 179 ≥ + $string =3D~ s/\xB6/\∂/g; #=8F 182 &pa= rt; + $string =3D~ s/\xCE/\Œ/g; #=91 206 = 38; + $string =3D~ s/\xD6/\˜/g; #=F7 214 = 32; + $string =3D~ s/\xD9/\Ÿ/g; #=8D 217 &Yu= ml; + $string =3D~ s/\xDA/\⁄/g; #=8E 218 &f= rasl; + $string =3D~ s/\xF5/\ı/g; #=9E 245 = 05 + $string =3D~ s/\xF6/\ˆ/g; #=96 246 = 10; + $string =3D~ s/\xF7/\Á/g; #=97 247 = 93; + $string =3D~ s/\xF8/\¯/g; #=AF 248 = 75; + $string =3D~ s/\xF9/\˘/g; #=98 249 = 28; + $string =3D~ s/\xFA/\˙/g; #=99 250 = 29; + $string =3D~ s/\xFB/\˚;/g; #=9A 251 &#= 730; $string; } =20 |