+2008-05-02 Koji Arai <arai@users.sourceforge.jp>
+
+ * added a long option --debug=dumplzss which display debugging information for the LZSS.
+
2008-03-08 Koji Arai <arai@users.sourceforge.jp>
* src/lhext.c (add_dirinfo): no longer suppose that contents of the LZH archive is sorted by pathname.
original_size,
verify_mode ? "Testing " : "Melting ",
2048);
+
+ if (dump_lzss)
+ printf("no use slide\n");
+
*read_sizep = copyfile(infp, (verify_mode ? NULL : outfp),
original_size, 2, &crc);
}
original_size,
verify_mode ? "Testing " : "Melting ",
1 << interface.dicbit);
+ if (dump_lzss)
+ printf("\n");
+
crc = decode(&interface);
*read_sizep = interface.read_size;
}
/* for debugging */
EXTERN boolean sort_contents;
EXTERN boolean recursive_archiving;
+EXTERN boolean dump_lzss;
/* ------------------------------------------------------------------------ */
decode_macbinary_contents = FALSE;
sort_contents = TRUE;
recursive_archiving = TRUE;
+ dump_lzss = FALSE;
}
/* ------------------------------------------------------------------------ */
case DEBUG_OPTION:
if (!optarg) {
- error("debugging item is not specified for --%s=item",
+ error("debugging item is not specified for --%s",
long_options[option_index].name);
return -1;
}
else if (strcmp(optarg, "norecursion") == 0) {
recursive_archiving = FALSE;
}
+ else if (strcmp(optarg, "dumplzss") == 0) {
+ dump_lzss = TRUE;
+ quiet = TRUE;
+ }
else {
- error("unknown debugging item \"%s\" for --%s=item",
+ error("unknown debugging item \"%s\" for --%s",
optarg, long_options[option_index].name);
return -1;
}
while (decode_count < origsize) {
c = decode_set.decode_c();
if (c < 256) {
-#ifdef DEBUG
- fprintf(fout, "%u C %02X\n", decode_count, c);
+ if (dump_lzss) {
+#if SIZEOF_OFF_T == 8
+ printf("%04llu %02x(%c)\n",
+ decode_count, c, isprint(c) ? c : '?');
+#else
+ printf("%04lu %02x(%c)\n",
+ decode_count, c, isprint(c) ? c : '?');
#endif
+ }
dtext[loc++] = c;
if (loc == dicsiz) {
fwrite_crc(&crc, dtext, dicsiz, outfile);
match.len = c - adjust;
match.off = decode_set.decode_p() + 1;
matchpos = (loc - match.off) & dicsiz1;
-#ifdef DEBUG
- fprintf(fout, "%u M <%u %u> ",
- decode_count, match.len, decode_count-match.off);
+ if (dump_lzss) {
+#if SIZEOF_OFF_T == 8
+ printf("%04llu <%u %llu>\n",
+ decode_count, match.len, decode_count-match.off);
+#else
+ printf("%04lu <%u %lu>\n",
+ decode_count, match.len, decode_count-match.off);
#endif
+ }
+
decode_count += match.len;
for (i = 0; i < match.len; i++) {
c = dtext[(matchpos + i) & dicsiz1];
-#ifdef DEBUG
- fprintf(fout, "%02X ", c & 0xff);
-#endif
+ /*
+ if (dump_lzss) {
+ printf(" %02x", c & 0xff);
+ }
+ */
dtext[loc++] = c;
if (loc == dicsiz) {
fwrite_crc(&crc, dtext, dicsiz, outfile);
loc = 0;
}
}
-#ifdef DEBUG
- fprintf(fout, "\n");
-#endif
+ /*
+ if (dump_lzss) {
+ printf("\n");
+ }
+ */
}
}
if (loc != 0) {
test -d test-1 || mkdir test-1
mv test-[abc] test-1
-$lha x test-1.lzh
+$lha x test-1.lzh --debug=dumplzss > test-tmp-stdout
+ check $? $LINENO
+cat test-tmp-stdout
+cat <<EOF | diff test-tmp-stdout -
+
+0000 66(f)
+0001 6f(o)
+0002 6f(o)
+0003 0a(?)
+0004 <256 0>
+0260 <140 256>
+
+0000 62(b)
+0001 61(a)
+0002 72(r)
+0003 0a(?)
+0004 <256 0>
+0260 <140 256>
+
+0000 62(b)
+0001 61(a)
+0002 7a(z)
+0003 0a(?)
+0004 <256 0>
+0260 <140 256>
+EOF
check $? $LINENO
diff test-1/test-a test-a
check $? $LINENO