From ab81993da29009836f639ccf518dbd92d08364fb Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 2 Mar 2013 01:40:51 +0100 Subject: gsmd: Support Operator Names with parenthesis in their long/short name The previous parser caused parsing errors when recognizing parenthesis '()' inside a network operator name like "O2 (Germany) GmbH" We now keep track if we are inside a quote, and ignore parenthesis until the end of the quote mark. --- src/gsmd/usock.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gsmd/usock.c b/src/gsmd/usock.c index 5e5b5c3..13c3bb1 100644 --- a/src/gsmd/usock.c +++ b/src/gsmd/usock.c @@ -961,6 +961,7 @@ static int network_oper_n_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) static int network_opers_parse(const char *str, struct gsmd_msg_oper **out) { int len = 0; + int in_quote = 0; struct gsm_extrsp *er; char buf[64]; char *head, *tail, *ptr; @@ -995,9 +996,11 @@ static int network_opers_parse(const char *str, struct gsmd_msg_oper **out) str = ptr; while (*str) { - if ( *str == '(' ) + if (*str == '"') + in_quote = !in_quote; + if (!in_quote && *str == '(') head = (char *) str; - else if ( *str == ')' ) { + else if (!in_quote && *str == ')') { tail = (char *) str; memset(buf, '\0', sizeof(buf)); -- cgit v1.2.3