OSDN Git Service
(root)
/
lha
/
olha.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b2799c5
)
should not change the value of the h->origsize
author
Koji Arai
<jca02266@gmail.com>
Thu, 5 Jun 2008 14:10:19 +0000
(23:10 +0900)
committer
Koji Arai
<jca02266@gmail.com>
Thu, 5 Jun 2008 14:10:19 +0000
(23:10 +0900)
ar.h
patch
|
blob
|
history
extract.c
patch
|
blob
|
history
diff --git
a/ar.h
b/ar.h
index
b9a5e64
..
b671538
100644
(file)
--- a/
ar.h
+++ b/
ar.h
@@
-106,4
+106,7
@@
extern struct lha_opts opts;
extern ushort left[], right[];
extern ushort left[], right[];
+/* utilities */
+#define MIN(a, b) (((a) > (b)) ? (b) : (a))
+
#include "prototypes.h"
#include "prototypes.h"
diff --git
a/extract.c
b/extract.c
index
22943b5
..
caa1b29
100644
(file)
--- a/
extract.c
+++ b/
extract.c
@@
-8,7
+8,6
@@
void
extract(struct lzh_istream *rp, int to_file, struct lzh_header *h)
{
void
extract(struct lzh_istream *rp, int to_file, struct lzh_header *h)
{
- int n;
FILE *outfile = NULL;
unsigned int crc;
FILE *outfile = NULL;
unsigned int crc;
@@
-57,12
+56,13
@@
extract(struct lzh_istream *rp, int to_file, struct lzh_header *h)
char buf[MAXDICSIZ];
unsigned int slide_off = 0;
int slide_len = 0;
char buf[MAXDICSIZ];
unsigned int slide_off = 0;
int slide_len = 0;
+ unsigned long remainder = h->origsize;
crc = INIT_CRC;
if (opts.method->dicbit != 0)
decode_start(rp);
crc = INIT_CRC;
if (opts.method->dicbit != 0)
decode_start(rp);
- while (
h->origsize
!= 0) {
-
n = (uint) ((h->origsize > MAXDICSIZ) ? MAXDICSIZ : h->origsize
);
+ while (
remainder
!= 0) {
+
uint n = (uint)MIN(remainder, MAXDICSIZ
);
if (opts.method->dicbit != 0)
decode(rp, n, buf, &slide_off, &slide_len);
else {
if (opts.method->dicbit != 0)
decode(rp, n, buf, &slide_off, &slide_len);
else {
@@
-74,7
+74,7
@@
extract(struct lzh_istream *rp, int to_file, struct lzh_header *h)
if (outfile != stdout && opts.quiet < 1) {
putc('.', stdout);
}
if (outfile != stdout && opts.quiet < 1) {
putc('.', stdout);
}
-
h->origsize
-= n;
+
remainder
-= n;
}
}
}
}