Improved debugging of mimetex

This commit is contained in:
fiedorow 2004-02-20 01:44:31 +00:00
parent 03cd979250
commit 1ed0ba1d77
5 changed files with 42 additions and 17 deletions

View File

@ -143,6 +143,9 @@ function tex2image($texexp) {
make_upload_directory($CFG->algebraimagedir);
}
$pathname = "$CFG->dataroot/$CFG->algebraimagedir/$image";
if (file_exists($pathname)) {
unlink($pathname);
}
$windows = 0;
switch (PHP_OS) {
case "Linux":
@ -159,7 +162,7 @@ function tex2image($texexp) {
$cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin -e $pathname ". escapeshellarg($texexp);
break;
}
system($cmd);
system($cmd, $status);
}
if ($texexp && file_exists($pathname)) {
$lastmodified = filemtime($pathname);
@ -173,8 +176,16 @@ function tex2image($texexp) {
readfile("$pathname");
} else {
if (!$windows) {
$cmd = "$cmd 2>&1";
echo `$cmd` . "<br>\n";
$ecmd = "$cmd 2>&1";
echo `$ecmd` . "<br>\n";
}
echo "The shell command<br>$cmd<br>returned status = $status<br>\n";
if ($status == 4) {
echo "Status corresponds to illegal instruction<br>\n";
} else if ($status == 11) {
echo "Status corresponds to bus error<br>\n";
} else if ($status == 22) {
echo "Status corresponds to abnormal termination<br>\n";
}
echo "Image not found!";
}

View File

@ -149,7 +149,7 @@ function algebra_filter ($courseid, $text) {
$texexp = `$cmd`;
if (preg_match('/parsehilight/',$texexp)) {
$text = str_replace( $matches[0][$i],"<b>Syntax error:</b> " . $texexp,$text);
} else {
} else if ($texexp) {
$texexp = str_replace('#','\not= ',$texexp);
$texexp = str_replace('%','\leq ',$texexp);
$texexp = str_replace('!','\geq ',$texexp);
@ -185,7 +185,9 @@ function algebra_filter ($courseid, $text) {
$texcache->timemodified = time();
insert_record("cache_filters",$texcache);
$text = str_replace( $matches[0][$i], string_file_picture_algebra($filename, $texexp), $text);
}
} else {
$text = str_replace( $matches[0][$i],"<b>Undetermined error:</b> ",$text);
}
} else {
$text = str_replace( $matches[0][$i], string_file_picture_algebra($filename, $texcache->rawtext), $text);
}

View File

@ -49,18 +49,19 @@
$texexp = '\Large ' . $texexp;
switch (PHP_OS) {
case "Linux":
system("$CFG->dirroot/$CFG->texfilterdir/mimetex.linux -e $pathname ". escapeshellarg($texexp) );
$cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.linux -e $pathname ". escapeshellarg($texexp);
break;
case "WINNT":
case "WIN32":
case "Windows":
$texexp = str_replace('"','\"',$texexp);
system("$CFG->dirroot/$CFG->texfilterdir/mimetex.exe -e $pathname \"$texexp\"");
$cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.exe -e $pathname \"$texexp\"";
break;
case "Darwin":
system("$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin -e $pathname ". escapeshellarg($texexp) );
$cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin -e $pathname ". escapeshellarg($texexp);
break;
}
system($cmd, $status);
}
}
@ -75,6 +76,7 @@
header("Content-type: $filetype");
readfile("$pathname");
} else {
echo "The shell command<br>$cmd<br>returned status = $status<br>\n";
echo "Image not found!";
}

View File

@ -48,21 +48,19 @@
$texexp = '\Large ' . $texexp;
switch (PHP_OS) {
case "Linux":
system("$CFG->dirroot/$CFG->texfilterdir/mimetex.linux -e $pathname ". escapeshellarg($texexp) );
$cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.linux -e $pathname ". escapeshellarg($texexp);
break;
case "WINNT":
case "WIN32":
case "Windows":
$texexp = str_replace('"','\"',$texexp);
system("$CFG->dirroot/$CFG->texfilterdir/mimetex.exe -e $pathname \"$texexp\"");
$cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.exe -e $pathname \"$texexp\"";
break;
case "Darwin":
system("$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin -e $pathname ". escapeshellarg($texexp) );
break;
default:
system("$CFG->dirroot/$CFG->texfilterdir/mimetex -e $pathname ". escapeshellarg($texexp) );
$cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin -e $pathname ". escapeshellarg($texexp);
break;
}
system($cmd, $status);
}
}
@ -77,6 +75,7 @@
header("Content-type: $filetype");
readfile("$pathname");
} else {
echo "The shell command<br>$cmd<br>returned status = $status<br>\n";
echo "Image not found!";
}

View File

@ -83,6 +83,9 @@ function tex2image($texexp) {
make_upload_directory($CFG->teximagedir);
}
$pathname = "$CFG->dataroot/$CFG->teximagedir/$image";
if (file_exists($pathname)) {
unlink($pathname);
}
$windows = 0;
switch (PHP_OS) {
case "Linux":
@ -99,7 +102,7 @@ function tex2image($texexp) {
$cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin -e $pathname ". escapeshellarg($texexp);
break;
}
system($cmd);
system($cmd, $status);
}
if ($texexp && file_exists($pathname)) {
$lastmodified = filemtime($pathname);
@ -113,8 +116,16 @@ function tex2image($texexp) {
readfile("$pathname");
} else {
if (!$windows) {
$cmd = "$cmd 2>&1";
echo `$cmd` . "<br>\n";
$ecmd = "$cmd 2>&1";
echo `$ecmd` . "<br>\n";
}
echo "The shell command<br>$cmd<br>returned status = $status<br>\n";
if ($status == 4) {
echo "Status corresponds to illegal instruction<br>\n";
} else if ($status == 11) {
echo "Status corresponds to bus error<br>\n";
} else if ($status == 22) {
echo "Status corresponds to abnormal termination<br>\n";
}
echo "Image not found!";
}