projects
/
ruby-vorbistagger.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Slightly reworked the final write loop.
[ruby-vorbistagger.git]
/
ext
/
vcedit.c
diff --git
a/ext/vcedit.c
b/ext/vcedit.c
index 795b0c3e1011510a60f18aa2eed53ef694c1b3db..75bf80db99aac4b3205172cb5c14b520b4d9193a 100644
(file)
--- a/
ext/vcedit.c
+++ b/
ext/vcedit.c
@@
-240,7
+240,7
@@
_fetch_next_packet (vcedit_state *s, ogg_packet *p, ogg_page *page)
bytes = fread (buffer, 1, CHUNKSIZE, s->in);
ogg_sync_wrote (&s->oy, bytes);
bytes = fread (buffer, 1, CHUNKSIZE, s->in);
ogg_sync_wrote (&s->oy, bytes);
- if (!bytes)
+ if (!bytes
&& feof (s->in)
)
return 0;
}
return 0;
}
@@
-355,7
+355,7
@@
vcedit_open (vcedit_state *state)
buffer = ogg_sync_buffer (&state->oy, CHUNKSIZE);
bytes = fread (buffer, 1, CHUNKSIZE, state->in);
buffer = ogg_sync_buffer (&state->oy, CHUNKSIZE);
bytes = fread (buffer, 1, CHUNKSIZE, state->in);
- if (!bytes && i < 2) {
+ if (!bytes &&
feof (state->in) &&
i < 2) {
ret = VCEDIT_ERR_INVAL;
goto err;
}
ret = VCEDIT_ERR_INVAL;
goto err;
}
@@
-512,7
+512,7
@@
vcedit_write (vcedit_state *state)
/* clear it, because not all paths to here do */
state->eosin = 0;
/* clear it, because not all paths to here do */
state->eosin = 0;
- while (!state->eosin) { /* We reached eos, not eof */
+ do {
/* We copy the rest of the stream (other logical streams)
* through, a page at a time.
*/
/* We copy the rest of the stream (other logical streams)
* through, a page at a time.
*/
@@
-536,9
+536,8
@@
vcedit_write (vcedit_state *state)
bytes = fread (buffer, 1, CHUNKSIZE, state->in);
ogg_sync_wrote (&state->oy, bytes);
bytes = fread (buffer, 1, CHUNKSIZE, state->in);
ogg_sync_wrote (&state->oy, bytes);
- if (!bytes)
- state->eosin = 1;
- }
+ state->eosin = !bytes && feof (state->in);
+ } while (!state->eosin);
fclose (out);
fclose (state->in);
fclose (out);
fclose (state->in);