From 69ec986af735961aee47229db35a86d150f17ff2 Mon Sep 17 00:00:00 2001 From: Vladimir Petrigo Date: Fri, 21 Dec 2018 11:37:59 +0300 Subject: [PATCH 1/3] minmea: Allow lines with only CR ending --- minmea.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minmea.c b/minmea.c index 32f7881..e0e0939 100644 --- a/minmea.c +++ b/minmea.c @@ -79,7 +79,7 @@ bool minmea_check(const char *sentence, bool strict) } // The only stuff allowed at this point is a newline. - if (*sentence && strcmp(sentence, "\n") && strcmp(sentence, "\r\n")) + if (*sentence && strcmp(sentence, "\n") != 0 && strcmp(sentence, "\r") != 0 && strcmp(sentence, "\r\n") != 0) return false; return true; From f75678a4268f52873d7b1e62c26e9a284e078444 Mon Sep 17 00:00:00 2001 From: Vladimir Petrigo Date: Sun, 22 May 2022 16:01:09 +0300 Subject: [PATCH 2/3] Fix PR comments Update CR and LF symbols skipping at the end of the line --- minmea.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/minmea.c b/minmea.c index e0e0939..1328f48 100644 --- a/minmea.c +++ b/minmea.c @@ -79,8 +79,13 @@ bool minmea_check(const char *sentence, bool strict) } // The only stuff allowed at this point is a newline. - if (*sentence && strcmp(sentence, "\n") != 0 && strcmp(sentence, "\r") != 0 && strcmp(sentence, "\r\n") != 0) + while (*sentence == '\r' || *sentence == '\n') { + sentence++; + } + + if (*sentence) { return false; + } return true; } From 908846d4f67bb86e514b2a5e2d6d4f58ec1a71f1 Mon Sep 17 00:00:00 2001 From: Kosma Moczek Date: Fri, 3 Jun 2022 00:44:58 +0200 Subject: [PATCH 3/3] add tests for newline handling --- tests.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests.c b/tests.c index c2ae730..388df29 100644 --- a/tests.c +++ b/tests.c @@ -18,6 +18,11 @@ static const char *valid_sentences_nochecksum[] = { "$GPTXT,xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + "$GPTXT,hello\n", + "$GPTXT,hello\r", + "$GPTXT,hello\r\n", + "$GPTXT,hello\r\n\r\n", + "$GPTXT,hello\n\r\r\n", NULL, }; @@ -55,6 +60,9 @@ static const char *invalid_sentences[] = { "gps: $GPGLL,,,,,,V,N", "$GPXTE,A,A,0.67,L,N*6e", "$GPXTE,A,A,0.67,L,N*6g", + "$GPTXT,hello\n ", + "$GPTXT,hello\r*24", + "$GPTXT,hello\r\n$", NULL, };