Re: Dillo and Irix

eocene <[email protected]>
Newsgroups gmane.comp.web.dillo.devel
Message-ID <[email protected]>
In the typical vsnprintf() (i.e., following the c99 standard), if you
have space for 10 bytes and you want to write 20 bytes (including '\0'),
you return 19, whereas irix returns 9.

Some options:

1. It's possible to make irix and the standard run with a change like

diff -r 5f63e28334b2 dlib/dlib.c
--- a/dlib/dlib.c       Tue Sep 16 00:21:49 2014 +0000
+++ b/dlib/dlib.c       Tue Sep 16 04:59:20 2014 +0000
@@ -406,11 +406,11 @@
          va_copy(argp2, argp);
          n = vsnprintf(ds->str + ds->len, ds->sz - ds->len, format, argp2);
          va_end(argp2);
-         if (n > -1 && n < ds->sz - ds->len) {
+         if (n > -1 && n+1 < ds->sz - ds->len) {
             ds->len += n;      /* Success! */
             break;
          } else if (n > -1) {  /* glibc >= 2.1 */
-            n_sz = ds->len + n + 1;
+            n_sz = ds->len + n + 2;
          } else {              /* old glibc */
             n_sz = ds->sz * 2;
          }

...although it would need tweaking to waste less running time.

But of course even if dillo is partly about retrocomputing, it'll be
99% linux+bsd retrocomputing and 1% other-stuff retrocomputing, so...

2. Throw an ifdef at it. Dillo has never had many ifdefs, and I'd thought
they were discouraged, but maybe the changes needed for all of that stuff
at the bottom of Compatibility.html like

SGI O2 running IRIX
Tru64 (OSF1) 4.0 on Alpha 
QNX RTP 6.1/x86 (with occasional memory faults out of GTK+) 
AIX 4.3 (with some tweaks) 
Atari-based 68k-systems running MiNT 
Microsoft Windows using Cygwin 
RISC OS

...just didn't make it back into mainline dillo1?

3. We could always borrow fltk's vsnprintf(), which is about 250 lines.


I lean toward giving it an ifdef.


--------------

Extra verbiage:

Autoconf's manual says:
The C99 standard says that if the output array isn't big enough and if no other errors occur, snprintf and vsnprintf truncate the output and return the number of bytes that ought to have been produced. Some older systems return the truncated length (e.g., GNU C Library 2.0.x or IRIX 6.5), some a negative value (e.g., earlier GNU C Library versions), and some the buffer length without truncation (e.g., 32-bit Solaris 7). Also, some buggy older systems ignore the length and overrun the buffer (e.g., 64-bit Solaris 7). 

glibc-2.1: 1999
solaris 7: 1998
irix 6.5: major release 1998
          regular minor releases until 2005
          "The last version of IRIX was 6.5.30, released in August 2006."
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.