Skip to content

Commit

Permalink
Merge pull request uzbl#244 from mathstuf/fix-scrollbar
Browse files Browse the repository at this point in the history
comm: fix appending doubles to events
  • Loading branch information
mathstuf committed Apr 5, 2016
2 parents fcbe5b7 + e48b55a commit af1b49b
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,22 @@

#include <string.h>

/* =========================== PUBLIC API =========================== */

static GString *
append_escaped (GString *dest, const gchar *src);

/* =========================== PUBLIC API =========================== */

void
uzbl_comm_string_append_double (GString *buf, double val)
{
gsize pos = buf->len;

/* Make sure the formatted double fits in the buffer. */
if (buf->allocated_len - pos < G_ASCII_DTOSTR_BUF_SIZE) {
g_string_set_size (buf, pos + G_ASCII_DTOSTR_BUF_SIZE);
}
gchar double_buf[G_ASCII_DTOSTR_BUF_SIZE];

/* Format in C locale. */
char *tmp = g_ascii_formatd (
buf->str + pos,
buf->allocated_len - pos,
g_ascii_formatd (
double_buf,
sizeof (double_buf),
"%.2g", val);
buf->len += pos + strlen (tmp);
g_string_append (buf, double_buf);
}

GString *
Expand Down

0 comments on commit af1b49b

Please sign in to comment.