]> sigrok.org Git - libsigrok.git/commitdiff
scpi: Strip trailing newlines in sr_scpi_get_string().
authorMartin Ling <redacted>
Fri, 17 Jan 2014 13:43:34 +0000 (13:43 +0000)
committerMartin Ling <redacted>
Mon, 20 Jan 2014 00:24:57 +0000 (00:24 +0000)
hardware/common/scpi.c

index 591b9770f8b1a0a40326209e2dcd51380f8ab2e4..0a1e52e97ad01fcfc67fe2cbb9f8599b4feac134 100644 (file)
@@ -312,6 +312,10 @@ SR_PRIV int sr_scpi_get_string(struct sr_scpi_dev_inst *scpi,
                g_string_append_len(response, buf, len);
        }
 
+       /* Get rid of trailing linefeed if present */
+       if (response->len >= 1 && response->str[response->len - 1] == '\n')
+               g_string_truncate(response, response->len - 1);
+
        *scpi_response = response->str;
        g_string_free(response, FALSE);