OSDN Git Service

refined. global tree1, tree2 and struct tree are hidden in pm2tree.c
authorKoji Arai <jca02266@gmail.com>
Sat, 30 Aug 2008 15:32:46 +0000 (00:32 +0900)
committerKoji Arai <jca02266@gmail.com>
Sat, 30 Aug 2008 15:32:46 +0000 (00:32 +0900)
src/Makefile.am
src/cproto.sh
src/pm2.c
src/pm2hist.h [deleted file]
src/pm2tree.c
src/pm2tree.h [deleted file]
src/prototypes.h

index aec7ef8..6aed212 100644 (file)
@@ -4,7 +4,7 @@ lha_SOURCES = append.c bitio.c crcio.c dhuf.c extract.c header.c huf.c \
        indicator.c larc.c lha.h lha_macro.h prototypes.h lhadd.c lharc.c \
        lhext.c lhlist.c maketbl.c maketree.c patmatch.c shuf.c slide.c \
        util.c getopt_long.c getopt_long.h \
-       pm2.c pm2hist.c pm2hist.h pm2tree.c pm2tree.h
+       pm2.c pm2hist.c pm2tree.c
 lha_LDADD = @LIBOBJS@
 EXTRA_DIST = lhdir.h fnmatch.h
 AM_CPPFLAGS=$(DEF_KCODE) $(SUPPORT_LZHUFF_METHOD)
index 9c5e8f5..b840f0e 100644 (file)
@@ -22,7 +22,7 @@ SOURCES='append.c bitio.c crcio.c dhuf.c extract.c header.c
        huf.c indicator.c larc.c lhadd.c lharc.c lhext.c
        lhlist.c maketbl.c maketree.c patmatch.c
        shuf.c slide.c util.c
-       pm2.c
+       pm2.c pm2tree.c pm2hist.c
 '
 
 test -f prototypes.h && mv -f prototypes.h prototypes.h.bak
index a90e203..4a1d0ce 100644 (file)
--- a/src/pm2.c
+++ b/src/pm2.c
@@ -2,8 +2,6 @@
        pm2.c -- extract pmext2 coding
 ***********************************************************/
 #include "lha.h"
-#include "pm2hist.h"
-#include "pm2tree.h"
 
 static off_t nextcount;
 static unsigned long lastupdate;
@@ -76,7 +74,7 @@ decode_c_pm2(void)
             break;
         }
     }
-    gettree1 = tree_get(&tree1);        /* value preserved for decode_p */
+    gettree1 = tree1_get();        /* value preserved for decode_p */
     if (gettree1 >= 29) {
         error("Bad table");
         exit(1);
@@ -104,7 +102,7 @@ decode_p_pm2(void)
         delta = 0;
     }
     else if (gettree1 < 28) {   /* n-byte repeat with offset 0..8191 */
-        gettree2 = tree_get(&tree2);
+        gettree2 = tree2_get();
         if (gettree2 == 0) {
             nbits = 6;
             delta = 0;
diff --git a/src/pm2hist.h b/src/pm2hist.h
deleted file mode 100644 (file)
index 879435f..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-/***********************************************************
-       pm2hist.h -- history for pmext2 decoding
-***********************************************************/
-
-/* Circular double-linked list. */
-
-void hist_init();
-unsigned char hist_lookup(int n);
-void hist_update(unsigned char data);
index a53ece7..5d98bc4 100644 (file)
@@ -2,25 +2,33 @@
        pm2tree.c -- tree for pmext2 decoding
 ***********************************************************/
 #include "lha.h"
-#include "pm2tree.h"
+
+struct tree {
+    unsigned char root, *leftarr, *rightarr;
+};
 
 static unsigned char tree1left[32];
 static unsigned char tree1right[32];
-struct tree tree1 = { 0, tree1left, tree1right };
-static unsigned char table1[32];
+static struct tree tree1 = { 0, tree1left, tree1right };
+static unsigned char tree1bound;
 
 static unsigned char tree2left[8];
 static unsigned char tree2right[8];
-struct tree tree2 = { 0, tree2left, tree2right };
-static unsigned char table2[8];
+static struct tree tree2 = { 0, tree2left, tree2right };
 
-static unsigned char tree1bound;
-static unsigned char mindepth;
+static void tree_setsingle(struct tree *t, unsigned char value);
+static void tree_rebuild(struct tree *t, unsigned char bound,
+                  unsigned char mindepth, unsigned char maxdepth,
+                  unsigned char *table);
+static void tree_setsingle(struct tree *t, unsigned char value);
 
 void
 maketree1()
 {
     int i, nbits, x;
+    unsigned char mindepth;
+    unsigned char table1[32];
+
 
     tree1bound = getbits(5);
     mindepth = getbits(3);
@@ -43,6 +51,8 @@ void
 maketree2(int tree2bound) /* in use: 5 <= tree2bound <= 8 */
 {
     int i, count, index;
+    unsigned char mindepth;
+    unsigned char table2[8];
 
     if (tree1bound < 10)
         return;
@@ -76,7 +86,7 @@ maketree2(int tree2bound) /* in use: 5 <= tree2bound <= 8 */
 
 }
 
-int
+static int
 tree_get(struct tree *t)
 {
     int i;
@@ -87,13 +97,25 @@ tree_get(struct tree *t)
     return i & 0x7F;
 }
 
-void
+int
+tree1_get()
+{
+    return tree_get(&tree1);
+}
+
+int
+tree2_get()
+{
+    return tree_get(&tree2);
+}
+
+static void
 tree_setsingle(struct tree *t, unsigned char value)
 {
     t->root = 128 | value;
 }
 
-void
+static void
 tree_rebuild(struct tree *t,
              unsigned char bound,
              unsigned char mindepth,
diff --git a/src/pm2tree.h b/src/pm2tree.h
deleted file mode 100644 (file)
index 89125ad..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/***********************************************************
-       pm2tree.h -- tree for pmext2 decoding
-***********************************************************/
-
-struct tree {
-    unsigned char root, *leftarr, *rightarr;
-};
-
-extern struct tree tree1, tree2;
-
-void maketree1();
-void maketree2(int tree2bound);
-int tree_get(struct tree *t);
-void tree_setsingle(struct tree *t, unsigned char value);
-void tree_rebuild(struct tree *t, unsigned char bound,
-                  unsigned char mindepth, unsigned char maxdepth, unsigned char *table);
index e633418..72ee93f 100644 (file)
@@ -133,6 +133,15 @@ int str_safe_copy P_((char *dst, const char *src, int dstsz));
 void decode_start_pm2 P_((void));
 unsigned short decode_c_pm2 P_((void));
 unsigned short decode_p_pm2 P_((void));
+/* pm2tree.c */
+void maketree1 P_((void));
+void maketree2 P_((int tree2bound));
+int tree1_get P_((void));
+int tree2_get P_((void));
+/* pm2hist.c */
+void hist_init P_((void));
+unsigned char hist_lookup P_((int n));
+void hist_update P_((unsigned char data));
 
 /* util.c */
 #if !HAVE_MEMMOVE