Index: ../includes/Math.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/Math.php,v
retrieving revision 1.23
diff -u -r1.23 Math.php
--- ../includes/Math.php	18 Jun 2005 05:09:27 -0000	1.23
+++ ../includes/Math.php	9 Feb 2006 22:56:47 -0000
@@ -32,7 +32,7 @@
 
 	function render() {
 		global $wgMathDirectory, $wgTmpDirectory, $wgInputEncoding;
-		global $wgTexvc;
+		global $wgTexvc, $wgRunTexvc;
 		$fname = 'MathRenderer::render';
 	
 		if( $this->mode == MW_MATH_SOURCE ) {
@@ -60,10 +60,12 @@
 			if( function_exists( 'is_executable' ) && !is_executable( $wgTexvc ) ) {
 				return $this->_error( 'math_notexvc' );
 			}
-			$cmd = $wgTexvc . ' ' . 
+
+			$cmd = ( $wgRunTexvc
+				? $wgRunTexvc . ' ' . escapeshellarg( $wgTexvc )
+				: wgTexvc ) . ' ' .
 					escapeshellarg( $wgTmpDirectory ).' '.
 					escapeshellarg( $wgMathDirectory ).' '.
-					escapeshellarg( $this->tex ).' '.
 					escapeshellarg( $wgInputEncoding );
 					
 			if ( wfIsWindows() ) {
@@ -72,7 +74,27 @@
 			} 
 
 			wfDebug( "TeX: $cmd\n" );
-			$contents = `$cmd`;
+			
+			if ( $wgRunTexvc ) {
+				$descriptorspec = array (
+					0 => array( "pipe", "r" ),
+					1 => array( "pipe", "w" )
+				);
+				$process = proc_open( $cmd, $descriptorspec, $pipes );
+				if ( is_resource( $process ) ) {
+					fwrite( $pipes[0], $this->tex );
+					fclose( $pipes[0] );
+					$contents = fread( $pipes[1], 8192 );	// FIXME
+					fclose( $pipes[1] );
+				}
+				else {
+					return $this->_error( 'math_unknown_error' );
+				}
+			}
+			else {
+				$contents = shell_exec( $cmd );
+			}
+			
 			wfDebug( "TeX output:\n $contents\n---\n" );
 		
 			if (strlen($contents) == 0) {
