#!/bin/sh
wget http://www.forkosh.com/mimetex.zip &&
mkdir tex &&
cd tex &&
unzip ../mimetex.zip &&
cd .. && patch -p0 --ignore-whitespace -i "$0" && cd tex &&
cc -DAA -DDISPLAYSIZE=0 mimetex.c gifsave.c -lm -o mimetex &&
mv mimetex ../ && cd .. &&
rm -rf tex/ mimetex.zip && echo -e "\nDone." && exit 0
exit 1

diff -Nru tex/mimetex.c tex/mimetex.c
--- tex/mimetex.c       2006-11-29 12:20:38.000000000 +0100
+++ tex/mimetex.c       2008-01-04 00:49:23.065779749 +0100
@@ -669,7 +669,7 @@
 /*SHARED(int,imageformat,1);*/         /* image is 1=bitmap, 2=.gf-like */
 GLOBAL(int,isdisplaystyle,1);          /* displaystyle mode (forced if 2) */
 GLOBAL(int,ispreambledollars,0);       /* displaystyle mode set by $$...$$ */
-GLOBAL(int,isemitcontenttype,1);       /* true to emit mime content-type */
+GLOBAL(int,isemitcontenttype,0);       /* true to emit mime content-type */
 GLOBAL(int,fontnum,0);                 /* cal=1,scr=2,rm=3,it=4,bb=5,bf=6 */
 GLOBAL(int,fontsize,NORMALSIZE);       /* current size */
 GLOBAL(int,displaysize,DISPLAYSIZE);   /* use \displaystyle when fontsize>=*/
@@ -13587,6 +13587,16 @@
 shrinkfactor = shrinkfactors[NORMALSIZE]; /* set shrinkfactor */
 for ( ipattern=1; ipattern<=51; ipattern++ )
  patternnumcount0[ipattern] = patternnumcount1[ipattern] = 0;
+isquery = 1;
+if(argc > 1 && strncmp(argv[1], "--help", 7) != 0 && strncmp(argv[1], "-h", 3) != 0 && strlen(argv[1]) <= MAXEXPRSZ) {
+       strcpy(expression, argv[1]);
+}
+else {
+       printf("Modified mimetex version - Will always output a GIF file\n"
+               "Usage: mimetex <expression>\n\n");
+       exit(0);
+}
+if(0 == 1) {
 /* ---
  * check QUERY_STRING query for expression overriding command-line arg
  * ------------------------------------------------------------------- */
@@ -13954,6 +13964,7 @@
 if ( !isdumpimage )                    /* don't mix ascii with image dump */
  if ( (!isquery||isqlogging) && msgfp!=NULL ) /* called from command line */
    fprintf(msgfp,"%s\n",copyright);    /* display copyright, gnu/gpl info */
+}
 /* -------------------------------------------------------------------------
 rasterize expression and put a border around it
 -------------------------------------------------------------------------- */
