From: Wolfram Sang Date: Sun, 10 Apr 2016 19:02:52 +0000 (+0200) Subject: input: vcd: skip BOM at beginning of file X-Git-Tag: libsigrok-0.5.0~523 X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=1f706c21a2977c768692f72d09b35633628d2b0d input: vcd: skip BOM at beginning of file According to the infos I have, VCD files should be plain ASCII, but we got report of a version adding a UTF8 BOM at the beginning of the file, so we need to skip it. This fixes bug #755. Signed-off-by: Wolfram Sang --- diff --git a/src/input/vcd.c b/src/input/vcd.c index 66f126b4..b25c7381 100644 --- a/src/input/vcd.c +++ b/src/input/vcd.c @@ -105,6 +105,10 @@ static gboolean parse_section(GString *buf, gchar **name, gchar **contents) status = FALSE; pos = 0; + /* Skip UTF8 BOM */ + if (buf->len >= 3 && !strncmp(buf->str, "\xef\xbb\xbf", 3)) + pos = 3; + /* Skip any initial white-space. */ while (pos < buf->len && g_ascii_isspace(buf->str[pos])) pos++;