strtok doesn't parse correctly following message:

  $GPGSA,A,1,,,,,,,,,,,,,,,*1E

Resulting in "datagram has wrong parameter count".

Signed-off-by: Petr Štetiar <yn...@true.cz>
---
 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;
-- 
1.9.1


_______________________________________________
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev

Reply via email to