From 882b239a2768e70143ace43205ead6cb56388042 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20=C5=A0tetiar?= Date: Wed, 27 Jul 2016 14:45:51 +0200 Subject: [PATCH] Use strsep for NMEA message tokenization MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit strtok doesn't parse correctly following message: $GPGSA,A,1,,,,,,,,,,,,,,,*1E Resulting in "datagram has wrong parameter count". Signed-off-by: Petr Å tetiar --- nmea.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nmea.c b/nmea.c index 05c904d..3646a36 100644 --- a/nmea.c +++ b/nmea.c @@ -221,13 +221,13 @@ static int nmea_tokenize(char *msg) { int cnt = 0; - char *tok = strtok(msg, ","); + char *tok = strsep(&msg, ","); while (tok && cnt < MAX_NMEA_PARAM) { nmea_params[cnt].str = tok; nmea_params[cnt].num = atoi(tok); cnt++; - tok = strtok(NULL, ","); + tok = strsep(&msg, ","); } return cnt; -- 2.11.0