diff options
author | corvid <devnull@localhost> | 2014-09-24 23:11:07 +0000 |
---|---|---|
committer | corvid <devnull@localhost> | 2014-09-24 23:11:07 +0000 |
commit | 9d1e3d80543c90b52b39b2d98aa4accb5e4fbc83 (patch) | |
tree | 6990035fdd945533ef99930dbe258cc91222dc5c | |
parent | 8e186583e3994242d3c3a9ac107da5028e66f656 (diff) |
handle irix's version of vsnprintf()
thread: http://lists.dillo.org/pipermail/dillo-dev/2014-September/010230.html
-rw-r--r-- | dlib/dlib.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/dlib/dlib.c b/dlib/dlib.c index d60f1bc6..23534730 100644 --- a/dlib/dlib.c +++ b/dlib/dlib.c @@ -406,6 +406,17 @@ void dStr_vsprintfa (Dstr *ds, const char *format, va_list argp) va_copy(argp2, argp); n = vsnprintf(ds->str + ds->len, ds->sz - ds->len, format, argp2); va_end(argp2); +#if defined(__sgi) + /* IRIX does not conform to C99; if the entire argument did not fit + * into the buffer, n = buffer space used (minus 1 for terminator) + */ + if (n > -1 && n + 1 < ds->sz - ds->len) { + ds->len += n; /* Success! */ + break; + } else { + n_sz = ds->sz * 2; + } +#else if (n > -1 && n < ds->sz - ds->len) { ds->len += n; /* Success! */ break; @@ -414,6 +425,7 @@ void dStr_vsprintfa (Dstr *ds, const char *format, va_list argp) } else { /* old glibc */ n_sz = ds->sz * 2; } +#endif dStr_resize(ds, n_sz, (ds->len > 0) ? 1 : 0); } } |