aboutsummaryrefslogtreecommitdiff
path: root/fastjar
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@unixuser.org>2003-01-31 22:48:13 +0000
committerTom Tromey <tromey@gcc.gnu.org>2003-01-31 22:48:13 +0000
commit73f2132b06be18ee0cc8758577d9ae38aa550e8e (patch)
tree00a5866e7b8c67768e3a1022f7f2d028c5aaf2f7 /fastjar
parent1437ed242fbdceec678004bb51da7a80c5058fab (diff)
jartool.c (extract_jar): Don't lseek to skip extra fields.
2003-01-31 Daiki Ueno <ueno@unixuser.org> * jartool.c (extract_jar): Don't lseek to skip extra fields. (consume): If the stream is seekable, do lseek. From-SVN: r62207
Diffstat (limited to 'fastjar')
-rw-r--r--fastjar/ChangeLog5
-rw-r--r--fastjar/jartool.c16
2 files changed, 14 insertions, 7 deletions
diff --git a/fastjar/ChangeLog b/fastjar/ChangeLog
index 02b0d913366..53d55dd1818 100644
--- a/fastjar/ChangeLog
+++ b/fastjar/ChangeLog
@@ -1,3 +1,8 @@
+2003-01-31 Daiki Ueno <ueno@unixuser.org>
+
+ * jartool.c (extract_jar): Don't lseek to skip extra fields.
+ (consume): If the stream is seekable, do lseek.
+
2003-01-28 Ranjit Mathew <rmathew@hotmail.com>
* jargrep.c: Include xregex.h from libiberty instead of
diff --git a/fastjar/jartool.c b/fastjar/jartool.c
index 359b785c520..615cc401834 100644
--- a/fastjar/jartool.c
+++ b/fastjar/jartool.c
@@ -1471,9 +1471,6 @@ int extract_jar(int fd, char **files, int file_num){
}
if(method == 8 || flags & 0x0008){
- if(seekable)
- lseek(fd, eflen, SEEK_CUR);
- else
consume(&pbf, eflen);
inflate_file(&pbf, f_fd, &ze);
@@ -1508,9 +1505,6 @@ int extract_jar(int fd, char **files, int file_num){
#endif
}
- if(seekable)
- lseek(fd, eflen, SEEK_CUR);
- else
consume(&pbf, eflen);
}
@@ -1856,6 +1850,14 @@ int consume(pb_file *pbf, int amt){
printf("Consuming %d bytes\n", amt);
#endif
+ if (seekable){
+ if (amt <= (int)pbf->buff_amt)
+ pb_read(pbf, buff, amt);
+ else {
+ lseek(pbf->fd, amt - pbf->buff_amt, SEEK_CUR);
+ pb_read(pbf, buff, pbf->buff_amt); /* clear pbf */
+ }
+ } else
while(tc < amt){
rdamt = pb_read(pbf, buff, ((amt - tc) < RDSZ ? (amt - tc) : RDSZ));
#ifdef DEBUG
@@ -1865,7 +1867,7 @@ int consume(pb_file *pbf, int amt){
}
#ifdef DEBUG
- printf("%d bytes consumed\n", tc);
+ printf("%d bytes consumed\n", amt);
#endif
return 0;