OSDN Git Service

re-applied the correct DJGPP patch. Thanks to Doug Kaufman.
authorarai <arai@6a8cc165-1e22-0410-a132-eb4e3f353aba>
Sun, 8 Oct 2006 14:20:14 +0000 (14:20 +0000)
committerarai <arai@6a8cc165-1e22-0410-a132-eb4e3f353aba>
Sun, 8 Oct 2006 14:20:14 +0000 (14:20 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/lha/lha/trunk@848 6a8cc165-1e22-0410-a132-eb4e3f353aba

ChangeLog
configure.ac
src/header.c
src/lha_macro.h
src/lhadd.c
src/lhext.c
src/lhlist.c
tests/lha-test12

index 85b1a51..bacdb8c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
+2006-10-08  Koji Arai  <arai@users.sourceforge.jp>
+
+       * configure.ac: updated version.
+
+       * configure.ac, src/header.c, src/lha_macro.h, src/lhadd.c, src/lhext.c, src/lhlist.c, tests/lha-test12:
+       re-applied the correct DJGPP patch. Thanks to Doug Kaufman.
+
 2006-10-02  Koji Arai  <arai@users.sourceforge.jp>
 
+       * configure.ac: updated version.
+
        * src/header.c, src/lha.h, src/lha_macro.h, src/lhadd.c, src/lharc.c, src/lhext.c, src/lhlist.c, src/vsnprintf.c, tests/lha-test.in, tests/lha-test11, tests/lha-test12:
        applied the patch for the DJGPP. Thanks to Doug Kaufman.
 
index bcd887b..a9643f0 100644 (file)
@@ -1,5 +1,5 @@
 # Process this file with autoconf to produce a configure script.
-AC_INIT([LHa for UNIX], 1.14i-ac20061002, arai@users.sourceforge.jp, lha)
+AC_INIT([LHa for UNIX], 1.14i-ac20061008, arai@users.sourceforge.jp, lha)
 AC_CANONICAL_HOST
 AC_CANONICAL_TARGET
 AM_INIT_AUTOMAKE
@@ -291,6 +291,12 @@ if test "x$enable_ignore_dot_files" = xyes; then
            [Define to 1 if you want to ignore dot files with -X command line switch])
 fi
 
+case $host_os in 
+*msdosdjgpp*)
+CFLAGS="$CFLAGS -DNOT_COMPATIBLE_MODE"
+;;
+esac
+
 AC_CONFIG_FILES([Makefile src/Makefile man/Makefile olddoc/Makefile])
 AC_CONFIG_FILES([tests/Makefile tests/lha-test])
 AC_OUTPUT
index e919a35..ef31de5 100644 (file)
@@ -719,7 +719,7 @@ get_header_level0(fp, hdr, data)
     hdr->name[i] = '\0';
 
     /* defaults for other type */
-    hdr->unix_mode = S_IFREG | UNIX_RW_RW_RW;
+    hdr->unix_mode = UNIX_FILE_REGULAR | UNIX_RW_RW_RW;
     hdr->unix_gid = 0;
     hdr->unix_uid = 0;
 
@@ -836,7 +836,7 @@ get_header_level1(fp, hdr, data)
     hdr->name[i] = '\0';
 
     /* defaults for other type */
-    hdr->unix_mode = S_IFREG | UNIX_RW_RW_RW;
+    hdr->unix_mode = UNIX_FILE_REGULAR | UNIX_RW_RW_RW;
     hdr->unix_gid = 0;
     hdr->unix_uid = 0;
 
@@ -919,7 +919,7 @@ get_header_level2(fp, hdr, data)
     hdr->header_level = get_byte();
 
     /* defaults for other type */
-    hdr->unix_mode = S_IFREG | UNIX_RW_RW_RW;
+    hdr->unix_mode = UNIX_FILE_REGULAR | UNIX_RW_RW_RW;
     hdr->unix_gid = 0;
     hdr->unix_uid = 0;
 
