[LON-CAPA-cvs] cvs: loncom /interface printout.pl

sakharuk lon-capa-cvs@mail.lon-capa.org
Thu, 05 Aug 2004 18:18:16 -0000


sakharuk		Thu Aug  5 14:18:16 2004 EDT

  Modified files:              
    /loncom/interface	printout.pl 
  Log:
  3266 - All Guy's critical notes were taken into account.  
  
  
Index: loncom/interface/printout.pl
diff -u loncom/interface/printout.pl:1.62 loncom/interface/printout.pl:1.63
--- loncom/interface/printout.pl:1.62	Wed Aug  4 14:19:11 2004
+++ loncom/interface/printout.pl	Thu Aug  5 14:18:15 2004
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # CGI-script to run LaTeX, dvips, ps2ps, ps2pdf etc.
 #
-# $Id: printout.pl,v 1.62 2004/08/04 18:19:11 sakharuk Exp $
+# $Id: printout.pl,v 1.63 2004/08/05 18:18:15 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -194,13 +194,19 @@
 			 "for $status_statement now LaTeXing file",
 			 \%prog_state,$dvi_file);
       if ($tableofcontents eq 'yes') {
-	  system("latex $name_file 1>/dev/null 2>/dev/null");
+      &busy_wait_command("latex $name_file 1>/dev/null 2>/dev/null",
+			 "for $status_statement now LaTeXing file for table of contents",
+			 \%prog_state,$dvi_file);
       } #to create table of contents
       my $idxname=$name_file;
       $idxname=~s/\.tex$/\.idx/;
       if ($tableofindex eq 'yes') {
-	  system("makeindex $idxname");
-	  system("latex $name_file 1>/dev/null 2>/dev/null");
+	  &busy_wait_command("makeindex $idxname",
+			     "making index file",
+			     \%prog_state,$idxname);
+	  &busy_wait_command("latex $name_file 1>/dev/null 2>/dev/null",
+			     "for $status_statement now LaTeXing file for index section",
+			     \%prog_state,$dvi_file);
       } #to create index
       #Do we have a latex error in the log file?
       my $logfilename = $texfile;
@@ -291,8 +297,10 @@
                   my $papera=$papers[$paper];
 		  if ($papera ne '') {$papera='-p'.$papera;}
 		  $comma = 'pstops '.$papera.' "2:0+1(0.48w,0)"';
-		  system("$comma $new_name_file $tempo_file 1>/dev/null 2>/dev/null");
-		  system("ps2pdf $tempo_file $name_file 1>/dev/null 2>/dev/null");
+		  &busy_wait_command("$comma $new_name_file $tempo_file 1>/dev/null 2>/dev/null",
+				     "for $status_statement now Modifying PS layout",
+				     \%prog_state,$tempo_file); 
+
 	      } else {
 		  $ps_file=$new_name_file;
 	      }	    
@@ -369,15 +377,17 @@
 	      }
 	      if ($paper eq '6') {
 		  open(FFH,'<',$ps_file) || die "Couldn't open file for reading: $!\n";
-		  my @content_of_file = <FFH>;
-		  close(FFH);
-		  open(FFH,'>',$ps_file) || die "Couldn't open file for writing: $!\n";
-                  print FFH '<< /PageSize [595.2 842] >> setpagedevice'."\n";
-		  for (my $i=0;$i<=$#content_of_file;$i++) {
-		      print FFH $content_of_file[$i];
-		      print "<br>$i<br>";
+		  my $new_ps_file='new'.$ps_file;
+		  open(FFHS,'>',$new_ps_file) || die "Couldn't open file for reading: $!\n";
+		  my $i=-1;
+		  while (<FFH>) {
+		      $i++;
+		      if ($i==0) {print FFHS '<< /PageSize [595.2 842] >> setpagedevice'."\n";} 
+		      print FFHS $_;
 		  }
-		  close(FFH);  		  
+		  close(FFH);
+		  close(FFHS);
+		  $ps_file=$new_ps_file;	  
 	      }
 	      &busy_wait_command("ps2pdf $ps_file $pdf_file 1>/dev/null 2>/dev/null",
 				 "for $status_statement now Converting PS to PDF",
@@ -397,7 +407,7 @@
 	      print "<a href=\"/prtspool/$pdf_file\">$link_text</a>";
 	      print "\n";
 	  }
-      }
+      }  
   } else {
       print "LaTeX file $texfile was not created successfully";
   }