OSDN Git Service

* src/lhext.c (cmd_extract): When error occurred in extract_one(),
authorarai <arai@6a8cc165-1e22-0410-a132-eb4e3f353aba>
Sat, 22 Jun 2002 15:56:01 +0000 (15:56 +0000)
committerarai <arai@6a8cc165-1e22-0410-a132-eb4e3f353aba>
Sat, 22 Jun 2002 15:56:01 +0000 (15:56 +0000)
should adjust point of file stream.

git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/lha/lha/trunk@230 6a8cc165-1e22-0410-a132-eb4e3f353aba

src/lhext.c

index efa6da7..2fdc2ed 100644 (file)
@@ -435,10 +435,15 @@ cmd_extract()
                if (need_file(hdr.name)) {
                        pos = ftell(afp);
                        extract_one(afp, &hdr);
-#if 0 /* On MinGW, if afp == stdin, fseek() will succeed.
-         but next getc(afp) return EOF */
-                       fseek(afp, pos + hdr.packed_size, SEEK_SET);
-#endif
+            /* when error occurred in extract_one(), should adjust
+               point of file stream */
+                       if (afp != stdin)
+                fseek(afp, pos + hdr.packed_size, SEEK_SET);
+            else {
+                long pos2 = ftell(afp);
+                int i = pos + hdr.packed_size - pos2;
+                               while (i-- > 0) fgetc(afp);
+            }
                } else {
                        if (afp != stdin)
                                fseek(afp, hdr.packed_size, SEEK_CUR);