playlist/cue/parser: pass StringView to Feed()
This commit is contained in:
parent
34bb53a29f
commit
e0c75da266
|
@ -21,6 +21,7 @@
|
||||||
#include "tag/ParseName.hxx"
|
#include "tag/ParseName.hxx"
|
||||||
#include "util/Alloc.hxx"
|
#include "util/Alloc.hxx"
|
||||||
#include "util/StringStrip.hxx"
|
#include "util/StringStrip.hxx"
|
||||||
|
#include "util/StringView.hxx"
|
||||||
#include "util/CharUtil.hxx"
|
#include "util/CharUtil.hxx"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
@ -271,12 +272,11 @@ CueParser::Feed2(char *p) noexcept
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CueParser::Feed(const char *line) noexcept
|
CueParser::Feed(StringView line) noexcept
|
||||||
{
|
{
|
||||||
assert(!end);
|
assert(!end);
|
||||||
assert(line != nullptr);
|
|
||||||
|
|
||||||
char *allocated = xstrdup(line);
|
char *allocated = xstrndup(line.data, line.size);
|
||||||
Feed2(allocated);
|
Feed2(allocated);
|
||||||
free(allocated);
|
free(allocated);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
struct StringView;
|
||||||
|
|
||||||
class CueParser {
|
class CueParser {
|
||||||
enum {
|
enum {
|
||||||
/**
|
/**
|
||||||
|
@ -104,7 +106,7 @@ public:
|
||||||
* Feed a text line from the CUE file into the parser. Call
|
* Feed a text line from the CUE file into the parser. Call
|
||||||
* Get() after this to see if a song has been finished.
|
* Get() after this to see if a song has been finished.
|
||||||
*/
|
*/
|
||||||
void Feed(const char *line) noexcept;
|
void Feed(StringView line) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tell the parser that the end of the file has been reached. Call
|
* Tell the parser that the end of the file has been reached. Call
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "../SongEnumerator.hxx"
|
#include "../SongEnumerator.hxx"
|
||||||
#include "../cue/CueParser.hxx"
|
#include "../cue/CueParser.hxx"
|
||||||
#include "input/TextInputStream.hxx"
|
#include "input/TextInputStream.hxx"
|
||||||
|
#include "util/StringView.hxx"
|
||||||
|
|
||||||
class CuePlaylist final : public SongEnumerator {
|
class CuePlaylist final : public SongEnumerator {
|
||||||
TextInputStream tis;
|
TextInputStream tis;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#include "playlist/cue/CueParser.hxx"
|
#include "playlist/cue/CueParser.hxx"
|
||||||
#include "util/IterableSplitString.hxx"
|
#include "util/IterableSplitString.hxx"
|
||||||
|
#include "util/StringView.hxx"
|
||||||
#include <string>
|
|
||||||
#include <string_view>
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
|
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
|
||||||
|
@ -15,7 +13,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||||
const std::string_view src{(const char *)data, size};
|
const std::string_view src{(const char *)data, size};
|
||||||
|
|
||||||
for (const auto line : IterableSplitString(src, '\n')) {
|
for (const auto line : IterableSplitString(src, '\n')) {
|
||||||
parser.Feed(std::string(line).c_str());
|
parser.Feed(line);
|
||||||
parser.Get();
|
parser.Get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue