From a49912c863a9402685a25c17fc86191b666203a6 Mon Sep 17 00:00:00 2001 From: markwkidd Date: Wed, 7 Dec 2016 15:35:49 -0500 Subject: [PATCH 1/7] accept playlists with Unix and Windows style line endings --- playlist.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/playlist.c b/playlist.c index 530296a7da..84631fd290 100644 --- a/playlist.c +++ b/playlist.c @@ -463,9 +463,13 @@ static bool playlist_read_file( if (!filestream_gets(file, buf[i], sizeof(buf[i]))) goto end; - last = strrchr(buf[i], '\n'); - if (last) + /* Read playlist entry regardless + * of Windows or Unix line endings + */ + if(last = strrchr(buf[i], '\r')) *last = '\0'; + else if(last = strrchr(buf[i], '\n')) + *last = '\0'; } entry = &playlist->entries[playlist->size]; From f710129f32862b1129b8cff2c452bc7f068bd4b3 Mon Sep 17 00:00:00 2001 From: markwkidd Date: Wed, 7 Dec 2016 15:51:09 -0500 Subject: [PATCH 2/7] cleaner to use strpbrk --- playlist.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/playlist.c b/playlist.c index 84631fd290..d1548df98d 100644 --- a/playlist.c +++ b/playlist.c @@ -466,10 +466,8 @@ static bool playlist_read_file( /* Read playlist entry regardless * of Windows or Unix line endings */ - if(last = strrchr(buf[i], '\r')) + if((last = strpbrk(buf[i], "\n\r"))) *last = '\0'; - else if(last = strrchr(buf[i], '\n')) - *last = '\0'; } entry = &playlist->entries[playlist->size]; From 72d31c6fbe6ead6b3e63b892d67331967ad0ed6b Mon Sep 17 00:00:00 2001 From: markwkidd Date: Wed, 7 Dec 2016 15:52:14 -0500 Subject: [PATCH 3/7] Update playlist.c --- playlist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/playlist.c b/playlist.c index d1548df98d..0de4958c7c 100644 --- a/playlist.c +++ b/playlist.c @@ -463,8 +463,8 @@ static bool playlist_read_file( if (!filestream_gets(file, buf[i], sizeof(buf[i]))) goto end; - /* Read playlist entry regardless - * of Windows or Unix line endings + /* Read playlist entry and terminate string with NULL + * regardless of Windows or Unix line endings */ if((last = strpbrk(buf[i], "\n\r"))) *last = '\0'; From e65b4d8c1c4581d7f4a38ed92dcfd508cd46128f Mon Sep 17 00:00:00 2001 From: markwkidd Date: Wed, 7 Dec 2016 16:07:45 -0500 Subject: [PATCH 4/7] Update playlist.c --- playlist.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/playlist.c b/playlist.c index 0de4958c7c..43a33078e9 100644 --- a/playlist.c +++ b/playlist.c @@ -465,9 +465,12 @@ static bool playlist_read_file( /* Read playlist entry and terminate string with NULL * regardless of Windows or Unix line endings - */ - if((last = strpbrk(buf[i], "\n\r"))) - *last = '\0'; + */ + if(last = strrchr(buf[i], '\r')) + *last = '\0'; + *last = '\0'; + else if(last = strrchr(buf[i], '\n')) + *last = '\0'; } entry = &playlist->entries[playlist->size]; From edf58d9e2987d1a3b2c31aa1ce0378eaa805cced Mon Sep 17 00:00:00 2001 From: markwkidd Date: Wed, 7 Dec 2016 16:08:09 -0500 Subject: [PATCH 5/7] Update playlist.c --- playlist.c | 1 - 1 file changed, 1 deletion(-) diff --git a/playlist.c b/playlist.c index 43a33078e9..c777fe11a4 100644 --- a/playlist.c +++ b/playlist.c @@ -468,7 +468,6 @@ static bool playlist_read_file( */ if(last = strrchr(buf[i], '\r')) *last = '\0'; - *last = '\0'; else if(last = strrchr(buf[i], '\n')) *last = '\0'; } From c6bc316e0471fec837109df9ef4c4e80c49ce9ba Mon Sep 17 00:00:00 2001 From: markwkidd Date: Sat, 10 Dec 2016 11:03:28 -0500 Subject: [PATCH 6/7] Update playlist.c --- playlist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/playlist.c b/playlist.c index c777fe11a4..42ee42f064 100644 --- a/playlist.c +++ b/playlist.c @@ -466,9 +466,9 @@ static bool playlist_read_file( /* Read playlist entry and terminate string with NULL * regardless of Windows or Unix line endings */ - if(last = strrchr(buf[i], '\r')) + if((last = strrchr(buf[i], '\r'))) *last = '\0'; - else if(last = strrchr(buf[i], '\n')) + else if((last = strrchr(buf[i], '\n'))) *last = '\0'; } From 35437057b982b5f9fffa905416616fce3a087420 Mon Sep 17 00:00:00 2001 From: markwkidd Date: Wed, 14 Dec 2016 15:32:47 -0500 Subject: [PATCH 7/7] correct comment for accuracy --- playlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playlist.c b/playlist.c index 42ee42f064..d0eb129a0d 100644 --- a/playlist.c +++ b/playlist.c @@ -463,7 +463,7 @@ static bool playlist_read_file( if (!filestream_gets(file, buf[i], sizeof(buf[i]))) goto end; - /* Read playlist entry and terminate string with NULL + /* Read playlist entry and terminate string with NUL character * regardless of Windows or Unix line endings */ if((last = strrchr(buf[i], '\r')))