From: Martin Ling Date: Fri, 17 Jan 2014 13:43:34 +0000 (+0000) Subject: scpi: Strip trailing newlines in sr_scpi_get_string(). X-Git-Tag: libsigrok-0.3.0~237 X-Git-Url: http://sigrok.org/gitweb/?a=commitdiff_plain;h=d03dfac6b9c07812c0b7b21858b247088d5605aa;p=libsigrok.git scpi: Strip trailing newlines in sr_scpi_get_string(). --- diff --git a/hardware/common/scpi.c b/hardware/common/scpi.c index 591b9770..0a1e52e9 100644 --- a/hardware/common/scpi.c +++ b/hardware/common/scpi.c @@ -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);