]> git.mjollnir.org Git - moodle.git/commitdiff
Improved debugging of mimetex
authorfiedorow <fiedorow>
Fri, 20 Feb 2004 01:44:31 +0000 (01:44 +0000)
committerfiedorow <fiedorow>
Fri, 20 Feb 2004 01:44:31 +0000 (01:44 +0000)
filter/algebra/algebradebug.php
filter/algebra/filter.php
filter/algebra/pix.php
filter/tex/pix.php
filter/tex/texdebug.php

index 0201dfaf3af4980b0e004d437f226703f3294462..27fcaf7d50973e01ae0b90ec25012a5fbe080f55 100644 (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!";
    }
index 05ace6f7ca5d7e4bc9584274248002331230e501..510151c2ed98b2436054a3e87322c3b658a82046 100644 (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);
        }
index b75fc21f0da1baaf2f3200d15ba649cf449686fd..30c8e5969b749769722a4bd0286362ae5a3f7dd9 100644 (file)
             $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!";
     }
 
index be1abc2f8124b42f6aae823dd3912b61fd59d4df..2a1b0accf4f1b25cc5f84b3e292f653e8c0b0660 100644 (file)
             $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!";
     }
 
index 67c489723a837b0465a66904cbd04d2b9c38ccc4..710e271e022a0bae3592195493852f05da1008ee 100644 (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!";
    }