Skip to content

Commit

Permalink
handle irix's version of vsnprintf()
Browse files Browse the repository at this point in the history
  • Loading branch information
corvid committed Sep 24, 2014
1 parent 8e18658 commit 9d1e3d8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions dlib/dlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
Expand Down

0 comments on commit 9d1e3d8

Please sign in to comment.