On Tue, Sep 16, 2014 at 06:29:27AM +0000, eocene wrote:
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.
Me too, it clearly is an IRIX issue and the #ifdef would make it cristal clear (compared to a soln. using fltk's vsnprintf() for instance). +1 -- Cheers Jorge.-