Skip to content

Commit

Permalink
-e を使用しタグレコードが4096バイトを超える時にそれ以降が反映されないバグを修正
Browse files Browse the repository at this point in the history
あとコード整理とか。FLAC対応をやめたので入力時のMBPを特別扱いする必要がなくなったのでそこらへんの削除。

そしてパッチバージョン上げ
  • Loading branch information
hcmiya committed Mar 18, 2019
1 parent a023c43 commit 89a4bea
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 87 deletions.
1 change: 0 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ int main(int argc, char **argv) {
fileerror(O.in);
}

uint8_t *fbp;
ogg_sync_state oy;
ogg_sync_init(&oy);

Expand Down
92 changes: 13 additions & 79 deletions src/parse-tags.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ static void err_bin(void) {
static void err_esc(void) {
tagerror(catgets(catd, 5, 5, "invalid escape sequence"));
}
static void err_utf8(void) {
tagerror(catgets(catd, 5, 6, "invalid UTF-8 sequence"));
}
static void err_noterm(void) {
mainerror(err_main_no_term);
}
Expand Down Expand Up @@ -121,16 +118,14 @@ static void finalize_record(void) {
first_call = true;
}

static size_t wsplen, fieldlen;
static size_t wsplen;
static bool on_field, keep_blank;
static uint8_t field_pending[22];
static bool test_blank(uint8_t *line, size_t n, bool lf) {
if (first_call) {
// = で始まってたらすぐエラー(575)
if (*line == 0x3d) err_nosep();
if (*line == 0x3d) err_empty();
first_call = false;
on_field = true;
fieldlen = 0;
keep_blank = true;
wsplen = 0;
recordlen = 0;
Expand Down Expand Up @@ -172,19 +167,14 @@ static bool test_blank(uint8_t *line, size_t n, bool lf) {
if (editlen > TAG_LENGTH_LIMIT__OUTPUT) {
exceed_output_limit();
}
fieldlen = recordlen = wsplen;
if (wsplen <= 22) {
memset(field_pending, 0x20, wsplen);
}
else {
// 空白と見做していた分を書き込み
uint8_t buf[STACK_BUF_LEN];
memset(buf, 0x20, STACK_BUF_LEN);
while (wsplen) {
size_t wlen = wsplen > STACK_BUF_LEN ? STACK_BUF_LEN : wsplen;
fwrite(buf, 1, wlen, strstore);
wsplen -= wlen;
}
recordlen = wsplen;
// 空白と見做していた分を書き込み
uint8_t buf[STACK_BUF_LEN];
memset(buf, 0x20, STACK_BUF_LEN);
while (wsplen) {
size_t wlen = wsplen > STACK_BUF_LEN ? STACK_BUF_LEN : wsplen;
fwrite(buf, 1, wlen, strstore);
wsplen -= wlen;
}
}
return false;
Expand All @@ -199,60 +189,6 @@ static void append_buffer(uint8_t *line, size_t n) {
fwrite(line, 1, n, strstore);
}

static bool count_field_len(uint8_t *line, size_t n) {
uint8_t *p = field_pending + fieldlen;
size_t add;
bool filled;
if (on_field) {
add = n - fieldlen;
}
else {
add = (uint8_t*)memchr(line, 0x3d, n) - line;
}
if (fieldlen + add <= 22) {
memcpy(&field_pending[fieldlen], line, add);
filled = !on_field;
}
else {
memcpy(&field_pending[fieldlen], line, 22 - fieldlen);
filled = true;
}
fieldlen += add;
return filled;
}

static void test_mbp(uint8_t **line, size_t *n) {
if (fieldlen > 22) {
append_buffer(*line, *n);
}
else {
bool filled;
size_t before = fieldlen;
filled = count_field_len(*line, *n);
size_t add = fieldlen - before;
if (filled) {
size_t w;
// M_B_Pを比較する分のバッファが埋まったか項目名が決まった場合
if (fieldlen > 22) {
if (add + before > 22) {
add = 22 - before;
}
w = 22;
}
else if (fieldlen == 22 && !on_field) {
w = 22;
}
else {
w = fieldlen;
}
append_buffer(field_pending, w);
*line += add;
*n -= add;
append_buffer(*line, *n);
}
}
}

static void line_oc(uint8_t *line, size_t n, bool lf) {
static bool afterlf = false;

Expand Down Expand Up @@ -289,11 +225,8 @@ static void line_oc(uint8_t *line, size_t n, bool lf) {
if (on_field) {
if(!test_tag_field(line, n, true, &on_field, NULL)) err_name();
if (on_field && lf) err_name();
test_mbp(&line, &n);
}
else {
append_buffer(line, n);
}
append_buffer(line, n);
afterlf = lf;
}

Expand Down Expand Up @@ -365,8 +298,8 @@ static void line_vc(uint8_t *line, size_t n, bool lf) {
if (on_field) {
if(!test_tag_field(line, n, true, &on_field, NULL)) err_name();
if (on_field && lf) err_nosep();
test_mbp(&line, &n);
}
append_buffer(line, n);
if (lf) {
finalize_record();
}
Expand Down Expand Up @@ -400,6 +333,7 @@ void *split(void *fp_) {
}
fclose(fp);
line(NULL, 0, false);
return NULL;
}

void *parse_tags(void* nouse_) {
Expand Down
1 change: 0 additions & 1 deletion src/put-tags.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ void *put_tags(void *fp_) {
putdest = O.tag_deferred ? tmpfile() : stdout;

iconv_t cd;
char charsetname[128];

if (!O.tag_raw) {
cd = iconv_new(nl_langinfo(CODESET), "UTF-8");
Expand Down
1 change: 0 additions & 1 deletion src/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ static bool copy_tag_packet(ogg_page *og, bool *packet_break_in_page) {
int lace_num = og->header[26];
if (!lace_num) return false;

uint8_t const *lace = &og->header[27];
uint8_t const *bin = og->body;

uint_fast8_t i;
Expand Down
5 changes: 2 additions & 3 deletions src/retrieve-tags.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ static bool rtcopy_delete(FILE *packet_input, void *fptag_) {

// 削除リストのループ
rewind(dellist_str); rewind(dellist_len);
bool copy = true;
bool matched = false;
while (fread(buf, 1, 5, dellist_len)) {
uint32_t cmplen = *(uint32_t*)buf;
Expand Down Expand Up @@ -244,10 +243,10 @@ void *retrieve_tags(void *packet_input_) {
}
fwrite(buf, 1, codec->commagic_len, fptag);
if (!rtn->part_of_comment) {
// コメントパケットが無かった時用
// VP8でコメントパケットが無かった時用
if (O.edit == EDIT_LIST) exit(0);
uint8_t buf2[8] = "";
fwrite(buf, 1, 8, fptag);
fwrite(buf2, 1, 8, fptag);
rtn->tagbegin = codec->commagic_len + 4;
goto NOTCOMMENT;
}
Expand Down
4 changes: 2 additions & 2 deletions src/version.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define OPUSCOMMENT_VERSION "1.4.9"
#define OPUSCOMMENT_VERSION "1.4.10"

#define OPUSCOMMENT_REVISION_YEAR (2019 - 1900)
#define OPUSCOMMENT_REVISION_MONTH (3 - 1)
#define OPUSCOMMENT_REVISION_DAY 16
#define OPUSCOMMENT_REVISION_DAY 18

0 comments on commit 89a4bea

Please sign in to comment.