OSDN Git Service

* src/lhext.c (make_parent_path): missing braces.
[lha/lha.git] / src / lhext.c
index efa6da7..bc49b9a 100644 (file)
@@ -116,9 +116,10 @@ make_parent_path(name)
                return FALSE;
 
 #if defined __MINGW32__
-    if (mkdir(path) < 0)
+    if (mkdir(path) < 0) {      /* try again */
                error("Cannot make directory", path);
         return FALSE;
+    }
 #else
        if (mkdir(path, 0777) < 0) {    /* try again */
                error("Cannot make directory", path);
@@ -150,13 +151,13 @@ adjust_info(name, hdr)
        char           *name;
        LzHeader       *hdr;
 {
-       time_t          utimebuf[2];
+    struct utimbuf utimebuf;
 
        /* adjust file stamp */
-       utimebuf[0] = utimebuf[1] = hdr->unix_last_modified_stamp;
+       utimebuf.actime = utimebuf.modtime = hdr->unix_last_modified_stamp;
 
        if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) != UNIX_FILE_SYMLINK)
-               utime(name, utimebuf);
+               utime(name, &utimebuf);
 
        if (hdr->extend_type == EXTEND_UNIX
            || hdr->extend_type == EXTEND_OS68K
@@ -200,7 +201,7 @@ extract_one(afp, hdr)
 {
        FILE           *fp;     /* output file */
        struct stat     stbuf;
-       char            name[257];
+       char            name[FILENAME_LENGTH];
        int             crc;
        int             method;
        boolean         save_quiet, save_verbose, up_flag;
@@ -240,7 +241,7 @@ extract_one(afp, hdr)
                   5, hdr->method, name);
                        return;
                }
-               if (bcmp(hdr->method, methods[method], 5) == 0)
+               if (memcmp(hdr->method, methods[method], 5) == 0)
                        break;
        }
 
@@ -251,14 +252,15 @@ extract_one(afp, hdr)
                        if (methods[method] == NULL) {
                 error("Unknown method \"%.*s\"; \"%s\" will be skiped ...",
                       5, hdr->method, name);
+                               return;
                        }
-                       if (bcmp(hdr->method, methods[method], 5) == 0)
+                       if (memcmp(hdr->method, methods[method], 5) == 0)
                                break;
                }
 #endif
 
                reading_filename = archive_name;
-               writting_filename = name;
+               writing_filename = name;
                if (output_to_stdout || verify_mode) {
                        if (noexec) {
                                printf("%s %s\n", verify_mode ? "VERIFY" : "EXTRACT", name);
@@ -353,7 +355,7 @@ extract_one(afp, hdr)
        else if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_DIRECTORY
                         || (hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK
                         || method == LZHDIRS_METHOD_NUM) {
-               /* ¢¬¤³¤ì¤Ç¡¢Symblic Link ¤Ï¡¢Âç¾æÉפ«¡© */
+               /* ¢¬¤³¤ì¤Ç¡¢Symbolic Link ¤Ï¡¢Âç¾æÉפ«¡© */
                if (!ignore_directory && !verify_mode) {
                        if (noexec) {
                                if (quiet != TRUE)
@@ -435,10 +437,16 @@ 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 {
+                /* FIXME: assume that the extract_one() has read
+                   packed_size bytes from stdin. */
+                long i = 0;
+                               while (i--) fgetc(afp);
+            }
                } else {
                        if (afp != stdin)
                                fseek(afp, hdr.packed_size, SEEK_CUR);