summaryrefslogtreecommitdiff
path: root/gatchat
diff options
context:
space:
mode:
authorMartin Hundebøll <martin@geanix.com>2019-07-16 21:10:47 +0200
committerDenis Kenzior <denkenz@gmail.com>2019-07-17 10:25:12 -0500
commit8905150bda45226eab4ba052d6fb383312fb3501 (patch)
tree167c6e1c356ca8e5b438c7af29c8e91cfcfc5cab /gatchat
parentc56b66bf4b5d0ff87e60e0cdca305be8e1c0840e (diff)
downloadofono-8905150bda45226eab4ba052d6fb383312fb3501.tar.gz
gatresult: strip trailing spaces from unquoted strings
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.
Diffstat (limited to 'gatchat')
-rw-r--r--gatchat/gatresult.c8
1 files changed, 7 insertions, 1 deletions
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);