Kaydet (Commit) a81f75b2 authored tarafından Colomban Wendling's avatar Colomban Wendling

Import upstream MIO changes not to require a C99 compiler


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5583 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst a1cbd0f6
2011-03-07 Colomban Wendling <colomban(at)geany(dot)org>
* tagmanager/mio/mio-memory.c:
Import upstream MIO changes not to require a C99 compiler.
2011-03-06 Colomban Wendling <colomban(at)geany(dot)org> 2011-03-06 Colomban Wendling <colomban(at)geany(dot)org>
* src/symbols.c: * src/symbols.c:
......
...@@ -247,28 +247,26 @@ mem_vprintf (MIO *mio, ...@@ -247,28 +247,26 @@ mem_vprintf (MIO *mio,
va_list ap) va_list ap)
{ {
gint rv = -1; gint rv = -1;
gint n; gsize n;
gchar tmp;
gsize old_pos; gsize old_pos;
gsize old_size; gsize old_size;
va_list ap_copy; va_list ap_copy;
old_pos = mio->impl.mem.pos; old_pos = mio->impl.mem.pos;
old_size = mio->impl.mem.size; old_size = mio->impl.mem.size;
va_copy (ap_copy, ap); G_VA_COPY (ap_copy, ap);
/* compute the size we will need into the buffer */ /* compute the size we will need into the buffer */
n = vsnprintf (&tmp, 1, format, ap_copy); n = g_printf_string_upper_bound (format, ap_copy);
va_end (ap_copy); va_end (ap_copy);
if (n >= 0 && mem_try_ensure_space (mio, ((guint)n) + 1)) { if (mem_try_ensure_space (mio, n)) {
guchar c; guchar c;
/* backup character at n+1 that will be overwritten by a \0 ... */ /* backup character at n+1 that will be overwritten by a \0 ... */
c = mio->impl.mem.buf[mio->impl.mem.pos + (guint)n]; c = mio->impl.mem.buf[mio->impl.mem.pos + (n - 1)];
rv = vsnprintf ((gchar *)&mio->impl.mem.buf[mio->impl.mem.pos], rv = vsprintf ((gchar *)&mio->impl.mem.buf[mio->impl.mem.pos], format, ap);
(guint)n + 1, format, ap);
/* ...and restore it */ /* ...and restore it */
mio->impl.mem.buf[mio->impl.mem.pos + (guint)n] = c; mio->impl.mem.buf[mio->impl.mem.pos + (n - 1)] = c;
if (G_LIKELY (rv >= 0 && rv == n)) { if (G_LIKELY (rv >= 0 && (gsize)rv == (n - 1))) {
/* re-compute the actual size since we might have allocated one byte /* re-compute the actual size since we might have allocated one byte
* more than needed */ * more than needed */
mio->impl.mem.size = MAX (old_size, old_pos + (guint)rv); mio->impl.mem.size = MAX (old_size, old_pos + (guint)rv);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment