OSDN Git Service

Merge commit 'origin/master' into pmarc
[lha/lha.git] / src / lhadd.c
index 4eb3a21..c9facf0 100644 (file)
@@ -20,7 +20,7 @@ add_one(fp, nafp, hdr)
     LzHeader       *hdr;
 {
     off_t header_pos, next_pos, org_pos, data_pos;
-    size_t v_original_size, v_packed_size;
+    off_t v_original_size, v_packed_size;
 
     reading_filename = hdr->name;
     writing_filename = temporary_name;
@@ -122,6 +122,17 @@ append_it(name, oafp, nafp)
             break;
         }
 
+        if (!sort_contents) {
+            if (!noexec) {
+                fseeko(oafp, old_header, SEEK_SET);
+                copy_old_one(oafp, nafp, &ahdr);
+            }
+            else
+                fseeko(oafp, ahdr.packed_size, SEEK_CUR);
+            cmp = -1;           /* to be -1 always */
+            continue;
+        }
+
         cmp = strcmp(ahdr.name, hdr.name);
         if (cmp < 0) {          /* SKIP */
             /* copy old to new */
@@ -166,7 +177,7 @@ append_it(name, oafp, nafp)
 
     if (fp) fclose(fp);
 
-    if (directory) {            /* recursive call */
+    if (directory && recursive_archiving) {            /* recursive call */
         if (find_files(name, &filec, &filev)) {
             for (i = 0; i < filec; i++)
                 oafp = append_it(filev[i], oafp, nafp);
@@ -311,14 +322,14 @@ report_archive_name_if_different()
 /* ------------------------------------------------------------------------ */
 void
 temporary_to_new_archive_file(new_archive_size)
-    size_t new_archive_size;
+    off_t new_archive_size;
 {
     FILE *oafp, *nafp;
 
     if (!strcmp(new_archive_name, "-")) {
         nafp = stdout;
-        writing_filename = "starndard output";
-#if __MINGW32__
+        writing_filename = "standard output";
+#if defined(__MINGW32__) || defined(__DJGPP__)
         setmode(fileno(stdout), O_BINARY);
 #endif
     }
@@ -400,7 +411,7 @@ remove_one(name)
 #ifdef S_IFLNK
     else if (is_symlink(&stbuf)) {
         if (noexec)
-            printf("REMOVE SYMBOLIC LINK %s.\n", name);
+            message("REMOVE SYMBOLIC LINK %s.", name);
         else if (unlink(name) < 0)
             warning("Cannot remove", name);
         else if (verbose)
@@ -434,7 +445,7 @@ cmd_add()
     int             i;
     long            old_header;
     boolean         old_archive_exist;
-    size_t          new_archive_size;
+    off_t           new_archive_size;
 
     /* exit if no operation */
     if (!update_if_newer && cmd_filec == 0) {
@@ -579,7 +590,7 @@ void
 cmd_delete()
 {
     FILE *oafp, *nafp;
-    size_t new_archive_size;
+    off_t new_archive_size;
 
     /* open old archive if exist */
     if ((oafp = open_old_archive()) == NULL)