@@ -999,7 +999,7 @@ get_header_level3(fp, hdr, data)
     hdr->header_level = get_byte();
 
     /* defaults for other type */
-    hdr->unix_mode = S_IFREG | UNIX_RW_RW_RW;
+    hdr->unix_mode = UNIX_FILE_REGULAR | UNIX_RW_RW_RW;
     hdr->unix_gid = 0;
     hdr->unix_uid = 0;
 
@@ -1119,7 +1119,7 @@ get_header(fp, hdr)
                      system_kanji_code,
                      archive_delim, system_delim, filename_case);
 
-    if (S_ISLNK(hdr->unix_mode)) {
+    if ((hdr->unix_mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK) {
         char *p;
         /* split symbolic link */
         p = strchr(hdr->name, '|');
@@ -1241,6 +1241,37 @@ init_header(name, v_stat, hdr)
     /* since 00:00:00 JAN.1.1970 */
 #ifdef NOT_COMPATIBLE_MODE
     /* Please need your modification in this space. */
+#ifdef __DJGPP__
+    hdr->unix_mode = 0;
+    if (S_ISREG(v_stat->st_mode))
+           hdr->unix_mode = hdr->unix_mode | UNIX_FILE_REGULAR;
+    if (S_ISDIR(v_stat->st_mode))
+           hdr->unix_mode = hdr->unix_mode | UNIX_FILE_DIRECTORY;
+    if (S_ISLNK(v_stat->st_mode))
+           hdr->unix_mode = hdr->unix_mode | UNIX_FILE_SYMLINK;
+    if (v_stat->st_mode & S_IRUSR) 
+           hdr->unix_mode = hdr->unix_mode | UNIX_OWNER_READ_PERM;
+    if (v_stat->st_mode & S_IRGRP) 
+           hdr->unix_mode = hdr->unix_mode | UNIX_GROUP_READ_PERM;
+    if (v_stat->st_mode & S_IROTH) 
+           hdr->unix_mode = hdr->unix_mode | UNIX_OTHER_READ_PERM;
+    if (v_stat->st_mode & S_IWUSR) 
+           hdr->unix_mode = hdr->unix_mode | UNIX_OWNER_WRITE_PERM;
+    if (v_stat->st_mode & S_IWGRP) 
+           hdr->unix_mode = hdr->unix_mode | UNIX_GROUP_WRITE_PERM;
+    if (v_stat->st_mode & S_IWOTH) 
+           hdr->unix_mode = hdr->unix_mode | UNIX_OTHER_WRITE_PERM;
+    if (v_stat->st_mode & S_IXUSR) 
+           hdr->unix_mode = hdr->unix_mode | UNIX_OWNER_EXEC_PERM;
+    if (v_stat->st_mode & S_IXGRP) 
+           hdr->unix_mode = hdr->unix_mode | UNIX_GROUP_EXEC_PERM;
+    if (v_stat->st_mode & S_IXOTH) 
+           hdr->unix_mode = hdr->unix_mode | UNIX_OTHER_EXEC_PERM;
+    if (v_stat->st_mode & S_ISUID) 
+           hdr->unix_mode = hdr->unix_mode | UNIX_SETUID;
+    if (v_stat->st_mode & S_ISGID) 
+           hdr->unix_mode = hdr->unix_mode | UNIX_SETGID;
+#endif /* __DJGPP__ */
 #else
     hdr->unix_mode = v_stat->st_mode;
 #endif
@@ -1285,7 +1316,7 @@ init_header(name, v_stat, hdr)
         }
     }
 
-#if defined(S_IFLNK) && !defined(__DJGPP__)
+#ifdef S_IFLNK
     if (is_symlink(v_stat)) {
         memcpy(hdr->method, LZHDIRS_METHOD, METHOD_TYPE_STORAGE);
         hdr->attribute = GENERIC_DIRECTORY_ATTRIBUTE;
@@ -1600,7 +1631,7 @@ write_header(fp, hdr)
         archive_delim = "\\";
     }
 
-    if (S_ISLNK(hdr->unix_mode)) {
+    if ((hdr->unix_mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK) {
         char *p;
         p = strchr(hdr->name, '|');
         if (p) {
index a1a1611..482b32a 100644 (file)
 # define kill(pid, sig)         0
 #endif
 
+#if defined __DJGPP__
+# define S_ISLNK(m)    0
+#endif
+
 /* ------------------------------------------------------------------------ */
 /* YOUR CUSTOMIZIES                                                         */
 /* ------------------------------------------------------------------------ */
 
 #define LZHEADER_STORAGE        4096
 
-#ifndef S_IFREG
-#define S_IFREG                        UNIX_FILE_REGULAR
-#endif
-
-#ifndef S_IFDIR
-#define S_IFDIR                        UNIX_FILE_DIRECTORY
-#endif
-
-#ifndef S_IFLNK
-#define S_IFLNK                        UNIX_FILE_SYMLINK
-#endif
-
-#ifndef S_ISREG
-#define S_ISREG(m)             (((m) & UNIX_FILE_TYPEMASK) == S_IFREG)
-#endif
-
-#ifndef S_ISDIR
-#define S_ISDIR(m)             (((m) & UNIX_FILE_TYPEMASK) == S_IFDIR)
-#endif
-
-#ifndef S_ISLNK
-#ifdef __DJGPP__
-#define S_ISLNK(m)             0
-#else
-#define S_ISLNK(m)             (((m) & UNIX_FILE_TYPEMASK) == S_IFLNK)
-#endif
-#endif
-
 /* ------------------------------------------------------------------------ */
 /*  FILE Attribute                                                          */
 /* ------------------------------------------------------------------------ */
index 6a8bd62..5b12a5a 100644 (file)
@@ -30,7 +30,7 @@ add_one(fp, nafp, hdr)
     header_pos = ftello(nafp);
     write_header(nafp, hdr);/* DUMMY */
 
-    if (S_ISLNK(hdr->unix_mode)) {
+    if ((hdr->unix_mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK) {
         if (!quiet)
             printf("%s -> %s\t- Symbolic Link\n", hdr->name, hdr->realname);
     }
@@ -192,11 +192,11 @@ find_update_files(oafp)
 
     init_sp(&sp);
     while (get_header(oafp, &hdr)) {
-        if (S_ISREG(hdr.unix_mode)) {
+        if ((hdr.unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_REGULAR) {
             if (stat(hdr.name, &stbuf) >= 0)    /* exist ? */
                 add_sp(&sp, hdr.name, strlen(hdr.name) + 1);
         }
-        else if (S_ISDIR(hdr.unix_mode)) {
+        else if ((hdr.unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_DIRECTORY) {
             strcpy(name, hdr.name); /* ok */
             len = strlen(name);
             if (len > 0 && name[len - 1] == '/')
@@ -225,7 +225,7 @@ delete(oafp, nafp)
         if (need_file(ahdr.name)) { /* skip */
             fseeko(oafp, ahdr.packed_size, SEEK_CUR);
             if (noexec || !quiet) {
-                if (S_ISLNK(ahdr.unix_mode))
+                if ((ahdr.unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK)
                     message("delete %s -> %s", ahdr.name, ahdr.realname);
                 else
                     message("delete %s", ahdr.name);
index 8100ffd..96fcde1 100644 (file)
@@ -164,16 +164,20 @@ adjust_info(name, hdr)
     /* adjust file stamp */
     utimebuf.actime = utimebuf.modtime = hdr->unix_last_modified_stamp;
 
-    if (!(S_ISLNK(hdr->unix_mode)))
+    if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) != UNIX_FILE_SYMLINK)
         utime(name, &utimebuf);
 
     if (hdr->extend_type == EXTEND_UNIX
         || hdr->extend_type == EXTEND_OS68K
         || hdr->extend_type == EXTEND_XOSK) {
 #ifdef NOT_COMPATIBLE_MODE
-        Please need your modification in this space.
+        /* Please need your modification in this space. */
+#ifdef __DJGPP__
+        if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) != UNIX_FILE_SYMLINK)
+            chmod(name, hdr->unix_mode);
+#endif /* __DJGPP__ */
 #else
-        if (!(S_ISLNK(hdr->unix_mode)))
+        if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) != UNIX_FILE_SYMLINK)
             chmod(name, hdr->unix_mode);
 #endif
         if (!getuid()){
@@ -271,7 +275,7 @@ extract_one(afp, hdr)
             break;
     }
 
-    if (S_ISREG(hdr->unix_mode)
+    if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_REGULAR
         && method != LZHDIRS_METHOD_NUM) {
     extract_regular:
 #if 0
@@ -435,8 +439,8 @@ extract_one(afp, hdr)
         if (hdr->has_crc && crc != hdr->crc)
             error("CRC error: \"%s\"", name);
     }
-    else if (S_ISDIR(hdr->unix_mode)
-             || S_ISLNK(hdr->unix_mode)
+    else if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_DIRECTORY
+             || (hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK
              || method == LZHDIRS_METHOD_NUM) {
         /* ¢¬¤³¤ì¤Ç¡¢Symbolic Link ¤Ï¡¢Âç¾æÉפ«¡© */
         if (!ignore_directory && !verify_mode) {
@@ -446,7 +450,7 @@ extract_one(afp, hdr)
                 return read_size;
             }
             /* NAME has trailing SLASH '/', (^_^) */
-            if (S_ISLNK(hdr->unix_mode)) {
+            if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK) {
                 int             l_code;
 
 #ifdef S_IFLNK
index a35b93c..e9b403b 100644 (file)
@@ -125,7 +125,7 @@ list_one(hdr)
     char modebits[11];
 
     if (verbose) {
-        if (S_ISLNK(hdr->unix_mode))
+        if ((hdr->unix_mode & UNIX_FILE_SYMLINK) != UNIX_FILE_SYMLINK)
             printf("%s\n", hdr->name);
         else
             printf("%s -> %s\n", hdr->name, hdr->realname);
@@ -138,9 +138,9 @@ list_one(hdr)
     case EXTEND_UNIX:
         mode = hdr->unix_mode;
 
-        if (S_ISDIR(mode))
+        if (mode & UNIX_FILE_DIRECTORY)
             modebits[0] = 'd';
-        else if (S_ISLNK(mode))
+        else if ((mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK)
             modebits[0] = 'l';
         else
             modebits[0] = '-';
@@ -259,7 +259,7 @@ list_one(hdr)
     print_stamp(hdr->unix_last_modified_stamp);
 
     if (!verbose) {
-        if (!(S_ISLNK(hdr->unix_mode)))
+        if ((hdr->unix_mode & UNIX_FILE_SYMLINK) != UNIX_FILE_SYMLINK)
             printf(" %s", hdr->name);
         else {
             printf(" %s -> %s", hdr->name, hdr->realname);
index 09dd2ee..49eaf5f 100644 (file)
@@ -8,7 +8,14 @@ $lha ct test-tmp-crlf.lzh test-a test-b test-c
 $lha xw=test-tmp-crlf test-tmp-crlf.lzh
                                                        check $? $LINENO
 # use GNU diff option --binary for DJGPP.
+case `$lha --version 2>&1` in
+*msdosdjgpp*)
 diff -r --binary test-1 test-tmp-crlf
+  ;;
+*)
+diff -r test-1 test-tmp-crlf
+  ;;
+esac
 test $? -ne 0
                                                        check $? $LINENO
 sed -e 's/$/