]> git.lyx.org Git - lyx.git/blobdiff - 3rdparty/dtl/dt2dv.c
inputenc only expects one option
[lyx.git] / 3rdparty / dtl / dt2dv.c
index 67d4a31aa55b10c2c35bb85ad003eada7b39fd99..1f5dbeb1ea76eedc36ca28fb743c4f53f6e0b9ce 100644 (file)
@@ -6,10 +6,14 @@
    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.3 - 2020
    - Geoffrey Tobin    G.Tobin@ee.latrobe.edu.au
    - fixes:  Michal Tomczak-Jaegermann    ntomczak@vm.ucs.ualberta.ca
              Nelson H. F. Beebe    beebe@math.utah.edu
+            Angus Leeming leeming@lyx.org: Enable dt2dv to handle .dvi files
+                 containing strings longer than 1024 chars.
+             Enrico Forestieri forenr@lyx.org: handle non-ASCII characters.
+             Juergen Spitzmueller spitz@lyx.org: fix compiler warnings
    - Reference:  "The DVI Driver Standard, Level 0",
                  by  The TUG DVI Driver Standards Committee.
                  Appendix A, "Device-Independent File Format".
@@ -38,7 +42,7 @@ typedef struct
 {
   COUNT num;    /* current line number */
   size_t max;   /* capacity of buf */
-  S4 wrote;     /* number of characters written into buf */
+  U4 wrote;     /* number of characters written into buf */
   size_t read;  /* position in buf of next character to read from buf */
   char * buf;   /* line buffer */
 } Line;
@@ -323,6 +327,7 @@ main
 #endif
 {
   Void (*handler) ARGS((int));  /* Previous signal handler */
+  (void)handler;// avoid compiler warning [-Wunused-but-set-variable]
   int i;
 
   progname = argv[0];  /* name of this program */
@@ -386,6 +391,7 @@ mem_viol
 #endif
 {
   Void (* handler) ARGS((int));
+  (void)handler;// avoid compiler warning [-Wunused-but-set-variable]
   handler = (Void (*) ARGS((int))) signal (SIGSEGV, mem_viol);
   if (sig != SIGSEGV)
   {
@@ -655,6 +661,7 @@ dt2dv
   int nprefixes = 0;  /* number of prefixes in cmd_prefixes[] list. */
   static Token dtl_cmd = "";  /* DTL command name */
   COUNT nread = 0;  /* number of bytes read by a function from dtl file. */
+  (void)nread;// avoid compiler warning [-Wunused-but-set-variable]
 
   nprefixes = sizeof (cmd_prefixes) / sizeof (CmdPrefix);
 
@@ -1095,7 +1102,7 @@ read_char
       dinfo();
       status = 0;
     }
-    else if ( ! isprint (c) && ! isspace (c))
+    else if ( ! isprint (c & 0x7f) && ! isspace (c))
     {
       PRINT_PROGNAME;
       fprintf (stderr,
@@ -1645,6 +1652,7 @@ xfer_hex
 {
   U4 unum = 0;  /* at most this space needed */
   COUNT nread = 0;  /* number of DTL bytes read by read_token */
+  (void)nread;// avoid compiler warning [-Wunused-but-set-variable]
   int nconv = 0;  /* number of arguments converted by sscanf */
   static Token token = "";  /* DTL token */
 
@@ -1691,6 +1699,7 @@ xfer_oct
 {
   U4 unum = 0;  /* at most this space needed */
   COUNT nread = 0;  /* number of DTL bytes read by read_token */
+  (void)nread;// avoid compiler warning [-Wunused-but-set-variable]
   int nconv = 0;  /* number of arguments converted by sscanf */
   static Token token = "";  /* DTL token */
 
@@ -1781,6 +1790,7 @@ get_unsigned
 {
   U4 unum = 0;  /* at most this space needed */
   COUNT nread = 0;  /* number of DTL bytes read by read_token */
+  (void)nread;// avoid compiler warning [-Wunused-but-set-variable]
   int nconv = 0;  /* number of arguments converted by sscanf */
   static Token token = "";  /* DTL token */
 
@@ -1814,6 +1824,7 @@ get_signed
 {
   S4 snum = 0;
   COUNT nread = 0;  /* number of DTL bytes read by read_token */
+  (void)nread;// avoid compiler warning [-Wunused-but-set-variable]
   int nconv = 0;  /* number of sscanf arguments converted and assigned */
   static Token token = "";
 
@@ -2203,7 +2214,7 @@ put_Lstring
 
   dvi_written += fwret;
 
-  if (fwret < lstr->l)
+  if ((long int) fwret < lstr->l)
   {
     PRINT_PROGNAME;
     fprintf (stderr,
@@ -2229,7 +2240,7 @@ xfer_len_string
 /* 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 +2249,13 @@ xfer_len_string
     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;
@@ -2573,7 +2585,7 @@ fontdef
 #ifdef HEX_CHECKSUM
   /* c[4] : (hexadecimal) checksum : I (gt) would prefer this */
   xfer_hex (4, dtl, dvi);
-#else /NOT HEX_CHECKSUM */
+#else /*NOT HEX_CHECKSUM */
   /* c[4] : checksum (octal, for comparison with tftopl's .pl file) */
   xfer_oct (4, dtl, dvi);
 #endif