mirror of
https://github.com/fmang/opustags.git
synced 2024-11-10 07:27:22 +01:00
set-all: do not ignore the last unterminated line
This commit is contained in:
parent
6f6cf8024b
commit
f75e484ebb
@ -89,10 +89,9 @@ or \fB--set\fP, which, in that case, are equivalent.
|
||||
.B \-S, \-\-set-all
|
||||
Sets the tags from scratch. All the original tags are deleted and new ones are
|
||||
read from \fBstdin\fP. Each line must specify a \fIFIELD=VALUE\fP pair and be
|
||||
LF-terminated. If the last line isn’t terminated when the end of the stream is
|
||||
reached, it is ignored. Invalid lines are skipped and cause a warning to be
|
||||
issued. This could be useful for batch processing tags through an utility like
|
||||
\fBsed\fP.
|
||||
LF-terminated (except for the last line). Invalid lines are skipped and cause
|
||||
a warning to be issued. Blank lines are ignored. This mode could be useful for
|
||||
batch processing tags through an utility like \fBsed\fP.
|
||||
.SH SEE ALSO
|
||||
.BR vorbiscomment (1),
|
||||
.BR sed (1)
|
||||
|
11
opustags.c
11
opustags.c
@ -379,16 +379,19 @@ int main(int argc, char **argv){
|
||||
}
|
||||
else{
|
||||
char *raw_comment[256];
|
||||
size_t raw_len = fread(raw_tags, 1, 16384, stdin);
|
||||
if(raw_len == 16384)
|
||||
size_t raw_len = fread(raw_tags, 1, 16383, stdin);
|
||||
if(raw_len == 16383)
|
||||
fputs("warning: truncating comment to 16 KiB\n", stderr);
|
||||
raw_tags[raw_len] = '\0';
|
||||
uint32_t raw_count = 0;
|
||||
size_t field_len = 0;
|
||||
int caught_eq = 0;
|
||||
size_t i = 0;
|
||||
char *cursor = raw_tags;
|
||||
for(i=0; i<raw_len && raw_count < 256; i++){
|
||||
if(raw_tags[i] == '\n'){
|
||||
for(i=0; i <= raw_len && raw_count < 256; i++){
|
||||
if(raw_tags[i] == '\n' || raw_tags[i] == '\0'){
|
||||
if(field_len == 0)
|
||||
continue;
|
||||
if(caught_eq)
|
||||
raw_comment[raw_count++] = cursor;
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user