On Mon, Jan 17, 2011 at 07:34:17PM +0100, [email protected] wrote:

> >  The point is that it currently does not work well. Loading
> >  examples/instant_preview.lyx I get:
> >  {{{
> >  Program "dt2dv" version 0.6.0 compiled in standard C.
> >  dt2dv (read_variety) : DTL variety sequences-6 is OK.
> >  dt2dv (ls_putb) : ERROR : No more room in Lstring.
> >  dt2dv (dinfo) : Current DTL input line 28 :
> >  "fstr{gsave pgfsoa .setopacityalpha stroke grestore}bind def}bind def
> >  /pgffoa 1 def /pgfsoa 1 def end '
> >  "
> >  Read 3321 DTL bytes (1042 in current command), wrote 2125 DVI bytes.
> >  Successfully interpreted 12 DVI commands.
> >  dt2dv (dexit) : exiting with status 1.
> 
> The problem is that TeX Live puts a special command in the DVI
> output longer than 1024, which is the maximum supported for each
> line by dt2dv (WTF?):

You are right. In the past, we had the dtl sources in our tree and
this problem had been already identified! Indeed, Angus patched
dt2dv.c just to solve this exact issue. I am attaching the diff
between the current dt2dv.c in CTAN and the patched one.
Most probably, for your tests you used the dt2dv program distributed
with the Windows installer (which uses the patched sources, me
thinks), such that you were not seeing the problem...

> What to do then?
> 1) Distribute a customized version of dv2dt which supports more than
> 1024 bytes per special (I don't think it's a good idea)
> 2) Do not call dt2dv and leave the non-working PostScript specials
> in the DVI file, which will slow down dvipng a little but won't make
> it fail; this means we just use dv2dt to understand which pages will
> have to go through the legacy method;
> 3) Write a custom DVI interpreter, not very complex but time-consuming;
> 4) Simply remove specials longer than 1024 bytes
> 5) Maybe special lines can be splitted over multiple lines, but I
> don't think so
> 
> I would go with 2).

Let's try it, then.

> Maybe we can launch the legacy method in
> parallel with dvipng to reduce the user's delay perception.

Hmm... Currently, the words parallel and thread bring me out in a
nettle-rash... :)

> >  Some more general remarks:
> >   * It solves the speed problem only if a small subset of 
> > snippets need the
> >  legacy method (however, this would be the case if one has dvipng
> >  installed)
> 
> Why? We make just two calls to LaTeX, the first for all the IPs and
> the second just for those needing the legacy method. Can't think a
> quicker way.

It's not the latex calls, it's the ghostscript calls that slow down
things.

> >   * It doesn't solve the general problem if XeTeX is used, as 
> > in that case
> >  a single big pdf file is handed to ghostscript, and thus a 
> > failing snippet
> >  still makes a global failure.
> 
> I've not yet investigated the XeTeX version of instant-preview, and
> how it works. I'll do it.

OK

> >   * The dtl file manipulation seems to be too simplistic and 
> > doesn't seem
> >  to lead to a valid dvi file in some cases (maybe also dependent on
> >  platform and software versions)
> 
> AFAIK was not my fault. However the 2) would solve the problem to the radix.

Yep, that's now clear.

-- 
Enrico
--- ctan/dt2dv.c	2008-11-14 16:55:54.000000000 +0100
+++ dtl_tools/dt2dv.c	2006-05-05 12:16:02.000000000 +0200
@@ -1,15 +1,11 @@
 /* dt2dv - convert human-readable "DTL" file to DVI format
          - this is intended to invert dv2dt version 0.6.0
-   
-   This file is public domain.
-   Originally written 1995, Geoffrey Tobin.
-   The author has expressed the hope that any modification will retain enough content to remain useful. He would also appreciate being acknowledged as the original author in the documentation.
-   This declaration added 2008/11/14 by Clea F. Rees with the permission of Geoffrey Tobin.
-
-   - version 0.6.1 - 14:38 GMT +11  Thu 9 March 1995
+   - version 0.6.2 - 27 July 2005
    - Geoffrey Tobin    [email protected]
    - fixes:  Michal Tomczak-Jaegermann    [email protected]
              Nelson H. F. Beebe    [email protected]
+	     Angus Leeming [email protected]: Enable dt2dv to handle
+	     .dvi files containing strings longer than 1024 chars.
    - Reference:  "The DVI Driver Standard, Level 0",
                  by  The TUG DVI Driver Standards Committee.
                  Appendix A, "Device-Independent File Format".
@@ -2229,7 +2225,7 @@
 /* transfer (length and) quoted string from dtl to dvi file, */
 /* return number of bytes written to dvi file. */
 {
-  U4 k, k2;
+  U4 k, k2, lstr_maxsize;
   Lstring lstr;
 
   if (debug)
@@ -2238,12 +2234,13 @@
     fprintf (stderr, "(xfer_len_string) : entering xfer_len_string.\n");
   }
 
-  init_Lstring (&lstr, LSIZE);
-
   /* k[n] : length of special string */
 
   k = get_unsigned (dtl);
 
+  lstr_maxsize = (k > LSIZE) ? k : LSIZE;
+  init_Lstring (&lstr, lstr_maxsize);
+
   if (debug)
   {
     PRINT_PROGNAME;

Reply via email to