--- gnuplot-4.2.rc2/src/util.c.orig 2006-12-21 10:56:49.798465000 +0100 +++ gnuplot-4.2.rc2/src/util.c 2006-12-21 13:39:23.333702432 +0100 @@ -546,6 +546,7 @@ output, already */ int stored_power = 0; /* power that matches the mantissa output earlier */ + int texpowers; for (;;) { /*{{{ copy to dest until % */ @@ -560,6 +561,12 @@ format += 2; continue; } + if (format[1] == '$') { + texpowers= 1; + ++format; + } + else + texpowers= 0; /*}}} */ /*{{{ copy format part to temp, excluding conversion character */ @@ -593,6 +600,37 @@ t[0] = *format; t[1] = 0; sprintf(dest, temp, x); + if ( texpowers ) { + char *scan, *exponent; + for( scan= dest; *scan; ++scan ) + if( *scan=='e' || *scan=='E' ) + if( scan==dest+1 && *dest=='1' ) { /* pure power for log scale */ + if( count-strlen(dest) < 3 ) { + fprintf (stderr,"%s:%d: Warning: too many digits for format\n",__FILE__,__LINE__); + break; + } + for( exponent= scan+1; *exponent=='+' || *exponent=='-' || *exponent=='0'; ++exponent ); + if( scan[1]=='-' ) + *--exponent= '-'; + memmove(scan+3, exponent, strlen(scan)); + strncpy(scan, "0^{", 3); + strcat(scan, "}"); + break; + } + else { + if( count-strlen(dest) < 9 ) { + fprintf (stderr,"%s:%d: Warning: too many digits for format\n",__FILE__,__LINE__); + break; + } + for( exponent= scan+1; *exponent=='+' || *exponent=='-' || *exponent=='0'; ++exponent ); + if( scan[1]=='-' ) + *--exponent= '-'; + memmove(scan+9, exponent, strlen(scan)); + strncpy(scan, "\\cdot10^{", 9); + strcat(scan, "}"); + break; + } + } break; /*}}} */ /*{{{ l --- mantissa to current log base */ @@ -761,6 +799,7 @@ } /* this was at the end of every single case, before: */ + count -= strlen(dest); dest += strlen(dest); ++format; } /* for ever */ --- gnuplot-4.2.rc2/src/term.c.orig 2006-12-21 13:05:06.455395464 +0100 +++ gnuplot-4.2.rc2/src/term.c 2006-12-21 13:31:16.141766864 +0100 @@ -2709,6 +2709,33 @@ FPRINTF((stderr,"Estimating length %d for enhanced text string \"%s\"\n",len,text)); } else #endif + if( !strcmp(term->name, "pstex") || !strcmp(term->name, "pslatex") || + !strcmp(term->name, "epslatex") ) { + char *scan; + for( scan= text, len= 0; *scan; ++scan ) { + if( *scan == '$' || *scan == '{' || *scan == '}' || *scan == '[' || + *scan == ']' || *scan == '^' || *scan == '_' || *scan == '&' ) + continue; + if( *scan == '\\' ) { + /* treat TeX control sequences as characters to allow things like \alpha */ + ++len; + ++scan; + if( isalpha(*scan) ) { + ++scan; + while( isalpha(*scan) ) + ++scan; + } + else + ++scan; + while( isspace(*scan) ) + ++scan; + --scan; + } + else + ++len; + } + } + else len = strlen(text); return len;