OSDN Git Service

* src/lharc.c (init_variable): do not use HEADER_LEVELx macros.
authorarai <arai@6a8cc165-1e22-0410-a132-eb4e3f353aba>
Fri, 21 Mar 2003 15:40:49 +0000 (15:40 +0000)
committerarai <arai@6a8cc165-1e22-0410-a132-eb4e3f353aba>
Fri, 21 Mar 2003 15:40:49 +0000 (15:40 +0000)
(parse_option): ditto.

* src/header.c (write_header): ditto.

* src/lha_macro.h (HEADER_LEVEL0, HEADER_LEVEL1, HEADER_LEVEL2, MATCHBIT): ditto.

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

src/header.c
src/lha_macro.h
src/lharc.c

index 3f13ff6..9fa4da9 100644 (file)
@@ -10,6 +10,8 @@
 /*  Ver. 1.13b Symbolic Link Bug Fix            1994.08.22  N.Watazaki      */
 /*  Ver. 1.14  Source All chagned               1995.01.14  N.Watazaki      */
 /*  Ver. 1.14i bug fixed                        2000.10.06  t.okamoto       */
+/*  Ver. 1.14i Contributed UTF-8 convertion for Mac OS X                    */
+/*                                              2002.06.29  Hiroto Sakai    */
 /*  Ver. 1.14i autoconfiscated & rewritten      2003.02.23  Koji Arai       */
 /* ------------------------------------------------------------------------ */
 #include "lha.h"
@@ -344,13 +346,13 @@ convert_filename(name, len, size,
 }
 
 /*
- * Generic (MS-DOS style) time stamp format:
+ * Generic (MS-DOS style) time stamp format (localtime):
  *
  *  31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
- * |<------- year ----->|<- month ->|<--- day ---->|
+ * |<---- year-1980 --->|<- month ->|<--- day ---->|
  *
  *  15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
- * |<--- hour --->|<---- minute --->|<- second*2 ->|
+ * |<--- hour --->|<---- minute --->|<- second/2 ->|
  *
  */
 
@@ -358,27 +360,22 @@ static time_t
 generic_to_unix_stamp(t)
     long t;
 {
-    struct tm dostm;
+    struct tm tm;
 
-    /*
-     * special case:  if MSDOS format date and time were zero, then we
-     * set time to be zero here too.
-     */
-    if (t == 0)
-        return 0;
+#define subbits(n, off, len) (((n) >> (off)) & ((1 << (len))-1))
 
-    dostm.tm_sec = (t & 0x1f) * 2;
-    dostm.tm_min = t >> 5 & 0x3f;
-    dostm.tm_hour = t >> 11 & 0x1f;
-    dostm.tm_mday = t >> 16 & 0x1f;
-    dostm.tm_mon = (t >> (16+5) & 0x0f) - 1;    /* 0..11 */
-    dostm.tm_year = (t >> (16+9) & 0x7f) + 80;
-    dostm.tm_isdst = -1;
+    tm.tm_sec  = subbits(t,  0, 5) * 2;
+    tm.tm_min  = subbits(t,  5, 6);
+    tm.tm_hour = subbits(t, 11, 5);
+    tm.tm_mday = subbits(t, 16, 5);
+    tm.tm_mon  = subbits(t, 21, 4) - 1;
+    tm.tm_year = subbits(t, 25, 7) + 80;
+    tm.tm_isdst = -1;
 
 #if HAVE_MKTIME
-    return mktime(&dostm);
+    return mktime(&tm);
 #else
-    return timelocal(&dostm);
+    return timelocal(&tm);
 #endif
 }
 
@@ -1531,7 +1528,7 @@ write_header(fp, hdr)
     if (generic_format)
         filename_case = TO_UPPER;
 
