Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH 1/7] gatresult: strip trailing spaces from unquoted strings
@ 2019-07-16 19:10 Martin =?unknown-8bit?q?Hundeb=C3=B8ll?=
  2019-07-16 19:10 ` [PATCH 2/7] atmodem: rename OFONO_VENDOR_QUECTEL_M95 to OFONO_VENDOR_QUECTEL_SERIAL Martin =?unknown-8bit?q?Hundeb=C3=B8ll?=
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Martin =?unknown-8bit?q?Hundeb=C3=B8ll?= @ 2019-07-16 19:10 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1058 bytes --]

Some vendors might print trailing spaces after unsolicited result codes.
Avoid duplicating and stripping the string after calling
g_at_result_iter_next_unquoted_string() by stripping the spaces in
gatresult instead.
---
 gatchat/gatresult.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gatchat/gatresult.c b/gatchat/gatresult.c
index 2659db28..883b4105 100644
--- a/gatchat/gatresult.c
+++ b/gatchat/gatresult.c
@@ -111,6 +111,7 @@ gboolean g_at_result_iter_next_unquoted_string(GAtResultIter *iter,
 	unsigned int pos;
 	unsigned int end;
 	unsigned int len;
+	unsigned int stripped;
 	char *line;
 
 	if (iter == NULL)
@@ -139,7 +140,12 @@ gboolean g_at_result_iter_next_unquoted_string(GAtResultIter *iter,
 	while (end < len && line[end] != ',' && line[end] != ')')
 		end += 1;
 
-	iter->buf[end] = '\0';
+	stripped = end;
+
+	while (line[stripped - 1] == ' ')
+		stripped -= 1;
+
+	iter->buf[stripped] = '\0';
 
 out:
 	iter->line_pos = skip_to_next_field(line, end, len);
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-07-19  6:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-16 19:10 [PATCH 1/7] gatresult: strip trailing spaces from unquoted strings Martin =?unknown-8bit?q?Hundeb=C3=B8ll?=
2019-07-16 19:10 ` [PATCH 2/7] atmodem: rename OFONO_VENDOR_QUECTEL_M95 to OFONO_VENDOR_QUECTEL_SERIAL Martin =?unknown-8bit?q?Hundeb=C3=B8ll?=
2019-07-16 19:10 ` [PATCH 3/7] quectel: enable call volume settings Martin =?unknown-8bit?q?Hundeb=C3=B8ll?=
2019-07-16 19:10 ` [PATCH 4/7] quectel: store model id in private data Martin =?unknown-8bit?q?Hundeb=C3=B8ll?=
2019-07-16 19:10 ` [PATCH 5/7] quectel: add support for the Quectel MC60 modem Martin =?unknown-8bit?q?Hundeb=C3=B8ll?=
2019-07-16 19:10 ` [PATCH 6/7] quectel: add dbus hardware interface Martin =?unknown-8bit?q?Hundeb=C3=B8ll?=
2019-07-19  6:11   ` Denis Kenzior
2019-07-16 19:10 ` [PATCH 7/7] quectel: implement dbus signals for modem power notifications Martin =?unknown-8bit?q?Hundeb=C3=B8ll?=
2019-07-19  6:14   ` Denis Kenzior
2019-07-19  4:45 ` [PATCH 1/7] gatresult: strip trailing spaces from unquoted strings Denis Kenzior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox