Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
69ae879c
Commit
69ae879c
authored
Aug 07, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input/TextInputStream: return char*
Revert to the old API before commit
e9e55b08
, removing unnecessary bloat.
parent
08fee9a2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
34 deletions
+27
-34
TextInputStream.cxx
src/input/TextInputStream.cxx
+13
-12
TextInputStream.hxx
src/input/TextInputStream.hxx
+2
-6
CuePlaylistPlugin.cxx
src/playlist/plugins/CuePlaylistPlugin.cxx
+3
-3
ExtM3uPlaylistPlugin.cxx
src/playlist/plugins/ExtM3uPlaylistPlugin.cxx
+4
-7
M3uPlaylistPlugin.cxx
src/playlist/plugins/M3uPlaylistPlugin.cxx
+2
-3
dump_text_file.cxx
test/dump_text_file.cxx
+3
-3
No files found.
src/input/TextInputStream.cxx
View file @
69ae879c
...
...
@@ -27,9 +27,10 @@
#include <assert.h>
#include <string.h>
bool
TextInputStream
::
ReadLine
(
std
::
string
&
line
)
char
*
TextInputStream
::
ReadLine
()
{
c
onst
c
har
*
src
,
*
p
;
char
*
src
,
*
p
;
do
{
size_t
nbytes
;
...
...
@@ -46,33 +47,33 @@ bool TextInputStream::ReadLine(std::string &line)
buffer
.
Append
(
nbytes
);
else
if
(
error
.
IsDefined
())
{
LogError
(
error
);
return
false
;
return
nullptr
;
}
}
else
nbytes
=
0
;
auto
src_p
=
buffer
.
Read
();
if
(
src_p
.
IsEmpty
())
return
false
;
return
nullptr
;
src
=
src_p
.
data
;
p
=
reinterpret_cast
<
c
onst
c
har
*>
(
memchr
(
src
,
'\n'
,
src_p
.
size
));
p
=
reinterpret_cast
<
char
*>
(
memchr
(
src
,
'\n'
,
src_p
.
size
));
if
(
p
==
nullptr
&&
nbytes
==
0
)
{
/* end of file (or line too long): terminate
the current line */
dest
=
buffer
.
Write
();
assert
(
!
dest
.
IsEmpty
());
dest
[
0
]
=
'\n'
;
buffer
.
Append
(
1
);
dest
[
0
]
=
0
;
buffer
.
Clear
();
return
src
;
}
}
while
(
p
==
nullptr
);
size_t
length
=
p
-
src
+
1
;
buffer
.
Consume
(
p
-
src
+
1
);
while
(
p
>
src
&&
IsWhitespaceOrNull
(
p
[
-
1
]))
--
p
;
line
=
std
::
string
(
src
,
p
-
src
);
buffer
.
Consume
(
length
);
return
true
;
*
p
=
0
;
return
src
;
}
src/input/TextInputStream.hxx
View file @
69ae879c
...
...
@@ -22,8 +22,6 @@
#include "util/StaticFifoBuffer.hxx"
#include <string>
class
InputStream
;
class
TextInputStream
{
...
...
@@ -46,11 +44,9 @@ public:
/**
* Reads the next line from the stream with newline character stripped.
*
* @param line a string to put result to
* @return true if line is read successfully, false on end of file
* or error
* @return a pointer to the line, or nullptr on end-of-file or error
*/
bool
ReadLine
(
std
::
string
&
line
);
char
*
ReadLine
(
);
};
#endif
src/playlist/plugins/CuePlaylistPlugin.cxx
View file @
69ae879c
...
...
@@ -52,9 +52,9 @@ CuePlaylist::NextSong()
if
(
song
!=
nullptr
)
return
song
;
std
::
string
line
;
while
(
tis
.
ReadLine
(
line
)
)
{
parser
.
Feed
(
line
.
c_str
()
);
const
char
*
line
;
while
(
(
line
=
tis
.
ReadLine
())
!=
nullptr
)
{
parser
.
Feed
(
line
);
song
=
parser
.
Get
();
if
(
song
!=
nullptr
)
return
song
;
...
...
src/playlist/plugins/ExtM3uPlaylistPlugin.cxx
View file @
69ae879c
...
...
@@ -39,9 +39,8 @@ public:
}
bool
CheckFirstLine
()
{
std
::
string
line
;
return
tis
.
ReadLine
(
line
)
&&
strcmp
(
line
.
c_str
(),
"#EXTM3U"
)
==
0
;
const
char
*
line
=
tis
.
ReadLine
();
return
line
!=
nullptr
&&
strcmp
(
line
,
"#EXTM3U"
)
==
0
;
}
virtual
DetachedSong
*
NextSong
()
override
;
...
...
@@ -105,15 +104,13 @@ DetachedSong *
ExtM3uPlaylist
::
NextSong
()
{
Tag
tag
;
std
::
string
line
;
const
char
*
line_s
;
do
{
if
(
!
tis
.
ReadLine
(
line
))
line_s
=
tis
.
ReadLine
();
if
(
line_s
==
nullptr
)
return
nullptr
;
line_s
=
line
.
c_str
();
if
(
StringStartsWith
(
line_s
,
"#EXTINF:"
))
{
tag
=
extm3u_parse_tag
(
line_s
+
8
);
continue
;
...
...
src/playlist/plugins/M3uPlaylistPlugin.cxx
View file @
69ae879c
...
...
@@ -45,14 +45,13 @@ m3u_open_stream(InputStream &is)
DetachedSong
*
M3uPlaylist
::
NextSong
()
{
std
::
string
line
;
const
char
*
line_s
;
do
{
if
(
!
tis
.
ReadLine
(
line
))
line_s
=
tis
.
ReadLine
();
if
(
line_s
==
nullptr
)
return
nullptr
;
line_s
=
line
.
c_str
();
line_s
=
strchug_fast
(
line_s
);
}
while
(
line_s
[
0
]
==
'#'
||
*
line_s
==
0
);
...
...
test/dump_text_file.cxx
View file @
69ae879c
...
...
@@ -43,9 +43,9 @@
static
void
dump_text_file
(
TextInputStream
&
is
)
{
std
::
string
line
;
while
(
is
.
ReadLine
(
line
)
)
printf
(
"'%s'
\n
"
,
line
.
c_str
()
);
const
char
*
line
;
while
(
(
line
=
is
.
ReadLine
())
!=
nullptr
)
printf
(
"'%s'
\n
"
,
line
);
}
static
int
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment