OSDN Git Service

extract.c and decode.c was refined.
[lha/olha.git] / extract.c
index cc70fb1..751babe 100644 (file)
--- a/extract.c
+++ b/extract.c
@@ -53,29 +53,28 @@ extract(struct lzh_istream *rp, int to_file, struct lzh_header *h)
         skip(rp->fp, h);
     }
     else {
-        char buf[MAXDICSIZ];
-        unsigned int slide_off = 0;
-        int slide_len = 0;
-        unsigned long remainder = h->origsize;
-        struct huf_t huf;
-
         crc = INIT_CRC;
-        if (opts.method->dicbit != 0)
-            decode_start(rp);
-        while (remainder != 0) {
-            uint n = (uint)MIN(remainder, MAXDICSIZ);
-            if (opts.method->dicbit != 0)
-                decode(&huf, rp, n, buf, &slide_off, &slide_len);
-            else {
+
+        if (opts.method->dicbit != 0) {
+            decode(rp, outfile, h->origsize, &crc);
+        }
+        else {
+            unsigned long remainder = h->origsize;
+
+            char buf[BUFSIZ];
+
+            while (remainder != 0) {
+                uint n = (uint)MIN(remainder, BUFSIZ);
+
                 /* no compress */
                 if (fread(buf, 1, n, rp->fp) != n)
                     error("Can't read");
+                fwrite_crc(buf, n, outfile, &crc);
+                if (outfile != stdout && opts.quiet < 1) {
+                    putc('.', stdout);
+                }
+                remainder -= n;
             }
-            fwrite_crc(buf, n, outfile, &crc);
-            if (outfile != stdout && opts.quiet < 1) {
-                putc('.', stdout);
-            }
-            remainder -= n;
         }
     }