-    if (hdr->header_level == HEADER_LEVEL0) {
+    if (hdr->header_level == 0) {
         archive_delim = "\\";
     }
 
index 8d35d3e..ad3b1d4 100644 (file)
 /* Added N.Watazaki ..^ */
 
 #define LZHUFF0_DICBIT           0      /* no compress */
-#define LZHUFF1_DICBIT          12      /* 2^12 =  4k sliding dictionary */
-#define LZHUFF2_DICBIT          13      /* 2^13 =  8k sliding dictionary */
-#define LZHUFF3_DICBIT          13      /* 2^13 =  8k sliding dictionary */
-#define LZHUFF4_DICBIT          12      /* 2^12 =  4k sliding dictionary */
-#define LZHUFF5_DICBIT          13      /* 2^13 =  8k sliding dictionary */
-#define LZHUFF6_DICBIT          15      /* 2^15 = 32k sliding dictionary */
-#define LZHUFF7_DICBIT          16      /* 2^16 = 64k sliding dictionary */
-#define LARC_DICBIT             11      /* 2^11 =  2k sliding dictionary */
-#define LARC5_DICBIT            12      /* 2^12 =  4k sliding dictionary */
+#define LZHUFF1_DICBIT          12      /* 2^12 =  4KB sliding dictionary */
+#define LZHUFF2_DICBIT          13      /* 2^13 =  8KB sliding dictionary */
+#define LZHUFF3_DICBIT          13      /* 2^13 =  8KB sliding dictionary */
+#define LZHUFF4_DICBIT          12      /* 2^12 =  4KB sliding dictionary */
+#define LZHUFF5_DICBIT          13      /* 2^13 =  8KB sliding dictionary */
+#define LZHUFF6_DICBIT          15      /* 2^15 = 32KB sliding dictionary */
+#define LZHUFF7_DICBIT          16      /* 2^16 = 64KB sliding dictionary */
+#define LARC_DICBIT             11      /* 2^11 =  2KB sliding dictionary */
+#define LARC5_DICBIT            12      /* 2^12 =  4KB sliding dictionary */
 #define LARC4_DICBIT             0      /* no compress */
 
 #ifdef SUPPORT_LH7
 
 #define GENERIC_ATTRIBUTE               0x20
 #define GENERIC_DIRECTORY_ATTRIBUTE     0x10
-#define HEADER_LEVEL0                   0x00
-#define HEADER_LEVEL1                   0x01
-#define HEADER_LEVEL2                   0x02
 
 #define CURRENT_UNIX_MINOR_VERSION      0x00
 
 /* bitio.c */
 #define peekbits(n)     (bitbuf >> (sizeof(bitbuf)*8 - (n)))
 
-/* from crcio.c */
+/* crcio.c */
 #define CRCPOLY         0xA001      /* CRC-16 (x^16+x^15+x^2+1) */
 #define INITIALIZE_CRC(crc) ((crc) = 0)
 #define UPDATE_CRC(crc, c) \
 */
 
 /* slide.c */
-#define MATCHBIT            8   /* bits for MAXMATCH - THRESHOLD */
 #define MAXMATCH            256 /* formerly F (not more than UCHAR_MAX + 1) */
 #define THRESHOLD           3   /* choose optimal value */
index e0130ec..d899d95 100644 (file)
@@ -65,7 +65,7 @@ init_variable()     /* Added N.Watazaki */
 
     compress_method = DEFAULT_LZHUFF_METHOD; /* defined in config.h */
 
-    header_level    = HEADER_LEVEL2;
+    header_level    = 2;        /* level 2 */
     quiet_mode      = 0;
 
 #ifdef EUC
@@ -392,13 +392,13 @@ parse_option(int argc, char **argv)
                 }
                 break;
             case '0':
-                header_level = HEADER_LEVEL0;
+                header_level = 0;
                 break;
             case '1':
-                header_level = HEADER_LEVEL1;
+                header_level = 1;
                 break;
             case '2':
-                header_level = HEADER_LEVEL2;
+                header_level = 2;
                 break;
             default:
                 error("Unknown option '%c'.", p[-1]);