diff -Nru lha-1.14i/00readme.autoconf lha-1.14i-acc20050924p1/00readme.autoconf --- lha-1.14i/00readme.autoconf 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/00readme.autoconf 2006-10-10 16:27:51.000000000 +0000 @@ -0,0 +1,401 @@ +# $Id: 00readme.autoconf,v 1.27 2005/09/24 12:48:27 arai Exp $ +# -*- Mode: text ; Coding: euc-japan -*- + +autoconfiscated for LHa for UNIX version 1.14i + Koji Arai + +このファイルは LHa for UNIX version 1.14i を autoconf、automake 化した +(autoconfiscate と言うそうです。Jargon 参照)ときのメモです。 + +LHa for UNIX に関しては岡本継男さんのページ + +を参照してください。 + +・コンパイルの手順 + + コンパイルの手順は以下のようになります。 + + gzip -dc lha-114i.autoconf-xxxx.tar.gz | tar xvf - + cd lha-114i.autoconf-xxx + + sh ./configure + make + make check + make install + + MinGW 対応はα版です。ほとんどテストされていません(make check が成功 + する程度)。Cygwin 環境で MinGW 版を試すには + + sh ./configure CC='gcc -mno-cygwin' + --build=i686-pc-mingw32 + --with-tmp-file=no + + などとしてください。 + + ※ Cygwin や MinGW 等、Windows 環境では深いディレクトリでコンパイル + するとmake check が失敗する場合があります。これは長いパスの格納 + チェックをするときに、Windows のフルパス長の制限にひっかかるため + です。このような場合は、以下のように configure を浅めのディレクト + リで実行してください。 + + 例: + cd /tmp/build + sh ~/src/lha/configure .... + make + make check + make install + + autoconf/automake がインストールされている場合で、lha ソースや + configure.ac, Makefile.am をメンテナンスする場合は以下の手順になりま + す。autoconf/automake のバージョンはそれぞれ autoconf 2.5x, automake + 1.6.x 以降での利用を前提としています。 + + gzip -dc lha-114i.autoconf-xxxx.tar.gz | tar xvf - + cd lha-114i.autoconf-xxxx + + aclocal + automake -a + autoheader + autoconf + sh ./configure + make + make check + make install + +・マクロの置き換え + + オリジナルの LHa for UNIX 1.14i で使われていたマクロは autoconf 標準 + のマクロ名に置き換えられました。(olddoc/IFNAMES ファイルに詳細が書か + れています) + + IFNAMESファイルは、 + マクロ名 定義のあるファイル... コメント + という構成になっています。このファイルはautoconfと一緒に配布される + ifnamesコマンドの出力を元にしました。 + IFNAMESファイルの# で始まっている行は該当のマクロが置き換えられたり、 + configure コマンドのコマンドオプションで指定されるようになったことを + 示します。そのままの行はautoconfで判断する必要がないかまたは私が判断 + できないため、そのまま放置したことを示します。 + +・-lh6-, -lh7- メソッドのアーカイブ作成 + + オリジナルの LHa for UNIX 1.14i では、SUPPORT_LH7 の定義をせずにコン + パイルした場合、-lh6- および -lh7- メソッドのアーカイブを作成できま + せんでした。このことは別に構わないのですが SUPPORT_LH7 を定義すると + デフォルトで -lh7- メソッドのアーカイブ作成を強制されてしまいます。 + そこで、もう少し柔軟に lha 利用者がこれらを選択できるよう + SUPPORT_LH7 は常に定義するようにし、デフォルトで作成されるアーカイブ + のメソッド指定を configure オプションの --with-default-method=[567] + で指定できるようにしました。 + + このオプションの省略値は -lh5- です。つまりデフォルトでは -lh5- アー + カイブを作成します。(そして、上で述べた通り、lhaの o6 または o7 オプ + ションによりいつでも-lh6-、-lh7- アーカイブを作成でき、configure オ + プションによりデフォルトの挙動を変更することができます) + +・アーカイブ中の漢字ファイル名 + + オリジナルの LHa for UNIX 1.14i はアーカイブに格納するファイル名の漢 + 字コードに関して無頓着です。コンパイル時に MULTIBYTE_CHAR を定義した + ときでもアーカイブ中の Shift JIS ファイル名を EUC にすることもなく、 + EUC コードのまま(正確にはシステムの漢字コードのまま)アーカイブに格納 + したりします。 + + autoconf 版では、configure オプション --enable-multibyte-filename に + より漢字ファイル名が使用でき、アーカイブに格納されるファイル名の漢字 + コードを SJIS 固定として扱います。 + + --enable-multibyte-filename の引数(システムのファイル名の漢字コード + 指定)は、以下の通りです。 + + --enable-multibyte-filename=sjis + システムの漢字コードを SJIS として扱います。 + --enable-multibyte-filename=euc + システムの漢字コードを EUC として扱います。 + --enable-multibyte-filename=utf8 + システムの漢字コードを UTF-8 として扱います。 + 今のところ Mac OS X でだけこのオプションをサポートします。 + --enable-multibyte-filename=auto (または yes または引数なし) + システムの漢字コードを自動で判別します。自動といっても現状は、 + Cygwin, MinGW, HP-UX の場合に SJIS、Mac OS X の場合 UTF-8、 + それ以外を EUC とみなすだけです。 + --enable-multibyte-filename=no + --disable-multibyte-filename + ファイル名のマルチバイトサポートを無効にします。 + + デフォルトは、auto です。 + + lha のコマンドラインオプションにより、コンパイル時のデフォルト指定を + 変更することができます。このコマンドラインオプションは、GNU style の + long option (ダッシュ2つが先行するスタイル)で指定します。 + + --system-kanji-code=xxx + システムのファイル名の漢字コードを指定します。 + + --archive-kanji-code=xxx + アーカイブ内へ格納するときのファイル名のコードを指定し + ます。これは通常 SJIS 固定なので変更するべきではありま + せん。 + + xxx は sjis, euc, utf8, cap のいずれかです。cap は、samba などで使われる + コードで、漢字コードを ":" と 16 進文字で表現するコードです。 + + 例えば、 + + $ touch 漢字 + $ lha c foo.lzh 漢字 + $ lha l foo.lzh + + PERMISSION UID GID SIZE RATIO STAMP NAME + ---------- ----------- ------- ------ ------------ -------------------- + -rw-r--r-- 1000/1000 0 ****** Mar 23 21:23 漢字 + ---------- ----------- ------- ------ ------------ -------------------- + Total 1 file 0 ****** Mar 23 21:23 + + $ lha l --system-kanji-code=cap foo.lzh + + PERMISSION UID GID SIZE RATIO STAMP NAME + ---------- ----------- ------- ------ ------------ -------------------- + -rw-r--r-- 1000/1000 0 ****** Mar 23 21:23 :8a:bf:8e:9a + ---------- ----------- ------- ------ ------------ -------------------- + + などとなります。 + + Mac OS X 用の utf8 <-> sjis 変換は、2002/6 に坂井浩人さんに作成して + いただきました。ありがとうございます。 + +・標準入力からの展開ファイルの指定 + + オリジナルの LHa for UNIX 1.14i は、 + + echo foo.txt | lha x foo.lzh + find bar -name '*.[ch]' | lha c bar.lzh + + とすると、foo.lzh から foo.txt だけを展開したり、bar ディレクトリ配 + 下のファイルを bar.lzh に格納したりできます。つまり、標準入力から、 + 圧縮/展開ファイルを指定できる機能なのですが、いまいち使い道がないわ + りに邪魔な機能です(圧縮の例は、cpio 同様まあ使えるけど、このためのオ + プションを新設するのが良いと考えています) + + tty からの利用しか想定してないと思われますが、おそらく daemon から + lha を実行する場合などで意図しない動作をするでしょう。そういうわけで + 勝手ながらこの機能は削除しました。以下のような事ができない Windows + 環境では意味のある機能だったかもしれませんが + + lha x bar.lzh `echo foo.txt` + + 残念ながら MinGW で isatty() がうまく動作しませんでしたから Windows + では使えないのでした。 + + オリジナルの仕様を復活させたい場合は、lharc.c の 360行目付近の #if 0 + を #if 1 にしてください。 + +・拡張ヘッダ(ユーザ名/グループ名)のサポート + + ユーザ名、グループ名の拡張ヘッダ(0x52, 0x53)を作成できるようにしまし + た(デフォルトはoff)。詳細は header.doc.euc を参照してください。展開 + と一覧表示のときにヘッダにこの情報があれば ID に優先してこの情報が利 + 用されます。作成は configure オプション --enable-user-name-header を + 指定して build した場合に有効になります。 + +・バックアップファイル作成の抑止 + + オリジナル LHa for UNIX 1.14i では、アーカイブにファイルを追加したと + きやアーカイブからファイルを削除したときに、元のアーカイブを .bak と + いう拡張子で保存します。この挙動は煩わしく感じたので autoconf 版では + バックアップファイルを作成しないようにしました。この autoconf 版パッ + チが信用できないような人は configure オプション --enable-backup-archive + を指定して build してください(ぜひそうするべきです:p)。オリジナルと + 同じ挙動になります。 + +・header.c の書き換え + + header.c は作り変えられました。上記に示した変更に加えてオリジナル + LHa for UNIX 1.14i から以下の不具合が修正されました。 + + o level 2 header のバグ + + total header size (アーカイブヘッダの先頭 2 byte) が 256 以上 + であるアーカイブを正しく読むことができませんでした。また、total + header size がちょうど 256 になるような不正なアーカイブを作成し + ていました。LHA のヘッダ仕様ではヘッダ先頭が 0 であればアーカイ + ブの終端とみなすため total header size を 256 の倍数にできません。 + (256 などは little-endian で 0x00 0x01 となるため、先頭が 0 にな + ります。) + + 読み込み時にヘッダの CRC check を行うようにしました。 + + o level 1 header のバグ + + ファイル名に対して拡張ヘッダを使用することがないため、230 バイト + を越えるファイル名(ディレクトリを含まない)をアーカイブに書くとアー + カイブヘッダのサイズ制限を越えた不正なアーカイブが作成されていま + した。 + + o level 0 header のバグ + + 長いパス名(ディレクトリも含む)に対してアーカイブヘッダのサイズ制 + 限を越えた不正なアーカイブが作成されていました(実際には、オリジ + ナルは level 0 header にディレクトリの情報を一切書かないのでこの + 制限はやはりファイル名長だけが対象になります)。autoconf 版では制 + 限を越えたパス名は warning メッセージを出力し、パス名の後ろを + 切り詰めます。(level 0 header は使用するべきではありません) + + 空の(ディレクトリ名情報のない) -lhd- ヘッダが作成されていました。 + + $ mkdir foo + $ lha c0 foo.lzh foo + $ lha v foo.lzh + PERMSSN UID GID PACKED SIZE RATIO METHOD CRC STAMP NAME + ---------- ----------- ------- ------- ------ ---------- ------------ ------------- + drwxrwxr-x 1000/1000 0 0 ****** -lhd- 0000 Jul 29 00:18 + ---------- ----------- ------- ------- ------ ---------- ------------ ------------- + Total 1 file 0 0 ****** Jul 29 00:18 + + なお、level 0 header で -lhd- method は使えないという説がある + + + + のですが、吉崎栄泰氏のオリジナル LHA (DOS/Windows版) (ver 2.55, + 2.67) などは -lhd- method を level 0 header で作成します。 + + o g オプションを付けたときの level 0, 1, 2 header + + g オプションは、アーカイブ作成のとき UNIX 固有の情報をアーカイブ + に作成するのを抑止すると man にはあるのですが、実際にはディレク + トリ情報まで抑止されていました。 + + $ mkdir foo + $ touch foo/bar + $ lha cg1 foo.lzh foo + $ lha foo.lzh + PERMSSN UID GID SIZE RATIO STAMP NAME + ---------- ----------- ------- ------ ------------ -------------------- + [generic] 0 ****** Jul 29 00:02 bar + ---------- ----------- ------- ------ ------------ -------------------- + Total 1 file 0 ****** Jul 29 00:02 + + autoconf 版では上記は foo/bar になります。(オリジナルはわざとそ + うしていたのかもしれませんが、そうする理由はないと判断しました) + g オプションで -lhd- の作成が抑止されるのは同じです。 + + なお、g オプションとヘッダレベルの指定を同時に行うときは上記のよ + うに g オプションを先に指定する必要があります。lha c1g など g オ + プションを後に指定すると level 0 header が作成されます(このオリ + ジナル仕様はちょっとわかりにくいです)。 + +・level 3 header + + 世の中には、level 3 header というものが存在するようですが、まだ仕様 + としてfix されてないようなので*読み込みのみ*サポートしました。追加の + 拡張ヘッダは未対応です。(特に対応すべきヘッダが見当たらなかった) + largefile 対応する場合は、この level 3 header をサポートした方が良さ + そうです。 + +・ヘッダのダンプ + + まったくのおまけ機能としてヘッダのダンプ機能を追加しました。これは完 + 全にデバッグ用です。 + lha vvv foo.lzh + とすると、アーカイブの内容一覧にまざってダンプが出力されます。 + +・ヘッダレベル + + アーカイブを作成するときのデフォルトのヘッダレベルを 2 にしました。 + (オリジナルの LHa for UNIX 1.14i ではレベル 1 がデフォルト) + +・拡張ヘッダ + + 拡張ヘッダ Windows timestamp (0x41) を解釈するようにしました。(level + 1 header のみ)。level 2 以上では、基本ヘッダに time_t の情報があるの + で、拡張ヘッダの方は無視します。 + level 1 header のアーカイブに対して、Windows timestamp 拡張ヘッダ + を出力する LHA アーカイバが存在するかどうかは未確認です。あまり、 + 役に立たない修正だった気がしますがせっかく作ったので残してます:-) + +・-x オプション + + 圧縮対象のファイルから除外されるパターンを指定する -x オプションを追 + 加しました。これに伴い、 + + lha c -x '*.o' -x='*.a' -x'*.c' src.lzh src + + といった指定ができるよう、オプション解析部は変更されました。 + 本バージョンの usage は以下のようになります。 + + usage: lha [-][] [- ...] archive_file [file...] + +・Cygwin での解凍 + + MS-DOS タイプなど permission の情報を持たないアーカイブを Cygwin で + 解凍する場合は、0777 & ~umask で展開するようにしました。これは、.exe + や .dll に実行属性を付けるためです。 + +・large files 対応 + + システムが対応していれば、2G over な large file を扱うことができます + (configure が適当なコンパイラオプションを指定してくれます)、もしこれ + を「無効」にしたければ、 + + ./configure --disable-largefile + + HP-UX 11.0 で large files に対応するには、以下のようにします。 + + ./configure --with-tmp-file=no CC="cc -Ae +DA2.0W" \ + ac_cv_have_mktime=yes \ + ac_cv_func_mktime=yes + + --with-tmp-file=no は、中間ファイルを出力先と同じディレクトリに + 作成します。テンポラリディレクトリが 2G over をサポートしていない + 場合を考慮しています。 + + (largefiles 対応とは関係ありませんが ac_cv_*=yes は、HP-UX ではなぜ + か mktime の判定に失敗するため強制的に mktime を使うようにしています) + + なお、level 0, 1, 2 ヘッダの仕様上 4G 未満のファイルしか書庫に格納で + きません。 + +・壊れたアーカイブの展開 (--extract-broken-archive) + + LHa for UNIX (autoconf版)は、バージョン 1.14i-ac20030713 (slide.c + revision 1.20) より壊れたアーカイブを作成してしまう致命的なバグがあ + りました。(このようなアーカイブが作成される現象に遭遇することはほと + んどないかも知れません。ただ、バグのある LHa for UNIX では正常に展開 + できてしまうので、壊れたアーカイブであることに気が付いてないだけかも + しれません) + + この壊れたアーカイブは他の正常な LHA (あるいは現在の LHa for UNIX) + では展開時に CRC エラーが発生してしまいます。 + + 現在のバージョンでは、 + + lha x --extract-broken-archive broken.lzh + + とオプション --extract-broken-archive を指定することで、このバグによ + り作成された壊れたアーカイブを強制的に展開することができます。CRC エ + ラーが発生するアーカイブを見付けたときには(そして、それが過去の LHa + for UNIX (autoconf版)で作成されたものである場合には)このオプションを + 試してみてください。 + +・再配布について + + 私は、src/header.c にはもはや元の lha 1.14i にあったコードは含まれて + いないと考えています。src/header.c は私の著作物です。ただし、lha + 1.14i にあったコードが参考になったことは事実です。敬意を表する意味で + も src/header.c にあった歴代の改変者の名前はそのまま残しています。 + + これの意図する所は、man/lha.man にある再配布条件を src/header.c に適 + 用しないことです。私は、より自由で使いやすいコードを LHa for UNIX の + 構成物にしようと考えています。src/header.c に適用するライセンスはま + だ未定です(なので、現状は LHa for UNIX の再配布条件が適用されると考 + えてください)。 + + ライセンス候補(メモ): + + + + 現在のところ、src/vsnprintf.c, src/fnmatch.[ch], src/getopt_long.[ch] + を除くその他の構成物や LHa for UNIX 全体には man/lha.man に含まれる + 条項が適用されます。(vsnprintf.c, fnmatch.c を利用するように make し + た LHa for UNIX には、各ソースに記述された条項も適用されることに注意 + してください) diff -Nru lha-1.14i/aclocal.m4 lha-1.14i-acc20050924p1/aclocal.m4 --- lha-1.14i/aclocal.m4 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/aclocal.m4 2006-10-10 16:50:54.000000000 +0000 @@ -0,0 +1,887 @@ +# generated automatically by aclocal 1.9.6 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"]) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION so it can be traced. +# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], + [AM_AUTOMAKE_VERSION([1.9.6])]) + +# AM_AUX_DIR_EXPAND -*- Autoconf -*- + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[dnl Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50])dnl +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 7 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE]) +AC_SUBST([$1_FALSE]) +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 8 + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "GCJ", or "OBJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH]) +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +#serial 3 + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # So let's grep whole file. + if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) +]) + +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 8 + +# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. +AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) + +# Do all the work for Automake. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 12 + +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.58])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +# test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AM_PROG_INSTALL_SH +AM_PROG_INSTALL_STRIP +AC_REQUIRE([AM_PROG_MKDIR_P])dnl +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +]) +]) + + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $1 | $1:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +install_sh=${install_sh-"$am_aux_dir/install-sh"} +AC_SUBST(install_sh)]) + +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 3 + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi +AC_SUBST([am__include]) +AC_SUBST([am__quote]) +AC_MSG_RESULT([$_am_result]) +rm -f confinc confmf +]) + +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_MKDIR_P +# --------------- +# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise. +# +# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories +# created by `make install' are always world readable, even if the +# installer happens to have an overly restrictive umask (e.g. 077). +# This was a mistake. There are at least two reasons why we must not +# use `-m 0755': +# - it causes special bits like SGID to be ignored, +# - it may be too restrictive (some setups expect 775 directories). +# +# Do not use -m 0755 and let people choose whatever they expect by +# setting umask. +# +# We cannot accept any implementation of `mkdir' that recognizes `-p'. +# Some implementations (such as Solaris 8's) are not thread-safe: if a +# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c' +# concurrently, both version can detect that a/ is missing, but only +# one can create it and the other will error out. Consequently we +# restrict ourselves to GNU make (using the --version option ensures +# this.) +AC_DEFUN([AM_PROG_MKDIR_P], +[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + # We used to keeping the `.' as first argument, in order to + # allow $(mkdir_p) to be used without argument. As in + # $(mkdir_p) $(somedir) + # where $(somedir) is conditionally defined. However this is wrong + # for two reasons: + # 1. if the package is installed by a user who cannot write `.' + # make install will fail, + # 2. the above comment should most certainly read + # $(mkdir_p) $(DESTDIR)$(somedir) + # so it does not work when $(somedir) is undefined and + # $(DESTDIR) is not. + # To support the latter case, we have to write + # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), + # so the `.' trick is pointless. + mkdir_p='mkdir -p --' +else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + for d in ./-p ./--version; + do + test -d $d && rmdir $d + done + # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. + if test -f "$ac_aux_dir/mkinstalldirs"; then + mkdir_p='$(mkinstalldirs)' + else + mkdir_p='$(install_sh) -d' + fi +fi +AC_SUBST([mkdir_p])]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 3 + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# ------------------------------ +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) + +# _AM_SET_OPTIONS(OPTIONS) +# ---------------------------------- +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# Copyright (C) 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +AC_DEFUN([AM_C_PROTOTYPES], +[AC_REQUIRE([AC_C_PROTOTYPES]) +if test "$ac_cv_prog_cc_stdc" != no; then + U= ANSI2KNR= +else + U=_ ANSI2KNR=./ansi2knr +fi +# Ensure some checks needed by ansi2knr itself. +AC_REQUIRE([AC_HEADER_STDC]) +AC_CHECK_HEADERS(string.h) +AC_SUBST(U)dnl +AC_SUBST(ANSI2KNR)dnl +]) + +AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of `v7', `ustar', or `pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. +AM_MISSING_PROG([AMTAR], [tar]) +m4_if([$1], [v7], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi +done +rm -rf conftest.dir + +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + diff -Nru lha-1.14i/change-114e.txt lha-1.14i-acc20050924p1/change-114e.txt --- lha-1.14i/change-114e.txt 2000-12-15 12:13:16.000000000 +0000 +++ lha-1.14i-acc20050924p1/change-114e.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,203 +0,0 @@ - -■■■■■■■■■■ 報告 ■■■■■■■■■■ -(1) - -ヘッダ-lhd-を持つ書庫を展開できない。 - -■原因 -directoryの展開はunixのファイル属性を見て -行うようになっていました。 -したがって、windows等のUNIXではないOSで -展開しようとすると、ファイル属性が無いため -directoryを示したヘッダを認識できなかった -ためだと思われます。 - -■対処 -ヘッダ-lhd-をみて展開するようにしました。 -1999.4.30 -■確認 -済 - -■■■■■■■■■■ 報告 ■■■■■■■■■■ -(2) - -Windowsで作成した自己展開実行ファイルの書庫を -展開できない。 - -■原因 -LHa for unixでは、.exeのついたファイルは -ms-dos版のlhaで作成されたsfxファイルであると認識 -するため。また、レベル2のヘッダに対応していなか -ったため。 - -■対処 1999.5.28 -圧縮されたファイルの前に付加されている -サフィックスコードをms-dos版lhaで作成された -サイズよりも多く読むようにした。 -レベル2ヘッダにも対応した。 - -■確認 -済 - - -■■■■■■■■■■ 報告 ■■■■■■■■■■ -(3) - -AIX 3.2でcgiを使ってlhaを起動したときに、正常終了 -しない不都合。lhaのe,fコマンドを利用したときのみ -この現象が発生する。main()関数のexit(0)まで処理が -終了しているが、lhaは終了しない。 - -■現象の確認 -試みたが確認できていない。 -■対処 -未 -■確認 -未 - -■■■■■■■■■■ 報告 ■■■■■■■■■■ -(4) - -IBM RS/6000-25T AIX Version 3.2.5(/bin/cc) -SWITCHESに-DSYSV_SYSTEM_DIR -BSD_INCLUDES -DAIXを追加 -MACHINEを-DSYSTIME_HAS_NO_TM -DTZSETに変更 - -slide.c内のtextと、lha.hのEXTERN unsigned char *textが -衝突している。 - -■説明 -slide.c内でローカルに定義されている*textは -グローバルに定義されている*textを利用しても -問題がない。 - -■対処 -slide.cでのローカル定義のtextをコメントアウトした。 - -■確認 -未 - -■■■■■■■■■■ 報告 ■■■■■■■■■■ -(5) - -Makefile 5行目の年が2995になっている。 -■対処 -1995に直した - -■■■■■■■■■■ 報告 ■■■■■■■■■■ -(6) - -slide.cでstatic unsigned char *textとなっていて、 -src/larc.cでも使っている。 -使い方が変である。 -(4)と関係ありと思われる。 - -■対処 -(4)の対処で大丈夫では? - - -■■■■■■■■■■ 報告 ■■■■■■■■■■ -(7) - -src/INSTALLが無い - -■対処 -とりあえず、src/INSTALLが存在するという記述を -無くした。 - - -■■■■■■■■■■ 報告 ■■■■■■■■■■ -(8) -EWS4800/360PXに関係するSWITCHESの -例がない。 - -■対処 -探します。 - -■■■■■■■■■■ 報告 ■■■■■■■■■■ -(9) - -Windows版lhaツールで作成されたレベル0の -アーカイブされたファイルが認識できない。 -拡張領域部分が1バイトのみ。 - -■原因 -レベル0の拡張可能部分の認識方法が間違えている。 -#CRCが含まれないレベル1の書庫がちょっと自身無し -■対処 -新しいロジックに入れ換えた。 - -■確認 -済 - -■■■■■■■■■■ 報告 ■■■■■■■■■■ -(10) - -標準入力がtty以外にリダイレクトされていて、 -かつ展開ファイル指定が無いときは、標準入力から -展開するファイルを受け取ることになっている。 -(展開動作のときのみ) - -IBMの新島智之さん(poortom@apmisc.ibm.co.jp)から -の情報です。 - -■tips -コマンドラインと同様の動作を期待するときは明示的に、 - lha -ex hogehoge.lzh < /dev/null -とすると良い様です。 - - -■■■■■■■■■■ 報告 ■■■■■■■■■■ -(11) - -閏年の計算方法が不十分で、2000年3月以降の -日付のファイルを展開すると1日ずれる恐れがある。 - -■対処 -2000年も閏年と扱うようにした。 -(奈良女子大学の新出氏のパッチを利用しました) - -■確認 -未 - -■■■■■■■■■■ 報告 ■■■■■■■■■■ -(12) -ファイルを一つだけ含むファイルから一つファイルを -削除すると、1バイトのゴミを含んだアーカイブファイル -ができてしまう。 - -■対処 -lhadd.cのcmd_delete()関数内のbuild_backup_file()関数呼び出し後に - -if(!noexec && new_archive_size <= 1){ - unlink(temporary_name); - printf("New archive file \"%s\" is not created because it would be empty.\n", new_archive_name); - return; -} - -を追加(修正)した。 - -■確認 -未 - -■■■■■■■■■■ 報告 ■■■■■■■■■■ -(13) - -シンボリックリンクファイルに対して時刻の修正、 -ファイル属性の修正をすると、シンボリックリンク -ではなくて、リンク先のファイルが修正されて -しまう。 - -■対処 -lhext.cのadjust_info()関数内で時刻・属性を修正している -箇所に、シンボリックリンクの場合は修正を行わない様な -条件をつけた。 - -■確認 -未 - -■■■■■■■■■■ 報告 ■■■■■■■■■■ -(14) - -■変更 -SUPPORT_LH6オプションをつけないと -圧縮method -lh6-を選択できないようにした。 diff -Nru lha-1.14i/change-114g.txt lha-1.14i-acc20050924p1/change-114g.txt --- lha-1.14i/change-114g.txt 2000-12-15 12:13:16.000000000 +0000 +++ lha-1.14i-acc20050924p1/change-114g.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -lha for unix ver 1.14gで対処 - -lha for unix ver 1.14f bugs - -■■■■■■■■■■ 報告 ■■■■■■■■■■ -(23) - -■問題 -chown,lchownの使い方が間違っていた。 -lchownのあるシステムでは、symbolic link先の -ファイルのownerを変更しようとしていた。 - -■原因 -chown()はlchwon()があるシステムと無いシステムで -挙動が異なる。展開したファイルがsymbolic link -のファイルである場合、下記のようにしなくては -いけなかったが、逆にしていた。 - - lchown()があるシステム:lchown()を使う - lchown()がないシステム:chown()を使う - -■対処 -原因はlchown()かchown()を選択するかの条件が逆に -なっていたので、lhext.cの条件を逆にした。 - -■対処確認 - -■■■■■■■■■■ 報告 ■■■■■■■■■■ -(24) - -■場所 -#define SJC_SECOND_P -のunsigned charのスペルを間違えていた。 - -■対処 -ungigned→unsignedに直した。 - -■■■■■■■■■■ 報告 ■■■■■■■■■■ -(25) - -■問題 -Header Level 2で作成したファイルの場合に、 -ファイルの長さを正常に計算していなかった。 - -■対処 -level2ヘッダでfilenameを取得している箇所に - name_length = header_size - 3; -を追加した。 - -■■■■■■■■■■ 不都合 ■■■■■■■■■■ -(26) - -■場所 -Header Level 2で作成した書庫のヘッダの読み込み時に -正常にヘッダ長の計算が行われていなかった。 -下位バイトしか計算していなかった。 - -■対処 -上位バイトもヘッダ長に含めて計算することにした。 - -■■■■■■■■■■ 報告 ■■■■■■■■■■ -(27) - -■問題 -level2ヘッダのappendがうまくいかず、エラーが -発生する。 - -■原因 -Header Level 2で作成した書庫のヘッダの読み込み時に -正常にヘッダ長の計算が行われていなかった。 -書庫への追加の際に、コピーするサイズの計算が -level 0,1と異なることを考慮していなかった。 - -■対処 -level0,1とlevel2のヘッダ長計算の箇所を場合わけした。 - -■■■■■■■■■■ 報告 ■■■■■■■■■■ -(28) - -■問題 -書庫内のsymbolic linkのファイルと、 -同じ名前のsymbolic linkファイルのappendが -うまくいかず、重なってしまう。 - -■原因 -ファイル名比較で、symbolic linkファイル名どうしの -比較アルゴリズムが間違えていた。 - -■対処 -正常に計算できるように修正した。 - -■■■■■■■■■■ 追加 ■■■■■■■■■■ -(29) - -■機能 --lh7-の書庫を生成/展開ができる機能を追加した。 - -■その他 -Makefileで-DSUPPORT_LH7のオプションを追加して -コンパイルすることで-lh7-の書庫が操作できるように -なる。 - - - diff -Nru lha-1.14i/change-114h.txt lha-1.14i-acc20050924p1/change-114h.txt --- lha-1.14i/change-114h.txt 2000-12-15 12:13:16.000000000 +0000 +++ lha-1.14i-acc20050924p1/change-114h.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -lha for unix ver 1.14hで対処 - -lha for unix ver 1.14g bugs - -■■■■■■■■■■ 追加 ■■■■■■■■■■ -(30) - -■問題 -壊れた-lh7-の書庫を生成してしまう。 -展開時にBad table (5)が出て、展開に失敗する。 - -■原因 -huf.cに-lh7-に対応していない箇所があった。 - - diff -Nru lha-1.14i/change-114i.txt lha-1.14i-acc20050924p1/change-114i.txt --- lha-1.14i/change-114i.txt 2000-10-05 17:53:51.000000000 +0000 +++ lha-1.14i-acc20050924p1/change-114i.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -lha for unix ver 1.14iで対処 - -lha for unix ver 1.14h bugs - -■■■■■■■■■■ 不都合 ■■■■■■■■■■ -(31) - -■問題 -macで生成した書庫(OSTYPEがMAC)のディレクトリの -区切りを正しく認識していなかった。 - -Lha failed to convert a delimitor used at Macintiosh. - -■原因 -一度拡張ヘッダのディレクトリを取得したときに -0xffから/への変換を行ったあと、ディレクトリと -ファイルネームを結合した文字列に対して、 -mac-unixの変換(:を/に、:を/に)をしていたため、 -区切りが:に変わっていた。 - -■対処 -変換後のディレクトリ名に対しては -mac-unix変換を行わないことにした。 - -■■■■■■■■■■ 追加 ■■■■■■■■■■ - -■内容 -OSがMSDOSのときは無差別にファイル名を小文字に -していたが、windowsでは小文字と大文字の混在が -あり得るため、この対処を行う。 - -Lha always converted upper-case into lower-case. -Modified that lha don't convert case when using -'g' option. - -■修正点 -展開時にオプションgを指定すると、小文字の変換は -行わないようにするオプションを追加した。 - ---- 以上 -(誰か英語直して〜) - diff -Nru lha-1.14i/ChangeLog lha-1.14i-acc20050924p1/ChangeLog --- lha-1.14i/ChangeLog 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/ChangeLog 2006-10-16 14:47:59.000000000 +0000 @@ -0,0 +1,1881 @@ +2006-10-16 Koji Arai + + * released. + +2006-10-11 Koji Arai + + * configure.ac: updated version and my mail address. + +2006-10-09 Koji Arai + + * src/lha_macro.h (MIN): newly added a macro for below. + + * maketbl.c (make_table): applied the security patch for the + CVE-2006-4335 and CVE-2006-4337. + + * huf.c (read_pt_len, read_c_len, decode_c_st1, decode_p_st1): + applied the security patch for the CVE-2006-4338. + +2005-09-24 Koji Arai + + * released. + + * configure.ac: updated version and my mail address. + + * Hacking_of_LHa: updated. (2003-02-23 edition) + + * 00readme.autoconf: updated. + +2005-06-08 Koji Arai + + * configure.ac: updated version. + + * src/lharc.c (parse_suboption): fixed a bug, when the + --system-kanji-code option specified, the --archive-kanji-code + option was infected. + +2005-05-08 Koji Arai + + * configure.ac: updated version. + + * src/lharc.c (print_usage): updated. + + * src/lhadd.c, src/header.c (remove_leading_dots): move to + header.c for readlink(). + + * src/lhadd.c (add_one): symbolic link indication was contrary. + ( not "realname -> linkname" but "linkname -> realname" ) + (delete): ditto. + + * src/lhext.c (extract_one): ditto. + + * src/lhlist.c (list_one): ditto. + + * tests/lha-test14: ditto. + + * src/lhadd.c (remove_leading_dots): newly added. + + * src/lhadd.c (append_it): remove leading relative path from + archive. + + * src/lhext.c (is_directory_traversal): should return true when + just ".." was found. + +2004-10-02 Koji Arai + + * src/lharc.c (print_tiny_usage): added long option helps. + + * src/prototypes.h: updated. + + * src/lharc.c: should accept a single option --help and --version. + +2004-09-29 Koji Arai + + * src/lharc.c (parse_option, parse_suboption): use getopt_long(). + + * src/Makefile.am: added getopt_long.c and getopt_long.h. + + * src/getopt_long.c, src/getopt_long.h: newly added. + +2004-09-29 Koji Arai + + * released. + + * 00readme.autoconf: note for builds on MS-Windows. + + * configure.ac: updated version. + + * Makefile.am: added Hacking_of_LHa in EXTRA_DIST. + + * Hacking_of_LHa: renamed (typo). + +2004-09-27 Koji Arai + + * configure.ac: updated version. + + * src/prototypes.h (str_safe_copy): newly added. + (build_standard_archive_name, build_backup_file): + added argument the size for build_standard_archive_name() and + build_backup_file(). + + * src/header.c (init_header): use str_safe_copy() instead of strcpy(). + + * src/lhadd.c (build_backup_file, cmd_add, cmd_delete): + added argument the size for build_standard_archive_name() and + build_backup_file(). + + * src/lhext.c (make_parent_path): use str_safe_copy() instead of strcpy(). + (extract_one): ditto. + + * src/lharc.c (find_files): use str_safe_copy() instead of strcpy(). + (build_temporary_name): ditto. + (modify_filename_extention): ditto. + (build_backup_name): ditto. + (build_standard_archive_name): ditto. + + * src/util.c (str_safe_copy): newly added. + +2004-09-26 Koji Arai + + * src/header.c: fixed typo. + +2004-09-18 Koji Arai + + * configure.ac: updated version. + + * 00readme.autoconf: added a description about + `--extract-broken-archive' option. + + * src/lharc.c (init_variable, parse_option): added an option + `--extract-broken-archive' to extract broken archive. + + * src/lha.h (extract_broken_archive): ditto. + + * src/slide.c (encode, decode): fixed a *FATAL* bug which make a + broken archive. + +2004-05-08 Koji Arai + + * configure.ac: updated version. + + * src/prototypes.h: updated. + + * src/lhext.c (extract_one, is_directory_traversal): applied a + security patch (CAN-2004-0235: directory traversal problems) + + * src/lharc.c (print_usage): updated. + +2003-12-18 Koji Arai + + * src/header.c (wintime_to_unix_stamp): no use 64bit constant to + avoid the warning `integer constant is too large for "long" type' + on GCC. however, for portability, no use the unsigned long long + suffix "ULL". + +2003-12-13 Koji Arai + + * configure.ac: updated version. + + * src/lhext.c (extract_one, cmd_extract): preserve directory + timestamp. Thanks Akihiro Iriyama. + + * src/lhext.c (add_dirinfo, adjust_dirinfo): newly added. + +2003-09-28 Koji Arai + + * Makefile.am (SUBDIRS): reordered to avoid useless re-compilation. + +2003-09-21 Koji Arai + + * released. + + * configure.ac: updated version. + +2003-08-18 Koji Arai + + * 00readme.autoconf: fixed. + + * configure.ac: use AC_SYS_LARGEFILE for largefile support. + + * config.h.in: ditto. + + * src/prototypes.h: updated. + +2003-07-29 Koji Arai + + * tests/Makefile.am (EXTRA_DIST): lha-test1 was missed. + + * tests/lha-test13: should set LANG=C for `tr'. + +2003-07-28 Koji Arai + + * tests/lha-test.in: filename should be contained in last error + information. + +2003-07-27 Koji Arai + + * tests/lha-test2: no need to set $FILENAME. + * tests/lha-test3: ditto. + * tests/lha-test4: ditto. + * tests/lha-test5: ditto. + * tests/lha-test6: ditto. + * tests/lha-test7: ditto. + * tests/lha-test8: ditto. + * tests/lha-test9: ditto. + * tests/lha-test10: ditto. + * tests/lha-test11: ditto. + * tests/lha-test12: ditto. + * tests/lha-test13: ditto. + * tests/lha-test14: ditto. + * tests/lha-test15: ditto. + + * tests/lha-test1: newly added. + + * tests/lha-test.in: improved. + + * src/prototypes.h: updated. + + * src/lha.h (exit): defined as lha_exit(). + + * src/lharc.c (init_variable): discard a variable + `remove_temporary_at_error'. + (fatal_error): ditto. + (cleanup): newly added. + (interrupt): call cleanup(). + (lha_exit): newly added; cleanup temporary files always. + + * src/lhadd.c (add_one): discard a variable + `remove_temporary_at_error'. + + * src/indicator.c (start_indicator): refined. + + * src/lharc.c (parse_option): fixed typo. + + * src/indicator.c (carriage_return): newly added; print CR on tty only. + (start_indicator): call above. + (finish_indicator): ditto. + (finish_indicator2): ditto. + + * src/lharc.c (print_usage): newly added. + (parse_option): strictly checking command line arguments. + (main): ditto. + +2003-07-26 Koji Arai + + * tests/lha-test13: use `tr' instead of `printf` for printing 8 bit + characters. + +2003-07-25 Koji Arai + + * tests/lha-test14: `test -e' is unavailable on some systems. + +2003-07-22 Koji Arai + + * tests/lha-test.in: should exit with status in trap. + + * src/shuf.c (decode_start_st0): wrong value was assigned. + + * src/lha.h: discard `prof' variable. + + * src/lharc.c (init_variable): discard `prof' variable. + (parse_option): discard undocumented `p' option. + (main): ditto. + + * src/append.c (encode_lzhuf): hate global variable. + + * src/extract.c (decode_lzhuf): ditto. + + * src/lha.h: ditto. + +2003-07-21 Koji Arai + + * configure.ac: updated version. + + * 00readme.autoconf: described largefiles. + + * src/header.c (get_header): avoid valgrind warning, `Source and + destination overlap in strncpy()'. + + * src/lharc.c (find_files): refined. + + * tests/lha-test.in: should exit in trap. + + * src/lharc.c (find_files): uninitialized variable was caught by + Valgrind. + + * src/prototypes.h: updated. + + * src/append.c (encode_lzhuf): set actual copied size. + + * src/util.c (encode_stored_crc): use size_t instead of long. + + * src/lhadd.c (temporary_to_new_archive_file): ditto. + (cmd_add): ditto. + (cmd_delete): ditto. + + * src/lhadd.c (add_one): fixed a comment. + + * src/indicator.c (MAX_INDICATOR_COUNT): changed to fit for the 80 + column screen. + + * src/extract.c (decode_lzhuf): refined. + + * src/prototypes.h: updated. + + * src/cproto.sh: added `indicator.c'. + + * src/Makefile.am: ditto. + + * src/indicator.c: separated from append.c. + + * src/append.c: ditto. + + * src/lha.h: ditto. + + * src/lha_macro.h: ditto. + +2003-07-20 Koji Arai + + * configure.ac: updated version. + + * src/Makefile.am (EXTRA_DIST): fnmatch.h was missed. + + * src/lha.h (fseeko, ftello): these macros had no effect. + +2003-07-19 Koji Arai + + * src/maketree.c (make_len): discard debug print. + + * configure.ac: updated version. + + * src/prototypes.h: updated. + + * config.h.in: updated. + + * configure.ac: check declaration of `basename'. + + * src/cproto.sh: ditto. + + * src/util.c (encode_stored_crc): use size_t. + + * src/lha.h (struct LzHeader): use size_t for the members + `packed_size' and `original_size'. + +2003-07-13 Koji Arai + + * configure.ac: updated version. + + * src/prototypes.h: updated. + + * src/append.c (encode_lzhuf): use size_t and off_t instead of long. + (start_indicator): ditto. + + * src/extract.c (decode_lzhuf): ditto. + + * src/lha.h (struct interfacing): ditto. + + * src/lhadd.c (add_one): ditto. + (find_update_files): ditto. + (delete): ditto. + + * src/lhext.c (cmd_extract): ditto. + + * src/util.c (copyfile): ditto. + + * src/lhlist.c (print_size): use "%7lu" format string instead of + "%7ld" for large files. + + * src/slide.c: refined. + +2003-07-11 Koji Arai + + * src/lharc.c (cleaning_files): should print errno. + +2003-05-23 Koji Arai + + * configure.ac: use fseeko(), ftello() instead of fseek(), ftell(). + + * config.h.in: ditto. + + * src/lha.h, src/lhlist.c, src/lhext.c, src/lharc.c: ditto. + + * src/lhadd.c, src/header.c: ditto. + +2003-05-10 Koji Arai + + * configure.ac: updated version. + + * src/lhext.c (inquire_extract): warning if stdin is not tty, + because you cannot reply from stdin. + (extract_one): return actual read size from archive. + (cmd_extract): fix a bug: skip correct size when error occurred. + + * tests/lha-test5: added tests for above. + + * src/lha.h (struct interfacing): added a member `read_size'. + + * src/extract.c (decode_lzhuf): added an argument `pointer of + read_size'. + + * src/prototypes.h: ditto. + + * src/slide.c (decode): set actual read size to interface->read_size. + +2003-04-14 Koji Arai + + * src/cproto.sh: The cproto 4.7a supports some gcc-specific keywords. + +2003-03-24 Koji Arai + + * configure.ac: updated version. + + * src/prototypes.h: updated. + +2003-03-23 Koji Arai + + * src/header.c (convert_filename): support Samba CAP code (experimental). + (hex2int, int2hex, cap_to_sjis, sjis_to_cap): added for above. + + * src/lha_macro.h (CODE_CAP): ditto. + + * src/lharc.c (parse_option): added new command line options, + --system-kanji-code=xxx and --archive-kanji-code=xxx (experimental). + + * 00readme.autoconf: described above features. + +2003-03-22 Koji Arai + + * src/lharc.c (init_variable): do not use HEADER_LEVELx macros. + (parse_option): ditto. + + * src/header.c (write_header): ditto. + + * src/lha_macro.h (HEADER_LEVEL0, HEADER_LEVEL1, HEADER_LEVEL2, MATCHBIT): ditto. + + * src/huf.c (encode_start_st1): do not use assert(). + (decode_start_st1): ditto. + +2003-03-12 Koji Arai + + * src/header.c (wintime_to_unix_stamp): should cast to unsigned type. + +2003-03-03 Koji Arai + + * src/prototypes.h: updated. + + * src/cproto.sh: improved. + +2003-02-24 Koji Arai + + * src/prototypes.h: updated. + + * src/maketree.c: hate global variables. + + * src/lha_macro.h: refined. + + * src/huf.c: refined. + + * src/util.c (strdup): defined more properly. + (memset): ditto. + + * prototypes.h: ditto. + + * cproto.sh: ditto. + +2003-02-23 Koji Arai + + * src/cproto.sh: improved. + + * src/prototypes.h: updated. + + * src/util.c: `strucmp()' was replaced by `strcasecmp()'. + + * src/util.c (archive_is_msdos_sfx1): ditto. + + * src/lharc.c (open_old_archive): ditto. + + * src/lha.h: ditto. + + * src/util.c: discard `rename()', `mkdir()' and `rmdir()'. + + * configure.ac: ditto. + + * config.h.in: ditto. + + * src/header.c: added credit. + no longer use `ftime()', `tzset()', `localtime()' and `gettimeofday()'. + +2003-02-17 Koji Arai + + * configure.ac: updated version. + + * src/fnmatch.h: no need to include . it does not + exist on MinGW. + +2003-02-14 Koji Arai + + * src/lharc.c (find_files): `goto' requires expression after label. + + * src/lhadd.c (cmd_add): ditto. + +2003-02-05 Koji Arai + + * tests/lha-test7: sleep 1 to make sure for updating tests. + + * src/fnmatch.c, src/fnmatch.h: added fnmatch.c derived from the + OpenBSD. + +2003-02-04 Koji Arai + + * configure.ac: need to call `AC_CANONICAL_HOST' for automake + 1.6.x (for installing the config.guess and config.sub). + +2003-02-02 Koji Arai + + * src/header.c, src/lharc.c: fix credit. + +2003-01-20 Koji Arai + + * src/lha.h (prev_char): discard unused variable `prev_char'. + + * src/crcio.c (fwrite_txt): ditto. + + * src/slide.c (decode): ditto. + + * src/slide.c: refined a little. + +2003-01-19 Koji Arai + + * src/slide.c: took off the debug flag. + + * src/slide.c (search_dict): split into 2 parts. + + * src/slide.c: refined: use the structure `matchdata'. + +2003-01-18 Koji Arai + + * src/lha.h (decode_count): rename a global variable `count' to + `decode_count'. + + * src/dhuf.c (decode_p_dyn): ditto. + + * src/slide.c (decode): ditto and refined. + +2003-01-17 Koji Arai + + * src/slide.c: refined ? + + * src/slide.c (INIT_HASH, NEXT_HASH): newly defined to refine. + +2003-01-13 Koji Arai + + * src/prototypes.h: updated. + + * src/slide.c: refined. + +2002-12-31 Koji Arai + + * src/lhext.c (adjust_info): On Cygwin, execute permission should + be set for .exe or .dll. + +2002-12-28 Koji Arai + + * src/lha_macro.h (peekbits): newly added. + + * src/huf.c (read_pt_len): use peekbits(). + (read_c_len): ditto. + (decode_c_st1): ditto. + (decode_p_st1): ditto. + + * src/shuf.c (decode_c_st0): ditto. + (decode_p_st0): ditto. + +2002-12-23 Koji Arai + + * configure.ac: added a configure option: --enable-ignore-dot-files. + + * config.h.in: ditto. + + * src/lharc.c (parse_option): added `-X' option to ignore dot files. + +2002-12-17 Koji Arai + + * configure.ac: should check whether system has `ssize_t'. + + * config.h.in: ditto. + + * lha.h: ditto. + + * configure.ac: added checking functions `fnmatch' and `basename'. + but not yet prepare the free fnmatch.c. + + * config.h.in: ditto. + + * src/util.c (basename): newly added. + + * src/lhadd.c (cmd_add): exclude files specified by -x option. + + * src/lharc.c (print_tiny_usage): refined. + +2002-12-16 Koji Arai + + * 00readme.autoconf: describe about new feature `-x'. + + * src/lha.h: include fnmatch.h. + added a global variable `exclude_files'. + + * src/lharc.c (init_variable): initialize `exclude_files'. + (print_tiny_usage): modify usage. + (parse_option): newly added. should regard leading `-' argument as + option (for new -x option). + added `-x ' option (specify exclude files pattern). + (find_files): files matched by pattern `exclude_files' exclude + from target files. + +2002-11-25 Koji Arai + + * src/header.c: use size_t for header_size. + (skip_msdos_sfx1_code): rename to `seek_lha_header()'. + + * src/lha.h: use size_t for header_size. + + * src/lhadd.c (cmd_add): rename `skip_msdos_sfx1_code()' to + `seek_lha_header()'. + (cmd_delete): ditto. + + * src/lhext.c (cmd_extract): ditto. + + * src/lhlist.c (cmd_list): ditto. + + * src/prototypes.h: updated. + + * tests/lha-test15: added tests to search any level headers. + +2002-11-17 Koji Arai + + * untabify all sources. + + * src/huf.c (encode_start_st1): refined. + (decode_start_st1): refined. + + * src/slide.c (encode_alloc): refined. + (update): refined. + +2002-11-15 Koji Arai + + * 00readme.autoconf: updated. + + * src/prototypes.h: updated. + + * configure.ac, Makefile.am, olddoc/Makefile.am: + old documentations moved to olddoc directory. + + * CHANGES.euc, MACHINES2.euc, README.euc, change-114h.txt, change-114e.txt, change-114i.txt, IFNAMES, Makefile.in, change-114f.txt, config.eng, MACHINES.euc, PROBLEMS.euc, change-114g.txt, config.jpn.euc: ditto. + + * Makefile.in.org, src/Makefile.in.org: removed. + + * configure.ac: updated version (source maintenance start on + sourceforge.jp) + +2002-11-11 Koji Arai + + * src/lhext.c (make_parent_path): On Cygwin, when `foo.exe' + exists, stat("foo", &buf) is successful and it is not a directory. + + * src/util.c (skip_msdos_sfx1_code): move to header.c + + * src/header.c (skip_msdos_sfx1_code): ditto. + some macro moved from lha_macro.h. + + * src/lha_macro.h: ditto. + + * tests/lha-test15: newly added for testing self extracting archive. + + * tests/lha-test.in: ditto. + + * tests/Makefile.am: ditto. + + * configure.ac: refined messages. + +2002-10-26 Koji Arai + + * src/bitio.c (putbits): use the function putcode(). + + * src/dhuf.c (decode_start_dyn): call init_code_cache(). + + * src/huf.c (encode_start_st1): ditto. + (decode_start_st1): ditto. + + * src/larc.c (decode_start_lzs): ditto. + + * src/shuf.c (decode_start_st0): ditto. + (encode_start_fix): ditto. + (decode_start_fix): ditto. + + * src/Makefile.am: added bitio.c + + * src/cproto.sh: added bitio.c + + * src/bitio.c: new file. + + * src/crcio.c: extracted bitio routines. + + * src/lha.h: ditto. + +2002-10-16 Koji Arai + + * 00readme.autoconf: modified. + +2002-10-02 Koji Arai + + * src/util.c (xstrchr): `strchr(s, 0)' should return the pointer + of the '\0' terminator. + +2002-09-14 Koji Arai + + * src/lhadd.c (add_one): Use chsize() if system does not have + ftruncate(2). (For MinGW) + + * configure.ac: ditto. + + * config.h.in: ditto. + +2002-09-03 Koji Arai + + * released. + + * 00readme.autoconf: modified for stable release. + + * configure.ac: updated version. + +2002-09-01 Koji Arai + + * tests/Makefile.am (EXTRA_DIST): lha-test12, lha-test13 and + lha-test14 were missed. + +2002-08-31 Koji Arai + + * src/lhadd.c (append_it): refined. + + * src/lhadd.c (append_it): no terminate when file cannot be opened. + +2002-08-29 Koji Arai + + * tests/lha-test11: change the way of checking the `header size field'. + + * configure.ac: the `--enable-user-name-header' switch has been + ineffective. corrected variable name. + +2002-08-26 Koji Arai + + * tests/lha-test14: on Cygwin, cannot use '|' as filesname. + + * tests/lha-test.in: on MinGW, skip lha-test14 test. + + * 00readme.autoconf: modified. + + * released. + + * configure.ac: updated version. + + * src/header.c: fixed a comment. + + * src/prototypes.h (strcmp_filename): removed. + + * src/header.c (dump_skip_bytes): note "ignored" if data is ignored. + + * src/header.c (wintime_to_unix_stamp): newly added for converting + from `FILETIME' to `time_t'. + (get_extended_header): use `wintime_to_unix_stamp()' to recognize + the Windows time stamp header (0x41). + + * src/lha.h: define `uint64_t' unless system has it. + + * configure.ac: check existence of the type `uint64_t'. + + * config.h.in: ditto. + + * src/lharc.c (init_variable): set default header level to 2. + +2002-08-24 Koji Arai + + * tests/lha-test.in (lha-test14): added to test the symbolic link file. + + * tests/lha-test14: ditto. + + * src/lhlist.c (list_one): use LzHeader.realname. + + * src/lhext.c (extract_one): use LzHeader.realname. + should call make_parent_path(symlink). + + * src/lhadd.c (add_one): use LzHeader.realname. + (delete): ditto. + (append_it): use strcmp() instead of strcmp_filename(). + (strcmp_filename): removed. + + * src/lha.h (struct LzHeader): added a member `realname' which is + symbolic linked name. + + * src/header.c (get_header): split symbolic name in archive. + (write_header): join symbolic link name and linked name to put it + in archive. + + * src/lhext.c (extract_one): force extract when `f' option is + specified. this is for OS-9 archives, [provisional]. + + * src/header.c: fixed cpp expressions around time functions. + + * tests/lha-test8: test MS-DOS timestamp `ftime' structure. + + * tests/lha-test.in (change_timestamp): newly added. + +2002-08-22 Koji Arai + + * released. + + * src/prototypes.h: regenerated. + + * src/cproto.sh: refined. + + * configure.ac: updated version. + + * configure.ac: should use `exit' rather than `return' on + AC_TRY_RUN(). see the Autoconf manual. + + * configure.ac: check whether the 2nd argument of gettimeofday() + is effective. + + * src/header.c: ditto. + + * config.h.in (GETTIMEOFDAY_HAS_2ND_ARG): ditto. + + * tests/lha-test.in: `++' is invalid arithmetic operator on POSIX + shell, Ksh and Bash version 2.03 or earlier. + + * tests/lha-test13: ditto. + +2002-08-18 Koji Arai + + * src/lharc.c (print_version): version string is made here. + + * src/lha_macro.h (LHA_VERSION): removed. + + * src/slide.c (encode_alloc): used newly named `dicbit' macro. + + * src/shuf.c (read_tree_p): ditto. + (decode_start_fix): ditto. + + * src/lha_macro.h: `xxx_DICBIT' for each method was defined. + + * src/header.c: correct a comment `Generic stamp format'. + (get_bytes): fixed for dumping header. + + * src/lha_macro.h, src/lha.h: `EXTERN' macro definition was moved + to lha.h. + + * src/header.c (get_bytes): print hex codes for invisible chars. + + * src/lhlist.c: hate global variables. + + * src/prototypes.h (convdelim): removed. + + * src/lhlist.c (print_stamp): use ISO 8601 date format when `lha vv'. + +2002-08-14 Koji Arai + + * src/header.c: discarded warning message for the extended header, + `Windows time stamp' ignored. + + * src/header.c: in spite of extended type value, read contents of + any ext headers. + + * src/header.c: comment fixed. + +2002-08-12 Koji Arai + + * src/header.c (dump_skip_bytes): do nothing when length is 0. + +2002-08-11 Koji Arai + + * src/lha_macro.h (SJC_FIRST_P): rename to SJIS_FIRST_P. + (SJC_SECOND_P): rename to SJIS_SECOND_P. + + * src/util.c (convdelim): removed. + + * src/header.c (convert_filename): when small letter is included + in filename, do not convert case. + + * tests/lha-test.in, tests/lha-test2, tests/lha-test3, tests/lha-test4, tests/lha-test5, tests/lha-test6, tests/lha-test7, tests/lha-test8, tests/lha-test9, tests/lha-test10, tests/lha-test11, tests/lha-test12, tests/lha-test13: + print filename when test failed. + + * tests/lha-test.in, tests/lha-test12, tests/lha-test13: + added tests for converting text files. + + * src/header.c (get_extended_header): recognize the Windows time + stamp header (0x41), but ignored. + + * src/header.c (write_unix_info): added. + +2002-08-11 Koji Arai + + * released. + + * configure.ac: updated version. + + * 00readme.autoconf: modified. + + * src/header.c: DUMP_HEADER is always true. + dump header when running `lha vvv foo.lzh'. + (get_header): added new extend type JAVA. + + * src/lha_macro.h (EXTEND_JAVA): added new extend type JAVA. + + * src/lhlist.c (list_one): ditto. + + * src/lharc.c (init_variable): `verbose' is changed to successive. + (main): ditto. + +2002-08-10 Koji Arai + + * src/lhlist.c (list_one): fixed mode checks. + + * src/prototypes.h: updated. + + * src/header.c (get_header_level2): check CRC value for reading + level 2 and 3 header. + (get_header_level3): ditto. + (get_extended_header): ditto. + (get_header_level0): set total header size to + `LzHeader.header_size' even if level 0 or 1 header is read. + (get_header_level1): ditto. + + * src/append.c (encode_lzhuf): encode(), decode() and copyfile() + were changed. + (put_indicator): moved from crcio.c. + + * src/crcio.c (put_indicator): moved to append.c. + (calccrc): generalized. + (fread_crc): changed interface. + (fwrite_crc): changed interface. + (calc_header_crc): removed. use calccrc() instead. + + * src/extract.c (decode_lzhuf): copyfile() and decode() were changed. + + * src/lha.h: hate global variable. `crc' is removed. + `reading_size' moved to append.c. + + * src/lha_macro.h (INITIALIZE_CRC): newly added. + (UPDATE_CRC): no update in macro code. + + * src/lhadd.c (temporary_to_new_archive_file): copyfile() was changed. + + * src/lharc.c (copy_old_one): header size adjusting is done by + the get_header(). + + * src/slide.c (update): changed interface. + (get_next): ditto. + (encode): ditto. + (decode): ditto. + + * src/util.c (copyfile): changed interface. + +2002-08-10 Koji Arai + + * tests/lha-test5: added tests using pipe. + + * src/lhadd.c (cmd_add): applied reverse patch. intermediate file + is the necessary when created archive put in pipe. + + * src/header.c (skip_bytes): newly added. + (dump_get_byte): newly added for dumping the data for debugging. + (dump_skip_bytes): ditto. + (get_word): ditto. + (get_longword): ditto. + (get_bytes): ditto. + (get_extended_header): modified for reading the level 3 header. + (get_header_level3): newly added. + + * src/lha.h (struct LzHeader): for level 3 header, added a new + member `size_field_length' and changed type of the `header_size' + from int to long. + + * src/header.c (init_header): the `hdr->method' should be + initialized to the "-lh0-" for empty files. + + * tests/lha-test2: ditto. + + * src/lhadd.c (add_one): should print indicator for empty files. + +2002-08-09 Koji Arai + + * tests/lha-test.in: adapt to ksh (and posix shell). + +2002-08-05 Koji Arai + + * 00readme.autoconf: refined. + + * config.h.in (BACKUP_OLD_ARCHIVE): added. + + * configure.ac: added a command line switch `--enable-backup-archive'. + + * src/lhadd.c (cmd_add): if `backup_old_archive' is true, no + backup archive. + (cmd_delete): ditto. + + * src/lharc.c (init_variable): initialize `backup_old_archive'. + + * src/lha.h (backup_old_archive): added for nobackup. + +2002-08-02 Koji Arai + + * src/lha_macro.h, src/lha.h, src/header.c, src/lhadd.c: Fixed + misspelling, not `STRAGE' but `STORAGE'. + +2002-07-29 Koji Arai + + * re-released. + + * src/header.c: should use error() instead of fatal_error(). + (get_header): fixed wrong end mark checking. + + * src/prototypes.h: updated. + + * released. + + * configure.ac: updated version. + + * 00readme.autoconf: described about header.c bug on original lha. + +2002-07-28 Koji Arai + + * tests/Makefile.am: added lha-test11. + + * src/crcio.c (fread_txt): responded to (gcc -Wall) compiler warnings. + + * src/header.c (generic_to_unix_stamp): ditto. + + * src/lha_macro.h: ditto. + + * src/lhadd.c (delete): ditto. + + * src/lharc.c (open_old_archive): ditto. + + * src/lhlist.c (list_one): ditto. + + * src/prototypes.h: updated. + + * tests/lha-test.in: added lha-test11. + + * tests/lha-test8: added tests for level 0 and 2 header. + + * tests/lha-test10: added tests for generic header. + + * tests/lha-test11: testing for long filename. moved from lha-test10. + +2002-07-26 Koji Arai + + * src/header.c (write_header): rewritten. + +2002-07-25 Koji Arai + + * tests/lha-test4: stderr should be redirected. + + * src/lharc.c (main): exit with status 1 (meaning failure) when the + function error() was called. + (error): ditto. + + * src/lha.h (LzHeader.last_modified_stamp;): no longer used it. + + * src/header.c (get_header): rewritten. + +2002-07-21 Koji Arai + + * tests/lha-test10: change grep pattern so that pattern matches + a carriage return at the end of line for MinGW. + + * src/lha.h: define `struct utimbuf' when utime.h is not given + such as MinGW. (Microsoft Visual Studio 6.0 has sys/utime.h). + + * src/lhext.c (make_parent_path): missing braces. + + * tests/lha-test.in (check): print script line number when test failed. + + * tests/lha-test2, tests/lha-test3, tests/lha-test4, tests/lha-test5, tests/lha-test6, tests/lha-test7, tests/lha-test8, tests/lha-test9, tests/lha-test10: ditto. + + * tests/lha-test10: on Cygwin/MinGW, could not make 255 bytes + filename. (the system limit of filename length contains the length + of current directory.) + + * tests/lha-test10: should use /bin/ls instead of ls, since + /usr/ucb/ls puts size on 4th field (on Solaris). + +2002-07-18 Koji Arai + + * released. + + * configure.ac: updated version. + + * src/lhext.c (adjust_info): should use `struct utimbuf' for + `utime(2)' rather than `time_t' array. + + * src/header.c (write_header): [BUG]: should not write zero at the + first byte on level 2 header. should adjust header size. + + * tests/lha-test10: added tests for level 2 header. + + * src/lha_macro.h, src/header.c (setup_get): moved to header.c. + (get_byte): ditto. + (put_ptr): ditto. + (setup_put): ditto. + (put_byte): ditto. + (get_bytes): newly added. + (put_bytes): newly added. + +2002-07-17 Koji Arai + + * src/header.c (get_header): [BUG]: Could not read level 2 header + when the header size is grater than 256. + (convert_filename): Should use the `FILENAME_LENGTH' macro rather + than 256. + (write_header): [BUG]: Suppress to overflow the header size when + long filename is written in level 0 or 1 header. On level 1 + header, always use the extended filename header instead of the + base header. + + * src/lha.h (LzHeader): the type of `header_size' was changed + from `unsigned char' to `int', for the level 2 header archive. + + * src/lhext.c (extract_one): should use the `FILENAME_LENGTH' + macro rather than 256 (provisionally fixed). + + * tests/lha-test.in: notify failed test number. + + * tests/lha-test10: added tests for long pathname. + +2002-07-14 Koji Arai + + * re-released. + + * src/header.c (get_header): archive path separator should be + converted always. + + * released. + + * configure.ac: updated version. + + * src/header.c (write_header): if user/group name is not set, + extended header (0x52 and 0x53) should not be made. + + * tests/lha-test10: added testing to handle deep directory. + + * src/header.c (write_header): fixed typo, not strchr() but + strrchr(). + + * src/prototypes.h: regenerated. + + * src/header.c (convert_filename): prefer to use the + `FILENAME_LENGTH' macro rather than 256. + + * src/cproto.sh: fixed typo. + +2002-07-11 Koji Arai + + * tests/Makefile.am (EXTRA_DIST): lha-test9 and lha-test10 were missed. + + * src/lharc.c (print_tiny_usage): no exit here. + + * src/header.c (ConvertEncodingByIconv): newly added. + Thanks to Hiroto Sakai. + + * configure.ac, config.h.in: Checking to have iconv() for utf-8 + conversion. + + * configure.ac: Checking whether strrchr() is 8 bit clean or not. + On Mac OS X, strchr() can handle 8 bit characters, but strrchr() + cannot. + Should use '\377' rather than '\xff' for de-ANSI compiler. + +2002-07-10 Koji Arai + + * released. + + * configure.ac: updated version. + + * src/header.c: change hex codes '\xff' to octal codes '\377'. + + * tests/lha-test.in: Skip the lha-test9. (this test is imcomplete + for now) + + * tests/lha-test10: Should extract directory even if the archive + header was level 0. + + * src/header.c (get_header): Should convert kanji code and path + separator for the level 0 header entry. + Should convert `\' to `/' for level 0 header (do always to make sure, + SO CANNOT CONTAIN THE `\' IN FILENAME). + (init_header): [BUG]: Should not convert path separator here (Should do + in write_header()). + (write_header): [BUG]: should set pathname (contains directory part) to + the LzHeader.name field on level 0 header archive even if the + archive methods is -lhd-. + +2002-07-09 Koji Arai + + * src/lha.h, src/header.c: the CoreFoundation header inclusion + moved to header.c. + + * src/lha.h, src/lharc.c, IFNAMES: macro NODIRECTORY was removed. + + * src/lha.h, src/lhadd.c, src/lharc.c, src/lhext.c: fixed + misspelling, not `writting' but `writing'. + +2002-07-07 Koji Arai + + * src/lha.h, src/lha_macro.h: refined. + + * src/lhadd.c (append_it): macro STRING_COMPARE() was discarded. + + * src/lha_macro.h: ditto. + + * IFNAMES: NOVOID was removed. + + * src/lharc.c (main): terminate with exit status 2 when specified + command line switche is wrong, + + * configure.ac, config.h.in: added checking utime.h existent. + + * src/crcio.c (putc_euc): void returned. + + * src/header.c, src/lha.h, src/lha_macro.h, src/lhadd.c: refined. + + * src/lharc.c, src/prototypes.h, src/slide.c: refined. + + * configure.ac: should specify the 4th argument to AC_TRY_RUN() + for cross compiling. + + * configure.ac: fix a test expression. + + * src/cproto.sh: added for maintainer. + + * src/lha.h: support de-ANSI variable arguments. + + * src/lharc.c: ditto. + + * src/util.c: ditto. + + * src/Makefile.am (lha_SOURCES): added prototypes.h. + + * src/lha.h: function prototypes moved to prototypes.h. + + * src/prototypes.h: generated by the cproto command. + + * configure.ac: On Mac OS X, in spite of using the CoreFoundation + for utf-8 conversion, I have missed specifying the `-framework + CoreFoundation' in LDFLAGS. + + * src/Makefile.am (EXTRA_DIST): no need to specify `lhdir.c'. + +2002-07-06 Koji Arai + + * released. + + * configure.ac: updated version. + + * tests/lha-test10: added testing the header level 0, 1 and 2. + + * tests/lha-test.in: ditto. + + * src/lharc.c: `#include ' moved to lha.h. + + * src/lha.h: ditto. + + * src/util.c: ditto. + + * configure.ac: AC_REPLACE_FUNCS(vsnprintf). + + * config.h.in: ditto. + + * src/lha.h: ditto. + + * src/vsnprintf.c: derived snprintf() which has the BSD licence. + + * configure.ac: fix typo. + + * configure.ac: checking whether strchr() is 8 bit clean or not. + + * config.h.in: ditto. + + * src/util.c: give functions strchr(), strrchr(), memchr() and + memrchr() which handle 8 bit characters correctly. + + * src/header.c: use above if needed. + + * src/lha_macro.h: deprecate the macro name `DELIM2' which is path + separattor for the filename in lha header. + use LHA_PATHSEP instead. + + * src/util.c (convdelim): ditto. + + * src/header.c (convert_filename): ditto. + (write_header): ditto. + + * src/header.c (convert_filename): fixed bug on utf8 conversion, + provisionally. + +2002-06-30 Koji Arai + + * configure.ac: fixed typo. + + * src/header.c (sjis_to_utf8): fixed typo. + (utf8_to_sjis): fixed typo. + + * src/lhadd.c (cmd_add): Missed to adjust the index when specified + adding file is same as the generating archive file. + +2002-06-29 Koji Arai + + * src/header.c (convert_filename): rename a function + `filename_conv()' to `convert_filename()'. + (sjis_to_utf8_static): no use the static variable. + (utf8_to_sjis_static): ditto. + + * src/lha.h: rename sjis_to_utf8_static() and utf8_to_sjis_static() + into sjis_to_utf8() and utf8_to_sjis(). + + * src/lha_macro.h: added a macro `CODE_UTF8'. + + * configure.ac: decide CODE_UTF8. + updated version. + + * 00readme.autoconf: modified. + + * configure.ac: modified for Mac OS X. + + * src/header.c, lha.h, lha_macro.h, lharc.c: Merged a patch for + the Mac OS X, convert utf-8 filename to shift_jis. This patch was + contributed on LHa BBS. Thanks to Hiroto Sakai. + + * src/lhext.c: replaced bcmp() with memcmp(). + + * src/lha_macro.h: ditto. + + * src/append.c: replace bcopy() with memcpy() or memmove(). + + * src/lha_macro.h: ditto. + + * src/lhadd.c: ditto. + + * src/lharc.c: ditto. + + * src/header.c: ditto. + replace bzero() with memset(). + + * src/lhadd.c (cmd_add): exlclude the target archive. (reported on + the LHa BBS [28]) + + * src/slide.c (encode_alloc): Wrong value was assigned to the + `dicbit', when SUPPORT_LH7 was not defined. (fixed by DANGAN, + reported on the LHa BBS [38]). + + * src/lha_macro.h: ditto. + + * src/shuf.c (decode_c_st0): the method of -lh3- extraction was + fixed by DANGAN (reported on the LHa BBS [35]). + + * src/lha_macro.h (LH3_DICBIT): ditto. + + * src/dhuf.c (encode_c_dyn): the method of -lh1- compression was + refined by DANGAN (reported on the LHa BBS [30], [39], [62]). + +2002-06-26 Koji Arai + + * tests/lha-test4: Skip a test for the LHa for UNIX (original version). + + * tests/lha-test3: Rewrite tests for generic format archives. + + * tests/lha-test2: Added tests for -lh0- method. + Moved from contents of lha-test3 (tests for print archive). + +2002-06-23 Koji Arai + + * tests/lha-test.in: On Cygwin/MinGW, cannot test lha-test9. + + * src/lhext.c: Fixed a misspelling. not `Symblic' but `Symbolic'. + reported on LHa BBS (see ). + + * src/lharc.c: ditto. + + * src/slide.c (interface;): Fixed wrong index. + reported on LHa BBS (see ). + + * 00readme.autoconf: refined. + + * tests/lha-test9: added tests for overriding files. + + * tests/lha-test.in: added test9. + + * src/lhext.c (cmd_extract): ftell(stdin) will return -1, so + re-fixed provisionaly. + + * src/lhext.c (cmd_extract): When error occurred in extract_one(), + should adjust point of file stream. + + * configure.ac: library checkings (for libmingwex) should be done + before header checkings. + +2002-06-22 Koji Arai + + * released: + + * configure.ac: updated version. + + * src/lharc.c (init_variable): Removed useless assignments. + + * src/lharc.c (main): Behavior was changed. when `q' or `q2' option + (not `q1') is specified, the `f' option is enabled implicitly. + In original behavior, the option `q', `q0', `q1' and `q2' will + enable `f' option implicitly (bug?). + + * src/lharc.c (main): [BUG]: When `q2' option is specified, + level 2 header is generated. + +2002-06-21 Koji Arai + + * tests/Makefile.am: Use the `DISTCLEANFILES' variable instead of the `dist-hook' target. + + * tests/Makefile.am: Added `dist-hook' target for `make distcheck'. + + * tests/lha-test.in: All tests are splited into some files. + + * tests/Makefile.am: ditto. + + * tests/lha-test2: ditto. + + * tests/lha-test3: ditto. + + * tests/lha-test4: ditto. + + * tests/lha-test5: ditto. + + * tests/lha-test6: ditto. + + * tests/lha-test7: ditto. + + * tests/lha-test8: ditto. + +2002-06-20 Koji Arai + + * src/lhadd.c (cmd_add): No create an intermediate file when archive + is written in stdout. + +2002-06-19 Koji Arai + + * 00readme.autoconf: Modified. + +2002-06-18 Koji Arai + + * configure.in: Removed. (no support the Autoconf version 2.13). + + * config.h.in: Changed meaning of the value of the `MULTIBYTE_FILENAME'. + + * src/header.c: Remove preprocess codes for kanji code decision. + + * configure.ac: When --enable-multibyte-filename[=auto] is specified, + decide kanji code for filename automatically. + Otherwise, euc or sjis is specified, it is EUC-JP or Shift_JIS. + +2002-06-17 Koji Arai + + * configure.in, configure.ac: updated version. + + * configure.in, configure.ac: On mingw-runtime-2.0-1, opendir() + has moved to libmingwex.a. For now, not listed in the + /usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-5/specs file. + + * src/lharc.c (message): use variable argument list with stdarg. + (warning): ditto. + (error): ditto. + (write_error): removed. + (read_error): removed. + (build_temporary_name): use xsnprintf(). + (open_old_archive): ditto. + (expanded_archive_name): move in the function (open_old_archive()) as static. + + * src/crcio.c (putcode): changed for fatal_error(). + (putbits): changed for fatal_error(). + (fwrite_crc): ditto. + (putc_euc): should return EOF when putc() cause error. + (fwrite_txt): changed for putc_euc(). + + * src/header.c (get_header): changed for fatal_error(), warning() and error(). + (init_header): use xsnprintf(). + (write_header): fixed wrong usage of fwrite(). + + * src/lha.h: updated declarations. + + * src/lhadd.c (append_it): changed for error(). + + * src/lhext.c (inquire_extract): ditto. + + * src/lhlist.c (cmd_list): ditto. + + * src/maketbl.c (make_table): ditto. + + * src/util.c (copyfile): changed for fatal_error(). + (xsnprintf): newly added to adopt to various snprintf(). + +2002-06-12 Koji Arai + + * src/lha_macro.h (UNIX_STICKYBIT): fixed a misspelling. + + * src/lhlist.c (list_one): ditto. + +2002-06-11 Koji Arai + + * src/lharc.c: index was wrong. + reported on LHa BBS (see ). + +2002-06-06 Koji Arai + + * configure.ac, configure.in: changed macro name. + not multibyte-char but multibyte-filename. + not MULTIBYTE_CHAR but MULTIBYTE_FILENAME. + + * 00readme.autoconf: ditto. + + * config.h.in: ditto. + + * src/util.c: ditto. + + * src/lha_macro.h: ditto. + + * src/header.c: ditto. + + * config.h.in (INCLUDE_OWNER_NAME_IN_HEADER): changed macro name. + + * configure.ac: ditto. + + * src/header.c (init_header): ditto. + + * src/header.c (init_header): should clear LzHeader. + +2002-06-05 Koji Arai + + * released. + + * configure.ac (AC_INIT): changed package name and specified tar name. + + * src/lharc.c: added `--help' command line switch. + + * Makefile.am: fixed EXTRA_DIST for 00readme.autoconf renaming. + + * README.autoconf, 00readme.autoconf: renamed. + + * configure.ac, configure.in: updated version. + +2002-06-04 Koji Arai + + * README.autoconf, header.doc.euc: describe about user/group name + header. + + * src/header.c (init_header): added a macro MAKE_USER_NAME_HEADER. + + * configure.ac, configure.in, config.h.in: added a switch + `--enable-user-name-header' whether user/name extended header is + made. + +2002-06-01 Koji Arai + + * README.autoconf: `-i' switch of automake is deprecated. + +2002-05-29 Koji Arai + + * configure.in, configure.ac, config.h.in: checks having uid_t/gid_t. + + * src/lha.h: define uid_t/gid_t as `int' if no have it. + + * src/lhext.c (adjust_info): mismatched braces. + + * header.doc.euc: around user/group name extention. + + * configure.in, configure.ac, config.h.in: checks having + getpwuid/getgrgid and so on. + + * src/header.c (get_header): use the extend header, user/group name. + (init_header): ditto. + + * src/lha.h: added , header includings. + + * src/lhext.c (adjust_info): change owner/group according to + user/group name when extracting. + + * src/lhlist.c (list_one): print user/group name when the header + has them. + (list_one): correct column position on OS68K. + + * tests/lha-test.in: added timestamp checks. + + * src/lha_macro.h: comment about OS code. + +2002-05-28 Koji Arai + + * src/lharc.c (xstrdup): no need to call fatal_error(). + + * src/lhdir.h, src/lha_macro.h, src/lha.h: added modeline for vi(m). + + * configure.ac, config.h.in: use new autoconf macro, AC_CHECK_MEMBERS(). + + * IFNAMES, configure.in, src/header.c, src/lharc.c: replaced with + new macro name to adopt to the AC_CHECK_MEMBERS(). + +2002-05-27 Koji Arai + + * tests/lha-test.in: use awk instead of GNU sh-utils's `seq'. + + * src/header.c (filename_conv): fix a bug, reverse condition and + conversion for filename case. + + * README.autoconf: added description about `get_filename_from_stdin' feature. + + * tests/lha-test.in: remove test around the `get_filename_from_stdin'. + + * src/lharc.c (main): never set `get_filename_from_stdin` to true. + `echo foo | lha x foo.lzh' does not work like original LHa for UNIX. + + * tests/lha-test.in: replace with #!/bin/bash. + + * README.autoconf: added E-Mail address. + + * configure.ac: updated version and added mail address for bug reports. + + * configure.in: updated version. + + * released. + + * README.autoconf: added `make check' on sample description. + + * configure.in, configure.ac: update version. + +2002-05-26 Koji Arai + + * tests/lha-test.in: added some tests. + + * tests/Makefile.am: refined. + + * src/lhext.c (cmd_extract): discard useless fseek() calling (for MinGW). + + * tests/lha-test.in: added some tests. + + * tests/lha-test.in: specified `q' option on print archive test. + + * src/lhadd.c (build_backup_file): On MinGW, cannot rename when + a new file already exists. + + * src/lhext.c (extract_one): On MinGW, set binary on stdout when + print archive (`p' switch). + + * tests/lha-test.in: added some tests. + + * src/lhadd.c (report_archive_name_if_different): warning messages + should be printed to stderr rather than stdout. + (cmd_delete): ditto. + + * tests/Makefile.am: fix EXTRA_DIST. + + * configure.in, configure.ac: update version. + + * tests/lha-test.in: added tests. + + * tests/Makefile.am: ditto. + + * configure.in, configure.ac, Makefile.am: ditto. + +2002-05-25 Koji Arai + + * IFNAMES: updated. + + * released. + + * README.autoconf: added description for developpers. + + * configure.in, configure.ac, config.h.in: refined. + + * src/util.c (memmove): use HAVE_MEMMOVE. + (mkdir): use HAVE_WORKING_FORK. + + * src/huf.c: use HAVE_SYS_PARAM_H instead of sony_news. + + * IFNAMES (sony_news): updated. + + * configure.ac, configure.in (AC_INIT): added autoconfiscated date. + see `lha --version'. + +2002-05-22 Koji Arai + + * src/append.c, src/crcio.c, src/dhuf.c, src/extract.c, src/header.c, src/huf.c, src/larc.c, src/lhadd.c, src/lharc.c, src/lhdir.c, src/lhext.c, src/lhlist.c, src/maketbl.c, src/maketree.c, src/patmatch.c, src/shuf.c, src/slide.c, src/util.c: + added modeline for vi(m). + + * src/lharc.c: backslash was missing. + +2002-05-20 Koji Arai + + * src/lharc.c (open_old_archive): On MinGW, set binary stdin. + + * src/lhadd.c (temporary_to_new_archive_file): On MinGW, set binary stdout. + + * src/lha_macro.h: no define TMP_FILENAME_TEMPLATE in source. + + * configure.ac, configure.in, README.autoconf: be able to specify + --with-tmp-file=no which meaning TMP_FILENAME_TEMPLATE is undefined. + + * src/lha.h: correct usage of mkstemp(). + On MinGW, opening file cannot be removed. + + * src/lhadd.c (build_temporary_file): ditto. + + * src/lharc.c (fatal_error): ditto. + +2002-05-19 Koji Arai + + * configure.in, configure.ac: added AM_C_PROTOTYPES, AC_C_CONST. + no use AM_C_PROTOTYPES for the present. + + * config.h.in: ditto. + + * src/lharc.c (print_tiny_usage_and_exit): change credit. + + * src/lha_macro.h: put PLATFORM in a macro LHA_VERSION. + + * src/lharc.c (print_version): ditto. + + * configure.ac: use AC_CANONICAL_TARGET instead of AC_CANONICAL_HOST. + +2002-05-19 Koji Arai + + * released. + + * src/lharc.c (print_tiny_usage_and_exit): added credit. + (print_version): print PLATFORM. + + * configure.ac, configure.in, config.h.in: define PLATFORM. + + * src/lharc.c (xstrdup): fix typo. + + * configure.ac: added for autoconf-2.53. + + * config.h.in: regenerate by autoconf-2.53. + + * src/lharc.c (find_files): MinGW has st_ino but always 0. + + * src/lharc.c (main): provisionally fix. set + `get_filename_from_stdin' to false. + + * src/util.c (rename): use builtin rename(2) on mingw32 (since have + no link(2)). + + * src/lharc.c (main): use xrealloc(). + + * src/lha_macro.h: specify "b" modifier always (for mingw32). + + * src/lharc.c: use xstrdup() instead of strdup(). + + * src/lha_macro.h: ditto. + + * src/lha_macro.h: getuid(), chown(), kill() are provisionally + defined as 0. + + * src/header.c: set `default_system_kanji_code' to Shift_JIS on mingw32. + + * src/lhadd.c (build_temporary_file): no use SIGHUP for mingw32. + (build_backup_file): ditto. + + * src/lharc.c (interrupt): ditto. + + * src/lhext.c (extract_one): ditto. + + * src/lhext.c (make_parent_path): mkdir() has no 2nd argument on + mingw32. + +2002-05-18 Koji Arai + + * lha_macro.h: define bcmp(), bzero(), bcopy() even if + STDC_HEADERS is defined. + + * huf.c (alloc_buf): call fatal_error() when memory allocation failed + instead of returning NULL. + + * lharc.c (main): use xmalloc(). + + * util.c (copyfile): use xmalloc(). + + * slide.c (encode_alloc): use xmalloc(). + + * header.c (default_system_kanji_code): On HP-UX, use Shift_JIS as + default kanji code. + +2001-02-03 Koji Arai + + * README.autoconf, src/header.c: treat archive and system kanji + code, correctly. + +2001-01-31 Koji Arai + + * configure.in: mistakes for default archive method. + + * src/header.c: directory separator 0xff must be transpose slash + at first. + +2001-01-29 Koji Arai + + * src/lharc.c: replace MKSTEMP with HAVE_MKSTEMP. + substitute DEFAULT_LZHUFF_METHOD for the `compress_method' variable (it's default value). + + * src/lha_macro.h: use the VERSION macro (defined by configure) for + the LHA_VERSION definition. + + * src/header.c: added condition whether the macro MULTIBYTE_CHAR + is defined or not. + + * src/Makefile.am: added $(SUPPORT_LZHUFF_METHOD) in AM_CPPFLAGS. + + * configure.in: change version number from 1.14f to 1.14i. + check function mkstemp(). + replace --enable-lh6 option to --with-default-method=[567]. + + * config.h.in: added definitions of HAVE_MKSTEMP and + DEFAULT_LZHUFF_METHOD. + + * IFNAMES: added a description about MKSTEMP. + + * Makefile.am: added extra files. + + * change-114f.txt, src/extract.c, src/header.c, src/huf.c, src/lha.h, src/lha_macro.h, src/lhadd.c, src/lharc.c, src/lhext.c, src/lhlist.c, src/maketbl.c, src/maketree.c, src/shuf.c, src/slide.c, src/util.c, src/dhuf.c, src/crcio.c: + merged changing from lha-1.14f to lha-1.14i. + + * change-114i.txt, src/header.c, src/huf.c, src/lha.h, src/lharc.c: + import lha-114i + + * src/huf.c, src/lharc.c, src/shuf.c, src/slide.c: import lha-114h + + * Makefile, README.euc, change-114g.txt, change-114h.txt: + import lha-114h + + * src/crcio.c, src/dhuf.c, src/extract.c, src/header.c, src/huf.c, src/lha.h, src/lha_macro.h, src/lhadd.c, src/lharc.c, src/lhext.c, src/util.c: + import lha-114g + + * MACHINES2.euc, Makefile, README.euc, change-114g.txt, config.eng, config.jpn.euc, header.doc.euc, src/lhlist.c, src/maketbl.c, src/maketree.c, src/makezero.c, src/shuf.c, src/slide.c: + import lha-114g + + * src/header.c, src/lha_macro.h: implemented kanji code conversion + on filename. + + * src/header.c: fix bug in euc2sjis(). + +1999-10-05 Koji Arai + + * src/header.c: rename the macro HANKAKU_KATAKANA_P to the X0201_KANA_P + +1999-09-30 Koji Arai + + * IFNAMES, configure.in, Makefile.in.org, README.autoconf, config.h.in, man/Makefile.am, src/Makefile.am, src/Makefile.in.org, Makefile.am, src/header.c, src/huf.c, src/larc.c, src/lha.h, src/lha_macro.h, src/lhadd.c, src/lharc.c, src/lhdir.c, src/lhdir.h, src/lhext.c, src/lhlist.c, src/makefile.dj, src/maketbl.c, src/maketree.c, src/patmatch.c, src/shuf.c, src/slide.c, src/util.c, Makefile, man/Makefile, src/Makefile, src/append.c, src/crcio.c, src/dhuf.c, src/extract.c: + use the autoconf/automake + +1999-08-28 Koji Arai + + * Makefile: import the lha-114f + + * change-114f.txt, config.jpn.euc, header.doc.euc: import the lha-114f + + * CHANGES.euc, MACHINES.euc, PROBLEMS.euc, README.euc, change-114e.txt, config.eng: + import the lha-114f + + * MACHINES2.euc, man/Makefile, man/lha.man, man/lha.n: + import the lha-114f + + * src/append.c, src/crcio.c: import the lha-114f + + * src/Makefile, src/lha.h, src/lha_macro.h, src/lharc.c, src/lhdir.c, src/lhdir.h, src/lhext.c, src/lhlist.c, src/makefile.dj, src/maketbl.c, src/maketree.c, src/patmatch.c, src/shuf.c, src/slide.c, src/util.c: + import the lha-114f + + * src/dhuf.c, src/extract.c, src/header.c, src/huf.c, src/larc.c, src/lhadd.c: + import the lha-114f diff -Nru lha-1.14i/CHANGES.euc lha-1.14i-acc20050924p1/CHANGES.euc --- lha-1.14i/CHANGES.euc 2000-12-15 12:13:16.000000000 +0000 +++ lha-1.14i-acc20050924p1/CHANGES.euc 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ -/* CHANGES (In Japanese) */ -LHx 0.01 -> 0.02 - - Usage の f オプションの説明表示がずれるのを直した。 - lhadd.c の 49 行目の Warning (&hdr->method)を修正した。 - strucmp.c の toupper() を static 関数に変更した。 - lharc.h の malloc(),realloc() の返り値の宣言(Warning)を修正。 - lhadd.c の 336 行目の copyfile() に第4引数 0 を追加。 - malloc 関連の Warning を修正(cast)した。 - patmatch.c の toupper を行なう条件に islower() を追加。 - stdlib.h をインクルードする箇所に || defined(sony_news) を追加。 - -lh0- のファイルをテストすると内容を表示するバグを修正。 - 展開時ヘッダレベル1に対応した。 - crcio.c で putc() の代わりに fwrite() を使用するよう変更。 - _errmsg() を使用しないよう変更。 - 石川@三菱電機さんの rename.c を付属。 - memset() のないマシンのために memset.c を追加。(書き下ろし) - -LHx 0.02 -> LHa 0.03 - 名称を LHx から LHa に変更。 - owner が root のときのみ chown() するよう変更。 - 本間隆之さんの timezone 関係のパッチを含めた。 - lharc.c の135 行目を #endif /* MULTIBYTE_CHAR */ に変更。 - g option 使用時にディレクトリ以下を圧縮できないバグを修正。 - z option なしで標準入力からファイル名を読み込むように変更。 - put_indicator() を append.c から crcio.c に移した。 - crcio.c で fwrite() の返り値の比較対象を EOF から 0 に修正。 - アーカイブ名に - を使用することで標準入出力を利用可能にした。 - 倉島@東大さんの EUC パッチを含めた。 - ヘッダ関係を lharc.c から分離し header.c とした。 - archive_is_msdos_sfx1() と skip_msdos_sfx1_code() を util.c に移した。 - 圧縮および展開をヘッダレベル1,2 に対応。 - デフォルトのヘッダレベルを 1 に変更。 - デフォルトの圧縮方式を -lh5- に変更。h オプションを廃止。 - 無圧縮格納(z)オプションを追加。 - LHarc 互換形式圧縮(o)オプションを追加。 - 標準入力のリダイレクト時にオーバーライト確認をしないよう変更。 - uchar,ushort,uint,ulong を使用しないよう変更。typedef.h を削除。 - -LHa 0.03 -> LHa 0.04 (beta) - -lh0- file で e, t option を有効にした。(by 倉島@東大さん) - 引数にアーカイブのみ指定時に list 表示するよう変更。(by 倉島@東大さん) - -DMKTIME でタイムスタンプが正常でないバグを修正。(by 渡邊@東北大さん) - NEED_INCREMENTAL_INDICATOR 設定時の変数宣言を追加した。 - lhadd.c の encode_stored_crc() の宣言の綴を修正した。(by 本間隆之さん) - NULL が 0 でなくても動作するよう slide.c を変更した。 - header.c の fwrite() で返り値を NULL ではなく 0 と比較するよう変更。 - 圧縮形式が正しくない時 Segmentation fault するバグを修正。 - ディレクトリの圧縮形式を -lhd- にするよう変更。 - strdup.c の strlib.h 読み込みの条件を修正。 - header level 2 で圧縮できないバグを修正した。 - 386MINIX に対応。(by youchan@日経MIX さん) - サブディレクトリのアーカイブと同名のファイルを圧縮できるようにした。 - -DNOFTRUNCATE で石川@三菱電機さんの rename() を使うよう変更。 - TITAN でコンパイルできるよう(?) lharc.h を変更。 - -LHa 0.04 -> LHa 0.05 - append.c で使用していた ushort を unsigned short に修正。 - 日付の年を 1991 から 1992 に修正。 - -DFTIME, -DTIMELOCAL パッチを追加。(by 本間隆之さん) - オブジェクトファイルのサフィックスを選択可能にした。 - -DNOMKDIR パッチを追加。(by 石川@三菱電機さん) - 標準入力からのファイル名の入力数を無制限にした。(by 佐藤 治@PFUさん) - rename.c, strdup,c, strucmp.c, memmove.c を util.c に集めた。 - archive file の suffix が .lzh に束縛されないようにした。 - slidehuf.h の __STDC__ の部分に AIX の判定を追加した。 - slidehuf.h,intrface.h の関数宣言に extern を追加した。 - -LHa 0.05 -> LHa 0.06 - USESTRCASECMP を追加し、strucmp の定義を #ifndef で括った。 - #elif などを使用しないよう変更。 - Makefile をトップディレクトリに用意。 - NEED_INCREMENT_INDICATOR 定義で z option 使用時のバグを退治。 - header level 2 のヘッダサイズが食い違うバグを修正。 - maketree.c で defined(_MINIX) が無駄とのことなので削除。 - -LHa 0.06 -> LHa 1.00 - 圧縮サイズの判定ルーチンのバグを修正。 - NOMEMSET を用意し、memset() を util.c に移した。 - -LHa 1.00 -> LHa 1.10 - lharc.h の FILE ATTRIBUTES に is_symlink を追加。 - lhadd.c の append_it()関数 の stat を lstat に変更し、処理を追加して - シンボリック・リンクに対応した。 - (シンボリック・リンクはディレクトリと同じ扱いになってます。) - シンボリック・リンクに対応させるため lhlist.c を変更して、圧縮ファイル内 - のリスト表示の際に、ls -al と同じような表示に変更。 - 圧縮ファイル内のファイルを削除する際に、デフォルトでファイル名を表示 - するように変更。 (quiet オプション可) - w オプション(ワークディレクトリの指定)を圧縮の際のワークディレクトリ - を指定可能に変更。 - -LHa 1.10 -> LHa 1.11 - lhext.c の inquire_extract() の関数に 'S'(Skip) を追加。 - 展開時のタイムスタンプ一応比較対応。 - -LHa 1.11 -> LHa 1.12 - タイムスタンプ対応のため、extract_one() の関数の展開時の処理を大幅追加。 - ローカル変数、skip_flg (FALSE..No Skip , TRUE..Skip)を追加。 - -LHa 1.12 -> LHa 1.13 - S_IFLNK のマクロがあったので対応するように変更。 このことに関連して - lhadd.c の append_it()関数 の lstat を GETSTAT に変更した。 - 長いファイル名の時に、core dump するのは append.c の MAX_INDICATOR_COUNT - の m の値が0になっていたので、if 文の (m<0) を (m<1) に修正。 - -LHa 1.13 -> LHa 1.13a - シンボリックリンクファイルがターゲットとなった場合に、append_it の - fclose(fp) が、fp == NULL となっていたために core dump するバグを修正。 - シンボリックリンクが、ターゲットファイルをなった際にうまく削除できない - Bug を修正。(by あにぃ さん) - -LHa 1.13a -> LHa 1.13b - 圧縮の際に更新してないのに、Symblic Link のファイル名のみ常時表示して - いた. - シンボリックリンクファイルをアーカイブファイルからリンク名で削除できなか - った. - Symbolic Link 先のファイル名を取得する際に、失敗していた. - 展開時に、Symbolic Link ファイルのみタイムスタンプ比較を忘れていた. - 以上のシンボリックリンクファイル関係の Bug を修正した. - - q Option で、INDICATOR を可変に出来るように変更. - t option を使用すると CRC Error で Test と extract ができない Bug と - Header Level 2 の書庫が MS_DOS 版 LHa で解凍できない Bug と - -1 -2 と -g Option の併用が出来ない Bug を修正. (by 岡本@北大) - - また、Makefile 中の 機種異存マクロの記述場所を SWITCHES から MACHINE - に変更しました. - -LHa 1.13b -> LHa 1.13c - 展開の際に、ファイルが存在していると確認のメッセージが表示されるが - そのファイルのどの項目を選んでも一つ目は展開されてしまう Bug を - 修正. - -LHa 1.13c -> LHa 1.14 - 気まぐれで、-lh6- の展開のみ出来るように処理を追加。 - ソースリストの見直しを行った。 - -LHa 1.14 -> LHa 1.14a (以下 t.okamoto) - 圧縮書庫を作れないバグを修正。 - -LHa 1.14a -> LHa 1.14b - シンボリックリンクの先が存在しない時、書庫に追加できないバグを - 修正した。書庫に存在するシンボリックリンクのファイルと同名のファ - イルを書庫に追加しようとしても、追加できないバグを修正。 - また、いくつかのシンボリックリンク関係のバグを修正した。 - -LHa 1.14b -> LHa 1.14c - 前バージョンのバグ修正の際に、新たなバグを付加してしまった点を - 修正した(lhadd.c)。 - 書庫内のファイル表示の際、setuid してある場合 's' のフラグを - 見えるようにした。 - 一部ソースの void をコメントに直して改良を行なった。 - LHa 1.00 に入っていた config.eng を入れ直した。 - -LHa 1.14c -> LHa 1.14d - FreeBSD でのバグの修正。MS-DOS で作成した書庫のファイルスタンプが - ずれて表示されるバグを修正した(header.c)。SWITCHES に HAVE_TM_ZONE - を追加することでバグは修正される。(by yav さん) - 二重定義をしていた部分を修正。二重定義を発見できるコンパイラーで - エラーまたは警告がたくさん出るということは、無くなったと思います。 - - -lh6- 圧縮形式の圧縮を可能にしました。圧縮アルゴリズムに hash 法 - を使った物に変更しました。 - - 開発環境を FreeBSD にしました。 - -LHa 1.14d -> LHa 1.14e - change-114e.txtに記述しています。 diff -Nru lha-1.14i/config.eng lha-1.14i-acc20050924p1/config.eng --- lha-1.14i/config.eng 2000-12-15 12:13:16.000000000 +0000 +++ lha-1.14i-acc20050924p1/config.eng 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -configration of LHa for UNIX ver 1.14g (see Makefile, SWITCHES macro.) - -machine independed macros - - NEED_INCREMENTAL_INDICATOR - EUC if you want to convert kanji-code, define this. - ARCHIVENAME_EXTENTION your default archive suffix. default is ".lzh". - BACKUPNAME_EXTENTION back up archive suffix. default is ".bak". - TMP_FILENAME_TEMPLATE temporary file template. default is "/tmp/lhXXXXXX". - SUPPORT_LH7 to use the -lh7- method, define SUPPORT_LH7 - -machine depended macros - ---include files - USG if your machine has no , define this. - SYSTIME_HAS_NO_TM if your sys/time.h has no struct tm, define this. - ---string stuff - NOBSTRING if your machine has no bstring(3), define this. - NOINDEX if your machine has no index(3), define this. - NOSTRDUP if your machine has no strdup(3), define this. - USESTRCASECMP if your machine has strcasecmp(3), define this. - NOMEMSET if your machine has no memset(3), define this. - ---timezone stuff - FTIME if your machine use ftime(3C), define this. - GETTIMEOFDAY if your machine use gettimeofday(2), define this. - MKTIME if your machine use mktime(3C), define this. - TIMELOCAL if your machine use timelocal(3V), define this. - TZSET if your machine use tzset(3C), define this. - TIMEZONE_HOOK - ---directory stuff - NONSYSTEM_DIR_LIBRARY if your machine has no directory manipulate - functions, define this. and you should add - lhdir$(O) to LIBRARYOBJS in Makefile. - SYSV_SYSTEM_DIR if your machine has struct dirent, define this. - NODIRECTORY otherwise. (give up..) - ---other stuff - NOFTRUNCATE if your machine has no ftruncate(2), define this. - NOMKDIR if your machine has no mkdir(2), define this. - MKDIRPATH to use external mkdir command, define with NOMKDIR. - RMDIRPATH to use external rmdir command, define with NOMKDIR. - NOT_COMPATIBLE_MODE - HAVE_NO_LCHOWN if your machine has no lchown(2), define this. diff -Nru lha-1.14i/config.guess lha-1.14i-acc20050924p1/config.guess --- lha-1.14i/config.guess 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/config.guess 2005-08-29 05:53:16.000000000 +0000 @@ -0,0 +1,1463 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + +timestamp='2005-07-08' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Originally written by Per Bothner . +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerppc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm:riscos:*:*|arm:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep __LP64__ >/dev/null + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + x86:Interix*:[34]*) + echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' + exit ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit ;; + crisv32:Linux:*:*) + echo crisv32-axis-linux-gnu + exit ;; + frv:Linux:*:*) + echo frv-unknown-linux-gnu + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + mips:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #ifdef __INTEL_COMPILER + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + test x"${LIBC}" != x && { + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit + } + test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in + *86) UNAME_PROCESSOR=i686 ;; + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix\n"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + c34*) + echo c34-convex-bsd + exit ;; + c38*) + echo c38-convex-bsd + exit ;; + c4*) + echo c4-convex-bsd + exit ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff -Nru lha-1.14i/config.h.in lha-1.14i-acc20050924p1/config.h.in --- lha-1.14i/config.h.in 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/config.h.in 2006-10-10 16:52:55.000000000 +0000 @@ -0,0 +1,281 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you want to leave an old archive */ +#undef BACKUP_OLD_ARCHIVE + +/* Define it to 5, 6 or 7 which you want to use -lhX- method, default */ +#undef DEFAULT_LZHUFF_METHOD + +/* Define to 1 if the 2nd argument of gettimeofday() is effective. */ +#undef GETTIMEOFDAY_HAS_2ND_ARG + +/* Define to 1 if you have the `basename' function. */ +#undef HAVE_BASENAME + +/* Define to 1 if you have the `chsize' function. */ +#undef HAVE_CHSIZE + +/* Define to 1 if you have the declaration of `basename', and to 0 if you + don't. */ +#undef HAVE_DECL_BASENAME + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_DIRENT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if you have the `fnmatch' function. */ +#undef HAVE_FNMATCH + +/* Define to 1 if you have the header file. */ +#undef HAVE_FNMATCH_H + +/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ +#undef HAVE_FSEEKO + +/* Define to 1 if you have the `ftello' function. */ +#undef HAVE_FTELLO + +/* Define to 1 if you have the `ftime' function. */ +#undef HAVE_FTIME + +/* Define to 1 if you have the `ftruncate' function. */ +#undef HAVE_FTRUNCATE + +/* Define to 1 if you have the `getgrgid' function. */ +#undef HAVE_GETGRGID + +/* Define to 1 if you have the `getgrnam' function. */ +#undef HAVE_GETGRNAM + +/* Define to 1 if you have the `getpwnam' function. */ +#undef HAVE_GETPWNAM + +/* Define to 1 if you have the `getpwuid' function. */ +#undef HAVE_GETPWUID + +/* Define to 1 if you have the `gettimeofday' function. */ +#undef HAVE_GETTIMEOFDAY + +/* Define to 1 if the system has the type `gid_t'. */ +#undef HAVE_GID_T + +/* Define to 1 if you have the header file. */ +#undef HAVE_GRP_H + +/* Define to 1 if you have the `iconv' function. */ +#undef HAVE_ICONV + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `lchown' function. */ +#undef HAVE_LCHOWN + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIMITS_H + +/* Define to 1 if the system has the type `long long'. */ +#undef HAVE_LONG_LONG + +/* Define to 1 if you have the `memcpy' function. */ +#undef HAVE_MEMCPY + +/* Define to 1 if you have the `memmove' function. */ +#undef HAVE_MEMMOVE + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `memset' function. */ +#undef HAVE_MEMSET + +/* Define to 1 if you have the `mkstemp' function. */ +#undef HAVE_MKSTEMP + +/* Define to 1 if you have the `mktime' function. */ +#undef HAVE_MKTIME + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +#undef HAVE_NDIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_PWD_H + +/* Define to 1 if the system has the type `ssize_t'. */ +#undef HAVE_SSIZE_T + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strcasecmp' function. */ +#undef HAVE_STRCASECMP + +/* Define to 1 if you have the `strchr' function. */ +#undef HAVE_STRCHR + +/* Define to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if `st_ino' is member of `struct stat'. */ +#undef HAVE_STRUCT_STAT_ST_INO + +/* Define to 1 if `tm_gmtoff' is member of `struct tm'. */ +#undef HAVE_STRUCT_TM_TM_GMTOFF + +/* Define to 1 if `tm_zone' is member of `struct tm'. */ +#undef HAVE_STRUCT_TM_TM_ZONE + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_DIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_FILE_H + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_NDIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_PARAM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the `timelocal' function. */ +#undef HAVE_TIMELOCAL + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#undef HAVE_TM_ZONE + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +#undef HAVE_TZNAME + +/* Define to 1 if you have the `tzset' function. */ +#undef HAVE_TZSET + +/* Define to 1 if the system has the type `uid_t'. */ +#undef HAVE_UID_T + +/* Define to 1 if the system has the type `uint64_t'. */ +#undef HAVE_UINT64_T + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the `utime' function. */ +#undef HAVE_UTIME + +/* Define to 1 if you have the header file. */ +#undef HAVE_UTIME_H + +/* Define to 1 if `utime(file, NULL)' sets file's timestamp to the present. */ +#undef HAVE_UTIME_NULL + +/* Define to 1 if you have the `vsnprintf' function. */ +#undef HAVE_VSNPRINTF + +/* Define to 1 if you want to ignore dot files with -X command line switch */ +#undef IGNORE_DOT_FILES + +/* Define to 1 if you want to use the user/group name extened header */ +#undef INCLUDE_OWNER_NAME_IN_HEADER + +/* Define to CODE_EUC or CODE_SJIS if you want to use multibyte filename */ +#undef MULTIBYTE_FILENAME + +/* Define to 1 if you want to use the incremental indicator */ +#undef NEED_INCREMENTAL_INDICATOR + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* the type of system on which the package will run. */ +#undef PLATFORM + +/* Define to 1 if the C compiler supports function prototypes. */ +#undef PROTOTYPES + +/* Define as the return type of signal handlers (`int' or `void'). */ +#undef RETSIGTYPE + +/* The size of a `long', as computed by sizeof. */ +#undef SIZEOF_LONG + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to 1 if strchr()/strrchr() works correctly. */ +#undef STRCHR_8BIT_CLEAN + +/* Define to 1 if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* temporary file template for mktemp/mkstemp */ +#undef TMP_FILENAME_TEMPLATE + +/* Define to 1 if your declares `struct tm'. */ +#undef TM_IN_SYS_TIME + +/* Version number of package */ +#undef VERSION + +/* Number of bits in a file offset, on hosts where this is settable. */ +#undef _FILE_OFFSET_BITS + +/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ +#undef _LARGEFILE_SOURCE + +/* Define for large files, on AIX-style hosts. */ +#undef _LARGE_FILES + +/* Define to 1 if on MINIX. */ +#undef _MINIX + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +#undef _POSIX_1_SOURCE + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +#undef _POSIX_SOURCE + +/* Define like PROTOTYPES; this can be used by system headers. */ +#undef __PROTOTYPES + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const diff -Nru lha-1.14i/config.jpn.euc lha-1.14i-acc20050924p1/config.jpn.euc --- lha-1.14i/config.jpn.euc 2000-12-15 12:13:16.000000000 +0000 +++ lha-1.14i-acc20050924p1/config.jpn.euc 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -LHa for UNIX ver 1.14g コンフィグレーション (Makefile, SWITCHESマクロ参照) - -機種依存マクロは、MACHINES ファイルに設定例がありますので参照願います。 - - -機種非依存のマクロ - - NEED_INCREMENTAL_INDICATOR 経過表示グラフを表示するようにします。 - EUC 漢字コード変換を行なう e オプションを用意します。 - ARCHIVENAME_EXTENTION デフォルトのアーカイブ拡張子。デフォルトは ".lzh" 。 - BACKUPNAME_EXTENTION バックアップアーカイブの拡張子。デフォルトは ".bak" 。 - TMP_FILENAME_TEMPLATE 作業ファイルのテンプレート。 - SUPPORT_LH7 -lh7- methodをサポートするときに定義します。 - -機種依存マクロ - ---インクルードファイル関係 - USG がないときに定義します。 - SYSTIME_HAS_NO_TM に struct tm がないときに定義します。 - ---文字列関係 - NOBSTRING bstring(3) がないときに定義します。 - NOINDEX index(3) がないときに定義します。 - NOSTRDUP strdup(3) がないときに定義します。 - USESTRCASECMP strcasecmp(3) があるときに定義します。 - NOMEMSET memset(3)がないときに定義します。 - ---timezone 情報の取得関係 - FTIME ftime(3C) を使用した変換を行なう時に定義します。 - GETTIMEOFDAY gettimeofday(2) を使用した変換を行なう時に定義します。 - MKTIME mktime(3C) を使用した変換を行なう時に定義します。 - TIMELOCAL timelocal(3V) を使用した変換を行なう時に定義します。 - TZSET tzset(3C) を使用した変換を行なう時に定義します。 - TIMEZONE_HOOK - ---ディレクトリ操作関係 - NONSYSTEM_DIR_LIBRARY ディレクトリ操作関数(opendir,readdir,closedir)が - ないときに定義します。Makefile の LIBRARYOBJS に - lhdir$(O) を追加してください。 - SYSV_SYSTEM_DIR struct dirent (direct ではない)があるときに定義します。 - NODIRECTORY 上記マクロを使用しても失敗する時に定義します。 - ---その他 - NOFTRUNCATE ftruncate(2) がない時に定義します。 - NOMKDIR mkdir(2) がないときに定義します。 - MKDIRPATH mkdir の外部コマンド名を定義します。NOMKDIR と - 同時に機能します。デフォルトは "/bin/mkdir" です。 - RMDIRPATH rmdir の外部コマンド名を定義します。NOMKDIR と - 同時に機能します。デフォルトは "/bin/rmdir" です。 - NOT_COMPATIBLE_MODE - HAVE_NO_LCHOWN lchown(2)が無いときに定義します。 diff -Nru lha-1.14i/config.sub lha-1.14i-acc20050924p1/config.sub --- lha-1.14i/config.sub 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/config.sub 2005-08-29 05:53:16.000000000 +0000 @@ -0,0 +1,1579 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + +timestamp='2005-07-08' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ + kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | ms1 \ + | msp430 \ + | ns16k | ns32k \ + | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b \ + | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ + | z8k) + basic_machine=$basic_machine-unknown + ;; + m32c) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | ms1-* \ + | msp430-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ + | xstormy16-* | xtensa-* \ + | ymp-* \ + | z8k-*) + ;; + m32c-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16c) + basic_machine=cr16c-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -zvmoe) + os=-zvmoe + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff -Nru lha-1.14i/configure lha-1.14i-acc20050924p1/configure --- lha-1.14i/configure 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/configure 2006-10-10 16:51:07.000000000 +0000 @@ -0,0 +1,9624 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.59 for LHa for UNIX 1.14i-ac20050924p1. +# +# Report bugs to . +# +# Copyright (C) 2003 Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +exec 6>&1 + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_config_libobj_dir=. +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +# Identity of this package. +PACKAGE_NAME='LHa for UNIX' +PACKAGE_TARNAME='lha' +PACKAGE_VERSION='1.14i-ac20050924p1' +PACKAGE_STRING='LHa for UNIX 1.14i-ac20050924p1' +PACKAGE_BUGREPORT='arai@users.sourceforge.jp' + +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#if HAVE_SYS_TYPES_H +# include +#endif +#if HAVE_SYS_STAT_H +# include +#endif +#if STDC_HEADERS +# include +# include +#else +# if HAVE_STDLIB_H +# include +# endif +#endif +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include +# endif +# include +#endif +#if HAVE_STRINGS_H +# include +#endif +#if HAVE_INTTYPES_H +# include +#else +# if HAVE_STDINT_H +# include +# endif +#endif +#if HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP U ANSI2KNR LIBOBJS DEF_KCODE SUPPORT_LZHUFF_METHOD LTLIBOBJS' +ac_subst_files='' + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +ac_prev= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_option in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "enable_$ac_feature='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package| sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "with_$ac_package='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_confdir=`(dirname "$0") 2>/dev/null || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } + else + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } + fi +fi +(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || + { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 + { (exit 1); exit 1; }; } +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS +ac_env_CPP_set=${CPP+set} +ac_env_CPP_value=$CPP +ac_cv_env_CPP_set=${CPP+set} +ac_cv_env_CPP_value=$CPP + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures LHa for UNIX 1.14i-ac20050924p1 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +_ACEOF + + cat <<_ACEOF +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] + --target=TARGET configure for building compilers for TARGET [HOST] +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of LHa for UNIX 1.14i-ac20050924p1:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + --disable-largefile omit support for large files + --enable-text-conv support text code convert from/to EUC + [default=yes] + --enable-indicator need incremental indicator [default=yes] + --enable-multibyte-filename + support multibyte filename. specify kanji code (euc, + sjis, utf8 or auto) [default=auto] + --enable-user-name-header + make user/group name extended header [default=no] + --enable-backup-archive backup old archive [default=no] + --enable-ignore-dot-files + enable -X option [default=no] + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-default-method=567 + create the -lh[567]- archive default [default=5] + --with-tmp-file=TEMPLATE + temporary file template [default=/tmp/lhXXXXXX] + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have + headers in a nonstandard directory + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to . +_ACEOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d $ac_dir || continue + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + cd $ac_dir + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_srcdir/configure.gnu; then + echo + $SHELL $ac_srcdir/configure.gnu --help=recursive + elif test -f $ac_srcdir/configure; then + echo + $SHELL $ac_srcdir/configure --help=recursive + elif test -f $ac_srcdir/configure.ac || + test -f $ac_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi + cd $ac_popdir + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\_ACEOF +LHa for UNIX configure 1.14i-ac20050924p1 +generated by GNU Autoconf 2.59 + +Copyright (C) 2003 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit 0 +fi +exec 5>config.log +cat >&5 <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by LHa for UNIX $as_me 1.14i-ac20050924p1, which was +generated by GNU Autoconf 2.59. Invocation command line was + + $ $0 $@ + +_ACEOF +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + echo "PATH: $as_dir" +done + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_sep= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + # Get rid of the leading space. + ac_sep=" " + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Be sure not to use single quotes in there, as some shells, +# such as our DU 5.0 friend, will then `close' the trap. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------- ## +## Output files. ## +## ------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + sed "/^$/d" confdefs.h | sort + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core && + rm -rf conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status + ' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val="\$ac_cv_env_${ac_var}_value" + eval ac_new_val="\$ac_env_${ac_var}_value" + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + + + + + + + + + + + + + + + + + + + + + + + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f $ac_dir/shtool; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 +echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} + { (exit 1); exit 1; }; } +fi +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + +# Make sure we can run config.sub. +$ac_config_sub sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 +echo "$as_me: error: cannot run $ac_config_sub" >&2;} + { (exit 1); exit 1; }; } + +echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6 +if test "${ac_cv_build+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_build_alias=$build_alias +test -z "$ac_cv_build_alias" && + ac_cv_build_alias=`$ac_config_guess` +test -z "$ac_cv_build_alias" && + { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6 +build=$ac_cv_build +build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +echo "$as_me:$LINENO: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6 +if test "${ac_cv_host+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_host_alias=$host_alias +test -z "$ac_cv_host_alias" && + ac_cv_host_alias=$ac_cv_build_alias +ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6 +host=$ac_cv_host +host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +echo "$as_me:$LINENO: checking target system type" >&5 +echo $ECHO_N "checking target system type... $ECHO_C" >&6 +if test "${ac_cv_target+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_target_alias=$target_alias +test "x$ac_cv_target_alias" = "x" && + ac_cv_target_alias=$ac_cv_host_alias +ac_cv_target=`$ac_config_sub $ac_cv_target_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_target_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_target" >&5 +echo "${ECHO_T}$ac_cv_target" >&6 +target=$ac_cv_target +target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +target_vendor=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +target_os=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +test -n "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- +am__api_version="1.9" +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL=$ac_install_sh + fi +fi +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +echo "$as_me:$LINENO: checking whether build environment is sane" >&5 +echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6 +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&5 +echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&2;} + { (exit 1); exit 1; }; } + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! +Check your system clock" >&5 +echo "$as_me: error: newly created file is older than distributed files! +Check your system clock" >&2;} + { (exit 1); exit 1; }; } +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +test "$program_prefix" != NONE && + program_transform_name="s,^,$program_prefix,;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s,\$,$program_suffix,;$program_transform_name" +# Double any \ or $. echo might interpret backslashes. +# By default was `s,x,x', remove it if useless. +cat <<\_ACEOF >conftest.sed +s/[\\$]/&&/g;s/;s,x,x,$// +_ACEOF +program_transform_name=`echo $program_transform_name | sed -f conftest.sed` +rm conftest.sed + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 +echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + # We used to keeping the `.' as first argument, in order to + # allow $(mkdir_p) to be used without argument. As in + # $(mkdir_p) $(somedir) + # where $(somedir) is conditionally defined. However this is wrong + # for two reasons: + # 1. if the package is installed by a user who cannot write `.' + # make install will fail, + # 2. the above comment should most certainly read + # $(mkdir_p) $(DESTDIR)$(somedir) + # so it does not work when $(somedir) is undefined and + # $(DESTDIR) is not. + # To support the latter case, we have to write + # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), + # so the `.' trick is pointless. + mkdir_p='mkdir -p --' +else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + for d in ./-p ./--version; + do + test -d $d && rmdir $d + done + # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. + if test -f "$ac_aux_dir/mkinstalldirs"; then + mkdir_p='$(mkinstalldirs)' + else + mkdir_p='$(install_sh) -d' + fi +fi + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_AWK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + echo "$as_me:$LINENO: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$AWK" && break +done + +echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +all: + @echo 'ac_maketemp="$(MAKE)"' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftest.make +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + SET_MAKE= +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +# test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} + { (exit 1); exit 1; }; } +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE='lha' + VERSION='1.14i-ac20050924p1' + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +install_sh=${install_sh-"$am_aux_dir/install-sh"} + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + echo "$as_me:$LINENO: result: $STRIP" >&5 +echo "${ECHO_T}$STRIP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":" +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +echo "${ECHO_T}$ac_ct_STRIP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + STRIP=$ac_ct_STRIP +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' + + + + + + ac_config_headers="$ac_config_headers config.h" + + + +cat >>confdefs.h <<_ACEOF +#define PLATFORM "$ac_cv_host" +_ACEOF + + +# Checks for programs. +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CC" && break +done + + CC=$ac_ct_CC +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. + +# Be careful to initialize this variable, since it used to be cached. +# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. +ac_cv_exeext= +# b.out is created by i960 compilers. +for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) + ;; + conftest.$ac_ext ) + # This is the source file. + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool, + # but it would be cool to find out if it's true. Does anybody + # maintain Libtool? --akim. + export ac_cv_exeext + break;; + * ) + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 + +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cc_g=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_stdc=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std1 is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std1. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext +done +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC + +fi + +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; +esac + +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + '' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +#include +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +DEPDIR="${am__leading_dot}deps" + + ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 +echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6 +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi + + +echo "$as_me:$LINENO: result: $_am_result" >&5 +echo "${ECHO_T}$_am_result" >&6 +rm -f confinc confmf + +# Check whether --enable-dependency-tracking or --disable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then + enableval="$enable_dependency_tracking" + +fi; +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + + +if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + + + +depcc="$CC" am_compiler_list= + +echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6 +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + + +if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6 +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6 +if test "${ac_cv_prog_egrep+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 +echo "${ECHO_T}$ac_cv_prog_egrep" >&6 + EGREP=$ac_cv_prog_egrep + + +if test $ac_cv_c_compiler_gnu = yes; then + echo "$as_me:$LINENO: checking whether $CC needs -traditional" >&5 +echo $ECHO_N "checking whether $CC needs -traditional... $ECHO_C" >&6 +if test "${ac_cv_prog_gcc_traditional+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_pattern="Autoconf.*'x'" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +Autoconf TIOCGETP +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "$ac_pattern" >/dev/null 2>&1; then + ac_cv_prog_gcc_traditional=yes +else + ac_cv_prog_gcc_traditional=no +fi +rm -f conftest* + + + if test $ac_cv_prog_gcc_traditional = no; then + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +Autoconf TCGETA +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "$ac_pattern" >/dev/null 2>&1; then + ac_cv_prog_gcc_traditional=yes +fi +rm -f conftest* + + fi +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_gcc_traditional" >&5 +echo "${ECHO_T}$ac_cv_prog_gcc_traditional" >&6 + if test $ac_cv_prog_gcc_traditional = yes; then + CC="$CC -traditional" + fi +fi + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL=$ac_install_sh + fi +fi +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +all: + @echo 'ac_maketemp="$(MAKE)"' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftest.make +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + SET_MAKE= +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_stdc=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_Header=no" +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +if test "${ac_cv_header_minix_config_h+set}" = set; then + echo "$as_me:$LINENO: checking for minix/config.h" >&5 +echo $ECHO_N "checking for minix/config.h... $ECHO_C" >&6 +if test "${ac_cv_header_minix_config_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: $ac_cv_header_minix_config_h" >&5 +echo "${ECHO_T}$ac_cv_header_minix_config_h" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking minix/config.h usability" >&5 +echo $ECHO_N "checking minix/config.h usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking minix/config.h presence" >&5 +echo $ECHO_N "checking minix/config.h presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: minix/config.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: minix/config.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: minix/config.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: minix/config.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: minix/config.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: minix/config.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: minix/config.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: minix/config.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: minix/config.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: minix/config.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: minix/config.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: minix/config.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: minix/config.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: minix/config.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: minix/config.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: minix/config.h: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ---------------------------------------- ## +## Report this to arai@users.sourceforge.jp ## +## ---------------------------------------- ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for minix/config.h" >&5 +echo $ECHO_N "checking for minix/config.h... $ECHO_C" >&6 +if test "${ac_cv_header_minix_config_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_minix_config_h=$ac_header_preproc +fi +echo "$as_me:$LINENO: result: $ac_cv_header_minix_config_h" >&5 +echo "${ECHO_T}$ac_cv_header_minix_config_h" >&6 + +fi +if test $ac_cv_header_minix_config_h = yes; then + MINIX=yes +else + MINIX= +fi + + +if test "$MINIX" = yes; then + +cat >>confdefs.h <<\_ACEOF +#define _POSIX_SOURCE 1 +_ACEOF + + +cat >>confdefs.h <<\_ACEOF +#define _POSIX_1_SOURCE 2 +_ACEOF + + +cat >>confdefs.h <<\_ACEOF +#define _MINIX 1 +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for function prototypes" >&5 +echo $ECHO_N "checking for function prototypes... $ECHO_C" >&6 +if test "$ac_cv_prog_cc_stdc" != no; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +cat >>confdefs.h <<\_ACEOF +#define PROTOTYPES 1 +_ACEOF + + +cat >>confdefs.h <<\_ACEOF +#define __PROTOTYPES 1 +_ACEOF + +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + +if test "$ac_cv_prog_cc_stdc" != no; then + U= ANSI2KNR= +else + U=_ ANSI2KNR=./ansi2knr +fi +# Ensure some checks needed by ansi2knr itself. + + +for ac_header in string.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ---------------------------------------- ## +## Report this to arai@users.sourceforge.jp ## +## ---------------------------------------- ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +# Check whether --enable-largefile or --disable-largefile was given. +if test "${enable_largefile+set}" = set; then + enableval="$enable_largefile" + +fi; +if test "$enable_largefile" != no; then + + echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5 +echo $ECHO_N "checking for special C compiler options needed for large files... $ECHO_C" >&6 +if test "${ac_cv_sys_largefile_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_sys_largefile_CC=no + if test "$GCC" != yes; then + ac_save_CC=$CC + while :; do + # IRIX 6.2 and later do not support large files by default, + # so use the C compiler's -n32 option if that helps. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext + CC="$CC -n32" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sys_largefile_CC=' -n32'; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext + break + done + CC=$ac_save_CC + rm -f conftest.$ac_ext + fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5 +echo "${ECHO_T}$ac_cv_sys_largefile_CC" >&6 + if test "$ac_cv_sys_largefile_CC" != no; then + CC=$CC$ac_cv_sys_largefile_CC + fi + + echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5 +echo $ECHO_N "checking for _FILE_OFFSET_BITS value needed for large files... $ECHO_C" >&6 +if test "${ac_cv_sys_file_offset_bits+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + while :; do + ac_cv_sys_file_offset_bits=no + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#define _FILE_OFFSET_BITS 64 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sys_file_offset_bits=64; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + break +done +fi +echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5 +echo "${ECHO_T}$ac_cv_sys_file_offset_bits" >&6 +if test "$ac_cv_sys_file_offset_bits" != no; then + +cat >>confdefs.h <<_ACEOF +#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits +_ACEOF + +fi +rm -f conftest* + echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5 +echo $ECHO_N "checking for _LARGE_FILES value needed for large files... $ECHO_C" >&6 +if test "${ac_cv_sys_large_files+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + while :; do + ac_cv_sys_large_files=no + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#define _LARGE_FILES 1 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sys_large_files=1; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + break +done +fi +echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5 +echo "${ECHO_T}$ac_cv_sys_large_files" >&6 +if test "$ac_cv_sys_large_files" != no; then + +cat >>confdefs.h <<_ACEOF +#define _LARGE_FILES $ac_cv_sys_large_files +_ACEOF + +fi +rm -f conftest* +fi + + +# Checks for libraries. +echo "$as_me:$LINENO: checking for library containing opendir" >&5 +echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6 +if test "${ac_cv_search_opendir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +ac_cv_search_opendir=no +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir (); +int +main () +{ +opendir (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_opendir="none required" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test "$ac_cv_search_opendir" = no; then + for ac_lib in mingwex; do + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir (); +int +main () +{ +opendir (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_opendir="-l$ac_lib" +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + done +fi +LIBS=$ac_func_search_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 +echo "${ECHO_T}$ac_cv_search_opendir" >&6 +if test "$ac_cv_search_opendir" != no; then + test "$ac_cv_search_opendir" = "none required" || LIBS="$ac_cv_search_opendir $LIBS" + +fi + + +# Checks for header files. + + + + + +ac_header_dirent=no +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do + as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5 +echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include <$ac_hdr> + +int +main () +{ +if ((DIR *) 0) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_Header=no" +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 +_ACEOF + +ac_header_dirent=$ac_hdr; break +fi + +done +# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. +if test $ac_header_dirent = dirent.h; then + echo "$as_me:$LINENO: checking for library containing opendir" >&5 +echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6 +if test "${ac_cv_search_opendir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +ac_cv_search_opendir=no +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir (); +int +main () +{ +opendir (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_opendir="none required" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test "$ac_cv_search_opendir" = no; then + for ac_lib in dir; do + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir (); +int +main () +{ +opendir (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_opendir="-l$ac_lib" +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + done +fi +LIBS=$ac_func_search_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 +echo "${ECHO_T}$ac_cv_search_opendir" >&6 +if test "$ac_cv_search_opendir" != no; then + test "$ac_cv_search_opendir" = "none required" || LIBS="$ac_cv_search_opendir $LIBS" + +fi + +else + echo "$as_me:$LINENO: checking for library containing opendir" >&5 +echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6 +if test "${ac_cv_search_opendir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +ac_cv_search_opendir=no +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir (); +int +main () +{ +opendir (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_opendir="none required" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test "$ac_cv_search_opendir" = no; then + for ac_lib in x; do + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir (); +int +main () +{ +opendir (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_opendir="-l$ac_lib" +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + done +fi +LIBS=$ac_func_search_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 +echo "${ECHO_T}$ac_cv_search_opendir" >&6 +if test "$ac_cv_search_opendir" != no; then + test "$ac_cv_search_opendir" = "none required" || LIBS="$ac_cv_search_opendir $LIBS" + +fi + +fi + +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_stdc=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + + + + + + +for ac_header in fcntl.h limits.h sys/file.h sys/param.h sys/time.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ---------------------------------------- ## +## Report this to arai@users.sourceforge.jp ## +## ---------------------------------------- ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + + + +for ac_header in pwd.h grp.h utime.h inttypes.h stdint.h fnmatch.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ---------------------------------------- ## +## Report this to arai@users.sourceforge.jp ## +## ---------------------------------------- ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +# Checks for typedefs, structures, and compiler characteristics. +echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 +echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 +if test "${ac_cv_c_const+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ +#ifndef __cplusplus + /* Ultrix mips cc rejects this. */ + typedef int charset[2]; + const charset x; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *ccp; + char **p; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + ccp = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++ccp; + p = (char**) ccp; + ccp = (char const *const *) p; + { /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + } +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_const=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_c_const=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 +echo "${ECHO_T}$ac_cv_c_const" >&6 +if test $ac_cv_c_const = no; then + +cat >>confdefs.h <<\_ACEOF +#define const +_ACEOF + +fi + +echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 +echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6 +if test "${ac_cv_header_time+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include + +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_time=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_time=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 +echo "${ECHO_T}$ac_cv_header_time" >&6 +if test $ac_cv_header_time = yes; then + +cat >>confdefs.h <<\_ACEOF +#define TIME_WITH_SYS_TIME 1 +_ACEOF + +fi + +echo "$as_me:$LINENO: checking whether struct tm is in sys/time.h or time.h" >&5 +echo $ECHO_N "checking whether struct tm is in sys/time.h or time.h... $ECHO_C" >&6 +if test "${ac_cv_struct_tm+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +struct tm *tp; tp->tm_sec; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_struct_tm=time.h +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_struct_tm=sys/time.h +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_struct_tm" >&5 +echo "${ECHO_T}$ac_cv_struct_tm" >&6 +if test $ac_cv_struct_tm = sys/time.h; then + +cat >>confdefs.h <<\_ACEOF +#define TM_IN_SYS_TIME 1 +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for struct tm.tm_zone" >&5 +echo $ECHO_N "checking for struct tm.tm_zone... $ECHO_C" >&6 +if test "${ac_cv_member_struct_tm_tm_zone+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include <$ac_cv_struct_tm> + + +int +main () +{ +static struct tm ac_aggr; +if (ac_aggr.tm_zone) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_tm_tm_zone=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include <$ac_cv_struct_tm> + + +int +main () +{ +static struct tm ac_aggr; +if (sizeof ac_aggr.tm_zone) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_tm_tm_zone=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_member_struct_tm_tm_zone=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_member_struct_tm_tm_zone" >&5 +echo "${ECHO_T}$ac_cv_member_struct_tm_tm_zone" >&6 +if test $ac_cv_member_struct_tm_tm_zone = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_TM_TM_ZONE 1 +_ACEOF + + +fi + +if test "$ac_cv_member_struct_tm_tm_zone" = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_TM_ZONE 1 +_ACEOF + +else + echo "$as_me:$LINENO: checking for tzname" >&5 +echo $ECHO_N "checking for tzname... $ECHO_C" >&6 +if test "${ac_cv_var_tzname+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#ifndef tzname /* For SGI. */ +extern char *tzname[]; /* RS6000 and others reject char **tzname. */ +#endif + +int +main () +{ +atoi(*tzname); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_var_tzname=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_var_tzname=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_var_tzname" >&5 +echo "${ECHO_T}$ac_cv_var_tzname" >&6 + if test $ac_cv_var_tzname = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_TZNAME 1 +_ACEOF + + fi +fi + + +echo "$as_me:$LINENO: checking for long" >&5 +echo $ECHO_N "checking for long... $ECHO_C" >&6 +if test "${ac_cv_type_long+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((long *) 0) + return 0; +if (sizeof (long)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_long=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_long=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_long" >&5 +echo "${ECHO_T}$ac_cv_type_long" >&6 + +echo "$as_me:$LINENO: checking size of long" >&5 +echo $ECHO_N "checking size of long... $ECHO_C" >&6 +if test "${ac_cv_sizeof_long+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type_long" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_long=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (long), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (long)); } +unsigned long ulongval () { return (long) (sizeof (long)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (long))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (long)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (long)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_long=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (long), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val +else + ac_cv_sizeof_long=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5 +echo "${ECHO_T}$ac_cv_sizeof_long" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF_LONG $ac_cv_sizeof_long +_ACEOF + + +echo "$as_me:$LINENO: checking for uid_t" >&5 +echo $ECHO_N "checking for uid_t... $ECHO_C" >&6 +if test "${ac_cv_type_uid_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((uid_t *) 0) + return 0; +if (sizeof (uid_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_uid_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_uid_t=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_uid_t" >&5 +echo "${ECHO_T}$ac_cv_type_uid_t" >&6 +if test $ac_cv_type_uid_t = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_UID_T 1 +_ACEOF + + +fi +echo "$as_me:$LINENO: checking for gid_t" >&5 +echo $ECHO_N "checking for gid_t... $ECHO_C" >&6 +if test "${ac_cv_type_gid_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((gid_t *) 0) + return 0; +if (sizeof (gid_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_gid_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_gid_t=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_gid_t" >&5 +echo "${ECHO_T}$ac_cv_type_gid_t" >&6 +if test $ac_cv_type_gid_t = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_GID_T 1 +_ACEOF + + +fi +echo "$as_me:$LINENO: checking for long long" >&5 +echo $ECHO_N "checking for long long... $ECHO_C" >&6 +if test "${ac_cv_type_long_long+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((long long *) 0) + return 0; +if (sizeof (long long)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_long_long=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_long_long=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5 +echo "${ECHO_T}$ac_cv_type_long_long" >&6 +if test $ac_cv_type_long_long = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_LONG_LONG 1 +_ACEOF + + +fi +echo "$as_me:$LINENO: checking for uint64_t" >&5 +echo $ECHO_N "checking for uint64_t... $ECHO_C" >&6 +if test "${ac_cv_type_uint64_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((uint64_t *) 0) + return 0; +if (sizeof (uint64_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_uint64_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_uint64_t=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_uint64_t" >&5 +echo "${ECHO_T}$ac_cv_type_uint64_t" >&6 +if test $ac_cv_type_uint64_t = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_UINT64_T 1 +_ACEOF + + +fi +echo "$as_me:$LINENO: checking for ssize_t" >&5 +echo $ECHO_N "checking for ssize_t... $ECHO_C" >&6 +if test "${ac_cv_type_ssize_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((ssize_t *) 0) + return 0; +if (sizeof (ssize_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_ssize_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_ssize_t=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_ssize_t" >&5 +echo "${ECHO_T}$ac_cv_type_ssize_t" >&6 +if test $ac_cv_type_ssize_t = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_SSIZE_T 1 +_ACEOF + + +fi + +echo "$as_me:$LINENO: checking for struct tm.tm_gmtoff" >&5 +echo $ECHO_N "checking for struct tm.tm_gmtoff... $ECHO_C" >&6 +if test "${ac_cv_member_struct_tm_tm_gmtoff+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#if HAVE_SYS_TYPES_H +# include +#endif +#if HAVE_SYS_STAT_H +# include +#endif +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + + +int +main () +{ +static struct tm ac_aggr; +if (ac_aggr.tm_gmtoff) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_tm_tm_gmtoff=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#if HAVE_SYS_TYPES_H +# include +#endif +#if HAVE_SYS_STAT_H +# include +#endif +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + + +int +main () +{ +static struct tm ac_aggr; +if (sizeof ac_aggr.tm_gmtoff) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_tm_tm_gmtoff=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_member_struct_tm_tm_gmtoff=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_member_struct_tm_tm_gmtoff" >&5 +echo "${ECHO_T}$ac_cv_member_struct_tm_tm_gmtoff" >&6 +if test $ac_cv_member_struct_tm_tm_gmtoff = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_TM_TM_GMTOFF 1 +_ACEOF + + +fi +echo "$as_me:$LINENO: checking for struct stat.st_ino" >&5 +echo $ECHO_N "checking for struct stat.st_ino... $ECHO_C" >&6 +if test "${ac_cv_member_struct_stat_st_ino+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#if HAVE_SYS_TYPES_H +# include +#endif +#if HAVE_SYS_STAT_H +# include +#endif +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + + +int +main () +{ +static struct stat ac_aggr; +if (ac_aggr.st_ino) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_stat_st_ino=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#if HAVE_SYS_TYPES_H +# include +#endif +#if HAVE_SYS_STAT_H +# include +#endif +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + + +int +main () +{ +static struct stat ac_aggr; +if (sizeof ac_aggr.st_ino) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_stat_st_ino=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_member_struct_stat_st_ino=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_member_struct_stat_st_ino" >&5 +echo "${ECHO_T}$ac_cv_member_struct_stat_st_ino" >&6 +if test $ac_cv_member_struct_stat_st_ino = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_STAT_ST_INO 1 +_ACEOF + + +fi + + +# Checks for library functions. +echo "$as_me:$LINENO: checking return type of signal handlers" >&5 +echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6 +if test "${ac_cv_type_signal+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#ifdef signal +# undef signal +#endif +#ifdef __cplusplus +extern "C" void (*signal (int, void (*)(int)))(int); +#else +void (*signal ()) (); +#endif + +int +main () +{ +int i; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_signal=void +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_signal=int +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 +echo "${ECHO_T}$ac_cv_type_signal" >&6 + +cat >>confdefs.h <<_ACEOF +#define RETSIGTYPE $ac_cv_type_signal +_ACEOF + + +echo "$as_me:$LINENO: checking whether utime accepts a null argument" >&5 +echo $ECHO_N "checking whether utime accepts a null argument... $ECHO_C" >&6 +if test "${ac_cv_func_utime_null+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + rm -f conftest.data; >conftest.data +# Sequent interprets utime(file, 0) to mean use start of epoch. Wrong. +if test "$cross_compiling" = yes; then + ac_cv_func_utime_null=no +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +struct stat s, t; + exit (!(stat ("conftest.data", &s) == 0 + && utime ("conftest.data", (long *)0) == 0 + && stat ("conftest.data", &t) == 0 + && t.st_mtime >= s.st_mtime + && t.st_mtime - s.st_mtime < 120)); + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_utime_null=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_utime_null=no +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +rm -f core *.core +fi +echo "$as_me:$LINENO: result: $ac_cv_func_utime_null" >&5 +echo "${ECHO_T}$ac_cv_func_utime_null" >&6 +if test $ac_cv_func_utime_null = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_UTIME_NULL 1 +_ACEOF + +fi +rm -f conftest.data + +echo "$as_me:$LINENO: checking for working POSIX fnmatch" >&5 +echo $ECHO_N "checking for working POSIX fnmatch... $ECHO_C" >&6 +if test "${ac_cv_func_fnmatch_works+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Some versions of Solaris, SCO, and the GNU C Library + # have a broken or incompatible fnmatch. + # So we run a test program. If we are cross-compiling, take no chance. + # Thanks to John Oleynick, Franc,ois Pinard, and Paul Eggert for this test. + if test "$cross_compiling" = yes; then + ac_cv_func_fnmatch_works=cross +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +# define y(a, b, c) (fnmatch (a, b, c) == 0) +# define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH) + +int +main () +{ +exit + (!(y ("a*", "abc", 0) + && n ("d*/*1", "d/s/1", FNM_PATHNAME) + && y ("a\\\\bc", "abc", 0) + && n ("a\\\\bc", "abc", FNM_NOESCAPE) + && y ("*x", ".x", 0) + && n ("*x", ".x", FNM_PERIOD) + && 1)); + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_fnmatch_works=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_fnmatch_works=no +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_func_fnmatch_works" >&5 +echo "${ECHO_T}$ac_cv_func_fnmatch_works" >&6 +if test $ac_cv_func_fnmatch_works = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_FNMATCH 1 +_ACEOF + +fi + + + +echo "$as_me:$LINENO: checking for _LARGEFILE_SOURCE value needed for large files" >&5 +echo $ECHO_N "checking for _LARGEFILE_SOURCE value needed for large files... $ECHO_C" >&6 +if test "${ac_cv_sys_largefile_source+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + while :; do + ac_cv_sys_largefile_source=no + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ +return !fseeko; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#define _LARGEFILE_SOURCE 1 +#include +int +main () +{ +return !fseeko; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sys_largefile_source=1; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + break +done +fi +echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_source" >&5 +echo "${ECHO_T}$ac_cv_sys_largefile_source" >&6 +if test "$ac_cv_sys_largefile_source" != no; then + +cat >>confdefs.h <<_ACEOF +#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source +_ACEOF + +fi +rm -f conftest* + +# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug +# in glibc 2.1.3, but that breaks too many other things. +# If you want fseeko and ftello with glibc, upgrade to a fixed glibc. +echo "$as_me:$LINENO: checking for fseeko" >&5 +echo $ECHO_N "checking for fseeko... $ECHO_C" >&6 +if test "${ac_cv_func_fseeko+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ +return fseeko && fseeko (stdin, 0, 0); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_fseeko=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_fseeko=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_fseeko" >&5 +echo "${ECHO_T}$ac_cv_func_fseeko" >&6 +if test $ac_cv_func_fseeko = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_FSEEKO 1 +_ACEOF + +fi + + + + + + + +for ac_func in strchr strdup memcpy memset memmove strcasecmp +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + + + + + +for ac_func in mktime timelocal tzset ftime gettimeofday utime +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + + + + +for ac_func in ftruncate chsize lchown mkstemp ftello +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + + + +for ac_func in getpwuid getgrgid getpwnam getgrnam +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + +for ac_func in iconv basename +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + +for ac_func in vsnprintf fnmatch +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +else + case $LIBOBJS in + "$ac_func.$ac_objext" | \ + *" $ac_func.$ac_objext" | \ + "$ac_func.$ac_objext "* | \ + *" $ac_func.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext" ;; +esac + +fi +done + + + +if test $ac_header_dirent = no; then + case $LIBOBJS in + "lhdir.$ac_objext" | \ + *" lhdir.$ac_objext" | \ + "lhdir.$ac_objext "* | \ + *" lhdir.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS lhdir.$ac_objext" ;; +esac + +fi + +echo "$as_me:$LINENO: checking whether basename is declared" >&5 +echo $ECHO_N "checking whether basename is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_basename+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +#ifndef basename + char *p = (char *) basename; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_basename=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_have_decl_basename=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_basename" >&5 +echo "${ECHO_T}$ac_cv_have_decl_basename" >&6 +if test $ac_cv_have_decl_basename = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_BASENAME 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_BASENAME 0 +_ACEOF + + +fi + + + +# checking whether 8 bit clean or not +echo "$as_me:$LINENO: checking whether strchr()/strrchr() is 8bit clean" >&5 +echo $ECHO_N "checking whether strchr()/strrchr() is 8bit clean... $ECHO_C" >&6 +if test "${lha_cv_func_strchr_8bit_clean+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + lha_cv_func_strchr_8bit_clean=no +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#if STDC_HEADERS +# include +#else +# if !HAVE_STRCHR +# define strchr index +# define strrchr rindex +# endif +char *strchr (), *strrchr (); +#endif + +main() +{ + char *s = "\377"; + if (strchr(s, 0xff) != s) exit(1); + if (strchr(s, '\377') != s) exit(1); + if (strrchr(s, 0xff) != s) exit(1); + if (strrchr(s, '\377') != s) exit(1); + exit(0); /* ok */ +} + +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + lha_cv_func_strchr_8bit_clean=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +lha_cv_func_strchr_8bit_clean=no +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +echo "$as_me:$LINENO: result: $lha_cv_func_strchr_8bit_clean" >&5 +echo "${ECHO_T}$lha_cv_func_strchr_8bit_clean" >&6 + +if test x$lha_cv_func_strchr_8bit_clean = xyes; then + +cat >>confdefs.h <<\_ACEOF +#define STRCHR_8BIT_CLEAN 1 +_ACEOF + +fi + +# checking whether the 2nd argument of gettimeofday() is effective or not. +# note that this timezone argument is obsolete. +echo "$as_me:$LINENO: checking whether the 2nd argument of gettimeofday() is effective" >&5 +echo $ECHO_N "checking whether the 2nd argument of gettimeofday() is effective... $ECHO_C" >&6 +if test "${lha_cv_func_gettimeofday_2nd_arg+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + lha_cv_func_gettimeofday_2nd_arg=no +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + +main() +{ + struct timeval tv; + struct timezone tz; + + tz.tz_minuteswest = -1; + if (gettimeofday(&tv, &tz) == -1) + exit(1); + + if (tz.tz_minuteswest == -1) + exit(1); /* the timezone information is no given */ + + exit(0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + lha_cv_func_gettimeofday_2nd_arg=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +lha_cv_func_gettimeofday_2nd_arg=no +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +echo "$as_me:$LINENO: result: $lha_cv_func_gettimeofday_2nd_arg" >&5 +echo "${ECHO_T}$lha_cv_func_gettimeofday_2nd_arg" >&6 + +if test x$lha_cv_func_gettimeofday_2nd_arg = xyes; then + +cat >>confdefs.h <<\_ACEOF +#define GETTIMEOFDAY_HAS_2ND_ARG 1 +_ACEOF + +fi + +# support kanji code conversion + +echo "$as_me:$LINENO: checking kanji code conversion on text file" >&5 +echo $ECHO_N "checking kanji code conversion on text file... $ECHO_C" >&6 +# Check whether --enable-text-conv or --disable-text-conv was given. +if test "${enable_text_conv+set}" = set; then + enableval="$enable_text_conv" + +else + enable_text_conv=yes +fi; + +echo "$as_me:$LINENO: result: $enable_text_conv" >&5 +echo "${ECHO_T}$enable_text_conv" >&6 +if test $enable_text_conv = yes; then + DEF_KCODE=-DEUC +fi + +# force support -lh7- + +SUPPORT_LZHUFF_METHOD=-DSUPPORT_LH7 + +# whether use the -lh567- method +echo "$as_me:$LINENO: checking default archive method" >&5 +echo $ECHO_N "checking default archive method... $ECHO_C" >&6 + +# Check whether --with-default-method or --without-default-method was given. +if test "${with_default_method+set}" = set; then + withval="$with_default_method" + case $withval in + 567) ;; + *) { { echo "$as_me:$LINENO: error: you should have specified 5" >&5 +echo "$as_me: error: you should have specified 5" >&2;} + { (exit 6 or 7); exit 6 or 7; }; };; + esac +else + with_default_method=5 +fi; +echo "$as_me:$LINENO: result: -lh$with_default_method-" >&5 +echo "${ECHO_T}-lh$with_default_method-" >&6 + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_LZHUFF_METHOD LZHUFF${with_default_method}_METHOD_NUM +_ACEOF + + +# decide temporary path names +echo "$as_me:$LINENO: checking template of the temporary file" >&5 +echo $ECHO_N "checking template of the temporary file... $ECHO_C" >&6 + +# Check whether --with-tmp-file or --without-tmp-file was given. +if test "${with_tmp_file+set}" = set; then + withval="$with_tmp_file" + case $withval in + yes) with_tmp_file=/tmp/lhXXXXXX ;; + no) ;; + esac +else + with_tmp_file=/tmp/lhXXXXXX +fi; + +echo "$as_me:$LINENO: result: $with_tmp_file" >&5 +echo "${ECHO_T}$with_tmp_file" >&6 +if test x"$with_tmp_file" != xno; then + +cat >>confdefs.h <<_ACEOF +#define TMP_FILENAME_TEMPLATE "$with_tmp_file" +_ACEOF + +fi + +# incremental indicator +echo "$as_me:$LINENO: checking whether incremental indicator is needed" >&5 +echo $ECHO_N "checking whether incremental indicator is needed... $ECHO_C" >&6 +# Check whether --enable-indicator or --disable-indicator was given. +if test "${enable_indicator+set}" = set; then + enableval="$enable_indicator" + +else + # default + enable_indicator=yes +fi; + +echo "$as_me:$LINENO: result: $enable_indicator" >&5 +echo "${ECHO_T}$enable_indicator" >&6 +if test "x$enable_indicator" = xyes; then + +cat >>confdefs.h <<\_ACEOF +#define NEED_INCREMENTAL_INDICATOR 1 +_ACEOF + +fi + +# support multibyte filename +echo "$as_me:$LINENO: checking kanji code of filename" >&5 +echo $ECHO_N "checking kanji code of filename... $ECHO_C" >&6 +# Check whether --enable-multibyte-filename or --disable-multibyte-filename was given. +if test "${enable_multibyte_filename+set}" = set; then + enableval="$enable_multibyte_filename" + +else + # default + enable_multibyte_filename=auto +fi; + +case $enable_multibyte_filename in +auto|yes) + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__hpux) +SJIS +#endif +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "SJIS" >/dev/null 2>&1; then + enable_multibyte_filename=CODE_SJIS +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#if defined(__APPLE__) /* for Mac OS X */ +UTF8 +#endif +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "UTF8" >/dev/null 2>&1; then + enable_multibyte_filename=CODE_UTF8 +else + enable_multibyte_filename=CODE_EUC +fi +rm -f conftest* + +fi +rm -f conftest* +;; +sjis) enable_multibyte_filename=CODE_SJIS;; +euc) enable_multibyte_filename=CODE_EUC;; +utf8) enable_multibyte_filename=CODE_UTF8;; +no) ;; +*) { { echo "$as_me:$LINENO: error: you should specify auto, sjis or euc as your system filename code." >&5 +echo "$as_me: error: you should specify auto, sjis or euc as your system filename code." >&2;} + { (exit 1); exit 1; }; };; +esac + +echo "$as_me:$LINENO: result: $enable_multibyte_filename" >&5 +echo "${ECHO_T}$enable_multibyte_filename" >&6 +if test x$enable_multibyte_filename != xno; then + +cat >>confdefs.h <<_ACEOF +#define MULTIBYTE_FILENAME $enable_multibyte_filename +_ACEOF + + + case $target_os in + darwin*) + # for multibyte filename + LDFLAGS="$LDFLAGS -framework CoreFoundation" + ;; + esac +fi + +# make user/group name extented header +echo "$as_me:$LINENO: checking whether user/group name extended header is needed" >&5 +echo $ECHO_N "checking whether user/group name extended header is needed... $ECHO_C" >&6 +# Check whether --enable-user-name-header or --disable-user-name-header was given. +if test "${enable_user_name_header+set}" = set; then + enableval="$enable_user_name_header" + +else + # default + enable_user_name_header=no +fi; + +echo "$as_me:$LINENO: result: $enable_user_name_header" >&5 +echo "${ECHO_T}$enable_user_name_header" >&6 +if test "x$enable_user_name_header" = xyes; then + +cat >>confdefs.h <<\_ACEOF +#define INCLUDE_OWNER_NAME_IN_HEADER 1 +_ACEOF + +fi + +# backup old archive file +echo "$as_me:$LINENO: checking whether backup file for old archive is left" >&5 +echo $ECHO_N "checking whether backup file for old archive is left... $ECHO_C" >&6 +# Check whether --enable-backup-archive or --disable-backup-archive was given. +if test "${enable_backup_archive+set}" = set; then + enableval="$enable_backup_archive" + +else + # default + enable_backup_archive=no +fi; + +echo "$as_me:$LINENO: result: $enable_backup_archive" >&5 +echo "${ECHO_T}$enable_backup_archive" >&6 +if test "x$enable_backup_archive" = xyes; then + +cat >>confdefs.h <<\_ACEOF +#define BACKUP_OLD_ARCHIVE 1 +_ACEOF + +fi + +# enable this option if you need to ignore '.file' files +# (mainly for the Mac OS X) *experimental* +echo "$as_me:$LINENO: checking whether enable -X option which ignore dot files" >&5 +echo $ECHO_N "checking whether enable -X option which ignore dot files... $ECHO_C" >&6 +# Check whether --enable-ignore-dot-files or --disable-ignore-dot-files was given. +if test "${enable_ignore_dot_files+set}" = set; then + enableval="$enable_ignore_dot_files" + +else + # default + enable_ignore_dot_files=no +fi; + +echo "$as_me:$LINENO: result: $enable_ignore_dot_files" >&5 +echo "${ECHO_T}$enable_ignore_dot_files" >&6 +if test "x$enable_ignore_dot_files" = xyes; then + +cat >>confdefs.h <<\_ACEOF +#define IGNORE_DOT_FILES 1 +_ACEOF + +fi + + ac_config_files="$ac_config_files Makefile src/Makefile man/Makefile olddoc/Makefile" + + ac_config_files="$ac_config_files tests/Makefile tests/lha-test" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if diff $cache_file confcache >/dev/null 2>&1; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' +fi + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_i=`echo "$ac_i" | + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + +exec 6>&1 + +# Open the log real soon, to keep \$[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + +This file was extended by LHa for UNIX $as_me 1.14i-ac20050924p1, which was +generated by GNU Autoconf 2.59. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\_ACEOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to ." +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +LHa for UNIX config.status 1.14i-ac20050924p1 +configured by $0, generated by GNU Autoconf 2.59, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2003 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=$srcdir +INSTALL="$INSTALL" +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + ac_shift=: + ;; + -*) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_option=$1 + ac_need_defaults=false;; + esac + + case $ac_option in + # Handling of the options. +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +# +# INIT-COMMANDS section. +# + +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" + +_ACEOF + + + +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_config_target in $ac_config_targets +do + case "$ac_config_target" in + # Handling of arguments. + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "src/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; + "man/Makefile" ) CONFIG_FILES="$CONFIG_FILES man/Makefile" ;; + "olddoc/Makefile" ) CONFIG_FILES="$CONFIG_FILES olddoc/Makefile" ;; + "tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;; + "tests/lha-test" ) CONFIG_FILES="$CONFIG_FILES tests/lha-test" ;; + "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason to put it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./confstat$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF + +# +# CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@build_alias@,$build_alias,;t t +s,@host_alias@,$host_alias,;t t +s,@target_alias@,$target_alias,;t t +s,@DEFS@,$DEFS,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@LIBS@,$LIBS,;t t +s,@build@,$build,;t t +s,@build_cpu@,$build_cpu,;t t +s,@build_vendor@,$build_vendor,;t t +s,@build_os@,$build_os,;t t +s,@host@,$host,;t t +s,@host_cpu@,$host_cpu,;t t +s,@host_vendor@,$host_vendor,;t t +s,@host_os@,$host_os,;t t +s,@target@,$target,;t t +s,@target_cpu@,$target_cpu,;t t +s,@target_vendor@,$target_vendor,;t t +s,@target_os@,$target_os,;t t +s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t +s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t +s,@INSTALL_DATA@,$INSTALL_DATA,;t t +s,@CYGPATH_W@,$CYGPATH_W,;t t +s,@PACKAGE@,$PACKAGE,;t t +s,@VERSION@,$VERSION,;t t +s,@ACLOCAL@,$ACLOCAL,;t t +s,@AUTOCONF@,$AUTOCONF,;t t +s,@AUTOMAKE@,$AUTOMAKE,;t t +s,@AUTOHEADER@,$AUTOHEADER,;t t +s,@MAKEINFO@,$MAKEINFO,;t t +s,@install_sh@,$install_sh,;t t +s,@STRIP@,$STRIP,;t t +s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t +s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t +s,@mkdir_p@,$mkdir_p,;t t +s,@AWK@,$AWK,;t t +s,@SET_MAKE@,$SET_MAKE,;t t +s,@am__leading_dot@,$am__leading_dot,;t t +s,@AMTAR@,$AMTAR,;t t +s,@am__tar@,$am__tar,;t t +s,@am__untar@,$am__untar,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@DEPDIR@,$DEPDIR,;t t +s,@am__include@,$am__include,;t t +s,@am__quote@,$am__quote,;t t +s,@AMDEP_TRUE@,$AMDEP_TRUE,;t t +s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t +s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t +s,@CCDEPMODE@,$CCDEPMODE,;t t +s,@am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t +s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t +s,@CPP@,$CPP,;t t +s,@EGREP@,$EGREP,;t t +s,@U@,$U,;t t +s,@ANSI2KNR@,$ANSI2KNR,;t t +s,@LIBOBJS@,$LIBOBJS,;t t +s,@DEF_KCODE@,$DEF_KCODE,;t t +s,@SUPPORT_LZHUFF_METHOD@,$SUPPORT_LZHUFF_METHOD,;t t +s,@LTLIBOBJS@,$LTLIBOBJS,;t t +CEOF + +_ACEOF + + cat >>$CONFIG_STATUS <<\_ACEOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat + fi +fi # test -n "$CONFIG_FILES" + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + esac + + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + configure_input= + else + configure_input="$ac_file. " + fi + configure_input=$configure_input"Generated from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo "$f";; + *) # Relative + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s,@configure_input@,$configure_input,;t t +s,@srcdir@,$ac_srcdir,;t t +s,@abs_srcdir@,$ac_abs_srcdir,;t t +s,@top_srcdir@,$ac_top_srcdir,;t t +s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t +s,@builddir@,$ac_builddir,;t t +s,@abs_builddir@,$ac_abs_builddir,;t t +s,@top_builddir@,$ac_top_builddir,;t t +s,@abs_top_builddir@,$ac_abs_top_builddir,;t t +s,@INSTALL@,$ac_INSTALL,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi + +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + +# +# CONFIG_HEADER section. +# + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='[ ].*$,\1#\2' +ac_dC=' ' +ac_dD=',;t' +# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='$,\1#\2define\3' +ac_uC=' ' +ac_uD=',;t' + +for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + # Do quote $f, to prevent DOS paths from being IFS'd. + echo "$f";; + *) # Relative + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + # Remove the trailing spaces. + sed 's/[ ]*$//' $ac_file_inputs >$tmp/in + +_ACEOF + +# Transform confdefs.h into two sed scripts, `conftest.defines' and +# `conftest.undefs', that substitutes the proper values into +# config.h.in to produce config.h. The first handles `#define' +# templates, and the second `#undef' templates. +# And first: Protect against being on the right side of a sed subst in +# config.status. Protect against being in an unquoted here document +# in config.status. +rm -f conftest.defines conftest.undefs +# Using a here document instead of a string reduces the quoting nightmare. +# Putting comments in sed scripts is not portable. +# +# `end' is used to avoid that the second main sed command (meant for +# 0-ary CPP macros) applies to n-ary macro definitions. +# See the Autoconf documentation for `clear'. +cat >confdef2sed.sed <<\_ACEOF +s/[\\&,]/\\&/g +s,[\\$`],\\&,g +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp +t end +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp +: end +_ACEOF +# If some macros were called several times there might be several times +# the same #defines, which is useless. Nevertheless, we may not want to +# sort them, since we want the *last* AC-DEFINE to be honored. +uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines +sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs +rm -f confdef2sed.sed + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >>conftest.undefs <<\_ACEOF +s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, +_ACEOF + +# Break up conftest.defines because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS +echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS +echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS +echo ' :' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.defines >/dev/null +do + # Write a limited-size here document to $tmp/defines.sed. + echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS + # Speed up: don't consider the non `#define' lines. + echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/defines.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines +echo ' fi # grep' >>$CONFIG_STATUS +echo >>$CONFIG_STATUS + +# Break up conftest.undefs because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #undef templates' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.undefs >/dev/null +do + # Write a limited-size here document to $tmp/undefs.sed. + echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS + # Speed up: don't consider the non `#undef' + echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/undefs.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail + rm -f conftest.undefs + mv conftest.tail conftest.undefs +done +rm -f conftest.undefs + +cat >>$CONFIG_STATUS <<\_ACEOF + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + echo "/* Generated by configure. */" >$tmp/config.h + else + echo "/* $ac_file. Generated by configure. */" >$tmp/config.h + fi + cat $tmp/in >>$tmp/config.h + rm -f $tmp/in + if test x"$ac_file" != x-; then + if diff $ac_file $tmp/config.h >/dev/null 2>&1; then + { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + rm -f $ac_file + mv $tmp/config.h $ac_file + fi + else + cat $tmp/config.h + rm -f $tmp/config.h + fi +# Compute $ac_file's index in $config_headers. +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $ac_file | $ac_file:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $ac_file" >`(dirname $ac_file) 2>/dev/null || +$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X$ac_file : 'X\(//\)[^/]' \| \ + X$ac_file : 'X\(//\)$' \| \ + X$ac_file : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X$ac_file | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'`/stamp-h$_am_stamp_count +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + +# +# CONFIG_COMMANDS section. +# +for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue + ac_dest=`echo "$ac_file" | sed 's,:.*,,'` + ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_dir=`(dirname "$ac_dest") 2>/dev/null || +$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_dest" : 'X\(//\)[^/]' \| \ + X"$ac_dest" : 'X\(//\)$' \| \ + X"$ac_dest" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_dest" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + + { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 +echo "$as_me: executing $ac_dest commands" >&6;} + case $ac_dest in + depfiles ) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # So let's grep whole file. + if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + dirpart=`(dirname "$mf") 2>/dev/null || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`(dirname "$file") 2>/dev/null || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p $dirpart/$fdir + else + as_dir=$dirpart/$fdir + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirpart/$fdir" >&5 +echo "$as_me: error: cannot create directory $dirpart/$fdir" >&2;} + { (exit 1); exit 1; }; }; } + + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done + ;; + esac +done +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi + diff -Nru lha-1.14i/configure.ac lha-1.14i-acc20050924p1/configure.ac --- lha-1.14i/configure.ac 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/configure.ac 2006-10-10 16:47:39.000000000 +0000 @@ -0,0 +1,294 @@ +# Process this file with autoconf to produce a configure script. +AC_INIT([LHa for UNIX], 1.14i-ac20050924p1, arai@users.sourceforge.jp, lha) +AC_CANONICAL_HOST +AC_CANONICAL_TARGET +AM_INIT_AUTOMAKE +AM_CONFIG_HEADER(config.h) + +AC_DEFINE_UNQUOTED(PLATFORM, "$ac_cv_host", + [the type of system on which the package will run.]) + +# Checks for programs. +AC_PROG_CC +AC_PROG_GCC_TRADITIONAL +AC_PROG_INSTALL +AC_PROG_MAKE_SET +AC_MINIX +AM_C_PROTOTYPES +AC_SYS_LARGEFILE + +# Checks for libraries. +AC_SEARCH_LIBS(opendir, [mingwex]) + +# Checks for header files. +AC_HEADER_DIRENT +AC_HEADER_STDC +AC_CHECK_HEADERS(fcntl.h limits.h sys/file.h sys/param.h sys/time.h) +AC_CHECK_HEADERS(pwd.h grp.h utime.h inttypes.h stdint.h fnmatch.h) + +# Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_HEADER_TIME +AC_STRUCT_TM +AC_STRUCT_TIMEZONE + +AC_CHECK_SIZEOF(long) +AC_CHECK_TYPES([uid_t, gid_t, long long, uint64_t, ssize_t]) +AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct stat.st_ino],,, +[ +#if HAVE_SYS_TYPES_H +# include +#endif +#if HAVE_SYS_STAT_H +# include +#endif +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif +]) + +# Checks for library functions. +AC_TYPE_SIGNAL +AC_FUNC_UTIME_NULL +AC_FUNC_FNMATCH +AC_FUNC_FSEEKO +AC_CHECK_FUNCS(strchr strdup memcpy memset memmove strcasecmp) +AC_CHECK_FUNCS(mktime timelocal tzset ftime gettimeofday utime) +AC_CHECK_FUNCS(ftruncate chsize lchown mkstemp ftello) +AC_CHECK_FUNCS(getpwuid getgrgid getpwnam getgrnam) +AC_CHECK_FUNCS(iconv basename) +AC_REPLACE_FUNCS(vsnprintf fnmatch) + +if test $ac_header_dirent = no; then + AC_LIBOBJ(lhdir) +fi + +AC_CHECK_DECLS([basename]) + +# checking whether 8 bit clean or not +AC_CACHE_CHECK([whether strchr()/strrchr() is 8bit clean], + [lha_cv_func_strchr_8bit_clean], + AC_TRY_RUN([ +#if STDC_HEADERS +# include +#else +# if !HAVE_STRCHR +# define strchr index +# define strrchr rindex +# endif +char *strchr (), *strrchr (); +#endif + +main() +{ + char *s = "\377"; + if (strchr(s, 0xff) != s) exit(1); + if (strchr(s, '\377') != s) exit(1); + if (strrchr(s, 0xff) != s) exit(1); + if (strrchr(s, '\377') != s) exit(1); + exit(0); /* ok */ +} +], lha_cv_func_strchr_8bit_clean=yes, + lha_cv_func_strchr_8bit_clean=no, + lha_cv_func_strchr_8bit_clean=no)) + +if test x$lha_cv_func_strchr_8bit_clean = xyes; then + AC_DEFINE(STRCHR_8BIT_CLEAN, 1, + [Define to 1 if strchr()/strrchr() works correctly.]) +fi + +# checking whether the 2nd argument of gettimeofday() is effective or not. +# note that this timezone argument is obsolete. +AC_CACHE_CHECK([whether the 2nd argument of gettimeofday() is effective], + [lha_cv_func_gettimeofday_2nd_arg], + AC_TRY_RUN([ +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + +main() +{ + struct timeval tv; + struct timezone tz; + + tz.tz_minuteswest = -1; + if (gettimeofday(&tv, &tz) == -1) + exit(1); + + if (tz.tz_minuteswest == -1) + exit(1); /* the timezone information is no given */ + + exit(0); +}], lha_cv_func_gettimeofday_2nd_arg=yes, + lha_cv_func_gettimeofday_2nd_arg=no, + lha_cv_func_gettimeofday_2nd_arg=no)) + +if test x$lha_cv_func_gettimeofday_2nd_arg = xyes; then + AC_DEFINE(GETTIMEOFDAY_HAS_2ND_ARG, 1, + [Define to 1 if the 2nd argument of gettimeofday() is effective.]) +fi + +# support kanji code conversion +AC_SUBST(DEF_KCODE) +AC_MSG_CHECKING(kanji code conversion on text file) +AC_ARG_ENABLE(text-conv, + AC_HELP_STRING([--enable-text-conv], + [support text code convert from/to EUC [[default=yes]]]), + , enable_text_conv=yes) + +AC_MSG_RESULT($enable_text_conv) +if test $enable_text_conv = yes; then + DEF_KCODE=-DEUC +fi + +# force support -lh7- +AC_SUBST(SUPPORT_LZHUFF_METHOD) +SUPPORT_LZHUFF_METHOD=-DSUPPORT_LH7 + +# whether use the -lh567- method +AC_MSG_CHECKING(default archive method) +AC_ARG_WITH(default-method, + AC_HELP_STRING([--with-default-method=[[567]]], + [create the -lh[[567]]- archive default [[default=5]]]), + [case $withval in + [567]) ;; + *) AC_MSG_ERROR(you should have specified 5, 6 or 7);; + esac], + with_default_method=5) +AC_MSG_RESULT(-lh$with_default_method-) +AC_DEFINE_UNQUOTED(DEFAULT_LZHUFF_METHOD, LZHUFF${with_default_method}_METHOD_NUM, [Define it to 5, 6 or 7 which you want to use -lhX- method, default]) + +# decide temporary path names +AC_MSG_CHECKING(template of the temporary file) +AC_ARG_WITH(tmp-file, + AC_HELP_STRING([--with-tmp-file=TEMPLATE], + [temporary file template [[default=/tmp/lhXXXXXX]]]), + [case $withval in + yes) with_tmp_file=/tmp/lhXXXXXX ;; + no) ;; + esac], + with_tmp_file=/tmp/lhXXXXXX) + +AC_MSG_RESULT($with_tmp_file) +if test x"$with_tmp_file" != xno; then + AC_DEFINE_UNQUOTED(TMP_FILENAME_TEMPLATE, "$with_tmp_file", + [temporary file template for mktemp/mkstemp]) +fi + +# incremental indicator +AC_MSG_CHECKING(whether incremental indicator is needed) +AC_ARG_ENABLE(indicator, + AC_HELP_STRING([--enable-indicator], + [need incremental indicator [[default=yes]]]), + , + # default + enable_indicator=yes) + +AC_MSG_RESULT($enable_indicator) +if test "x$enable_indicator" = xyes; then + AC_DEFINE(NEED_INCREMENTAL_INDICATOR, 1, + [Define to 1 if you want to use the incremental indicator]) +fi + +# support multibyte filename +AC_MSG_CHECKING(kanji code of filename) +AC_ARG_ENABLE(multibyte-filename, + AC_HELP_STRING([--enable-multibyte-filename], + [support multibyte filename. specify kanji code (euc, sjis, utf8 or auto) [[default=auto]]]),, + # default + enable_multibyte_filename=auto) + +case $enable_multibyte_filename in +auto|yes) + AC_EGREP_CPP(SJIS,[ +#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__hpux) +SJIS +#endif], enable_multibyte_filename=CODE_SJIS, + AC_EGREP_CPP(UTF8,[ +#if defined(__APPLE__) /* for Mac OS X */ +UTF8 +#endif], enable_multibyte_filename=CODE_UTF8, + enable_multibyte_filename=CODE_EUC));; +sjis) enable_multibyte_filename=CODE_SJIS;; +euc) enable_multibyte_filename=CODE_EUC;; +utf8) enable_multibyte_filename=CODE_UTF8;; +no) ;; +*) AC_MSG_ERROR([you should specify auto, sjis or euc as your system filename code.]);; +esac + +AC_MSG_RESULT($enable_multibyte_filename) +if test x$enable_multibyte_filename != xno; then + AC_DEFINE_UNQUOTED(MULTIBYTE_FILENAME, $enable_multibyte_filename, + [Define to CODE_EUC or CODE_SJIS if you want to use multibyte filename]) + + case $target_os in + darwin*) + # for multibyte filename + LDFLAGS="$LDFLAGS -framework CoreFoundation" + ;; + esac +fi + +# make user/group name extented header +AC_MSG_CHECKING(whether user/group name extended header is needed) +AC_ARG_ENABLE(user-name-header, + AC_HELP_STRING([--enable-user-name-header], + [make user/group name extended header [[default=no]]]), + , + # default + enable_user_name_header=no) + +AC_MSG_RESULT($enable_user_name_header) +if test "x$enable_user_name_header" = xyes; then + AC_DEFINE(INCLUDE_OWNER_NAME_IN_HEADER, 1, + [Define to 1 if you want to use the user/group name extened header]) +fi + +# backup old archive file +AC_MSG_CHECKING(whether backup file for old archive is left) +AC_ARG_ENABLE(backup-archive, + AC_HELP_STRING([--enable-backup-archive], + [backup old archive [[default=no]]]), + , + # default + enable_backup_archive=no) + +AC_MSG_RESULT($enable_backup_archive) +if test "x$enable_backup_archive" = xyes; then + AC_DEFINE(BACKUP_OLD_ARCHIVE, 1, + [Define to 1 if you want to leave an old archive]) +fi + +# enable this option if you need to ignore '.file' files +# (mainly for the Mac OS X) *experimental* +AC_MSG_CHECKING(whether enable -X option which ignore dot files) +AC_ARG_ENABLE(ignore-dot-files, + AC_HELP_STRING([--enable-ignore-dot-files], + [enable -X option [[default=no]]]), + , + # default + enable_ignore_dot_files=no) + +AC_MSG_RESULT($enable_ignore_dot_files) +if test "x$enable_ignore_dot_files" = xyes; then + AC_DEFINE(IGNORE_DOT_FILES, 1, + [Define to 1 if you want to ignore dot files with -X command line switch]) +fi + +AC_CONFIG_FILES([Makefile src/Makefile man/Makefile olddoc/Makefile]) +AC_CONFIG_FILES([tests/Makefile tests/lha-test]) +AC_OUTPUT diff -Nru lha-1.14i/debian/changelog lha-1.14i-acc20050924p1/debian/changelog --- lha-1.14i/debian/changelog 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/changelog 2012-04-17 15:10:03.000000000 +0000 @@ -1,193 +1,5 @@ -lha (1.14i-10.3) unstable; urgency=medium +lha (1.14i-acc20050924p1-3~ppa5) precise; urgency=low - * Non-maintainer upload. - * Fix subsequent open with O_EXCL after mkstemp (Closes: #446236) - - -- Philipp Kern Sat, 01 Dec 2007 16:32:52 +0100 - -lha (1.14i-10.2) unstable; urgency=high - - * Non-maintainer upload by testing security team. - * Included patch.CVE-2007-2030.patch to fix insecure handling of - temporary files (CVE-2007-2030) (Closes: #437621). - - -- Nico Golde Sun, 09 Sep 2007 14:49:16 +0200 - -lha (1.14i-10.1) unstable; urgency=high - - * Security NMU for vulnerabilities inherited from GNU Gzip: - [CVE-2006-4335 CVE-2006-4337 CVE-2006-4338] - - -- Moritz Muehlenhoff Wed, 13 Dec 2006 20:21:32 +0100 - -lha (1.14i-10) unstable; urgency=high - - * debian/patch.redhat-sec2: Add one more security patch to fix: - - CAN-2004-0771 (-w working directory option buffer overflow) - http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0771 - - CAN-2004-0769 (buffer overflow can be executed arbitrary code - via long pathnames in headers, another issue of bug fixed in -9) - http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0769 - - CAN-2004-0745 (execute arbitrary commands via a directory with - shell metacharacters in its name.) - http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0745 - - CAN-2004-0694 (reserved number) - http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0694 - taken from RedHat patch. (Closes: #279870) - * man/lha.n: Fix typo "flie" instead of "file". (Closes: #277545) - - -- GOTO Masanori Sat, 13 Nov 2004 15:31:22 +0900 - -lha (1.14i-9) unstable; urgency=high - - * debian/patch.header-overflow: Add fix another lha buffer overflow - problem. It warns when hitting an archive which includes - long directory name with option l, v, x. See: - http://lw.ftw.zamosc.pl/lha-exploit.txt - http://www.securityfocus.com/archive/1/363418 - http://bugs.gentoo.org/show_bug.cgi?id=51285 - Thanks to Lukasz Wojtow for pointing this problem. - - -- GOTO Masanori Wed, 16 Jun 2004 09:51:06 +0900 - -lha (1.14i-8) unstable; urgency=high - - * debian/patch.CAN-2004-0234_0235: Add fix CAN-2004-0235 symlink part - patches. (Closes: #247355, #247357) - - -- GOTO Masanori Sat, 8 May 2004 02:24:57 +0900 - -lha (1.14i-7) unstable; urgency=high - - * debian/patch.CAN-2004-ulf: Add to fix CAN-2004-0234 (buffer overflows), - CAN-2004-0235 (directory traversal). See: - http://marc.theaimsgroup.com/?l=full-disclosure&m=108345064008698&w=2 - * debian/control: Change my mail address. - - -- GOTO Masanori Thu, 6 May 2004 15:13:14 +0900 - -lha (1.14i-6) unstable; urgency=low - - * debian/copyright: Added more copyright license statement, translated - by Osamu Aoki . - * debian/copyright: Added good summary of upstream author, investigated by - Osamu Aoki and - Tatsuya Kinoshita . - * debian/header-e.doc: Added English version of header.doc (LHa header - structure format document) translated by Osamu Aoki - . - - -- GOTO Masanori Tue, 27 Aug 2002 13:08:22 +0900 - -lha (1.14i-5) unstable; urgency=low - - * debian/patch.multibyte: Add multibyte character mode option 'y'. - You can use multibyte filename especially SHIFTJIS code - with this option. - - -- GOTO Masanori Fri, 19 Jul 2002 16:57:11 +0900 - -lha (1.14i-4) unstable; urgency=low - - * debian/copyright: add original/translated license statement - (closes: Bug#144582). - - -- GOTO Masanori Wed, 1 May 2002 09:53:24 +0900 - -lha (1.14i-3) unstable; urgency=low - - * fix lha reports a wrong version number (closes: Bug#135199). - - -- GOTO Masanori Sun, 3 Mar 2002 21:38:46 +0900 - -lha (1.14i-2) unstable; urgency=low - - * Applied the patch not to get compiling warning message. - Patched by Paul Slootman . (Closes: #109634). - - -- GOTO Masanori Thu, 23 Aug 2001 00:26:53 +0900 - -lha (1.14i-1) unstable; urgency=low - - * New upstream release (Closes: #62256). - * New maintainer. - * Updated Standards-version 3.5.2. - * Use build this package with dh_*. - * New upstream version is ready for -lh7- format (Closes: #67592). - * Japanese manual is now included (Closes: #49245). - * Unclosed Bugs (No copyright file is included) - has just re-closed (Closes: #48748). - - -- GOTO Masanori Sun, 22 Jul 2001 13:11:50 +0900 - -lha (1.14e-2) unstable; urgency=low - - * Moved /usr/man/* and /usr/doc/* under /usr/share. Closes: #80759. - * Updated Standards-version, fixed lintian warnings. - - -- Steve McIntyre Sun, 21 Jan 2001 17:35:52 +0000 - -lha (1.14e-0) unstable; urgency=low - - * New upstream release. Thanks to Jiro Iwamoto for pointing this out. - - -- Steve McIntyre Sun, 25 Jul 1999 23:05:24 +0100 - -lha (1.14d-1) unstable; urgency=low - - * Fixed manpage - no need to specify "-b" for command line help. Closes bug #33328. - - -- Steve McIntyre Sun, 14 Feb 1999 16:24:44 +0000 - -lha (1.14d-0) unstable; urgency=low - - * New upstream release. Thanks to Tomohiro KUBOTA for pointing this out. - - -- Steve McIntyre Sat, 16 Jan 1999 21:54:37 +0000 - -lha (1.14c-1) frozen unstable; urgency=low - - * New man page, supplied by Martin Schulze . Fixes Bug#27195. - - -- Steve McIntyre Sun, 18 Oct 1998 13:53:12 +0100 - -lha (1.14c-0) unstable; urgency=low - - * New upstream release. Thanks to Atsushi KAMOSHIDA for pointing this out. - - -- Steve McIntyre Sat, 15 Aug 1998 14:16:19 +0100 - -lha (1.00-6) unstable; urgency=low - - * New maintainer. - - -- Steve McIntyre Mon, 12 Jan 1998 00:09:12 +0000 - -lha (1.00-5) unstable; urgency=low, closes=16756 - - * Corrected Standards-Version to 2.3.0.1 (Bug#16756) - - -- Martin Schulze Fri, 9 Jan 1998 02:08:03 +0100 - -lha (1.00-4) unstable; urgency=low - - * Compiled against libc6 (Bug#11696) - - -- Martin Schulze Wed, 31 Dec 1997 20:51:38 +0100 - -lha (1.00-3) unstable; urgency=low - - * Corrected manpage (Bug#7980) - - * New maintainer address - - -- Martin Schulze Mon, 28 Apr 1997 13:10:10 +0200 - -lha (1.00-2) unstable; urgency=low - - * Installed ChangeLog files - - * Converted into new packaging scheme - - -- Martin Schulze Sun, 23 Feb 1997 12:22:13 +0100 + * + -- Sawa (ikoinoba) Sun, 09 Oct 2011 19:05:08 +0900 diff -Nru lha-1.14i/debian/compat lha-1.14i-acc20050924p1/debian/compat --- lha-1.14i/debian/compat 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/compat 2011-02-18 16:39:16.000000000 +0000 @@ -0,0 +1 @@ +7 diff -Nru lha-1.14i/debian/control lha-1.14i-acc20050924p1/debian/control --- lha-1.14i/debian/control 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/control 2011-10-09 10:06:22.000000000 +0000 @@ -1,13 +1,18 @@ Source: lha -Section: non-free/utils -Priority: optional -Maintainer: GOTO Masanori -Build-Depends: debhelper (>> 4.0.0) -Standards-Version: 3.6.0 +Section: utils +Priority: extra +Maintainer: Sawa +Build-Depends: debhelper (>= 7.0.50~), autotools-dev +Standards-Version: 3.8.4 +Homepage: http://sourceforge.jp/projects/lha/ -Package: lha +Package: lha-sjis Architecture: any -Depends: ${shlibs:Depends} -Description: lzh archiver - The famous lzh archiver, known from DOS. When mixing DOS and Unix - you might need it. (Especially for fido <--> rfc conversions.) +Depends: ${shlibs:Depends}, ${misc:Depends} +Conflicts: lha +Replaces: lha +Provides: lha +Description: LHA is an archiving and compression utility for LHarc/lha/lzh format archives. + lha 篁ヤ綵障 + 1. 鴻紊≪若綮罩 + 2. <ゃ紊絎茖宴若 + iconv 箴絖臀 diff -Nru lha-1.14i/debian/copyright lha-1.14i-acc20050924p1/debian/copyright --- lha-1.14i/debian/copyright 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/copyright 2011-10-03 15:39:18.000000000 +0000 @@ -1,172 +1,62 @@ -This package was debianized by Atsushi KAMOSHIDA kamop@post1.com on -Sun, 13 Apr 1997 17:52:59 +0900. - -It was downloaded from http://www2m.biglobe.ne.jp/~dolphin/lha/lha.htm - -Upstream Authors: - - LHarc 0.01-1.00: Yooichi Tagawa (LHa code taken from here, 1988-1989) - Nikkei-mix ID: y.tagawa (Now this is defunct BBS, Licensing term - in manual page come from his licence for lharc) - His new web page seems to be www2s.biglibe.ne.jp/~yex/ - yooedit2001@yahoo.co.jp is the contact e-mail address for another - software. Page updated at least July/2001 - - LHa 0.01-1.00: Masaru Oki (LHa original author, 1991-1992) - E-Mail address: oki@netbsd.org - - LHa 1.10-1.14: Nobutaka Watazaki (Last official release? 1993-1995) - ALICE-NET ALS00595 Nasty - E-Mail JBD02514@niftyserve.or.jp - E-Mail femcs@mbox.kyoto-inet.or.jp - NIFTY-Serve JBD02514 - E-Mail address: watazaki@shimadzu.co.jp - E-Mail address: watazaki@shimadzusd.co.jp - - Lha 1.14a-1.14e: Tsugio Okamoto (1996-2000) - - -Copyright: - -Original Source Code License Statement: - - /* Copyright (C) MCMLXXXIX Yooichi.Tagawa */ - /* Modified Nobutaka Watazaki */ - /* Thanks to H.Yoshizaki. (MS-DOS LHarc) */ - - -Original Authors License Statement (from man/lha.man, in Japanese -EUC-JP): - - 再配布について - 以下の条件で、再配布、転載、改変を許可します。 - - 1. 著作権表示を削除しないこと。 - - 2. 配布内容については、 - - a. 配布の際に存在する内容(すなわち ソー ス コー - ド、 ド キュメント、プログラマーへの手引きな - ど)が再配布されたものの中に必ず存在 す る こ - と。 改 変されているならば、それを明示したド - キュメントを用意すること。 - - b. LHa に対する付加価値が付けられて再配布される - 場合にはそれらもできるだけ含めるよう努力する - こと。また、その際には付加価値が付けられてい - ることを明示したドキュメントを用意すること。 - - c. バイナリのみの配布は許されない。(付加価値 の - ものも含む) - - 3. 最新版の配布に務めること。(義務はない) - - 注. なお、ネットでの配付は自由であるが、ネットに - アクセスできない方(雑誌および、 CDROM な ど - に よる)配付は、配付前にこちらに EMail をお - 願いします。配付前に出来ない際には、後日必ず - EMail をお願いします。 - - 4. このプログラムの存在や使用したことによって生じた損 - 害は全く保証しない。 - - 5. 作者は、このプログラムに不備があっても、それを訂 正 - する義務を負わない。 - - 6. このプログラムの一部、または全部を他のプログラムに - 組み込んで利用してもかまわない。この場合、そのプ ロ - グラムは LHa ではなく、 LHa と名乗ってはいけない。 - - 7. 商利用に関しては、上記の条件に加え、下記の条件のも - とにこれを認める。 - - a. このプログラムをメインとする商利用は禁 止 す - る。 - - b. 商利用の相手がこのプログラムの使用者として不 - 適切と判断した場合には配布しない。 - - c. インストールの手段として使用する場合、このプ - ログラムを使うことを相手に強制しない。この場 - 合、商利用者が作業を行う。また、そのときの損 - 害は、商利用者が全責任を負う。 - - d. 商利用を付加価値として行いこのプログラムを使 - 用する場合、商利用者は、そのサポートを行う。 - - -Original Authors License Statement (from man/lha.man, translated by -Osamu Aoki ): - - Permission is given for redistribution, copy, and modification provided - following conditions are met. - - 1. Do not remove copyright clause. - 2. Distribution shall conform: - a. The content of redistribution (i.e., source code, documentation, - and reference guide for programmers) shall include original contents. - If contents are modified, the document clearly indicating - the fact of modification must be included. - b. If LHa is redistributed with added values, you must put your best - effort to include them (Translator comment: If read literally, - original Japanese was unclear what "them" means here. But - undoubtedly this "them" means source code for the added value - portion and this is a typical Japanese sloppy writing style to - abbreviate as such) Also the document clearly indicating that - added value was added must be included. - c. Binary only distribution is not allowed (including added value - ones.) - 3. You need to put effort to distribute the latest version (This is not - your duty). - - NB: Distribution on Internet is free. Please notify me by e-mail or - other means prior to the distribution if distribution is done through - non-Internet media (Magazine, CDROM etc.) If not, make sure to Email - me later. - - 4. Any damage caused by the existence and use of this program will not - be compensated. - - 5. Author will not be responsible to correct errors even if program is - defective. - - 6. This program, either as a part of this or as a whole of this, may be - included into other programs. In this case, that program is not LHa - and can not call itself LHa. - - 7. For commercial use, in addition to above conditions, following - condition needs to be met. - - a. The program whose content is mainly this program can not be used - commercially. - b. If the recipient of commercial use deems inappropriate as a - program user, you must not distribute. - c. If used as a method for the installation, you must not force - others to use this program. In this case, commercial user will - perform its work while taking full responsibility of its outcome. - d. If added value is done under the commercial use by using this - program, commercial user shall provide its support. - - -(Osamu Aoki also comments: - Here "commercial" may be interpreted as "for-fee". "Added value" seems - to mean "feature enhancement". ) - - -License Statement by Tsugio Okamoto (in Japanese EUC-JP): - - なお、ネットでの配付は自由ですが、ネットにアクセスできない方(雑誌および、 - CD-ROM などによる)への配付は、配付前にこちらに Inter-Net の方にE-Mail - を お願いします。 どこそこに、掲載するという旨があれば結構ですので。 - また、それも出来ない際には、後日 E-Mail を必ずお願いします。 - - -Translated License Statement by Tsugio Okamoto (translated by -GOTO Masanori ): - - It's free to distribute on the network, but if you distribute for - the people who cannot access the network (by magazine or CD-ROM), - please send E-Mail (Inter-Net address) to the author before the - distribution. That's well where this software is appeard. - If you cannot do, you must send me the E-Mail later. - +Format: http://dep.debian.net/deps/dep5 +Upstream-Name: lha +Source: http://sourceforge.jp/projects/lha/ + +Files: * +Copyright: 1989 Y.Tagawa + 1990 H.Yoshizaki + 1990 Momozou + 1992 Masaru Oki + 1995 Nobutaka Watazaki + 2000 Tsugio Okamoto + 2001-2005 Koji Arai +License: + 篁ヤ>散с絽荵∵劫荐怨障 + . + 1. 篏罔茵腓冴ゃ + . + 2. 絽絎鴻ゃ + . + a. 絽絖絎(<純若鴻潟若ャ<潟 + 違若吾綣)絽筝綽絖 + 劫違腓冴ャ<潟 + . + b. LHa 絲障篁箴≦ゃ篁絽翫с + 障篁箴≦ゃ篁 + 腓冴ャ<潟 + . + c. ゃ帥絽荐宴(篁箴≦ゃ) + . + 3. 亥絽(臂) + . + 羈. с篁宴с≪祉鴻с + 鐚茯潟CD-ROM鐚篁篁< E-Mail + 蕁障篁堺ャ緇ュ E-Mail 蕁障 + . + 4. 違絖篏睡c絎潟鋓荐若 + . + 5. 篏違筝c荐罩c臂莢 + . + 6. 違筝障篁違腟粋昭у + 障翫違 LHa сLHa 箙c + . + 7. ≪筝荐>散筝荐>散 茯 + . + a. 違<ゃ潟胼罩≪ + . + b. 御違篏睡筝ゆ翫絽 + . + c. ゃ潟鴻若罧泣篏睡翫違篏帥御 + 綣桁吟翫篏罐茵障絎潟 + 莢篁祉莢 + . + d. 篁箴≦ゃ茵違篏睡翫 + 泣若茵 + +Files: debian/* +Copyright: 2011 Sawa +License: lha + +Files: debian/lha-1.14i-ac20050924p1-iconv.patch +Copyright: 2006 Kyoichiro Suda +License: lha diff -Nru lha-1.14i/debian/dirs lha-1.14i-acc20050924p1/debian/dirs --- lha-1.14i/debian/dirs 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/dirs 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -usr/bin -usr/share/man/man1 -usr/share/man/ja/man1/ diff -Nru lha-1.14i/debian/docs lha-1.14i-acc20050924p1/debian/docs --- lha-1.14i/debian/docs 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/docs 2011-02-18 17:48:27.000000000 +0000 @@ -1,10 +1,6 @@ -README.euc -change-114e.txt -change-114g.txt -change-114h.txt -change-114i.txt -MACHINES -MACHINES2 -PROBLEMS -header.doc -debian/header-e.doc +*readme* +ChangeLog +olddoc/CHANGES.euc +olddoc/PROBLEMS.euc +olddoc/README.euc +olddoc/change-*.txt diff -Nru lha-1.14i/debian/header-e.doc lha-1.14i-acc20050924p1/debian/header-e.doc --- lha-1.14i/debian/header-e.doc 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/header-e.doc 1970-01-01 00:00:00.000000000 +0000 @@ -1,189 +0,0 @@ -/* header.doc (In English) */ -Header structure used in LHa for UNIX Mar. 2, 1992, Masaru Oki. -(Translated by Osamu Aoki) - ----------------------------------------------------------------- -This version, as a transitional mreasure, uses level-1 as default value while -offering 3 types of header types. In the future, I plan to use level-2 which -has no limit on number of characters for the path mname. - - A. Spec for header - -Basic part ------------------------------------------------------------------------------ - level-0 level-1 level-2 ------------------------------------------------------------------------------ - 1 header size 1 header size 2 total header size - 1 header sum 1 header sum - 5 method ID 5 method ID 5 method ID - 4 packed size 4 skip size 4 packed size - 4 original size 4 original size 4 original size - 2 time 2 time 4 time(UNIX type) - 2 date 2 date - 1 attribute 1 0x20 1 RESERVED - 1 level 0x00 1 level 0x01 1 level 0x02 - 1 name length 1 name length - ? pathname ? filename - 2 file crc 2 file crc 2 file crc - . ........ 1 OS ID 'U' 1 OS ID 'U' - . ........ - 2 next-header size 2 next-header size - ************************************************************************* - 24 + ? 27 + ? 26 - -Extension part ------------------------------------------------------------------------------ - 1 ext-type 1 ext-type - . ........ . ........ - 2 next-header size 2 next-header size - ------------------------------------------------------------------------------ - - a. Types of header - - level-0 header - Same format as conventional LHarc, LArc. Separator for directory - name is '\' as default. - - level-1 header - This header is used as default. Archive type -lh0 made with -x0 can - be unfrozen by LHarc but there will be no checking on CRC. - - level-2 header - Header for supporting long file names. I would like to standarize - on this format in the future. Please follow this if you wish to - make utilities related ti LH. - - b. method ID for freeze/unfreeze - - * these methods are freeze/unfreeze, others are unfreeze only - - -lh0- * no compression - - -lh1- * 4k sliding dictionary(max 60 bytes) + dynamic Huffman - + fixed encoding of position - - -lh2- 8k sliding dictionary(max 256 bytes) + dynamic Huffman - - -lh3- 8k sliding dictionary(max 256 bytes) + static Huffman - - -lh4- * 4k sliding dictionary(max 256 bytes) + static Huffman - + improved encoding of position and trees - - -lh5- * 8k sliding dictionary(max 256 bytes) + static Huffman - + improved encoding of position and trees - - -lh6- 32k sliding dictionary(max 256 bytes) + static Huffman - + improved encoding of position and trees - - -lh7- 64k sliding dictionary(max 256 bytes) + static Huffman - + improved encoding of position and trees - - -lzs- 2k sliding dictionary(max 17 bytes) - - -lz4- no compression - - -lz5- 4k sliding dictionary(max 17 bytes) - - c. About OS ID - - Following OS ID are reserved. - - MS-DOS 'M' - OS/2 '2' - OS9 '9' - OS/68K 'K' - OS/386 '3' - HUMAN 'H' - UNIX 'U' - CP/M 'C' - FLEX 'F' - Mac 'm' - Runser 'R' - - B. Extension - - a. OS independent (0x00 - 0x3f) - - common header - 1 0x00 - 2 header crc - ( 1 information ) - 2 next-header size - - filename header - 1 0x01 - ? filename - 2 next-header size - - dirname header - 1 0x02 - ? dirname - 2 next-header size - - comment header - 1 0x3f - ? comments - 2 next-header size - -(Above portion, from lhx.doc by Mr. Yoshizaki) ----------------------------------------------------------------- -LHa for UNIX : specification for extension header - -* Category of machine specific information (Information to be recorded) - Followings are UNIX specific information which requires to be recorded - (1) Permission - (2) GID,UID - (3) Group name, User name - (4) Last change time (UNIX time) - -* Type of machine specific information (ext-type) - First 1 byte of extension header contain value to distinguish types of - the infoemation. Foe UNIX specific information, 0x50 - 0x54 will be - used. - -* Method to store - Above categories (1) - (4) will be different type. - - - (1) Pemission - size value - 1 0x50 - 2 Valur of permission - 2 next-header size - - (2)GID,UID - size value - 1 0x51 - 2 GID - 2 UID - 2 next-header size - - (3)-1 Group name - 1 0x52 - ? Group name string - 2 next-header size - - (3)-2 user name - 1 0x53 - ? User name string - 2 next-header size - - (4) Last change time (for header_level1) - 1 0x54 - 4 UNIX time - 2 next-header size - -* Implimentation of LHa for UNIX ver 1.14 (Watazaki) - Above (3) is not supported - Group name and user name specified by (3) is not used to make an - archive thus ignored during expansion. - Also (4) is contained only in level-1 archive. ----------------------------------------------------------------- -That's all folks :) - -Partially modified by -Nobutaka Watazaki -watazaki@shimadzu.co.jp - - diff -Nru lha-1.14i/debian/install lha-1.14i-acc20050924p1/debian/install --- lha-1.14i/debian/install 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/install 2011-02-18 17:11:02.000000000 +0000 @@ -0,0 +1 @@ +/usr/bin/lha diff -Nru lha-1.14i/debian/lha.1 lha-1.14i-acc20050924p1/debian/lha.1 --- lha-1.14i/debian/lha.1 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/lha.1 1970-01-01 00:00:00.000000000 +0000 @@ -1,139 +0,0 @@ - .\" lha - LZH un-archiver -.\" Copyright (c) 1996 Martin Schulze -.\" -.\" This manual page is free software; you can redistribute it and/or modify -.\" it under the terms of the GNU General Public License as published by -.\" the Free Software Foundation; either version 2 of the License, or -.\" (at your option) any later version. -.\" -.\" This program is distributed in the hope that it will be useful, -.\" but WITHOUT ANY WARRANTY; without even the implied warranty of -.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -.\" GNU General Public License for more details. -.\" -.\" You should have received a copy of the GNU General Public License -.\" along with this program; if not, write to the Free Software -.\" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -.\" -.\" This manpage is written especially for Debian GNU/Linux. -.\" -.\" LHarc for UNIX V 1.02 Copyright(C) 1989 Y.Tagawa -.\" LHx for MSDOS V C2.01 Copyright(C) 1990 H.Yoshizaki -.\" LHx(arc) for OSK V 2.01 Modified 1990 Momozou -.\" LHa for UNIX V 1.00 Copyright(C) 1992 Masaru Oki -.\" -.\" Additions by Joerg Boehnke -.\" -.TH LHA 1 "22 Sept, 1998" "Debian GNU/Linux" "Archiver" -.SH NAME -LHa \- LZH un-archiver -.SH SYNOPSIS -.B lha -.B key -[ -.B - -] -.B {axelvudmcp} -[ -.B qvnfodizg012 -] -[ -.B w= -] -.I archive_file -[ -.I flie -\&.\|.\|. ] -.br -.B lha -.I archive_file -.SH DESCRIPTION -The -.B lha -program displays or extracts the contents of a LZH archive. - -For a list of commands, please refer to the executable. It will -display a list of valid commands and modifiers if you omit any -parameter. - -.TP -commands: - -.B a -Add(or replace) to archive - -.B x,e -EXtract from archive - -.B l,v -List / Verbose List - -.B u -Update newer files to archive - -.B d -Delete from archive - -.B m -Move to archive (means 'ad') - -.B c -re-Construct new archive - -.B p -Print to STDOUT from archive - -.B t -Test file CRC in archive - -.TP -options: - -.B q -quiet - -.B v -verbose - -.B n -not execute - -.B f -force (over write at extract) - -.B t -FILES are TEXT file - -.B o -use LHarc compatible method (a/u) - -.B w= -specify extract directory (x/e) - -.B d -delete FILES after (a/u/c) - -.B i -ignore directory path (x/e) - -.B z -files not compress (a/u) - -.B g -[Generic] format (for compatibility) - -.B 0/1/2 -header level (a/u) - -.B e -TEXT code convert from/to EUC - -.B y -filename multibyte convert - -.SH BUGS - -This manpage is poor, it really should be improved, but the original -is in Japanese. - -Try lha without any command line arguments to get help diff -Nru lha-1.14i/debian/lha-1.14i-manpage-en.1 lha-1.14i-acc20050924p1/debian/lha-1.14i-manpage-en.1 --- lha-1.14i/debian/lha-1.14i-manpage-en.1 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/lha-1.14i-manpage-en.1 2006-12-26 13:03:10.000000000 +0000 @@ -0,0 +1,261 @@ +.TH LHA 1 "December 26,2006" "" "LHa for UNIX Users Manual" +.SH "NAME" +LHa \- high compression archiver +.SH "SYNOPSIS" +.B lha +.B operation +[ +.B options +] +.I archive +[ +.I flie +\&.\|.\|. ] +.br +.B lha +.I archive +.SH "DESCRIPTION" +.B LHa +is a file archiver with high performance compression. +It can add, update, extract, delete and list by command letter at +.B operation. +It works as specifing command letter +.B l +when +.B lha +called only with an +.I archive. +.PP +.B Operations: +.TP 8 +.B a +Adds +.I files +in an +.I archive. +If a +.I file +is directory, the all files in directory are added recursively. +.TP 8 +.B u +Update +.I files +in an +.I archive. +If a +.I file +is not contained in an +.I archive +or that is older, a +.I file +is addes in an +.I archive. +.TP 8 +.B "l | v" +List +.I files +in an +.I archive. +It displays infomation about +.I files +contained in an +.I archive. +If any +.I files +are not specified, all files in an +.I archive +are listed. +.B v +shows more details than +.B l. +.TP 8 +.B "x | e" +Extract +.I files +from an +.I archive +If any +.I files +are not specified, all files in an +.I archive +are extracted. +If extracted file already exist, it will be inquired overwrite or not. +.TP 8 +.B p +Print contents of +.I files +from an +.I archive +to standard output. +If any +.I files +are not specified, all contents are printed. +.TP 8 +.B d +Delete +.I files +from an +.I archive +.TP 8 +.B m +Move +.I files +to an +.I archive. +.I files +are removed after they are added in an +.I archive. +.B Operation a +with +.B option d +means same as move. +.TP 8 +.B c +Create new +.I archive +and add +.I files. +.PP +.B Options: +.TP 8 +.B q[num] +Quiet interactive message. +.I num +changes displaying style for INDICATOR. default is 2. +.RS +.IP +.B q0 +\ show progress meter. +.br +.B q1 +\ show only file names. +.br +.B q2 +\ don't show anything. +.RE +.TP 8 +.B v +Verbose displaying message. +.TP 8 +.B n +Not execute. Do not update or extract. +It is for confirming what will be done. +.TP 8 +.B f +Force to execute without inquiry when existing files are overwriten. +.TP 8 +.B o[num] +Choose compression algorithm. It works with +.B operation a, u, m +and it doesn't work with +.B e +(extract), just ignored. +.RS +.IP +.B o +\ Ceate an archive compatible with LHarc (obsolete), +.RS +and \`-lh1-' will be used for compression algorithm. + +.B o5, o6, o7 +\ \`-lh5-', \`-lh6-', \`-lh7-' will be used for compression algorithm. + +.RE +Take care of compatibility between LHa version for DOS|Windows. +.RE +.TP 8 +.B w= +Change working directory for ectracting files. +.TP 8 +.B d +Delete +.I files +after included. It is used with +.B operation a +or +.B u. +Pay attention, if it is used with +.B u, +and If the file is older than which it's in an +.I archive, +the file will be removed. +.TP 8 +.B i +Ignore directories in an +.I archive +with extracting. +.TP 8 +.B z +Do not compress +.I files +with including in an +.I archive. +It is used in case of expected no more compression, +when files are already compressed. +It is ignored when extracting. +.TP 8 +.B g +Create generic archive. +generic archive does not have additional infomation for UNIX. +It is ignored when extracting. +.TP 8 +.B 0/1/2 +Specify format of an +.I archvie +by header level. +1 is default. +0 is classic format for LHarc. +2 would be standard in the future. +It effects when including. +It will be identified automatically when extracting. +.PP +Standard input or output is used when +.I - +is writen as +.I archive. +It turns to standard output for creating or updating archives, +while it turns to standard input for extracting, like the +.BR tar (1). +.PP +LHa tries to match with suffix ".lzh" when an +.I archive +to be extracted is not found. +.PP +LHa inspects whether it is self extracting file +made by the version of MS-DOS, +in case of suffix is +.B ".com" +or +.B ".exe", +and correspond to it. +.PP +LHa inspects whether it is self extracting file +made by the version of Human68k (The OS for SHARP X68000 made in Japan), +in case of suffix is +.B ".x", +and correspond to it. +.PP +LHa changes suffix to +.B ".lzh", +and removes infomation for self extracting file +when it has done to add or to delete. +.PP +.SH "FILES" +.ta \w'*.com *.exe 'u +*.lzh - LHa/LHarc archive file +.br +*.bak - backup file +.br +/tmp/lh* - temporary file +.br +*.com *.exe - MS-DOS self extracting file +.br +*.x - Human68k self extracting file +.PP +.SH "SEE ALSO" +.BR tar (1), +.BR ar (1), +.BR compress (1) +.SH "DISTRIBUTION" +.PP +It is not translated. Read japanese man page. diff -Nru lha-1.14i/debian/manpages lha-1.14i-acc20050924p1/debian/manpages --- lha-1.14i/debian/manpages 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/manpages 2011-02-18 17:24:34.000000000 +0000 @@ -0,0 +1 @@ +lha.1 diff -Nru lha-1.14i/debian/org/header.c lha-1.14i-acc20050924p1/debian/org/header.c --- lha-1.14i/debian/org/header.c 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/org/header.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,875 +0,0 @@ -/* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* header.c -- header manipulate functions */ -/* */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Original Y.Tagawa */ -/* modified 1991.12.16 M.Oki */ -/* Ver. 1.10 Symbolic Link added 1993.10.01 N.Watazaki */ -/* 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 */ -/* ------------------------------------------------------------------------ */ -#include "lha.h" - -/* ------------------------------------------------------------------------ */ -static char *get_ptr; -/* ------------------------------------------------------------------------ */ -int -calc_sum(p, len) - register char *p; - register int len; -{ - register int sum; - - for (sum = 0; len; len--) - sum += *p++; - - return sum & 0xff; -} - -/* ------------------------------------------------------------------------ */ -static unsigned short -get_word() -{ - int b0, b1; - - b0 = get_byte(); - b1 = get_byte(); - return (b1 << 8) + b0; -} - -/* ------------------------------------------------------------------------ */ -static void -put_word(v) - unsigned int v; -{ - put_byte(v); - put_byte(v >> 8); -} - -/* ------------------------------------------------------------------------ */ -static long -get_longword() -{ - long b0, b1, b2, b3; - - b0 = get_byte(); - b1 = get_byte(); - b2 = get_byte(); - b3 = get_byte(); - return (b3 << 24) + (b2 << 16) + (b1 << 8) + b0; -} - -/* ------------------------------------------------------------------------ */ -static void -put_longword(v) - long v; -{ - put_byte(v); - put_byte(v >> 8); - put_byte(v >> 16); - put_byte(v >> 24); -} - -/* ------------------------------------------------------------------------ */ -static void -msdos_to_unix_filename(name, len) - register char *name; - register int len; -{ - register int i; - -#ifdef MULTIBYTE_CHAR - for (i = 0; i < len; i++) { - if (MULTIBYTE_FIRST_P(name[i]) && - MULTIBYTE_SECOND_P(name[i + 1])) - i++; - else if (name[i] == '\\') - name[i] = '/'; - else if (!noconvertcase && isupper(name[i])) - name[i] = tolower(name[i]); - } -#else - for (i = 0; i < len; i++) { - if (name[i] == '\\') - name[i] = '/'; - else if (!noconvertcase && isupper(name[i])) - name[i] = tolower(name[i]); - } -#endif -} - -/* ------------------------------------------------------------------------ */ -static void -generic_to_unix_filename(name, len) - register char *name; - register int len; -{ - register int i; - boolean lower_case_used = FALSE; - -#ifdef MULTIBYTE_CHAR - for (i = 0; i < len; i++) { - if (MULTIBYTE_FIRST_P(name[i]) && - MULTIBYTE_SECOND_P(name[i + 1])) - i++; - else if (islower(name[i])) { - lower_case_used = TRUE; - break; - } - } - for (i = 0; i < len; i++) { - if (MULTIBYTE_FIRST_P(name[i]) && - MULTIBYTE_SECOND_P(name[i + 1])) - i++; - else if (name[i] == '\\') - name[i] = '/'; - else if (!noconvertcase && !lower_case_used && isupper(name[i])) - name[i] = tolower(name[i]); - } -#else - for (i = 0; i < len; i++) - if (islower(name[i])) { - lower_case_used = TRUE; - break; - } - for (i = 0; i < len; i++) { - if (name[i] == '\\') - name[i] = '/'; - else if (!noconvertcase && !lower_case_used && isupper(name[i])) - name[i] = tolower(name[i]); - } -#endif -} - -/* ------------------------------------------------------------------------ */ -static void -macos_to_unix_filename(name, len) - register char *name; - register int len; -{ - register int i; - - for (i = 0; i < len; i++) { - if (name[i] == ':') - name[i] = '/'; - else if (name[i] == '/') - name[i] = ':'; - } -} - -/* ------------------------------------------------------------------------ */ -static void -unix_to_generic_filename(name, len) - register char *name; - register int len; -{ - register int i; - - for (i = 0; i < len; i++) { - if (name[i] == '/') - name[i] = '\\'; - else if (islower(name[i])) - name[i] = toupper(name[i]); - } -} - -/* ------------------------------------------------------------------------ */ -/* */ -/* Generic stamp format: */ -/* */ -/* 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 */ -/* |<-------- year ------->|<- month ->|<-- day -->| */ -/* */ -/* 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 */ -/* |<--- hour --->|<---- minute --->|<- second*2 ->| */ -/* */ -/* ------------------------------------------------------------------------ */ - -/* - * NOTE : If you don't have `gettimeofday(2)', or your gettimeofday(2) - * returns bogus timezone information, try FTIME, MKTIME, TIMELOCAL or TZSET. - */ - -/* choose one */ -#if defined(MKTIME) -#ifdef TIMELOCAL -#undef TIMELOCAL -#endif -#endif /* defined(MKTIME) */ - -#if defined(MKTIME) || defined(TIMELOCAL) -#ifdef TZSET -#undef TZSET -#endif -#endif /* defined(MKTIME) || defined(TIMELOCAL) */ - -#if defined(MKTIME) || defined(TIMELOCAL) || defined(TZSET) -#ifdef FTIME -#undef FTIME -#endif -#endif - -#if defined(MKTIME) || defined(TIMELOCAL) || defined(TZSET) || defined(FTIME) -#ifdef GETTIMEOFDAY -#undef GETTIMEOFDAY -#endif -#else -#ifndef GETTIMEOFDAY -#define GETTIMEOFDAY /* use gettimeofday() */ -#endif -#endif - -#ifdef FTIME -#include -#endif - -/* - * You may define as : #define TIMEZONE_HOOK \ extern long - * timezone ; \ extern void tzset(); - */ -#ifdef TIMEZONE_HOOK -TIMEZONE_HOOK -/* Which do you like better, `TIMEZONE_HOOK' or `TIMEZONE_HOOK;' ? */ -#endif - -#if defined(TZSET) && defined(_MINIX) -extern long timezone; /* not defined in time.h */ -#endif - -/* ------------------------------------------------------------------------ */ -#if defined(FTIME) || defined(GETTIMEOFDAY) || defined(TZSET) -static long -gettz() -#ifdef TZSET -{ - tzset(); - return timezone; -} -#endif - -/* ------------------------------------------------------------------------ */ -#if !defined(TZSET) && defined(FTIME) -{ - struct timeb buf; - - ftime(&buf); - return buf.timezone * 60L; -} -#endif - -/* ------------------------------------------------------------------------ */ -#if !defined(TZSET) && !defined(FTIME) /* maybe defined(GETTIMEOFDAY) */ -{ -#ifdef HAVE_TM_ZONE - time_t tt; - - time(&tt); - return -localtime(&tt)->tm_gmtoff; -#else /* HAVE_TM_ZONE */ - struct timeval tp; - struct timezone tzp; - gettimeofday(&tp, &tzp);/* specific to 4.3BSD */ - /* - * return (tzp.tz_minuteswest * 60L + (tzp.tz_dsttime != 0 ? 60L * - * 60L : 0)); - */ - return (tzp.tz_minuteswest * 60L); -#endif /* HAVE_TM_ZONE */ -} -#endif -#endif /* defined(FTIME) || defined(GETTIMEOFDAY) || - * defined(TZSET) */ - -/* ------------------------------------------------------------------------ */ -#ifdef NOT_USED -static struct tm * -msdos_to_unix_stamp_tm(a) - long a; -{ - static struct tm t; - - t.tm_sec = (a & 0x1f) * 2; - t.tm_min = (a >> 5) & 0x3f; - t.tm_hour = (a >> 11) & 0x1f; - t.tm_mday = (a >> 16) & 0x1f; - t.tm_mon = ((a >> 16 + 5) & 0x0f) - 1; - t.tm_year = ((a >> 16 + 9) & 0x7f) + 80; - return &t; -} -#endif - -/* ------------------------------------------------------------------------ */ -static time_t -generic_to_unix_stamp(t) - long t; -#if defined(MKTIME) || defined(TIMELOCAL) -{ - struct tm dostm; - - /* - * special case: if MSDOS format date and time were zero, then we - * set time to be zero here too. - */ - if (t == 0) - return (time_t) 0; - - 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; -#if 0 - dostm.tm_isdst = 0; /* correct? */ -#endif - dostm.tm_isdst = -1; /* correct? */ -#ifdef MKTIME - return (time_t) mktime(&dostm); -#else /* maybe defined(TIMELOCAL) */ - return (time_t) timelocal(&dostm); -#endif -} - -#else /* defined(MKTIME) || defined(TIMELOCAL) */ -{ - int year, month, day, hour, min, sec; - long longtime; - static unsigned int dsboy[12] = {0, 31, 59, 90, 120, 151, - 181, 212, 243, 273, 304, 334}; - unsigned int days; - - /* - * special case: if MSDOS format date and time were zero, then we - * set time to be zero here too. - */ - if (t == 0) - return (time_t) 0; - - year = ((int) (t >> 16 + 9) & 0x7f) + 1980; - month = (int) (t >> 16 + 5) & 0x0f; /* 1..12 means Jan..Dec */ - day = (int) (t >> 16) & 0x1f; /* 1..31 means 1st,...31st */ - - hour = ((int) t >> 11) & 0x1f; - min = ((int) t >> 5) & 0x3f; - sec = ((int) t & 0x1f) * 2; - - /* Calculate days since 1970.01.01 */ - days = (365 * (year - 1970) + /* days due to whole years */ - (year - 1970 + 1) / 4 + /* days due to leap years */ - dsboy[month - 1] + /* days since beginning of this year */ - day - 1); /* days since beginning of month */ - - if ((year % 4 == 0) && - (year % 100 != 0 || year % 400 == 0) && /* 1999.5.24 t.oka */ - (month >= 3)) /* if this is a leap year and month */ - days++; /* is March or later, add a day */ - - /* Knowing the days, we can find seconds */ - longtime = (((days * 24) + hour) * 60 + min) * 60 + sec; - longtime += gettz(); /* adjust for timezone */ - - /* LONGTIME is now the time in seconds, since 1970/01/01 00:00:00. */ - return (time_t) longtime; -} -#endif /* defined(MKTIME) || defined(TIMELOCAL) */ - -/* ------------------------------------------------------------------------ */ -static long -unix_to_generic_stamp(t) - time_t t; -{ - struct tm *tm = localtime(&t); - - return ((((long) (tm->tm_year - 80)) << 25) + - (((long) (tm->tm_mon + 1)) << 21) + - (((long) tm->tm_mday) << 16) + - (long) ((tm->tm_hour << 11) + - (tm->tm_min << 5) + - (tm->tm_sec / 2))); -} - -/* ------------------------------------------------------------------------ */ -/* build header functions */ -/* ------------------------------------------------------------------------ */ -boolean -get_header(fp, hdr) - FILE *fp; - register LzHeader *hdr; -{ - int header_size; - int name_length; - char data[LZHEADER_STRAGE]; - char dirname[FILENAME_LENGTH]; - int dir_length = 0; - int checksum; - int i; - char *ptr; - int extend_size; - int dmy; - - bzero(hdr, sizeof(LzHeader)); - - if (((header_size = getc(fp)) == EOF) || (header_size == 0)) { - return FALSE; /* finish */ - } - - if (fread(data + I_HEADER_CHECKSUM, - sizeof(char), header_size - 1, fp) < header_size - 1) { - fatal_error("Invalid header (LHarc file ?)"); - return FALSE; /* finish */ - } - setup_get(data + I_HEADER_LEVEL); - hdr->header_level = get_byte(); - if (hdr->header_level != 2 && - fread(data + header_size, sizeof(char), 2, fp) < 2) { - fatal_error("Invalid header (LHarc file ?)"); - return FALSE; /* finish */ - } - - if (hdr->header_level >= 3) { - fatal_error("Unknown level header"); - return FALSE; - } - - setup_get(data + I_HEADER_CHECKSUM); - checksum = get_byte(); - - if (hdr->header_level == 2) { - hdr->header_size = header_size + checksum*256; - } else { - hdr->header_size = header_size; - } - bcopy(data + I_METHOD, hdr->method, METHOD_TYPE_STRAGE); - setup_get(data + I_PACKED_SIZE); - hdr->packed_size = get_longword(); - hdr->original_size = get_longword(); - hdr->last_modified_stamp = get_longword(); - hdr->attribute = get_byte(); - - if ((hdr->header_level = get_byte()) != 2) { - if (calc_sum(data + I_METHOD, header_size) != checksum) - warning("Checksum error (LHarc file?)", ""); - name_length = get_byte(); - for (i = 0; i < name_length; i++) - hdr->name[i] = (char) get_byte(); - hdr->name[name_length] = '\0'; - } - else { - hdr->unix_last_modified_stamp = hdr->last_modified_stamp; - name_length = 0; - } - - /* defaults for other type */ - hdr->unix_mode = UNIX_FILE_REGULAR | UNIX_RW_RW_RW; - hdr->unix_gid = 0; - hdr->unix_uid = 0; - - if (hdr->header_level == 0) { - extend_size = header_size - name_length -22; - if (extend_size < 0) { - if (extend_size == -2) { - hdr->extend_type = EXTEND_GENERIC; - hdr->has_crc = FALSE; - } else { - fatal_error("Unkonwn header (lha file?)"); - return FALSE; - } - } else { - hdr->has_crc = TRUE; - hdr->crc = get_word(); - } - - if (extend_size >= 1) { - hdr->extend_type = get_byte(); - extend_size--; - } - if (hdr->extend_type == EXTEND_UNIX) { - if (extend_size >= 11) { - hdr->minor_version = get_byte(); - hdr->unix_last_modified_stamp = (time_t) get_longword(); - hdr->unix_mode = get_word(); - hdr->unix_uid = get_word(); - hdr->unix_gid = get_word(); - extend_size -= 11; - } else { - hdr->extend_type = EXTEND_GENERIC; - } - } - while (extend_size-- > 0) - dmy = get_byte(); - if (hdr->extend_type == EXTEND_UNIX) - return TRUE; - } else if (hdr->header_level == 1) { - hdr->has_crc = TRUE; - extend_size = header_size - name_length-25; - hdr->crc = get_word(); - hdr->extend_type = get_byte(); - while (extend_size-- > 0) - dmy = get_byte(); - } else { /* level 2 */ - hdr->has_crc = TRUE; - hdr->crc = get_word(); - hdr->extend_type = get_byte(); - } - - if (hdr->header_level > 0) { - /* Extend Header */ - if (hdr->header_level != 2) - setup_get(data + hdr->header_size); - ptr = get_ptr; - while ((header_size = get_word()) != 0) { - if (hdr->header_level != 2 && - ((data + LZHEADER_STRAGE - get_ptr < header_size) || - fread(get_ptr, sizeof(char), header_size, fp) < header_size)) { - fatal_error("Invalid header (LHa file ?)"); - return FALSE; - } - switch (get_byte()) { - case 0: - /* - * header crc - */ - setup_get(get_ptr + header_size - 3); - break; - case 1: - /* - * filename - */ - for (i = 0; i < header_size - 3; i++) - hdr->name[i] = (char) get_byte(); - hdr->name[header_size - 3] = '\0'; - name_length = header_size - 3; - break; - case 2: - /* - * directory - */ - for (i = 0; i < header_size - 3; i++) - dirname[i] = (char) get_byte(); - dirname[header_size - 3] = '\0'; - convdelim(dirname, DELIM); - dir_length = header_size - 3; - break; - case 0x40: - /* - * MS-DOS attribute - */ - if (hdr->extend_type == EXTEND_MSDOS || - hdr->extend_type == EXTEND_HUMAN || - hdr->extend_type == EXTEND_GENERIC) - hdr->attribute = get_word(); - break; - case 0x50: - /* - * UNIX permission - */ - if (hdr->extend_type == EXTEND_UNIX) - hdr->unix_mode = get_word(); - break; - case 0x51: - /* - * UNIX gid and uid - */ - if (hdr->extend_type == EXTEND_UNIX) { - hdr->unix_gid = get_word(); - hdr->unix_uid = get_word(); - } - break; - case 0x52: - /* - * UNIX group name - */ - setup_get(get_ptr + header_size - 3); - break; - case 0x53: - /* - * UNIX user name - */ - setup_get(get_ptr + header_size - 3); - break; - case 0x54: - /* - * UNIX last modified time - */ - if (hdr->extend_type == EXTEND_UNIX) - hdr->unix_last_modified_stamp = (time_t) get_longword(); - break; - default: - /* - * other headers - */ - setup_get(get_ptr + header_size - 3); - break; - } - } - if (hdr->header_level != 2 && get_ptr - ptr != 2) { - hdr->packed_size -= get_ptr - ptr - 2; - hdr->header_size += get_ptr - ptr - 2; - } - } - - switch (hdr->extend_type) { - case EXTEND_MSDOS: - msdos_to_unix_filename(hdr->name, name_length); - msdos_to_unix_filename(dirname, dir_length); - case EXTEND_HUMAN: - if (hdr->header_level == 2) - hdr->unix_last_modified_stamp = hdr->last_modified_stamp; - else - hdr->unix_last_modified_stamp = - generic_to_unix_stamp(hdr->last_modified_stamp); - break; - -#ifdef OSK - case EXTEND_OS68K: - case EXTEND_XOSK: -#endif - case EXTEND_UNIX: - break; - - case EXTEND_MACOS: - macos_to_unix_filename(hdr->name, name_length); - /* macos_to_unix_filename(dirname, dir_length); */ - hdr->unix_last_modified_stamp = - generic_to_unix_stamp(hdr->last_modified_stamp); - break; - - default: - generic_to_unix_filename(hdr->name, name_length); - generic_to_unix_filename(dirname, dir_length); - if (hdr->header_level == 2) - hdr->unix_last_modified_stamp = hdr->last_modified_stamp; - else - hdr->unix_last_modified_stamp = - generic_to_unix_stamp(hdr->last_modified_stamp); - } - - if (dir_length) { - strcat(dirname, hdr->name); - strcpy(hdr->name, dirname); - name_length += dir_length; - } - - return TRUE; -} - -/* ------------------------------------------------------------------------ */ -void -init_header(name, v_stat, hdr) - char *name; - struct stat *v_stat; - LzHeader *hdr; -{ - int len; - - if (compress_method == LZHUFF5_METHOD_NUM) /* Changed N.Watazaki */ - bcopy(LZHUFF5_METHOD, hdr->method, METHOD_TYPE_STRAGE); - else if (compress_method) - bcopy(LZHUFF1_METHOD, hdr->method, METHOD_TYPE_STRAGE); - else - bcopy(LZHUFF0_METHOD, hdr->method, METHOD_TYPE_STRAGE); - - hdr->packed_size = 0; - hdr->original_size = v_stat->st_size; - hdr->last_modified_stamp = unix_to_generic_stamp(v_stat->st_mtime); - hdr->attribute = GENERIC_ATTRIBUTE; - hdr->header_level = header_level; - strcpy(hdr->name, name); - len = strlen(name); - hdr->crc = 0x0000; - hdr->extend_type = EXTEND_UNIX; - hdr->unix_last_modified_stamp = v_stat->st_mtime; - /* since 00:00:00 JAN.1.1970 */ -#ifdef NOT_COMPATIBLE_MODE - /* Please need your modification in this space. */ -#else - hdr->unix_mode = v_stat->st_mode; -#endif - - hdr->unix_uid = v_stat->st_uid; - hdr->unix_gid = v_stat->st_gid; - - if (is_directory(v_stat)) { - bcopy(LZHDIRS_METHOD, hdr->method, METHOD_TYPE_STRAGE); - hdr->attribute = GENERIC_DIRECTORY_ATTRIBUTE; - hdr->original_size = 0; - if (len > 0 && hdr->name[len - 1] != '/') - strcpy(&hdr->name[len++], "/"); - } - -#ifdef S_IFLNK - if (is_symlink(v_stat)) { - char lkname[257]; - int len; - bcopy(LZHDIRS_METHOD, hdr->method, METHOD_TYPE_STRAGE); - hdr->attribute = GENERIC_DIRECTORY_ATTRIBUTE; - hdr->original_size = 0; - len = readlink(name, lkname, 256); - lkname[len] = (char)'\0'; - sprintf(hdr->name, "%s|%s", hdr->name, lkname); - } -#endif - if (generic_format) - unix_to_generic_filename(hdr->name, len); -} - -/* ------------------------------------------------------------------------ */ -/* Write unix extended header or generic header. */ -void -write_header(nafp, hdr) - FILE *nafp; - LzHeader *hdr; -{ - int header_size; - int name_length; - char data[LZHEADER_STRAGE]; - char *p; - char *headercrc_ptr; - - bzero(data, LZHEADER_STRAGE); - bcopy(hdr->method, data + I_METHOD, METHOD_TYPE_STRAGE); - setup_put(data + I_PACKED_SIZE); - put_longword(hdr->packed_size); - put_longword(hdr->original_size); - - if (hdr->header_level == HEADER_LEVEL2) - put_longword((long) hdr->unix_last_modified_stamp); - else - put_longword(hdr->last_modified_stamp); - - switch (hdr->header_level) { - case HEADER_LEVEL0: - put_byte(hdr->attribute); - break; - case HEADER_LEVEL1: - case HEADER_LEVEL2: - put_byte(0x20); - break; - } - - put_byte(hdr->header_level); - - convdelim(hdr->name, DELIM2); - if (hdr->header_level != HEADER_LEVEL2) { - if (p = (char *) rindex(hdr->name, DELIM2)) - name_length = strlen(++p); - else - name_length = strlen(hdr->name); - put_byte(name_length); - bcopy(p ? p : hdr->name, data + I_NAME, name_length); - setup_put(data + I_NAME + name_length); - } - - put_word(hdr->crc); - if (header_level == HEADER_LEVEL0) { - if (generic_format) { - header_size = I_GENERIC_HEADER_BOTTOM - 2 + name_length; - data[I_HEADER_SIZE] = header_size; - data[I_HEADER_CHECKSUM] = calc_sum(data + I_METHOD, header_size); - } else { - /* write old-style extend header */ - put_byte(EXTEND_UNIX); - put_byte(CURRENT_UNIX_MINOR_VERSION); - put_longword((long) hdr->unix_last_modified_stamp); - put_word(hdr->unix_mode); - put_word(hdr->unix_uid); - put_word(hdr->unix_gid); - header_size = I_UNIX_EXTEND_BOTTOM - 2 + name_length; - data[I_HEADER_SIZE] = header_size; - data[I_HEADER_CHECKSUM] = calc_sum(data + I_METHOD, header_size); - } - } else { - /* write extend header. */ - char *ptr; - - if (generic_format) - put_byte(0x00); - else - put_byte(EXTEND_UNIX); - - ptr = put_ptr; - if (hdr->header_level == HEADER_LEVEL2) { - /* write common header */ - put_word(5); - put_byte(0x00); - headercrc_ptr = put_ptr; - put_word(0x0000); - } - - if (generic_format) { - header_size = put_ptr - data; /* +2 for last 0x0000 */ - } else { - put_word(5); - if (hdr->header_level == HEADER_LEVEL1) - header_size = put_ptr - data - 2; - put_byte(0x50); /* permission */ - put_word(hdr->unix_mode); - put_word(7); - put_byte(0x51); /* gid and uid */ - put_word(hdr->unix_gid); - put_word(hdr->unix_uid); - - if (p = (char *) rindex(hdr->name, DELIM2)) { - int i; - - name_length = p - hdr->name + 1; - put_word(name_length + 3); - put_byte(2); /* dirname */ - for (i = 0; i < name_length; i++) - put_byte(hdr->name[i]); - } - } /* if generic .. */ - - if (header_level != HEADER_LEVEL2) { - if (!generic_format) { - put_word(7); - put_byte(0x54); /* time stamp */ - put_longword(hdr->unix_last_modified_stamp); - } - hdr->packed_size += put_ptr - ptr; - ptr = put_ptr; - setup_put(data + I_PACKED_SIZE); - put_longword(hdr->packed_size); - put_ptr = ptr; - data[I_HEADER_SIZE] = header_size; - data[I_HEADER_CHECKSUM] = calc_sum(data + I_METHOD, header_size); - } else { /* header level 2 */ - int i; - if (p = (char *) rindex(hdr->name, DELIM2)) - name_length = strlen(++p); - else { - p = hdr->name; - name_length = strlen(hdr->name); - } - put_word(name_length + 3); - put_byte(1); /* filename */ - for (i = 0; i < name_length; i++) - put_byte(*p++); - } /* if he.. != HEAD_LV2 */ - header_size = put_ptr - data; - } - - if (header_level == HEADER_LEVEL2) { - unsigned short hcrc; - setup_put(data + I_HEADER_SIZE); - put_word(header_size + 2); - /* common header */ - hcrc = calc_header_crc(data, (unsigned int) header_size + 2); - setup_put(headercrc_ptr); - put_word(hcrc); - } - - if (fwrite(data, sizeof(char), header_size + 2, nafp) == 0) - fatal_error("Cannot write to temporary file"); - - convdelim(hdr->name, DELIM); -} - -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* compile-command:"gcc -c header.c" */ -/* End: */ diff -Nru lha-1.14i/debian/org/lha.h lha-1.14i-acc20050924p1/debian/org/lha.h --- lha-1.14i/debian/org/lha.h 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/org/lha.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,322 +0,0 @@ -/* ------------------------------------------------------------------------ */ -/* LHa for UNIX Archiver Driver */ -/* */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 1.14 Soruce All chagned 1995.01.14 N.Watazaki */ -/* Ver. 1.14i Modified and bug fixed 2000.10.06 t.okamoto */ -/* ------------------------------------------------------------------------ */ -/* - Included... - lharc.h interface.h slidehuf.h -*/ -#include -#include -#include -#include -#include -#include - -#include - -#include "lha_macro.h" - -struct encode_option { -#if defined(__STDC__) || defined(AIX) - void (*output) (); - void (*encode_start) (); - void (*encode_end) (); -#else - int (*output) (); - int (*encode_start) (); - int (*encode_end) (); -#endif -}; - -struct decode_option { - unsigned short (*decode_c) (); - unsigned short (*decode_p) (); -#if defined(__STDC__) || defined(AIX) - void (*decode_start) (); -#else - int (*decode_start) (); -#endif -}; - -/* ------------------------------------------------------------------------ */ -/* LHa File Type Definition */ -/* ------------------------------------------------------------------------ */ -struct string_pool { - int used; - int size; - int n; - char *buffer; -}; - -typedef struct LzHeader { - unsigned char header_size; - char method[METHOD_TYPE_STRAGE]; - long packed_size; - long original_size; - long last_modified_stamp; - unsigned char attribute; - unsigned char header_level; - char name[256]; - unsigned short crc; - boolean has_crc; - unsigned char extend_type; - unsigned char minor_version; - - /* extend_type == EXTEND_UNIX and convert from other type. */ - time_t unix_last_modified_stamp; - unsigned short unix_mode; - unsigned short unix_uid; - unsigned short unix_gid; -} LzHeader; - -struct interfacing { - FILE *infile; - FILE *outfile; - unsigned long original; - unsigned long packed; - int dicbit; - int method; -}; - - -/* ------------------------------------------------------------------------ */ -/* Option switch variable */ -/* ------------------------------------------------------------------------ */ -/* command line options (common options) */ -EXTERN boolean quiet; -EXTERN boolean text_mode; -EXTERN boolean verbose; -EXTERN boolean noexec; /* debugging option */ -EXTERN boolean force; -EXTERN boolean prof; -EXTERN boolean delete_after_append; -EXTERN int compress_method; -EXTERN int header_level; -/* EXTERN int quiet_mode; */ /* 1996.8.13 t.okamoto */ -#ifdef EUC -EXTERN boolean euc_mode; -#endif - -/* list command flags */ -EXTERN boolean verbose_listing; - -/* extract/print command flags */ -EXTERN boolean output_to_stdout; - -/* add/update/delete command flags */ -EXTERN boolean new_archive; -EXTERN boolean update_if_newer; -EXTERN boolean generic_format; - -EXTERN boolean remove_temporary_at_error; -EXTERN boolean recover_archive_when_interrupt; -EXTERN boolean remove_extracting_file_when_interrupt; -EXTERN boolean get_filename_from_stdin; -EXTERN boolean ignore_directory; -EXTERN boolean verify_mode; - -/* Indicator flag */ -EXTERN int quiet_mode; - -/* ------------------------------------------------------------------------ */ -/* Globale Variable */ -/* ------------------------------------------------------------------------ */ -EXTERN char **cmd_filev; -EXTERN int cmd_filec; - -EXTERN char *archive_name; -EXTERN char expanded_archive_name[FILENAME_LENGTH]; -EXTERN char temporary_name[FILENAME_LENGTH]; -EXTERN char backup_archive_name[FILENAME_LENGTH]; - -EXTERN char *reading_filename, *writting_filename; - -/* 1996.8.13 t.okamoto */ -#if 0 -EXTERN boolean remove_temporary_at_error; -EXTERN boolean recover_archive_when_interrupt; -EXTERN boolean remove_extracting_file_when_interrupt; -#endif - -EXTERN int archive_file_mode; -EXTERN int archive_file_gid; - -EXTERN struct interfacing interface; -EXTERN node *next; -/* EXTERN unsigned short crc; */ /* 1996.8.13 t.okamoto */ - -EXTERN int noconvertcase; /* 2000.10.6 */ - -/* slide.c */ -EXTERN int unpackable; -EXTERN unsigned long origsize, compsize; -EXTERN unsigned short dicbit; -EXTERN unsigned short maxmatch; -EXTERN unsigned long count; -EXTERN unsigned long loc; /* short -> long .. Changed N.Watazaki */ -EXTERN unsigned char *text; -EXTERN int prev_char; - -/* huf.c */ -#ifndef LHA_MAIN_SRC /* t.okamoto 96/2/20 */ -EXTERN unsigned short left[], right[]; -EXTERN unsigned char c_len[], pt_len[]; -EXTERN unsigned short c_freq[], c_table[], c_code[]; -EXTERN unsigned short p_freq[], pt_table[], pt_code[], t_freq[]; -#endif - -/* append.c */ -#ifdef NEED_INCREMENTAL_INDICATOR -EXTERN long indicator_count; -EXTERN long indicator_threshold; -#endif - -/* crcio.c */ -EXTERN FILE *infile, *outfile; -EXTERN unsigned short crc, bitbuf; -EXTERN int dispflg; -EXTERN long reading_size; - -/* from dhuf.c */ -EXTERN unsigned int n_max; - -/* lhadd.c */ -EXTERN FILE *temporary_fp; - -/* ------------------------------------------------------------------------ */ -/* Functions */ -/* ------------------------------------------------------------------------ */ -/* from lharc.c */ -extern int patmatch(); - -extern void interrupt(); - -extern void message(); -extern void warning(); -extern void error(); -extern void fatal_error(); - -extern boolean need_file(); -extern int inquire(); -extern FILE *xfopen(); - -extern boolean find_files(); -extern void free_files(); - -extern void init_sp(); -extern void add_sp(); -extern void finish_sp(); -extern void free_sp(); -extern void cleaning_files(); - -extern void build_temporary_name(); -extern void build_backup_file_name(); -extern void build_standard_archive_name(); - -extern FILE *open_old_archive(); -extern void init_header(); -extern boolean get_header(); -extern boolean archive_is_msdos_sfx1(); -extern boolean skip_msdos_sfx1_code(); -extern void write_header(); -extern void write_archive_tail(); -extern void copy_old_one(); -extern unsigned char *convdelim(); -extern long copyfile(); - -extern void cmd_list(), cmd_extract(), cmd_add(), cmd_delete(); - -extern boolean ignore_directory; -extern boolean compress_method; -extern boolean verify_mode; - -extern char *extract_directory; - -/* from slide.c */ - -extern int encode_alloc(); -extern void encode(); -extern void decode(); - -/* from append.c */ -extern void start_indicator(); -extern void finish_indicator(); -extern void finish_indicator2(); - -/* slide.c */ -extern void output_st1(); -extern unsigned char *alloc_buf(); -extern void encode_start_st1(); -extern void encode_end_st1(); -extern unsigned short decode_c_st1(); -extern unsigned short decode_p_st1(); -extern void decode_start_st1(); - -/* from shuf.c */ -extern void decode_start_st0(); -extern void encode_p_st0( /* unsigned short j */ ); -extern void encode_start_fix(); -extern void decode_start_fix(); -extern unsigned short decode_c_st0(); -extern unsigned short decode_p_st0(); - -/* from dhuf.c */ -extern void start_c_dyn(); -extern void decode_start_dyn(); -extern unsigned short decode_c_dyn(); -extern unsigned short decode_p_dyn(); -extern void output_dyn( /* int code, unsigned int pos */ ); -extern void encode_end_dyn(); - -extern int decode_lzhuf(); - -/* from larc.c */ - -extern unsigned short decode_c_lzs(); -extern unsigned short decode_p_lzs(); -extern unsigned short decode_c_lz5(); -extern unsigned short decode_p_lz5(); -extern void decode_start_lzs(); -extern void decode_start_lz5(); - -extern void make_table( /* int nchar, uchar bitlen[], int tablebits, - ushort table[] */ ); - -/* from maketree.c */ -/* - * void make_code(short n, uchar len[], ushort code[]); short make_tree(short - * nparm, ushort freqparm[], uchar lenparm[], ushort codeparam[]); - */ -extern void make_code( /* int n, uchar len[], ushort code[] */ ); -extern short make_tree( /* int nparm, ushort freqparm[], uchar lenparm[], - ushort codeparam[] */ ); - -/* from crcio.c */ -extern void make_crctable(); -extern unsigned short calccrc( /* uchar *p, uint n */ ); -extern void fillbuf( /* uchar n */ ); -extern unsigned short getbits( /* uchar n */ ); -extern void putcode( /* uchar n, ushort x */ ); -extern void putbits( /* uchar n, ushort x */ ); -extern int fread_crc( /* uchar *p, int n, FILE *f */ ); -extern void fwrite_crc( /* uchar *p, int n, FILE *f */ ); -extern void init_getbits(); -extern void init_putbits(); -extern void make_crctable(); -extern unsigned short calccrc(); - -/* from lhadd.c */ -extern int encode_lzhuf(); -extern int encode_stored_crc(); - -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* End: */ - - diff -Nru lha-1.14i/debian/org/lha_macro.h lha-1.14i-acc20050924p1/debian/org/lha_macro.h --- lha-1.14i/debian/org/lha_macro.h 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/org/lha_macro.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,420 +0,0 @@ -/* ------------------------------------------------------------------------ */ -/* LHa for UNIX Archiver Driver macro define */ -/* */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 1.14 Soruce All chagned 1995.01.14 N.Watazaki */ -/* Ver. 1.14g modified 2000.05.06 T.OKAMOTO */ -/* ------------------------------------------------------------------------ */ - -#define LHA_VERSION "lha for unix version 1.14i" - -/* Most of System V, define SYSTIME_HAS_NO_TM */ -#ifdef SYSTIME_HAS_NO_TM -#include -#else -#include -#endif /* SYSTIME_HAS_NO_TM */ - -/* ------------------------------------------------------------------------ */ -/* Directory Access Stuff */ -/* ------------------------------------------------------------------------ */ -#ifndef NODIRECTORY -#ifdef SYSV_SYSTEM_DIR - -#include - -#define DIRENTRY struct dirent -#define NAMLEN(p) strlen (p->d_name) - -#else /* not SYSV_SYSTEM_DIR */ - -#ifdef NONSYSTEM_DIR_LIBRARY -#include "lhdir.h" -#else -#include -#endif /* not NONSYSTEM_DIR_LIBRARY */ - -#define DIRENTRY struct direct -#define NAMLEN(p) p->d_namlen - -#endif /* not SYSV_SYSTEM_DIR */ -#endif /* NODIRECTORY */ - -/* ------------------------------------------------------------------------ */ -/* Other Define */ -/* ------------------------------------------------------------------------ */ -/* Not support 'void' */ -#ifdef NOVOID -#define void -#endif - -#ifndef SEEK_SET -#define SEEK_SET 0 -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif /* SEEK_SET - - -/* non-integral functions */ -extern struct tm *localtime(); -extern char *getenv(); - -#ifndef _MINIX -#ifndef __STDC__ -extern char *malloc(); -extern char *realloc(); -#endif -#endif - -/* external variables */ -extern int errno; - -#define FALSE 0 -#define TRUE 1 -typedef int boolean; - -/* used by qsort() for alphabetic-sort */ -#define STRING_COMPARE(a,b) strcmp((a),(b)) - -#define FILENAME_LENGTH 1024 - -/* ------------------------------------------------------------------------ */ -/* YOUR CUSTOMIZIES */ -/* ------------------------------------------------------------------------ */ - -#ifndef ARCHIVENAME_EXTENTION -#define ARCHIVENAME_EXTENTION ".lzh" -#endif -#ifndef BACKUPNAME_EXTENTION -#define BACKUPNAME_EXTENTION ".bak" -#endif -#ifndef TMP_FILENAME_TEMPLATE -#define TMP_FILENAME_TEMPLATE "/tmp/lhXXXXXX" -#endif - -#define SJC_FIRST_P(c) \ - (((unsigned char)(c) >= 0x80) && \ - (((unsigned char)(c) < 0xa0) || \ - ((unsigned char)(c) >= 0xe0) && \ - ((unsigned char)(c) < 0xfd))) -#define SJC_SECOND_P(c) \ - (((unsigned char)(c) >= 0x40) && \ - ((unsigned char)(c) < 0xfd) && \ - ((unsigned char)(c) != 0x7f)) - -#ifdef MULTIBYTE_CHAR -#define MULTIBYTE_FIRST_P SJC_FIRST_P -#define MULTIBYTE_SECOND_P SJC_SECOND_P -#endif /* MULTIBYTE_CHAR */ - -/* ------------------------------------------------------------------------ */ -/* LHa File Definitions */ -/* ------------------------------------------------------------------------ */ -#ifdef S_IFLNK -#define GETSTAT lstat -#else -#define GETSTAT stat -#endif - -#ifdef LHA_MAIN_SRC -#define EXTERN -#else -#define EXTERN extern -#endif /* LHA_MAIN_SRC */ - -#define LZHUFF0_METHOD "-lh0-" -#define LZHUFF1_METHOD "-lh1-" -#define LZHUFF2_METHOD "-lh2-" -#define LZHUFF3_METHOD "-lh3-" -#define LZHUFF4_METHOD "-lh4-" -#define LZHUFF5_METHOD "-lh5-" -#define LZHUFF6_METHOD "-lh6-" -#define LZHUFF7_METHOD "-lh7-" -#define LARC_METHOD "-lzs-" -#define LARC5_METHOD "-lz5-" -#define LARC4_METHOD "-lz4-" -#define LZHDIRS_METHOD "-lhd-" - -#define METHOD_TYPE_STRAGE 5 - -/* Added N.Watazaki ..V */ -#define LZHUFF0_METHOD_NUM 0 -#define LZHUFF1_METHOD_NUM 1 -#define LZHUFF2_METHOD_NUM 2 -#define LZHUFF3_METHOD_NUM 3 -#define LZHUFF4_METHOD_NUM 4 -#define LZHUFF5_METHOD_NUM 5 -#define LZHUFF6_METHOD_NUM 6 -#define LZHUFF7_METHOD_NUM 7 -#define LARC_METHOD_NUM 8 -#define LARC5_METHOD_NUM 9 -#define LARC4_METHOD_NUM 10 -#define LZHDIRS_METHOD_NUM 11 -/* Added N.Watazaki ..^ */ - -#define I_HEADER_SIZE 0 -#define I_HEADER_CHECKSUM 1 -#define I_METHOD 2 -#define I_PACKED_SIZE 7 -#define I_ORIGINAL_SIZE 11 -#define I_LAST_MODIFIED_STAMP 15 -#define I_ATTRIBUTE 19 -#define I_HEADER_LEVEL 20 -#define I_NAME_LENGTH 21 -#define I_NAME 22 - -#define I_CRC 22 /* + name_length */ -#define I_EXTEND_TYPE 24 /* + name_length */ -#define I_MINOR_VERSION 25 /* + name_length */ -#define I_UNIX_LAST_MODIFIED_STAMP 26 /* + name_length */ -#define I_UNIX_MODE 30 /* + name_length */ -#define I_UNIX_UID 32 /* + name_length */ -#define I_UNIX_GID 34 /* + name_length */ -#define I_UNIX_EXTEND_BOTTOM 36 /* + name_length */ - -#define I_GENERIC_HEADER_BOTTOM I_EXTEND_TYPE - -#define EXTEND_GENERIC 0 -#define EXTEND_UNIX 'U' -#define EXTEND_MSDOS 'M' -#define EXTEND_MACOS 'm' -#define EXTEND_OS9 '9' -#define EXTEND_OS2 '2' -#define EXTEND_OS68K 'K' -#define EXTEND_OS386 '3' /* OS-9000??? */ -#define EXTEND_HUMAN 'H' -#define EXTEND_CPM 'C' -#define EXTEND_FLEX 'F' -#define EXTEND_RUNSER 'R' - -/* this OS type is not official */ - -#define EXTEND_TOWNSOS 'T' -#define EXTEND_XOSK 'X' - -/*---------------------------------------------------------------------------*/ - -#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 - -#define DELIM ('/') -#define DELIM2 (0xff) -#define DELIMSTR "/" - -#define OSK_RW_RW_RW 0000033 -#define OSK_FILE_REGULAR 0000000 -#define OSK_DIRECTORY_PERM 0000200 -#define OSK_SHARED_PERM 0000100 -#define OSK_OTHER_EXEC_PERM 0000040 -#define OSK_OTHER_WRITE_PERM 0000020 -#define OSK_OTHER_READ_PERM 0000010 -#define OSK_OWNER_EXEC_PERM 0000004 -#define OSK_OWNER_WRITE_PERM 0000002 -#define OSK_OWNER_READ_PERM 0000001 - -#define UNIX_FILE_TYPEMASK 0170000 -#define UNIX_FILE_REGULAR 0100000 -#define UNIX_FILE_DIRECTORY 0040000 -#define UNIX_FILE_SYMLINK 0120000 -#define UNIX_SETUID 0004000 -#define UNIX_SETGID 0002000 -#define UNIX_STYCKYBIT 0001000 -#define UNIX_OWNER_READ_PERM 0000400 -#define UNIX_OWNER_WRITE_PERM 0000200 -#define UNIX_OWNER_EXEC_PERM 0000100 -#define UNIX_GROUP_READ_PERM 0000040 -#define UNIX_GROUP_WRITE_PERM 0000020 -#define UNIX_GROUP_EXEC_PERM 0000010 -#define UNIX_OTHER_READ_PERM 0000004 -#define UNIX_OTHER_WRITE_PERM 0000002 -#define UNIX_OTHER_EXEC_PERM 0000001 -#define UNIX_RW_RW_RW 0000666 - -#define LZHEADER_STRAGE 4096 - -#define MAX_INDICATOR_COUNT 64 - -typedef short node; - -/* ------------------------------------------------------------------------ */ -/* Slide relation */ -/* ------------------------------------------------------------------------ */ -#if defined(__STDC__) || defined(AIX) - -#include - -#else - -#ifndef CHAR_BIT -#define CHAR_BIT 8 -#endif - -#ifndef UCHAR_MAX -#define UCHAR_MAX ((1<<(sizeof(unsigned char)*8))-1) -#endif - -#ifndef USHRT_MAX -#define USHRT_MAX ((1<<(sizeof(unsigned short)*8))-1) -#endif - -#ifndef SHRT_MAX -#define SHRT_MAX ((1<<(sizeof(short)*8-1))-1) -#endif - -#ifndef SHRT_MIN -#define SHRT_MIN (SHRT_MAX-USHRT_MAX) -#endif - -#ifndef ULONG_MAX -#define ULONG_MAX ((1<<(sizeof(unsigned long)*8))-1) -#endif - -#ifndef LONG_MAX -#define LONG_MAX ((1<<(sizeof(long)*8-1))-1) -#endif - -#ifndef LONG_MIN -#define LONG_MIN (LONG_MAX-ULONG_MAX) -#endif - -#endif /* not __STDC__ */ - -/* ------------------------------------------------------------------------ */ -/* FILE Attribute */ -/* ------------------------------------------------------------------------ */ -#define is_directory(statp) (((statp)->st_mode & S_IFMT) == S_IFDIR) -#define is_symlink(statp) (((statp)->st_mode & S_IFMT) == S_IFLNK) -#define is_regularfile(statp) (((statp)->st_mode & S_IFMT) == S_IFREG) - -#ifdef MSDOS -#define WRITE_BINARY "wb" -#define READ_BINARY "rb" -#else -#define WRITE_BINARY "w" -#define READ_BINARY "r" -#endif - -/* ------------------------------------------------------------------------ */ -/* Memory and String function */ -/* ------------------------------------------------------------------------ */ -#include - -#ifdef NOINDEX -#define index strchr -#define rindex strrchr -#endif /* NOINDEX */ - -#ifdef NOBSTRING -#define bcmp(a,b,n) memcmp ((a),(b),(n)) -#define bzero(d,n) memset((d),0,(n)) -#define bcopy(s,d,n) memmove((d),(s),(n)) -#endif /* NOBSTRING */ - -#ifdef USESTRCASECMP -#define strucmp(p,q) strcasecmp((p),(q)) -#endif - -/* ------------------------------------------------------------------------ */ -/* Individual macro define */ -/* ------------------------------------------------------------------------ */ - -/* from crcio.c */ -#define CRCPOLY 0xA001 /* CRC-16 */ -#define UPDATE_CRC(c) crc = crctable[(crc ^ (c)) & 0xFF] ^ (crc >> CHAR_BIT) - -/* dhuf.c */ -#define N_CHAR (256 + 60 - THRESHOLD + 1) -#define TREESIZE_C (N_CHAR * 2) -#define TREESIZE_P (128 * 2) -#define TREESIZE (TREESIZE_C + TREESIZE_P) -#define ROOT_C 0 -#define ROOT_P TREESIZE_C - -/* header.c */ -#define setup_get(PTR) (get_ptr = (PTR)) -#define get_byte() (*get_ptr++ & 0xff) -#define put_ptr get_ptr -#define setup_put(PTR) (put_ptr = (PTR)) -#define put_byte(c) (*put_ptr++ = (char)(c)) - -/* huf.c */ -#define NP (MAX_DICBIT + 1) -#define NT (USHRT_BIT + 3) -#if 0 -#define PBIT 4 /* smallest integer such that (1 << PBIT) > * NP */ -#define TBIT 5 /* smallest integer such that (1 << TBIT) > * NT */ -#endif - -#define PBIT 5 /* smallest integer such that (1 << PBIT) > * NP */ -#define TBIT 5 /* smallest integer such that (1 << TBIT) > * NT */ - -#define NC (UCHAR_MAX + MAXMATCH + 2 - THRESHOLD) - -/* #if NT > NP #define NPT NT #else #define NPT NP #endif */ -#define NPT 0x80 - -/* larc.c */ -#define MAGIC0 18 -#define MAGIC5 19 - -/* lharc.c */ -#define CMD_UNKNOWN 0 -#define CMD_EXTRACT 1 -#define CMD_ADD 2 -#define CMD_LIST 3 -#define CMD_DELETE 4 - -#define STREQU(a,b) (((a)[0] == (b)[0]) ? (strcmp ((a),(b)) == 0) : FALSE) - -/* shuf.c */ -#define N1 286 /* alphabet size */ -#define N2 (2 * N1 - 1) /* # of nodes in Huffman tree */ -#define EXTRABITS 8 /* >= log2(F-THRESHOLD+258-N1) */ -#define BUFBITS 16 /* >= log2(MAXBUF) */ -#define LENFIELD 4 /* bit size of length field for tree output */ - -/* util.c */ -#define BUFFERSIZE 2048 -#define MAXSFXCODE 1024*64 - -#ifndef NULL -#define NULL (char *)0 -#endif - -/* slide.c */ -/* -#define PERCOLATE 1 -#define NIL 0 -#define HASH(p, c) ((p) + ((c) << hash1) + hash2) -*/ - -/* slide.c */ -#ifdef SUPPORT_LH7 -#define MAX_DICBIT 16 /* lh7 use 16bits */ -#endif - -#ifndef SUPPORT_LH7 -#define MAX_DICBIT 15 /* lh6 use 15bits */ -#endif - -#define MAX_DICSIZ (1 << MAX_DICBIT) -#define MATCHBIT 8 /* bits for MAXMATCH - THRESHOLD */ -#define MAXMATCH 256 /* formerly F (not more than UCHAR_MAX + 1) */ -#define THRESHOLD 3 /* choose optimal value */ - -/* from huf.c */ - -/* alphabet = {0, 1, 2, ..., NC - 1} */ -#define CBIT 9 /* $\lfloor \log_2 NC \rfloor + 1$ */ -#define USHRT_BIT 16 /* (CHAR_BIT * sizeof(ushort)) */ - -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* End: */ diff -Nru lha-1.14i/debian/org/lharc.c lha-1.14i-acc20050924p1/debian/org/lharc.c --- lha-1.14i/debian/org/lharc.c 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/org/lharc.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,1135 +0,0 @@ -/* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* lharc.c -- append to archive */ -/* */ -/* Copyright (C) MCMLXXXIX Yooichi.Tagawa */ -/* Modified Nobutaka Watazaki */ -/* Thanks to H.Yoshizaki. (MS-DOS LHarc) */ -/* */ -/* Ver. 0.00 Original 1988.05.23 Y.Tagawa */ -/* Ver. 0.01 Alpha Version (for 4.2BSD) 1989.05.28 Y.Tagawa */ -/* Ver. 0.02 Alpha Version Rel.2 1989.05.29 Y.Tagawa */ -/* Ver. 0.03 Release #3 Beta Version 1989.07.02 Y.Tagawa */ -/* Ver. 0.03a Debug 1989.07.03 Y.Tagawa */ -/* Ver. 0.03b Modified 1989.07.13 Y.Tagawa */ -/* Ver. 0.03c Debug (Thanks to void@rena.dit.junet) */ -/* 1989.08.09 Y.Tagawa */ -/* Ver. 0.03d Modified (quiet and verbose) 1989.09.14 Y.Tagawa */ -/* V1.00 Fixed 1989.09.22 Y.Tagawa */ -/* V1.01 Bug Fixed 1989.12.25 Y.Tagawa */ -/* */ -/* DOS-Version Original LHx V C2.01 (C) H.Yohizaki */ -/* */ -/* V2.00 UNIX Lharc + DOS LHx -> OSK LHx 1990.11.01 Momozou */ -/* V2.01 Minor Modified 1990.11.24 Momozou */ -/* */ -/* Ver. 0.02 LHx for UNIX 1991.11.18 M.Oki */ -/* Ver. 0.03 LHa for UNIX 1991.12.17 M.Oki */ -/* Ver. 0.04 LHa for UNIX beta version 1992.01.20 M.Oki */ -/* Ver. 1.00 LHa for UNIX Fixed 1992.03.19 M.Oki */ -/* */ -/* Ver. 1.10 for Symblic Link 1993.06.25 N.Watazaki */ -/* Ver. 1.11 for Symblic Link Bug Fixed 1993.08.18 N.Watazaki */ -/* Ver. 1.12 for File Date Check 1993.10.28 N.Watazaki */ -/* Ver. 1.13 Bug Fixed (Idicator calcurate) 1994.02.21 N.Watazaki */ -/* Ver. 1.13a Bug Fixed (Sym. Link delete) 1994.03.11 N.Watazaki */ -/* Ver. 1.13b Bug Fixed (Sym. Link delete) 1994.07.29 N.Watazaki */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ -/* Ver. 1.14b,c Bug Fixed 1996.03.07 t.okamoto */ -/* Ver. 1.14d Version up 1997.01.12 t.okamoto */ -/* Ver. 1.14g Bug Fixed 2000.05.06 t.okamoto */ -/* Ver. 1.14i Modified 2000.10.06 t.okamoto */ -/* ------------------------------------------------------------------------ */ -#define LHA_MAIN_SRC - -#include "lha.h" - -/* ------------------------------------------------------------------------ */ -/* PROGRAM */ -/* ------------------------------------------------------------------------ */ -static int cmd = CMD_UNKNOWN; - -/* 1996.8.13 t.okamoto */ -#if 0 -char **cmd_filev; -int cmd_filec; - -char *archive_name; -char expanded_archive_name[FILENAME_LENGTH]; -char temporary_name[FILENAME_LENGTH]; -char backup_archive_name[FILENAME_LENGTH]; -#endif - -/* static functions */ -static void sort_files(); -static void print_version(); - -char *extract_directory = NULL; -char **xfilev; -int xfilec = 257; - -/* 1996.8.13 t.okamoto */ -#if 0 -char *writting_filename; -char *reading_filename; - -int archive_file_mode; -int archive_file_gid; -#endif -/* ------------------------------------------------------------------------ */ -static void -init_variable() /* Added N.Watazaki */ -{ -/* options */ - quiet = FALSE; - text_mode = FALSE; - verbose = FALSE; - noexec = FALSE; /* debugging option */ - force = FALSE; - prof = FALSE; -#ifndef SUPPORT_LH7 - compress_method = LZHUFF5_METHOD_NUM; -#endif -#ifdef SUPPORT_LH7 - compress_method = LZHUFF7_METHOD_NUM; -#endif - - header_level = HEADER_LEVEL1; - quiet_mode = 0; - -#ifdef EUC - euc_mode = FALSE; -#endif - -/* view command flags */ - verbose_listing = FALSE; - -/* extract command flags */ - output_to_stdout = FALSE; - -/* append command flags */ - new_archive = FALSE; - update_if_newer = FALSE; - delete_after_append = FALSE; - generic_format = FALSE; - - remove_temporary_at_error = FALSE; - recover_archive_when_interrupt = FALSE; - remove_extracting_file_when_interrupt = FALSE; - get_filename_from_stdin = FALSE; - ignore_directory = FALSE; - verify_mode = FALSE; - - noconvertcase = FALSE; - - extract_directory = NULL; - xfilec = 257; -} - -/* ------------------------------------------------------------------------ */ -/* NOTES : Text File Format */ -/* GENERATOR NewLine */ -/* [generic] 0D 0A */ -/* [MS-DOS] 0D 0A */ -/* [OS9][MacOS] 0D */ -/* [UNIX] 0A */ -/* ------------------------------------------------------------------------ */ -static void -print_tiny_usage_and_exit() -{ - fprintf(stderr, "\ -LHarc for UNIX V 1.02 Copyright(C) 1989 Y.Tagawa\n\ -LHx for MSDOS V C2.01 Copyright(C) 1990 H.Yoshizaki\n\ -LHx(arc) for OSK V 2.01 Modified 1990 Momozou\n\ -LHa for UNIX V 1.00 Copyright(C) 1992 Masaru Oki\n\ -LHa for UNIX V 1.14 Modified 1995 Nobutaka Watazaki\n\ -LHa for UNIX V 1.14i Modified 2000 Tsugio Okamoto\n\ -"); - fprintf(stderr, "\ -usage: lha [-]{axelvudmcp[q[num]][vnfodizg012]}[w=] archive_file [file...]\n\ -commands: options:\n\ - a Add(or replace) to archive q{num} quiet (num:quiet mode)\n\ - x,e EXtract from archive v verbose\n\ - l,v List / Verbose List n not execute\n\ - u Update newer files to archive f force (over write at extract)\n\ - d Delete from archive t FILES are TEXT file\n"); -#ifdef SUPPORT_LH7 - fprintf(stderr, "\ - m Move to archive (means 'ad') o[567] compression method (a/u)\n\ -"); -#endif -#ifndef SUPPORT_LH7 - fprintf(stderr, "\ - m Move to archive (means 'ad') o use LHarc compatible method (a/u)\n\ -"); -#endif - fprintf(stderr, "\ - c re-Construct new archive w= specify extract directory (a/u/m/x/e)\n\ - p Print to STDOUT from archive d delete FILES after (a/u/c)\n\ - t Test file CRC in archive i ignore directory path (x/e)\n\ - z files not compress (a/u)\n\ - g Generic format (for compatibility)\n\ - or not convert case when extracting\n\ - 0/1/2 header level (a/u)\n\ -"); -#ifdef EUC - fprintf(stderr, "\ - e TEXT code convert from/to EUC\n\ -"); -#endif - exit(1); -} - -/* ------------------------------------------------------------------------ */ -int -main(argc, argv) - int argc; - char *argv[]; -{ - char *p, inpbuf[256]; - - int i; - int ac; - char **av, *m; - - init_variable(); /* Added N.Watazaki */ - - ac = argc; - av = (char **)malloc( sizeof(char*)*argc ); - if (av == NULL) fatal_error("not enough memory\n"); - for (i=0; i= xfilec) { - xfilec += 256; - cmd_filev = (char **) realloc(xfilev, - sizeof(char *) * xfilec); - if (cmd_filev == NULL) - fatal_error("Virtual memory exhausted\n"); - xfilev = cmd_filev; - } - if (strlen(inpbuf) < 1) - continue; - if ((xfilev[cmd_filec++] = (char *) strdup(inpbuf)) == NULL) - fatal_error("Virtual memory exhausted\n"); - } - xfilev[cmd_filec] = NULL; - cmd_filev = xfilev; - } else { - cmd_filec = ac - 3; - cmd_filev = av + 3; - } - sort_files(); - - /* make crc table */ - make_crctable(); - - switch (cmd) { - case CMD_EXTRACT: - cmd_extract(); - break; - case CMD_ADD: - cmd_add(); - break; - case CMD_LIST: - cmd_list(); - break; - case CMD_DELETE: - cmd_delete(); - break; - } - -#ifdef USE_PROF - if (!prof) - exit(0); -#endif - - return 0; -} - - -/* ------------------------------------------------------------------------ */ -/* */ -/* ------------------------------------------------------------------------ */ - -/* ------------------------------------------------------------------------ */ -static void -print_version() -{ - fprintf(stderr, "%s\n", LHA_VERSION); -} - -/* ------------------------------------------------------------------------ */ -static void -message_1(title, subject, name) - char *title, *subject, *name; -{ - fprintf(stderr, "LHa: %s%s ", title, subject); - fflush(stderr); - - if (errno == 0) - fprintf(stderr, "%s\n", name); - else - perror(name); -} - -/* ------------------------------------------------------------------------ */ -void -message(subject, name) - char *subject, *name; -{ - message_1("", subject, name); -} - -/* ------------------------------------------------------------------------ */ -void -warning(subject, name) - char *subject, *name; -{ - message_1("Warning: ", subject, name); -} - -/* ------------------------------------------------------------------------ */ -void -error(subject, msg) - char *subject, *msg; -{ - message_1("Error: ", subject, msg); -} - -/* ------------------------------------------------------------------------ */ -void -fatal_error(msg) - char *msg; -{ - message_1("Fatal error:", "", msg); - - if (remove_temporary_at_error) - unlink(temporary_name); - - exit(1); -} - -/* ------------------------------------------------------------------------ */ -void -write_error() -{ - fatal_error(writting_filename); -} - -/* ------------------------------------------------------------------------ */ -void -read_error() -{ - fatal_error(reading_filename); -} - -/* ------------------------------------------------------------------------ */ -void -interrupt(signo) - int signo; -{ - errno = 0; - message("Interrupted\n", ""); - - if (temporary_fp) - fclose(temporary_fp); - unlink(temporary_name); - if (recover_archive_when_interrupt) - rename(backup_archive_name, archive_name); - if (remove_extracting_file_when_interrupt) { - errno = 0; - message("Removing", writting_filename); - unlink(writting_filename); - } - signal(SIGINT, SIG_DFL); - signal(SIGHUP, SIG_DFL); - kill(getpid(), signo); -} - -/* ------------------------------------------------------------------------ */ -/* */ -/* ------------------------------------------------------------------------ */ -static int -sort_by_ascii(a, b) - char **a, **b; -{ - register char *p, *q; - register int c1, c2; - - p = *a, q = *b; - if (generic_format) { - do { - c1 = *(unsigned char *) p++; - c2 = *(unsigned char *) q++; - if (!c1 || !c2) - break; - if (islower(c1)) - c1 = toupper(c1); - if (islower(c2)) - c2 = toupper(c2); - } - while (c1 == c2); - return c1 - c2; - } - else { - while (*p == *q && *p != '\0') - p++, q++; - return *(unsigned char *) p - *(unsigned char *) q; - } -} - -/* ------------------------------------------------------------------------ */ -static void -sort_files() -{ - if (cmd_filec > 1) - qsort(cmd_filev, cmd_filec, sizeof(char *), sort_by_ascii); -} - -/* ------------------------------------------------------------------------ */ -char * -xmalloc(size) - int size; -{ - char *p = (char *) malloc(size); - if (!p) - fatal_error("Not enough memory"); - return p; -} - -/* ------------------------------------------------------------------------ */ -char * -xrealloc(old, size) - char *old; - int size; -{ - char *p = (char *) realloc(old, size); - if (!p) - fatal_error("Not enough memory"); - return p; -} - -/* ------------------------------------------------------------------------ */ -/* STRING POOL */ -/* ------------------------------------------------------------------------ */ -/* - string pool : - +-------------+-------------+------+-------------+----------+ - | N A M E 1 \0| N A M E 2 \0| .... | N A M E n \0| | - +-------------+-------------+------+-------------+----------+ - ^ ^ ^ buffer+0 buffer+used buffer+size - - vector : - +---------------+---------------+------------- -----------------+ - | pointer to | pointer to | pointer to ... pointer to | - | stringpool | N A M E 1 | N A M E 2 ... N A M E n | - +---------------+---------------+------------- -------------+ - ^ malloc base returned -*/ - -/* ------------------------------------------------------------------------ */ -void -init_sp(sp) - struct string_pool *sp; -{ - sp->size = 1024 - 8; /* any ( >=0 ) */ - sp->used = 0; - sp->n = 0; - sp->buffer = (char *) xmalloc(sp->size * sizeof(char)); -} - -/* ------------------------------------------------------------------------ */ -void -add_sp(sp, name, len) - struct string_pool *sp; - char *name; /* stored '\0' at tail */ - int len; /* include '\0' */ -{ - while (sp->used + len > sp->size) { - sp->size *= 2; - sp->buffer = (char *) xrealloc(sp->buffer, sp->size * sizeof(char)); - } - bcopy(name, sp->buffer + sp->used, len); - sp->used += len; - sp->n++; -} - -/* ------------------------------------------------------------------------ */ -void -finish_sp(sp, v_count, v_vector) - register struct string_pool *sp; - int *v_count; - char ***v_vector; -{ - int i; - register char *p; - char **v; - - v = (char **) xmalloc((sp->n + 1) * sizeof(char *)); - *v++ = sp->buffer; - *v_vector = v; - *v_count = sp->n; - p = sp->buffer; - for (i = sp->n; i; i--) { - *v++ = p; - if (i - 1) - p += strlen(p) + 1; - } -} - -/* ------------------------------------------------------------------------ */ -void -free_sp(vector) - char **vector; -{ - vector--; - free(*vector); /* free string pool */ - free(vector); -} - - -/* ------------------------------------------------------------------------ */ -/* READ DIRECTORY FILES */ -/* ------------------------------------------------------------------------ */ -static boolean -include_path_p(path, name) - char *path, *name; -{ - char *n = name; - while (*path) - if (*path++ != *n++) - return (path[-1] == '/' && *n == '\0'); - return (*n == '/' || (n != name && path[-1] == '/' && n[-1] == '/')); -} - -/* ------------------------------------------------------------------------ */ -void -cleaning_files(v_filec, v_filev) - int *v_filec; - char ***v_filev; -{ - char *flags; - struct stat stbuf; - - register char **filev = *v_filev; - register int filec = *v_filec; - register char *p; - register int i, j; - - if (filec == 0) - return; - - flags = xmalloc(filec * sizeof(char)); - - /* flags & 0x01 : 1: ignore */ - /* flags & 0x02 : 1: directory, 0 : regular file */ - /* flags & 0x04 : 1: need delete */ - - - for (i = 0; i < filec; i++) - if (GETSTAT(filev[i], &stbuf) < 0) { - flags[i] = 0x04; - fprintf(stderr, - "LHa: Cannot access \"%s\", ignored.\n", filev[i]); - } - else { - if (is_regularfile(&stbuf)) - flags[i] = 0x00; - else if (is_directory(&stbuf)) - flags[i] = 0x02; -#ifdef S_IFLNK - else if (is_symlink(&stbuf)) /* t.okamoto */ - flags[i] = 0x00; -#endif - else { - flags[i] = 0x04; - fprintf(stderr, - "LHa: Cannot archive \"%s\", ignored.\n", filev[i]); - } - } - errno = 0; - - for (i = 0; i < filec; i++) { - p = filev[i]; - if ((flags[i] & 0x07) == 0x00) { /* regular file, not - * deleted/ignored */ - for (j = i + 1; j < filec; j++) { - if ((flags[j] & 0x07) == 0x00) { /* regular file, not - * deleted/ignored */ - if (STREQU(p, filev[j])) - flags[j] = 0x04; /* delete */ - } - } - } - else if ((flags[i] & 0x07) == 0x02) { /* directory, not - * deleted/ignored */ - for (j = i + 1; j < filec; j++) { - if ((flags[j] & 0x07) == 0x00) { /* regular file, not - * deleted/ignored */ - if (include_path_p(p, filev[j])) - flags[j] = 0x04; /* delete */ - } - else if ((flags[j] & 0x07) == 0x02) { /* directory, not - * deleted/ignored */ - if (include_path_p(p, filev[j])) - flags[j] = 0x04; /* delete */ - } - } - } - } - - for (i = j = 0; i < filec; i++) { - if ((flags[i] & 0x04) == 0) { - if (i != j) - filev[j] = filev[i]; - j++; - } - } - *v_filec = j; - - free(flags); -} - -/* ------------------------------------------------------------------------ */ -#ifdef NODIRECTORY -/* please need your imprementation */ -boolean -find_files(name, v_filec, v_filev) - char *name; - int *v_filec; - char ***v_filev; -{ - return FALSE; /* DUMMY */ -} - -/* ------------------------------------------------------------------------ */ -void -free_files(filec, filev) - int filec; - char **filev; -{ - /* do nothing */ -} -/* ------------------------------------------------------------------------ */ -#else -boolean -find_files(name, v_filec, v_filev) - char *name; - int *v_filec; - char ***v_filev; -{ - struct string_pool sp; - char newname[FILENAME_LENGTH]; - int len, n; - DIR *dirp; - DIRENTRY *dp; - struct stat tmp_stbuf, arc_stbuf, fil_stbuf; - - strcpy(newname, name); - len = strlen(name); - if (len > 0 && newname[len - 1] != '/') - newname[len++] = '/'; - - dirp = opendir(name); - if (!dirp) - return FALSE; - - init_sp(&sp); - - GETSTAT(temporary_name, &tmp_stbuf); - GETSTAT(archive_name, &arc_stbuf); - - for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) { - n = NAMLEN(dp); - strncpy(newname + len, dp->d_name, n); - newname[len + n] = '\0'; - if (GETSTAT(newname, &fil_stbuf) < 0) - continue; -#ifdef NO_INODE - if ( dp->d_name[0] != '.' || - (n != 1 && - (dp->d_name[1] != '.' || - n != 2)) ) { - add_sp(&sp, newname, len+n+1); - } -#else - if ((dp->d_ino != 0) && - /* exclude '.' and '..' */ - ((dp->d_name[0] != '.') || - ((n != 1) && - ((dp->d_name[1] != '.') || - (n != 2)))) && - ((tmp_stbuf.st_dev != fil_stbuf.st_dev || - tmp_stbuf.st_ino != fil_stbuf.st_ino) && - (arc_stbuf.st_dev != fil_stbuf.st_dev || - arc_stbuf.st_ino != fil_stbuf.st_ino))) { - add_sp(&sp, newname, len + n + 1); - } -#endif - } - closedir(dirp); - finish_sp(&sp, v_filec, v_filev); - if (*v_filec > 1) - qsort(*v_filev, *v_filec, sizeof(char *), sort_by_ascii); - cleaning_files(v_filec, v_filev); - - return TRUE; -} - -/* ------------------------------------------------------------------------ */ -void -free_files(filec, filev) - int filec; - char **filev; -{ - free_sp(filev); -} -#endif -/* ------------------------------------------------------------------------ */ -/* */ -/* ------------------------------------------------------------------------ */ -/* Build temporary file name and store to TEMPORARY_NAME */ -void -build_temporary_name() -{ -#ifdef TMP_FILENAME_TEMPLATE - /* "/tmp/lhXXXXXX" etc. */ - if (extract_directory == NULL) { - strcpy(temporary_name, TMP_FILENAME_TEMPLATE); - } - else { - sprintf(temporary_name, "%s/lhXXXXXX", extract_directory); - } -#ifdef MKSTEMP - mkstemp(temporary_name); -#else - mktemp(temporary_name); -#endif -#else - char *p, *s; - - strcpy(temporary_name, archive_name); - for (p = temporary_name, s = (char *) 0; *p; p++) - if (*p == '/') - s = p; - strcpy((s ? s + 1 : temporary_name), "lhXXXXXX"); -#ifdef MKSTEMP - mkstemp(temporary_name); -#else - mktemp(temporary_name); -#endif -#endif -} - -/* ------------------------------------------------------------------------ */ -static void -modify_filename_extention(buffer, ext) - char *buffer; - char *ext; -{ - register char *p, *dot; - - for (p = buffer, dot = (char *) 0; *p; p++) { - if (*p == '.') - dot = p; - else if (*p == '/') - dot = (char *) 0; - } - - if (dot) - p = dot; - - strcpy(p, ext); -} - -/* ------------------------------------------------------------------------ */ -/* build backup file name */ -void -build_backup_name(buffer, original) - char *buffer; - char *original; -{ - strcpy(buffer, original); - modify_filename_extention(buffer, BACKUPNAME_EXTENTION); /* ".bak" */ -} - -/* ------------------------------------------------------------------------ */ -void -build_standard_archive_name(buffer, orginal) - char *buffer; - char *orginal; -{ - strcpy(buffer, orginal); - modify_filename_extention(buffer, ARCHIVENAME_EXTENTION); /* ".lzh" */ -} - -/* ------------------------------------------------------------------------ */ -/* */ -/* ------------------------------------------------------------------------ */ -boolean -need_file(name) - char *name; -{ - int i; - - if (cmd_filec == 0) - return TRUE; - - for (i = 0; i < cmd_filec; i++) { - if (patmatch(cmd_filev[i], name, 0)) - return TRUE; - } - - return FALSE; -} - -FILE * -xfopen(name, mode) - char *name, *mode; -{ - FILE *fp; - - if ((fp = fopen(name, mode)) == NULL) - fatal_error(name); - - return fp; -} - -/* ------------------------------------------------------------------------ */ -/* */ -/* ------------------------------------------------------------------------ */ -static boolean -open_old_archive_1(name, v_fp) - char *name; - FILE **v_fp; -{ - FILE *fp; - struct stat stbuf; - - if (stat(name, &stbuf) >= 0 && - is_regularfile(&stbuf) && - (fp = fopen(name, READ_BINARY)) != NULL) { - *v_fp = fp; - archive_file_gid = stbuf.st_gid; - archive_file_mode = stbuf.st_mode; - return TRUE; - } - - *v_fp = NULL; - archive_file_gid = -1; - return FALSE; -} - -/* ------------------------------------------------------------------------ */ -FILE * -open_old_archive() -{ - FILE *fp; - char *p; - - if (!strcmp(archive_name, "-")) { - if (cmd == CMD_EXTRACT || cmd == CMD_LIST) - return stdin; - else - return NULL; - } - if (p = (char *) rindex(archive_name, '.')) { - if (strucmp(".LZH", p) == 0 - || strucmp(".LZS", p) == 0 - || strucmp(".COM", p) == 0 /* DOS SFX */ - || strucmp(".EXE", p) == 0 - || strucmp(".X", p) == 0 /* HUMAN SFX */ - || strucmp(".BAK", p) == 0) { /* for BackUp */ - open_old_archive_1(archive_name, &fp); - return fp; - } - } - - if (open_old_archive_1(archive_name, &fp)) - return fp; - sprintf(expanded_archive_name, "%s.lzh", archive_name); - if (open_old_archive_1(expanded_archive_name, &fp)) { - archive_name = expanded_archive_name; - return fp; - } - /* - * if ( (errno&0xffff)!=E_PNNF ) { archive_name = - * expanded_archive_name; return NULL; } - */ - sprintf(expanded_archive_name, "%s.lzs", archive_name); - if (open_old_archive_1(expanded_archive_name, &fp)) { - archive_name = expanded_archive_name; - return fp; - } - /* - * if ( (errno&0xffff)!=E_PNNF ) { archive_name = - * expanded_archive_name; return NULL; } - */ - /* - * sprintf( expanded_archive_name , "%s.lzh",archive_name); - * archive_name = expanded_archive_name; - */ - return NULL; -} - -/* ------------------------------------------------------------------------ */ -int -inquire(msg, name, selective) - char *msg, *name, *selective; -{ - char buffer[1024]; - char *p; - - for (;;) { - fprintf(stderr, "%s %s ", name, msg); - fflush(stderr); - - fgets(buffer, 1024, stdin); - - for (p = selective; *p; p++) - if (buffer[0] == *p) - return p - selective; - } - /* NOTREACHED */ -} - -/* ------------------------------------------------------------------------ */ -void -write_archive_tail(nafp) - FILE *nafp; -{ - putc(0x00, nafp); -} - -/* ------------------------------------------------------------------------ */ -void -copy_old_one(oafp, nafp, hdr) - FILE *oafp, *nafp; - LzHeader *hdr; -{ - if (noexec) { - fseek(oafp, (long) (hdr->header_size + 2) + hdr->packed_size, SEEK_CUR); - } - else { - reading_filename = archive_name; - writting_filename = temporary_name; - if (hdr->header_level != 2) { - copyfile(oafp, nafp, - (long) (hdr->header_size + 2) + hdr->packed_size, 0); - } else { - copyfile(oafp, nafp, - (long) (hdr->header_size) + hdr->packed_size, 0); - } - } -} - -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* compile-command:"gcc -c lharc.c" */ -/* End: */ diff -Nru lha-1.14i/debian/org/lhext.c lha-1.14i-acc20050924p1/debian/org/lhext.c --- lha-1.14i/debian/org/lhext.c 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/org/lhext.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,425 +0,0 @@ -/* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* lhext.c -- LHarc extract */ -/* */ -/* Copyright (C) MCMLXXXIX Yooichi.Tagawa */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 0.00 Original 1988.05.23 Y.Tagawa */ -/* Ver. 1.00 Fixed 1989.09.22 Y.Tagawa */ -/* Ver. 0.03 LHa for UNIX 1991.12.17 M.Oki */ -/* Ver. 1.12 LHa for UNIX 1993.10.01 N.Watazaki */ -/* Ver. 1.13b Symbolic Link Update Bug Fix 1994.06.21 N.Watazaki */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ -/* Ver. 1.14e bugfix 1999.04.30 T.Okamoto */ -/* ------------------------------------------------------------------------ */ -#include "lha.h" -/* ------------------------------------------------------------------------ */ -static int skip_flg = FALSE; /* FALSE..No Skip , TRUE..Skip */ -static char *methods[] = -{ - LZHUFF0_METHOD, LZHUFF1_METHOD, LZHUFF2_METHOD, LZHUFF3_METHOD, - LZHUFF4_METHOD, LZHUFF5_METHOD, LZHUFF6_METHOD, LZHUFF7_METHOD, - LARC_METHOD, LARC5_METHOD, LARC4_METHOD, - LZHDIRS_METHOD, - NULL -}; - -/* ------------------------------------------------------------------------ */ -static boolean -inquire_extract(name) - char *name; -{ - struct stat stbuf; - - skip_flg = FALSE; - if (stat(name, &stbuf) >= 0) { - if (!is_regularfile(&stbuf)) { - error("Already exist (not a file)", name); - return FALSE; - } - - if (noexec) { - printf("EXTRACT %s but file is exist.\n", name); - return FALSE; - } - else if (!force) { - if (!isatty(0)) - return FALSE; - - switch (inquire("OverWrite ?(Yes/[No]/All/Skip)", name, "YyNnAaSs\n")) { - case 0: - case 1:/* Y/y */ - break; - case 2: - case 3:/* N/n */ - case 8:/* Return */ - return FALSE; - case 4: - case 5:/* A/a */ - force = TRUE; - break; - case 6: - case 7:/* S/s */ - skip_flg = TRUE; - break; - } - } - } - if (noexec) - printf("EXTRACT %s\n", name); - - return TRUE; -} - -/* ------------------------------------------------------------------------ */ -static boolean -make_parent_path(name) - char *name; -{ - char path[FILENAME_LENGTH]; - struct stat stbuf; - register char *p; - - /* make parent directory name into PATH for recursive call */ - strcpy(path, name); - for (p = path + strlen(path); p > path; p--) - if (p[-1] == '/') { - *--p = '\0'; - break; - } - - if (p == path) { - message("Why?", "ROOT"); - return FALSE; /* no more parent. */ - } - - if (GETSTAT(path, &stbuf) >= 0) { - if (is_directory(&stbuf)) - return TRUE; - error("Not a directory", path); - return FALSE; - } - errno = 0; - - if (verbose) - printf("Making directory \"%s\".\n", path); - - if (mkdir(path, 0777) >= 0) /* try */ - return TRUE; /* successful done. */ - errno = 0; - - if (!make_parent_path(path)) - return FALSE; - - if (mkdir(path, 0777) < 0) { /* try again */ - message("Cannot make directory", path); - return FALSE; - } - - return TRUE; -} - -/* ------------------------------------------------------------------------ */ -static FILE * -open_with_make_path(name) - char *name; -{ - FILE *fp; - - if ((fp = fopen(name, WRITE_BINARY)) == NULL) { - errno = 0; - if (!make_parent_path(name) || - (fp = fopen(name, WRITE_BINARY)) == NULL) - error("Cannot extract", name); - errno = 0; - } - return fp; -} - -/* ------------------------------------------------------------------------ */ -static void -adjust_info(name, hdr) - char *name; - LzHeader *hdr; -{ - time_t utimebuf[2]; - - /* adjust file stamp */ - utimebuf[0] = utimebuf[1] = hdr->unix_last_modified_stamp; - - 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. -#else - if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) != UNIX_FILE_SYMLINK) - chmod(name, hdr->unix_mode); -#endif - if (!getuid()) { -#ifndef HAVE_NO_LCHOWN - if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK) - lchown(name, hdr->unix_uid, hdr->unix_gid); - else -#endif /* HAVE_NO_LCHWON */ - chown(name, hdr->unix_uid, hdr->unix_gid); - } - errno = 0; - } -} - -/* ------------------------------------------------------------------------ */ -static void -extract_one(afp, hdr) - FILE *afp; /* archive file */ - LzHeader *hdr; -{ - FILE *fp; /* output file */ - struct stat stbuf; - char name[257]; - int crc; - int method; - boolean save_quiet, save_verbose, up_flag; - char *q = hdr->name, c; - - if (ignore_directory && rindex(hdr->name, '/')) { - q = (char *) rindex(hdr->name, '/') + 1; - } - else { - if (*q == '/') { - q++; - /* - * if OSK then strip device name - */ - if (hdr->extend_type == EXTEND_OS68K - || hdr->extend_type == EXTEND_XOSK) { - do - c = (*q++); - while (c && c != '/'); - if (!c || !*q) - q = "."; /* if device name only */ - } - } - } - - if (extract_directory) - sprintf(name, "%s/%s", extract_directory, q); - else - strcpy(name, q); - - - /* LZHDIRS_METHODを持つヘッダをチェックする */ - /* 1999.4.30 t.okamoto */ - for (method = 0;; method++) { - if (methods[method] == NULL) { - error("Unknown method skiped ...", name); - return; - } - if (bcmp(hdr->method, methods[method], 5) == 0) - break; - } - - if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_REGULAR - && method != LZHDIRS_METHOD_NUM) { -#if 0 - for (method = 0;; method++) { - if (methods[method] == NULL) { - error("Unknown method skiped ...", name); - return; - } - if (bcmp(hdr->method, methods[method], 5) == 0) - break; - } -#endif - - reading_filename = archive_name; - writting_filename = name; - if (output_to_stdout || verify_mode) { - if (noexec) { - printf("%s %s\n", verify_mode ? "VERIFY" : "EXTRACT", name); - if (afp == stdin) { - int i = hdr->packed_size; - while (i--) - fgetc(afp); - } - return; - } - - save_quiet = quiet; - save_verbose = verbose; - if (!quiet && output_to_stdout) { - printf("::::::::\n%s\n::::::::\n", name); - quiet = TRUE; - verbose = FALSE; - } - else if (verify_mode) { - quiet = FALSE; - verbose = TRUE; - } - - crc = decode_lzhuf - (afp, stdout, hdr->original_size, hdr->packed_size, name, method); - quiet = save_quiet; - verbose = save_verbose; - } - else { - if (skip_flg == FALSE) { - up_flag = inquire_extract(name); - if (up_flag == FALSE && force == FALSE) { - return; - } - } - - if (skip_flg == TRUE) { /* if skip_flg */ - if (stat(name, &stbuf) == 0 && force != TRUE) { - if (stbuf.st_mtime >= hdr->unix_last_modified_stamp) { - if (quiet != TRUE) - printf("%s : Skipped...\n", name); - return; - } - } - } - if (noexec) { - if (afp == stdin) { - int i = hdr->packed_size; - while (i--) - fgetc(afp); - } - return; - } - - signal(SIGINT, interrupt); - signal(SIGHUP, interrupt); - - unlink(name); - errno = 0; - remove_extracting_file_when_interrupt = TRUE; - - if ((fp = open_with_make_path(name)) != NULL) { - crc = decode_lzhuf - (afp, fp, hdr->original_size, hdr->packed_size, name, method); - fclose(fp); - } - remove_extracting_file_when_interrupt = FALSE; - signal(SIGINT, SIG_DFL); - signal(SIGHUP, SIG_DFL); - - if (!fp) - return; - } - - errno = 0; - if (hdr->has_crc && crc != hdr->crc) - error("CRC error", name); - } - else if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_DIRECTORY - || (hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK - || method == LZHDIRS_METHOD_NUM) { - /* ↑これで、Symblic Link は、大丈夫か? */ - if (!ignore_directory && !verify_mode) { - if (noexec) { - if (quiet != TRUE) - printf("EXTRACT %s (directory)\n", name); - return; - } - /* NAME has trailing SLASH '/', (^_^) */ - if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK) { - char buf[256], *bb1, *bb2; - int l_code; - strcpy(buf, name); - bb1 = strtok(buf, "|"); - bb2 = strtok(NULL, "|"); - -#ifdef S_IFLNK - if (skip_flg == FALSE) { - up_flag = inquire_extract(name); - if (up_flag == FALSE && force == FALSE) { - return; - } - } else { - if (GETSTAT(bb1, &stbuf) == 0 && force != TRUE) { - if (stbuf.st_mtime >= hdr->unix_last_modified_stamp) { - if (quiet != TRUE) - printf("%s : Skipped...\n", bb1); - return; - } - } - } - - unlink(bb1); - l_code = symlink(bb2, bb1); - if (l_code < 0) { - if (quiet != TRUE) - warning("Can't make Symbolic Link : "); - } - if (quiet != TRUE) { - printf("Symbolic Link %s -> %s\n", bb1, bb2); - } - strcpy(name, bb1); /* Symbolic's name set */ -#else - sprintf(buf, "%s -> %s", bb1, bb2); - warning("Can't make Symbolic Link", buf); - return; -#endif - } else { /* make directory */ - if (!output_to_stdout && !make_parent_path(name)) - return; - } - } - } - else { - error("Unknown information", name); - } - - if (!output_to_stdout) - adjust_info(name, hdr); -} - -/* ------------------------------------------------------------------------ */ -/* EXTRACT COMMAND MAIN */ -/* ------------------------------------------------------------------------ */ -void -cmd_extract() -{ - LzHeader hdr; - long pos; - FILE *afp; - - /* open archive file */ - if ((afp = open_old_archive()) == NULL) - fatal_error(archive_name); - - if (archive_is_msdos_sfx1(archive_name)) - skip_msdos_sfx1_code(afp); - - /* extract each files */ - while (get_header(afp, &hdr)) { - if (need_file(hdr.name)) { - pos = ftell(afp); - extract_one(afp, &hdr); - fseek(afp, pos + hdr.packed_size, SEEK_SET); - } else { - if (afp != stdin) - fseek(afp, hdr.packed_size, SEEK_CUR); - else { - int i = hdr.packed_size; - while (i--) - fgetc(afp); - } - } - } - - /* close archive file */ - fclose(afp); - - return; -} - -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* End: */ diff -Nru lha-1.14i/debian/org/lhlist.c lha-1.14i-acc20050924p1/debian/org/lhlist.c --- lha-1.14i/debian/org/lhlist.c 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/org/lhlist.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,348 +0,0 @@ -/* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* lhlist.c -- LHarc list */ -/* */ -/* Copyright (C) MCMLXXXIX Yooichi.Tagawa */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 0.00 Original 1988.05.23 Y.Tagawa */ -/* Ver. 1.00 Fixed 1989.09.22 Y.Tagawa */ -/* Ver. 1.01 Bug Fix for month name 1989.12.25 Y.Tagawa */ -/* Ver. 1.10 Changed list format 1993.10.01 N.Watazaki */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ -/* Ver. 1.14e Bug Fix for many problems 1999.05.25 T.Okamoto */ -/* ------------------------------------------------------------------------ */ -#include "lha.h" - -/* ------------------------------------------------------------------------ */ -static long packed_size_total; -static long original_size_total; -static int list_files; - -/* ------------------------------------------------------------------------ */ -/* Print Stuff */ -/* ------------------------------------------------------------------------ */ -/* need 14 or 22 (when verbose_listing is TRUE) column spaces */ -static void -print_size(packed_size, original_size) - long packed_size, original_size; -{ - if (verbose_listing) - printf("%7d ", packed_size); - - printf("%7d ", original_size); - - if (original_size == 0L) - printf("******"); - else /* Changed N.Watazaki */ - printf("%5.1f%%", packed_size * 100.0 / original_size); -} - -/* ------------------------------------------------------------------------ */ -/* need 12 or 17 (when verbose_listing is TRUE) column spaces */ -static void -print_stamp(t) - time_t t; -{ - static boolean got_now = FALSE; - static time_t now; - static unsigned int threshold; - static char t_month[12 * 3 + 1] = "JanFebMarAprMayJunJulAugSepOctNovDec"; - struct tm *p; - - if (t == 0) { - printf(" "); /* 12 spaces */ - return; - } - - if (!got_now) { - now = time((time_t *) 0); - p = localtime(&now); - threshold = p->tm_year * 12 + p->tm_mon - 6; - got_now = TRUE; - } - - p = localtime(&t); - - if (p->tm_year * 12 + p->tm_mon > threshold) - printf("%.3s %2d %02d:%02d", - &t_month[p->tm_mon * 3], p->tm_mday, p->tm_hour, p->tm_min); - else - printf("%.3s %2d %04d", - &t_month[p->tm_mon * 3], p->tm_mday, p->tm_year + 1900); -} - -/* ------------------------------------------------------------------------ */ -static void -print_bar() -{ - char *p, *q; - /* 17+1+(0 or 7+1)+7+1+6+1+(0 or 1+4)+(12 or 17)+1+20 */ - /* 12345678901234567_ 1234567_123456 _123456789012 1234 */ - - if (verbose_listing) { - p = "- ------ ---------- "; - q = " -------------"; - } - else { - p = " "; - q = " --------------------"; - } - - if (verbose) - q = ""; - - printf("---------- ----------- ------- ------%s------------%s\n", p, q); -} - -/* ------------------------------------------------------------------------ */ -/* */ -/* ------------------------------------------------------------------------ */ -static void -list_header() -{ - char *p, *q; - - if (verbose_listing) { - p = "PACKED SIZE RATIO METHOD CRC"; - q = " NAME"; - } - else { - p = " SIZE RATIO"; - q = " NAME"; - } - - if (verbose) - q = ""; - - printf(" PERMSSN UID GID %s STAMP%s\n", p, q); -#if 0 - printf(" PERMSSN UID GID %s SIZE RATIO%s %s STAMP%s%s\n", - verbose_listing ? " PACKED " : "", /* 8,0 */ - verbose_listing ? " CRC" : "", /* 5,0 */ - verbose_listing ? " " : "", /* 2,0 */ - verbose_listing ? " " : " ", /* 6,3 */ - verbose ? "" : " NAME"); -#endif - print_bar(); -} - -/* ------------------------------------------------------------------------ */ -static void -list_one(hdr) - register LzHeader *hdr; -{ - register int mode; - register char *p; - char method[6]; - char modebits[11]; - - if (verbose) - printf("%s\n", hdr->name); - - strncpy(method, hdr->method, 5); - method[5] = '\0'; - - switch (mode = hdr->extend_type) { - case EXTEND_UNIX: - mode = hdr->unix_mode; - - if (mode & UNIX_FILE_DIRECTORY) - modebits[0] = 'd'; - else if ((mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK) - modebits[0] = 'l'; - else - modebits[0] = '-'; - modebits[1] = ((mode & UNIX_OWNER_READ_PERM) ? 'r' : '-'); - modebits[2] = ((mode & UNIX_OWNER_WRITE_PERM) ? 'w' : '-'); - modebits[3] = (mode & UNIX_SETUID) ? 's' : - ((mode & UNIX_OWNER_EXEC_PERM) ? 'x' : '-'); - modebits[4] = ((mode & UNIX_GROUP_READ_PERM) ? 'r' : '-'); - modebits[5] = ((mode & UNIX_GROUP_WRITE_PERM) ? 'w' : '-'); - modebits[6] = (mode & UNIX_SETGID) ? 's' : - ((mode & UNIX_GROUP_EXEC_PERM) ? 'x' : '-'); - modebits[7] = ((mode & UNIX_OTHER_READ_PERM) ? 'r' : '-'); - modebits[8] = ((mode & UNIX_OTHER_WRITE_PERM) ? 'w' : '-'); - modebits[9] = (mode & UNIX_STYCKYBIT) ? 't' : - ((mode & UNIX_OTHER_EXEC_PERM) ? 'x' : '-'); - modebits[10] = 0; - - printf("%s %5d/%-5d ", modebits, - hdr->unix_uid, hdr->unix_gid); - break; - case EXTEND_OS68K: - /**/ case EXTEND_XOSK:/**/ - mode = hdr->unix_mode; - printf("%c%c%c%c%c%c%c%c %5d/%-5d", - ((mode & OSK_DIRECTORY_PERM) ? 'd' : '-'), - ((mode & OSK_SHARED_PERM) ? 's' : '-'), - ((mode & OSK_OTHER_EXEC_PERM) ? 'e' : '-'), - ((mode & OSK_OTHER_WRITE_PERM) ? 'w' : '-'), - ((mode & OSK_OTHER_READ_PERM) ? 'r' : '-'), - ((mode & OSK_OWNER_EXEC_PERM) ? 'e' : '-'), - ((mode & OSK_OWNER_WRITE_PERM) ? 'w' : '-'), - ((mode & OSK_OWNER_READ_PERM) ? 'r' : '-'), - hdr->unix_uid, hdr->unix_gid); - break; - default: - switch (hdr->extend_type) { /* max 18 characters */ - case EXTEND_GENERIC: - p = "[generic]"; - break; - case EXTEND_CPM: - p = "[CP/M]"; - break; - case EXTEND_FLEX: - p = "[FLEX]"; - break; - case EXTEND_OS9: - p = "[OS-9]"; - break; - case EXTEND_OS68K: - p = "[OS-9/68K]"; - break; - case EXTEND_MSDOS: - p = "[MS-DOS]"; - break; - case EXTEND_MACOS: - p = "[Mac OS]"; - break; - case EXTEND_OS2: - p = "[OS/2]"; - break; - case EXTEND_HUMAN: - p = "[Human68K]"; - break; - case EXTEND_OS386: - p = "[OS-386]"; - break; - case EXTEND_RUNSER: - p = "[Runser]"; - break; -#ifdef EXTEND_TOWNSOS - /* This ID isn't fixed */ - case EXTEND_TOWNSOS: - p = "[TownsOS]"; - break; -#endif - /* Ouch! Please customize it's ID. */ - default: - p = "[unknown]"; - break; - } - printf("%-23.23s", p); - break; - } - - print_size(hdr->packed_size, hdr->original_size); - - if (verbose_listing) - if (hdr->has_crc) - printf(" %s %04x", method, hdr->crc); - else - printf(" %s ****", method); - - printf(" "); - print_stamp(hdr->unix_last_modified_stamp); - - if (!verbose) - if ((mode & UNIX_FILE_SYMLINK) != UNIX_FILE_SYMLINK) - printf(" %s", hdr->name); - else { - char buf[256], *b1, *b2; - strcpy(buf, hdr->name); - b1 = strtok(buf, "|"); - b2 = strtok(NULL, "|"); - printf(" %s -> %s", b1, b2); - } - - if (verbose) - printf(" [%d]", hdr->header_level); - printf("\n"); - -} - -/* ------------------------------------------------------------------------ */ -static void -list_tailer() -{ - struct stat stbuf; - - print_bar(); - - printf(" Total %9d file%c ", - list_files, (list_files == 1) ? ' ' : 's'); - print_size(packed_size_total, original_size_total); - printf(" "); - - if (verbose_listing) - printf(" "); - - if (stat(archive_name, &stbuf) < 0) - print_stamp((time_t) 0); - else - print_stamp(stbuf.st_mtime); - - printf("\n"); -} - -/* ------------------------------------------------------------------------ */ -/* LIST COMMAND MAIN */ -/* ------------------------------------------------------------------------ */ -void -cmd_list() -{ - FILE *afp; - LzHeader hdr; - int i; - - /* initialize total count */ - packed_size_total = 0L; - original_size_total = 0L; - list_files = 0; - - /* open archive file */ - if ((afp = open_old_archive()) == NULL) { - error(archive_name, ""); - exit(1); - } - if (archive_is_msdos_sfx1(archive_name)) - skip_msdos_sfx1_code(afp); - - /* print header message */ - if (!quiet) - list_header(); - - /* print each file information */ - while (get_header(afp, &hdr)) { - if (need_file(hdr.name)) { - list_one(&hdr); - list_files++; - packed_size_total += hdr.packed_size; - original_size_total += hdr.original_size; - } - - if (afp != stdin) - fseek(afp, hdr.packed_size, SEEK_CUR); - else { - i = hdr.packed_size; - while (i--) - fgetc(afp); - } - } - - /* close archive file */ - fclose(afp); - - /* print tailer message */ - if (!quiet) - list_tailer(); - - return; -} - -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* compile-command:"gcc -c lhlist.c" */ -/* End: */ diff -Nru lha-1.14i/debian/org/util.c lha-1.14i-acc20050924p1/debian/org/util.c --- lha-1.14i/debian/org/util.c 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/org/util.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,375 +0,0 @@ -/* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* util.c -- LHarc Util */ -/* */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ -/* Ver. 1.14e Support for sfx archives 1999.05.28 T.Okamoto */ -/* ------------------------------------------------------------------------ */ -#include "lha.h" -/* - * util.c - part of LHa for UNIX Feb 26 1992 modified by Masaru Oki Mar 4 - * 1992 modified by Masaru Oki #ifndef USESTRCASECMP added. Mar 31 1992 - * modified by Masaru Oki #ifdef NOMEMSET added. - */ -#include - -/* ------------------------------------------------------------------------ */ -extern unsigned short crc; -extern int quiet; -/* ------------------------------------------------------------------------ */ -long -copyfile(f1, f2, size, crc_flg) /* return: size of source file */ - FILE *f1; - FILE *f2; - long size; - int crc_flg;/* 0: no crc, 1: crc check, 2: extract, 3: - * append */ -{ - unsigned short xsize; - char *buf; - long rsize = 0; - - if ((buf = (char *) malloc(BUFFERSIZE)) == NULL) - fatal_error("virtual memory exhausted.\n"); - crc = 0; - if ((crc_flg == 2 || crc_flg) && text_mode) - init_code_cache(); - while (size > 0) { - /* read */ - if (crc_flg == 3 && text_mode) { - xsize = fread_txt(buf, BUFFERSIZE, f1); - if (xsize == 0) - break; - if (ferror(f1)) { - fatal_error("file read error\n"); - } - } - else { - xsize = (size > BUFFERSIZE) ? BUFFERSIZE : size; - if (fread(buf, 1, xsize, f1) != xsize) { - fatal_error("file read error\n"); - } - } - /* write */ - if (f2) { - if (crc_flg == 2 && text_mode) { - if (fwrite_txt(buf, xsize, f2)) { - fatal_error("file write error\n"); - } - } - else { - if (fwrite(buf, 1, xsize, f2) != xsize) { - fatal_error("file write error\n"); - } - } - } - /* calculate crc */ - if (crc_flg) { - calccrc(buf, xsize); - } - rsize += xsize; - if (crc_flg != 3 || !text_mode) - size -= xsize; - } - free(buf); - return rsize; -} - -/* ------------------------------------------------------------------------ */ -int -encode_stored_crc(ifp, ofp, size, original_size_var, write_size_var) - FILE *ifp, *ofp; - long size; - long *original_size_var; - long *write_size_var; -{ - int save_quiet; - - save_quiet = quiet; - quiet = 1; - size = copyfile(ifp, ofp, size, 3); - *original_size_var = *write_size_var = size; - quiet = save_quiet; - return crc; -} - -/* ------------------------------------------------------------------------ */ -/* convert path delimit - erreturns *filename */ -/* ------------------------------------------------------------------------ */ -unsigned char * -convdelim(path, delim) - unsigned char *path; - unsigned char delim; -{ - unsigned char c; - unsigned char *p; -#ifdef MULTIBYTE_CHAR - int kflg; - - kflg = 0; -#endif - for (p = path; (c = *p) != 0; p++) { -#ifdef MULTIBYTE_CHAR - if (kflg) { - kflg = 0; - } - else if (MULTIBYTE_FIRST_P(c)) { - kflg = 1; - } - else -#endif - if (c == '\\' || c == DELIM || c == DELIM2) { - *p = delim; - path = p + 1; - } - } - return path; -} - -/* ------------------------------------------------------------------------ */ -/* If TRUE, archive file name is msdos SFX file name. */ -boolean -archive_is_msdos_sfx1(name) - char *name; -{ - int len = strlen(name); - - return ((len >= 4) && - (strucmp(".COM", name + len - 4) == 0 || - strucmp(".EXE", name + len - 4) == 0)) || - ((len >= 2) && - (strucmp(".x", name + len - 2) == 0)); -} - -/* ------------------------------------------------------------------------ */ -/* skip SFX header */ -boolean -skip_msdos_sfx1_code(fp) - FILE *fp; -{ - unsigned char buffer[MAXSFXCODE]; - unsigned char *p, *q; - int n; - - n = fread(buffer, sizeof(char), MAXSFXCODE, fp); - - for (p = buffer + 2, q = buffer + n - /* 5 */ (I_HEADER_LEVEL+1)-2; p < q; p++) { - /* found "-l??-" keyword (as METHOD type string) */ - if (p[0] == '-' && p[1] == 'l' && p[4] == '-') { - /* size and checksum validate check */ - if ( (p[I_HEADER_LEVEL-2] == 0 || p[I_HEADER_LEVEL-2] == 0) - && p[I_HEADER_SIZE-2] > 20 - && p[I_HEADER_CHECKSUM-2] == calc_sum(p, p[-2])) { - fseek(fp, ((p - 2) - buffer) - n, SEEK_CUR); - return TRUE; - } else if (p[I_HEADER_LEVEL-2] == 2 && p[I_HEADER_SIZE-2] >= 24 - && p[I_ATTRIBUTE-2] == 0x20) { - fseek(fp, ((p - 2) - buffer) - n, SEEK_CUR); - return TRUE; - } - } - } - - fseek(fp, -n, SEEK_CUR); - return FALSE; -} - -/* - * strdup(3) - */ - -/* ------------------------------------------------------------------------ */ -#ifdef NOSTRDUP -char * -strdup(buf) - char *buf; -{ - char *p; - - if ((p = (char *) malloc(strlen(buf) + 1)) == NULL) - return NULL; - strcpy(p, buf); - return p; -} -#endif - -/* - * memmove( char *dst , char *src , size_t cnt ) - */ - -/* ------------------------------------------------------------------------ */ -#if defined(NOBSTRING) && !defined(__STDC__) -void * -memmove(dst, src, cnt) - register char *dst, *src; - register int cnt; -{ - if (dst == src) - return dst; - if (src > dst) { - while (--cnt >= 0) - *dst++ = *src++; - } - else { - dst += cnt; - src += cnt; - while (--cnt >= 0) - *--dst = *--src; - } - return dst; -} -#endif - -/* - * rename - change the name of file 91.11.02 by Tomohiro Ishikawa - * (ishikawa@gaia.cow.melco.CO.JP) 92.01.20 little modified (added #ifdef) by - * Masaru Oki 92.01.28 added mkdir() and rmdir() by Tomohiro Ishikawa - */ - -#if defined(NOFTRUNCATE) && !defined(_MINIX) - -/* ------------------------------------------------------------------------ */ -int -rename(from, to) - char *from, *to; -{ - struct stat s1, s2; - extern int errno; - - if (stat(from, &s1) < 0) - return (-1); - /* is 'FROM' file a directory? */ - if ((s1.st_mode & S_IFMT) == S_IFDIR) { - errno = ENOTDIR; - return (-1); - } - if (stat(to, &s2) >= 0) { /* 'TO' exists! */ - /* is 'TO' file a directory? */ - if ((s2.st_mode & S_IFMT) == S_IFDIR) { - errno = EISDIR; - return (-1); - } - if (unlink(to) < 0) - return (-1); - } - if (link(from, to) < 0) - return (-1); - if (unlink(from) < 0) - return (-1); - return (0); -} -#endif /* NOFTRUNCATE */ -/* ------------------------------------------------------------------------ */ - -#ifdef NOMKDIR -#ifndef MKDIRPATH -#define MKDIRPATH "/bin/mkdir" -#endif -#ifndef RMDIRPATH -#define RMDIRPATH "/bin/rmdir" -#endif -int -rmdir(path) - char *path; -{ - int stat, rtn = 0; - char *cmdname; - if ((cmdname = (char *) malloc(strlen(RMDIRPATH) + 1 + strlen(path) + 1)) - == 0) - return (-1); - strcpy(cmdname, RMDIRPATH); - *(cmdname + strlen(RMDIRPATH)) = ' '; - strcpy(cmdname + strlen(RMDIRPATH) + 1, path); - if ((stat = system(cmdname)) < 0) - rtn = -1; /* fork or exec error */ - else if (stat) { /* RMDIR command error */ - errno = EIO; - rtn = -1; - } - free(cmdname); - return (rtn); -} - -/* ------------------------------------------------------------------------ */ -int -mkdir(path, mode) - char *path; - int mode; -{ - int child, stat; - char *cmdname, *cmdpath = MKDIRPATH; - if ((cmdname = (char *) strrchr(cmdpath, '/')) == (char *) 0) - cmdname = cmdpath; - if ((child = fork()) < 0) - return (-1); /* fork error */ - else if (child) { /* parent process */ - while (child != wait(&stat)) /* ignore signals */ - continue; - } - else { /* child process */ - int maskvalue; - maskvalue = umask(0); /* get current umask() value */ - umask(maskvalue | (0777 & ~mode)); /* set it! */ - execl(cmdpath, cmdname, path, (char *) 0); - /* never come here except execl is error */ - return (-1); - } - if (stat != 0) { - errno = EIO; /* cannot get error num. */ - return (-1); - } - return (0); -} -#endif - -/* - * strucmp modified: Oct 29 1991 by Masaru Oki - */ - -#ifndef USESTRCASECMP -static int -my_toupper(n) - register int n; -{ - if (n >= 'a' && n <= 'z') - return n & (~('a' - 'A')); - return n; -} - -/* ------------------------------------------------------------------------ */ -int -strucmp(s, t) - register char *s, *t; -{ - while (my_toupper(*s++) == my_toupper(*t++)) - if (!*s || !*t) - break; - if (!*s && !*t) - return 0; - return 1; -} -#endif - -/* ------------------------------------------------------------------------ */ -#ifdef NOMEMSET -/* Public Domain memset(3) */ -char * -memset(s, c, n) - char *s; - int c, n; -{ - char *p = s; - while (n--) - *p++ = (char) c; - return s; -} -#endif - -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* compile-command:"gcc -c util.c" */ -/* End: */ diff -Nru lha-1.14i/debian/patch.CAN-2004-0234_0235 lha-1.14i-acc20050924p1/debian/patch.CAN-2004-0234_0235 --- lha-1.14i/debian/patch.CAN-2004-0234_0235 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/patch.CAN-2004-0234_0235 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ ---- src/header.c.old 2000-10-05 19:36:03.000000000 +0200 -+++ src/header.c 2004-04-17 23:55:54.000000000 +0200 -@@ -538,6 +538,10 @@ - /* - * filename - */ -+ if (header_size >= 256) { -+ fprintf(stderr, "Possible buffer overflow hack attack, type #1\n"); -+ exit(109); -+ } - for (i = 0; i < header_size - 3; i++) - hdr->name[i] = (char) get_byte(); - hdr->name[header_size - 3] = '\0'; -@@ -547,6 +551,10 @@ - /* - * directory - */ -+ if (header_size >= FILENAME_LENGTH) { -+ fprintf(stderr, "Possible buffer overflow hack attack, type #2\n"); -+ exit(110); -+ } - for (i = 0; i < header_size - 3; i++) - dirname[i] = (char) get_byte(); - dirname[header_size - 3] = '\0'; ---- src/lhext.c.old 2000-10-04 16:57:38.000000000 +0200 -+++ src/lhext.c 2004-04-18 01:27:44.000000000 +0200 -@@ -190,8 +190,13 @@ - q = (char *) rindex(hdr->name, '/') + 1; - } - else { -+ if (is_directory_traversal(q)) { -+ fprintf(stderr, "Possible directory traversal hack attempt in %s\n", q); -+ exit(111); -+ } -+ - if (*q == '/') { -- q++; -+ while (*q == '/') { q++; } - /* - * if OSK then strip device name - */ -@@ -419,6 +424,33 @@ - return; - } - -+int -+is_directory_traversal(char *string) -+{ -+ unsigned int type = 0; /* 0 = new, 1 = only dots, 2 = other chars than dots */ -+ char *temp; -+ -+ temp = string; -+ -+ while (*temp != 0) { -+ if (temp[0] == '/') { -+ if (type == 1) { return 1; } -+ type = 0; -+ temp++; -+ continue; -+ } -+ -+ if ((temp[0] == '.') && (type < 2)) -+ type = 1; -+ if (temp[0] != '.') -+ type = 2; -+ -+ temp++; -+ } /* while */ -+ -+ return (type == 1); -+} -+ - /* Local Variables: */ - /* mode:c */ - /* tab-width:4 */ ---- src/lhext.c.symlink 2000-10-04 10:57:38.000000000 -0400 -+++ src/lhext.c 2003-05-19 22:55:57.000000000 -0400 -@@ -351,6 +351,7 @@ extract_one(afp, hdr) - } - - unlink(bb1); -+ make_parent_path(bb1); - l_code = symlink(bb2, bb1); - if (l_code < 0) { - if (quiet != TRUE) diff -Nru lha-1.14i/debian/patch.CVE-2006-4335-CVE-2006-4337-CVE-2006-4338 lha-1.14i-acc20050924p1/debian/patch.CVE-2006-4335-CVE-2006-4337-CVE-2006-4338 --- lha-1.14i/debian/patch.CVE-2006-4335-CVE-2006-4337-CVE-2006-4338 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/patch.CVE-2006-4335-CVE-2006-4337-CVE-2006-4338 1970-01-01 00:00:00.000000000 +0000 @@ -1,137 +0,0 @@ -diff -aur lha-1.14i.orig/src/huf.c lha-1.14i/src/huf.c ---- lha-1.14i.orig/src/huf.c 2000-10-05 19:35:49.000000000 +0200 -+++ lha-1.14i/src/huf.c 2006-12-11 10:07:31.000000000 +0100 -@@ -332,7 +332,7 @@ - } - else { - i = 0; -- while (i < n) { -+ while (i < MIN(n, NPT)) { - c = bitbuf >> (16 - 3); - if (c == 7) { - unsigned short mask = 1 << (16 - 4); -@@ -345,7 +345,7 @@ - pt_len[i++] = c; - if (i == i_special) { - c = getbits(2); -- while (--c >= 0) -+ while (--c >= 0 && i < NPT) - pt_len[i++] = 0; - } - } -@@ -370,7 +370,7 @@ - c_table[i] = c; - } else { - i = 0; -- while (i < n) { -+ while (i < MIN(n,NC)) { - c = pt_table[bitbuf >> (16 - 8)]; - if (c >= NT) { - unsigned short mask = 1 << (16 - 9); -@@ -380,7 +380,7 @@ - else - c = left[c]; - mask >>= 1; -- } while (c >= NT); -+ } while (c >= NT && (mask || c != left[c])); /* CVE-2006-4338 */ - } - fillbuf(pt_len[c]); - if (c <= 2) { -@@ -427,7 +427,7 @@ - else - j = left[j]; - mask >>= 1; -- } while (j >= NC); -+ } while (j >= NC && (mask || j != left[j])); /* CVE-2006-4338 */ - fillbuf(c_len[j] - 12); - } - return j; -@@ -451,7 +451,7 @@ - else - j = left[j]; - mask >>= 1; -- } while (j >= np); -+ } while (j >= np && (mask || j != left[j])); /* CVE-2006-4338 */ - fillbuf(pt_len[j] - 8); - } - if (j != 0) -Only in lha-1.14i/src: huf.c~ -diff -aur lha-1.14i.orig/src/lha_macro.h lha-1.14i/src/lha_macro.h ---- lha-1.14i.orig/src/lha_macro.h 2006-12-11 09:43:54.000000000 +0100 -+++ lha-1.14i/src/lha_macro.h 2006-12-11 09:55:42.000000000 +0100 -@@ -408,6 +408,8 @@ - #define MAXMATCH 256 /* formerly F (not more than UCHAR_MAX + 1) */ - #define THRESHOLD 3 /* choose optimal value */ - -+#define MIN(a,b) ((a) <= (b) ? (a) : (b)) -+ - /* from huf.c */ - - /* alphabet = {0, 1, 2, ..., NC - 1} */ -Only in lha-1.14i/src: lha_macro.h~ -diff -aur lha-1.14i.orig/src/maketbl.c lha-1.14i/src/maketbl.c ---- lha-1.14i.orig/src/maketbl.c 2000-10-04 16:57:38.000000000 +0200 -+++ lha-1.14i/src/maketbl.c 2006-12-11 09:59:51.000000000 +0100 -@@ -32,8 +32,15 @@ - } - - /* count */ -- for (i = 0; i < nchar; i++) -- count[bitlen[i]]++; -+ for (i = 0; i < nchar; i++) { -+ if (bitlen[i] > 16) { -+ /* CVE-2006-4335 */ -+ error("Bad table (case a)"); -+ exit(1); -+ } -+ else -+ count[bitlen[i]]++; -+ } - - /* calculate first code */ - total = 0; -@@ -41,8 +48,11 @@ - start[i] = total; - total += weight[i] * count[i]; - } -- if ((total & 0xffff) != 0) -- error("make_table()", "Bad table (5)\n"); -+ -+ if ((total & 0xffff) != 0 || tablebits > 16) { /* 16 for weight below */ -+ error("make_table(): Bad table (case b)"); -+ exit(1); -+ } - - /* shift data for make table. */ - m = 16 - tablebits; -@@ -53,7 +63,7 @@ - - /* initialize */ - j = start[tablebits + 1] >> m; -- k = 1 << tablebits; -+ k = MIN(1 << tablebits, 4096); - if (j != 0) - for (i = j; i < k; i++) - table[i] = 0; -@@ -66,12 +76,19 @@ - l = start[k] + weight[k]; - if (k <= tablebits) { - /* code in table */ -+ l = MIN(l, 4096); - for (i = start[k]; i < l; i++) - table[i] = j; - } - else { - /* code not in table */ -- p = &table[(i = start[k]) >> m]; -+ i = start[k]; -+ if ((i >> m) > 4096) { -+ /* CVE-2006-4337 */ -+ error("Bad table (case c)"); -+ exit(1); -+ } -+ p = &table[i >> m]; - i <<= tablebits; - n = k - tablebits; - /* make tree (n length) */ -Only in lha-1.14i/src: maketbl.c~ diff -Nru lha-1.14i/debian/patch.CVE-2007-2030.patch lha-1.14i-acc20050924p1/debian/patch.CVE-2007-2030.patch --- lha-1.14i/debian/patch.CVE-2007-2030.patch 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/patch.CVE-2007-2030.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,123 +0,0 @@ -diff -Naur lha-1.14i.orig/src/lhadd.c lha-1.14i/src/lhadd.c ---- lha-1.14i.orig/src/lhadd.c 2000-10-04 16:57:38.000000000 +0200 -+++ lha-1.14i/src/lhadd.c 2007-12-01 16:29:29.000000000 +0100 -@@ -35,6 +35,8 @@ - if ((hdr->unix_mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK) { - char buf[256], *b1, *b2; - if (!quiet) { -+ /* make sure we use a zero-terminated buffer */ -+ hdr->name[255] = 0; - strcpy(buf, hdr->name); - b1 = strtok(buf, "|"); - b2 = strtok(NULL, "|"); -@@ -108,7 +110,7 @@ - if (symlink) - fp = NULL; - else -- fp = xfopen(name, READ_BINARY); -+ fp = xfopen(name, READ_BINARY, 0); - else { - fp = NULL; - } -@@ -211,8 +213,11 @@ - add_sp(&sp, hdr.name, strlen(hdr.name) + 1); - } - else if ((hdr.unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_DIRECTORY) { -+ /* make sure we use a zero-terminated buffer */ -+ hdr.name[sizeof(hdr.name)-1] = 0; - strcpy(name, hdr.name); - len = strlen(name); -+ /* XXX thomas: what about multiple '/' or about ".." */ - if (len > 0 && name[len - 1] == '/') - name[--len] = '\0'; /* strip tail '/' */ - if (stat(name, &stbuf) >= 0) /* exist ? */ -@@ -237,17 +242,21 @@ - - old_header_pos = ftell(oafp); - while (get_header(oafp, &ahdr)) { -+ /* make sure we use a zero-terminated buffer */ -+ ahdr.name[sizeof(ahdr.name)-1] = 0; - strcpy(lpath, ahdr.name); - b1 = strtok(lpath, "|"); - b2 = strtok(NULL, "|"); - if (need_file(b1)) { /* skip */ - fseek(oafp, ahdr.packed_size, SEEK_CUR); - if (noexec || !quiet) -+ { - if (b2 != NULL) - printf("delete %s -> %s\n", b1, b2); - else - printf("delete %s\n", b1); - } -+ } - else { /* copy */ - if (noexec) { - fseek(oafp, ahdr.packed_size, SEEK_CUR); -@@ -276,7 +285,7 @@ - signal(SIGHUP, interrupt); - - old_umask = umask(077); -- afp = xfopen(temporary_name, WRITE_BINARY); -+ afp = xfopen(temporary_name, "!" WRITE_BINARY, 1); - remove_temporary_at_error = TRUE; - temporary_fp = afp; - umask(old_umask); -@@ -319,13 +328,13 @@ - { - FILE *oafp, *nafp; - -- oafp = xfopen(temporary_name, READ_BINARY); -+ oafp = xfopen(temporary_name, READ_BINARY, 1); - if (!strcmp(new_archive_name, "-")) { - nafp = stdout; - writting_filename = "starndard output"; - } - else { -- nafp = xfopen(new_archive_name, WRITE_BINARY); -+ nafp = xfopen(new_archive_name, WRITE_BINARY, 0); - writting_filename = archive_name; - } - reading_filename = temporary_name; -diff -Naur lha-1.14i.orig/src/lharc.c lha-1.14i/src/lharc.c ---- lha-1.14i.orig/src/lharc.c 2007-12-01 16:17:19.000000000 +0100 -+++ lha-1.14i/src/lharc.c 2007-12-01 16:36:24.000000000 +0100 -@@ -1016,13 +1016,26 @@ - } - - FILE * --xfopen(name, mode) -+xfopen(name, mode, safe) - char *name, *mode; -+ int safe; - { -- FILE *fp; -+ FILE *fp = NULL; -+ -+ if (mode[0] == '!') { -+ int fd; - -+ int mask = O_RDWR|O_CREAT; -+ if(safe == 0) -+ mask |= O_EXCL; -+ -+ fd = open(name, mask, 0600); -+ if (fd < 0 || (fp = fdopen(fd, mode + 1)) == NULL) -+ fatal_error(name); -+ } else { - if ((fp = fopen(name, mode)) == NULL) - fatal_error(name); -+ } - - return fp; - } -diff -Naur lha-1.14i.orig/src/lhext.c lha-1.14i/src/lhext.c ---- lha-1.14i.orig/src/lhext.c 2007-12-01 16:17:19.000000000 +0100 -+++ lha-1.14i/src/lhext.c 2007-12-01 16:17:39.000000000 +0100 -@@ -360,7 +360,6 @@ - } - - unlink(bb1); -- make_parent_path(bb1); - l_code = symlink(bb2, bb1); - if (l_code < 0) { - if (quiet != TRUE) diff -Nru lha-1.14i/debian/patches/lha-1.14i-ac20050924p1-iconv.patch lha-1.14i-acc20050924p1/debian/patches/lha-1.14i-ac20050924p1-iconv.patch --- lha-1.14i/debian/patches/lha-1.14i-ac20050924p1-iconv.patch 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/patches/lha-1.14i-ac20050924p1-iconv.patch 2011-02-18 16:54:34.000000000 +0000 @@ -0,0 +1,1601 @@ +diff -urbBN lha-1.14i-ac20050924p1.orig/01readme.iconv lha-1.14i-ac20050924p1/01readme.iconv +--- lha-1.14i-ac20050924p1.orig/01readme.iconv 1970-01-01 09:00:00.000000000 +0900 ++++ lha-1.14i-ac20050924p1/01readme.iconv 2006-12-26 21:26:13.000000000 +0900 +@@ -0,0 +1,54 @@ ++lha-1.14i-ac20050924p1-iconv.patch ++ ++ ++This patch breaks spellbound code by 2 steps. ++ ++ 1. Do away text converting mode. ++ 2. Replace to locale system and iconv for file-name conversion. ++ ++ ++ (1) removes `--enable-text-conv' in configure script and option ++(it's not command) `t' and `e' in lha executable. ++# Use other command for text converting. (e.g. iconv, dos2unix) ++ ++ ++ (2) adds `--with-charenc' in configure script. it can select when ++iconv is installed in system. An allowed string is limited in format ++that is displayed by `iconv -l' (up-case, with hyphen). ++ ++ Example: --with-charenc=CP932, --with-charenc=CP437 ++ ++ NULL is defined when string is not specified. It means ready for ++convert, but doesn't. It is default for this option. ++ ++ ++ `--enable-multibyte-filename' in configure script and ++lha options `--system-kanji-code' and `--archive-kanji-code' ++will be disabled by --with-charenc. can't use both, ++because they have same purpose. ++ ++ If you want to use process that is brought by ++`--enable-multibyte-filename', specify `--wtithout-charenc'. ++ ++ ++ When this option is enabled (including NULL is defined), ++Options `--charenc' and `--no-charenc' will be added. ++ ++ `--charenc' can specify name of character encoding for archives. ++argument is handled by iconv. The short option is `E'. ++ ++ Example: --charenc=ISO-8859-1, vEiso88591 ++ ++ `--no-charenc' disable to convert file-names. ++ ++ ++Miscellaneous: ++ ++`--with-tmp-file=TEMPLATE' was removed. use `--with-tmpdir=DIR'. ++Environment variable `TMPDIR' be used as temporary directory. ++ ++Copyright notice was moved into version infomation. ++ ++ ++-- ++2006-12-26 Kyoichiro Suda +diff -urbBN lha-1.14i-ac20050924p1.orig/01readme.iconv.ja lha-1.14i-ac20050924p1/01readme.iconv.ja +--- lha-1.14i-ac20050924p1.orig/01readme.iconv.ja 1970-01-01 09:00:00.000000000 +0900 ++++ lha-1.14i-ac20050924p1/01readme.iconv.ja 2006-12-26 22:39:45.000000000 +0900 +@@ -0,0 +1,77 @@ ++lha-1.14i-ac20050924p1-iconv.patch ++ ++ ++罨< 2ゃ罧泣 lha ゃ膰障障 ++ ++ 1. 鴻紊≪若綮罩≪ ++ 2. <ゃ紊絎茖宴若 + iconv 箴絖臀 ++ ++ ++1. 紊眼 configure 鴻 --enable-text-conv ++篏激с (潟潟с<) t, e ゅ障 ++# 鴻紊紊潟潟篏帥c ++# nkf, kcc, iconv, dos2unix ++ ++ ++2.紊眼 configure 鴻 --with-charenc 菴遵障 ++iconv ゃ潟鴻若激鴻ч御純障 ++絎純絖 iconv -l ц;腓冴綵√ (紊ф絖, ゃ恰) ++障 ++ ++ 箴: --with-charenc=CP932, --with-charenc=CP437 ++ ++絖絎 NULL 羝<潟若筝с鴻絎茵罩≪障 ++倶х鴻絎綽荀障 ++ ++ ++configure 鴻 --enable-multibyte-filename 篏激с ++--system-kanji-code, --archive-kanji-code --with-charencc ++≦劫障у篏睡с障 ++ ++--enable-multibyte-filename ф鴻篏睡翫 ++--wtithout-charenc 絎 ++ ++ ++--with-charenc 鴻翫 (NULL defined 倶) ++篏激с潟 --charenc, --no-charenc 菴遵障 ++ ++--charenc ф後昆絖潟潟若c潟亥┏絎с障 ++綣違 iconv 宴障激с若激с潟 E с ++ ++ 箴: --charenc=EUC-JP, vEeucjp ++ ++--no-charenc с<ゃ紊罩≪障 ++ ++ ++篁 ++ ++configure 鴻ф絎с --with-temp-file=TEMPLATE 綮罩≪障 ++ ++激鴻≪篋 configure 鴻ф障鴻с ++潟若篏∽違篁罕≪с若吟羂 ++с<ゃ茲羂с違潟若у上鴻 ++сc若吟荐絎ф荵荐с ++ ++激с潟ら荀鴻筝<ゃ贋с ++激鴻激若у眼宴若鴻泣若篋 ++dс若吟c荐絎純сc祉障 ++configure 鴻ゃ羆冴 --with-tmpdir=DIR ++障絎茵医紊 TMPDIR с潟若ャ障 ++ ++絮c筝<ゃ吾冴c篏帥 ++潟т信罩c障 ++ ++ ++篁2 ++ ++help <祉若吾с羌篏罔茵腓冴若吾с恰宴腱祉障 ++ ++help <祉若後阪潟潟ゃ潟≪宴若激с潟c蚊荀 ++ゃ潟帥若сゃ鴻с 1 茵 2 茵 (吾篏罔若 ++憟∞g機罧泣) 障ゃ潟帥若сゃ鴻膂∞ュ荐障 ++篏茵篁綽荀<宴冴若吟薤藕帥с ++罔筝糸宍紙√荀сcゃ潟帥若сゃ鴻障 ++ ++ ++-- ++2006-12-26 Kyoichiro Suda +diff -urbBN lha-1.14i-ac20050924p1.orig/Makefile.in lha-1.14i-ac20050924p1/Makefile.in +--- lha-1.14i-ac20050924p1.orig/Makefile.in 2006-10-16 23:50:10.000000000 +0900 ++++ lha-1.14i-ac20050924p1/Makefile.in 2006-12-26 13:53:45.000000000 +0900 +@@ -36,7 +36,6 @@ + build_triplet = @build@ + host_triplet = @host@ + target_triplet = @target@ +-LIBOBJDIR = + DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(srcdir)/config.h.in \ + $(top_srcdir)/configure ChangeLog config.guess config.sub \ +@@ -88,7 +87,6 @@ + CPPFLAGS = @CPPFLAGS@ + CYGPATH_W = @CYGPATH_W@ + DEFS = @DEFS@ +-DEF_KCODE = @DEF_KCODE@ + DEPDIR = @DEPDIR@ + ECHO_C = @ECHO_C@ + ECHO_N = @ECHO_N@ +diff -urbBN lha-1.14i-ac20050924p1.orig/config.h.in lha-1.14i-ac20050924p1/config.h.in +--- lha-1.14i-ac20050924p1.orig/config.h.in 2006-10-11 01:52:55.000000000 +0900 ++++ lha-1.14i-ac20050924p1/config.h.in 2006-12-26 13:54:10.000000000 +0900 +@@ -3,6 +3,9 @@ + /* Define to 1 if you want to leave an old archive */ + #undef BACKUP_OLD_ARCHIVE + ++/* Define name of character encoding it is used in archives. */ ++#undef DEFAULT_CHARENC ++ + /* Define it to 5, 6 or 7 which you want to use -lhX- method, default */ + #undef DEFAULT_LZHUFF_METHOD + +@@ -201,6 +204,9 @@ + /* Define to 1 if you want to use the user/group name extened header */ + #undef INCLUDE_OWNER_NAME_IN_HEADER + ++/* temporary path for mktemp/mkstemp */ ++#undef LHA_TMPDIR ++ + /* Define to CODE_EUC or CODE_SJIS if you want to use multibyte filename */ + #undef MULTIBYTE_FILENAME + +@@ -246,9 +252,6 @@ + /* Define to 1 if you can safely include both and . */ + #undef TIME_WITH_SYS_TIME + +-/* temporary file template for mktemp/mkstemp */ +-#undef TMP_FILENAME_TEMPLATE +- + /* Define to 1 if your declares `struct tm'. */ + #undef TM_IN_SYS_TIME + +diff -urbBN lha-1.14i-ac20050924p1.orig/configure lha-1.14i-ac20050924p1/configure +--- lha-1.14i-ac20050924p1.orig/configure 2006-10-11 01:51:07.000000000 +0900 ++++ lha-1.14i-ac20050924p1/configure 2006-12-26 13:53:46.000000000 +0900 +@@ -310,7 +310,7 @@ + # include + #endif" + +-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP U ANSI2KNR LIBOBJS DEF_KCODE SUPPORT_LZHUFF_METHOD LTLIBOBJS' ++ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP U ANSI2KNR LIBOBJS SUPPORT_LZHUFF_METHOD LTLIBOBJS' + ac_subst_files='' + + # Initialize some variables set by options. +@@ -856,8 +856,6 @@ + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + --disable-largefile omit support for large files +- --enable-text-conv support text code convert from/to EUC +- [default=yes] + --enable-indicator need incremental indicator [default=yes] + --enable-multibyte-filename + support multibyte filename. specify kanji code (euc, +@@ -871,10 +869,10 @@ + Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) ++ --with-charenc=NAME character encoding in archives [default=yes] + --with-default-method=567 + create the -lh[567]- archive default [default=5] +- --with-tmp-file=TEMPLATE +- temporary file template [default=/tmp/lhXXXXXX] ++ --with-tmpdir=DIR temporary path [default=/tmp] + + Some influential environment variables: + CC C compiler command +@@ -7965,22 +7963,40 @@ + + fi + +-# support kanji code conversion +- +-echo "$as_me:$LINENO: checking kanji code conversion on text file" >&5 +-echo $ECHO_N "checking kanji code conversion on text file... $ECHO_C" >&6 +-# Check whether --enable-text-conv or --disable-text-conv was given. +-if test "${enable_text_conv+set}" = set; then +- enableval="$enable_text_conv" +- ++# character encoding for archive ++if test "x${ac_cv_func_iconv}" == xyes ;then ++ echo "$as_me:$LINENO: checking character encoding in archives" >&5 ++echo $ECHO_N "checking character encoding in archives... $ECHO_C" >&6 ++ ++# Check whether --with-charenc or --without-charenc was given. ++if test "${with_charenc+set}" = set; then ++ withval="$with_charenc" ++ case $with_charenc in ++ no|yes) ;; ++ *) if ! iconv -l | grep -q "^$with_charenc//$" ; then ++ { { echo "$as_me:$LINENO: error: You must select a name in list (see iconv -l)" >&5 ++echo "$as_me: error: You must select a name in list (see iconv -l)" >&2;} ++ { (exit 1); exit 1; }; } ++ fi ;; ++ esac + else +- enable_text_conv=yes ++ with_charenc=yes + fi; +- +-echo "$as_me:$LINENO: result: $enable_text_conv" >&5 +-echo "${ECHO_T}$enable_text_conv" >&6 +-if test $enable_text_conv = yes; then +- DEF_KCODE=-DEUC ++ echo "$as_me:$LINENO: result: $with_charenc" >&5 ++echo "${ECHO_T}$with_charenc" >&6 ++ case $with_charenc in ++ yes) ++cat >>confdefs.h <<\_ACEOF ++#define DEFAULT_CHARENC NULL ++_ACEOF ++ ;; ++ no) ;; ++ *) ++cat >>confdefs.h <<_ACEOF ++#define DEFAULT_CHARENC "$with_charenc" ++_ACEOF ++ ;; ++ esac + fi + + # force support -lh7- +@@ -8012,26 +8028,31 @@ + + + # decide temporary path names +-echo "$as_me:$LINENO: checking template of the temporary file" >&5 +-echo $ECHO_N "checking template of the temporary file... $ECHO_C" >&6 ++echo "$as_me:$LINENO: checking default temporary path" >&5 ++echo $ECHO_N "checking default temporary path... $ECHO_C" >&6 + +-# Check whether --with-tmp-file or --without-tmp-file was given. +-if test "${with_tmp_file+set}" = set; then +- withval="$with_tmp_file" ++# Check whether --with-tmpdir or --without-tmpdir was given. ++if test "${with_tmpdir+set}" = set; then ++ withval="$with_tmpdir" + case $withval in +- yes) with_tmp_file=/tmp/lhXXXXXX ;; ++ yes) with_tmpdir=/tmp ;; + no) ;; + esac + else +- with_tmp_file=/tmp/lhXXXXXX ++ with_tmpdir=/tmp + fi; + +-echo "$as_me:$LINENO: result: $with_tmp_file" >&5 +-echo "${ECHO_T}$with_tmp_file" >&6 +-if test x"$with_tmp_file" != xno; then ++echo "$as_me:$LINENO: result: $with_tmpdir" >&5 ++echo "${ECHO_T}$with_tmpdir" >&6 ++if test x"$with_tmpdir" != xno; then ++ if ${with_tmpdir:0:1} != '/'; then ++ { { echo "$as_me:$LINENO: error: temporary path must be start with root directory." >&5 ++echo "$as_me: error: temporary path must be start with root directory." >&2;} ++ { (exit 1); exit 1; }; } ++ fi + + cat >>confdefs.h <<_ACEOF +-#define TMP_FILENAME_TEMPLATE "$with_tmp_file" ++#define LHA_TMPDIR "$with_tmpdir" + _ACEOF + + fi +@@ -8072,6 +8093,17 @@ + + case $enable_multibyte_filename in + auto|yes) ++ if test x$with_charenc != xno; then ++ if test x$enable_multibyte_filename == xyes; then ++ { { echo "$as_me:$LINENO: error: can not set this option with --with-charenc. using it means this character encoding for system will be desided by locale in just executing." >&5 ++echo "$as_me: error: can not set this option with --with-charenc. using it means this character encoding for system will be desided by locale in just executing." >&2;} ++ { (exit 1); exit 1; }; } ++ else ++ { echo "$as_me:$LINENO: WARNING: this option was disabled by --with-charenc." >&5 ++echo "$as_me: WARNING: this option was disabled by --with-charenc." >&2;} ++ enable_multibyte_filename=no ++ fi ++ else + cat >conftest.$ac_ext <<_ACEOF + /* confdefs.h. */ + _ACEOF +@@ -8108,7 +8140,8 @@ + + fi + rm -f conftest* +-;; ++ ++ fi;; + sjis) enable_multibyte_filename=CODE_SJIS;; + euc) enable_multibyte_filename=CODE_EUC;; + utf8) enable_multibyte_filename=CODE_UTF8;; +@@ -8121,6 +8154,11 @@ + echo "$as_me:$LINENO: result: $enable_multibyte_filename" >&5 + echo "${ECHO_T}$enable_multibyte_filename" >&6 + if test x$enable_multibyte_filename != xno; then ++ if test x$with_charenc != xno; then ++ { { echo "$as_me:$LINENO: error: can not set this option with --with-charenc. using it means this character encoding for system will be desided by locale in just executing." >&5 ++echo "$as_me: error: can not set this option with --with-charenc. using it means this character encoding for system will be desided by locale in just executing." >&2;} ++ { (exit 1); exit 1; }; } ++ fi + + cat >>confdefs.h <<_ACEOF + #define MULTIBYTE_FILENAME $enable_multibyte_filename +@@ -8288,10 +8326,9 @@ + # 1. Remove the extension, and $U if already installed. + ac_i=`echo "$ac_i" | + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` +- # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR +- # will be set to the directory where LIBOBJS objects are built. +- ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" +- ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' ++ # 2. Add them. ++ ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" ++ ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' + done + LIBOBJS=$ac_libobjs + +@@ -8904,7 +8941,6 @@ + s,@U@,$U,;t t + s,@ANSI2KNR@,$ANSI2KNR,;t t + s,@LIBOBJS@,$LIBOBJS,;t t +-s,@DEF_KCODE@,$DEF_KCODE,;t t + s,@SUPPORT_LZHUFF_METHOD@,$SUPPORT_LZHUFF_METHOD,;t t + s,@LTLIBOBJS@,$LTLIBOBJS,;t t + CEOF +diff -urbBN lha-1.14i-ac20050924p1.orig/configure.ac lha-1.14i-ac20050924p1/configure.ac +--- lha-1.14i-ac20050924p1.orig/configure.ac 2006-10-11 01:47:39.000000000 +0900 ++++ lha-1.14i-ac20050924p1/configure.ac 2006-12-26 13:36:28.000000000 +0900 +@@ -142,17 +142,27 @@ + [Define to 1 if the 2nd argument of gettimeofday() is effective.]) + fi + +-# support kanji code conversion +-AC_SUBST(DEF_KCODE) +-AC_MSG_CHECKING(kanji code conversion on text file) +-AC_ARG_ENABLE(text-conv, +- AC_HELP_STRING([--enable-text-conv], +- [support text code convert from/to EUC [[default=yes]]]), +- , enable_text_conv=yes) +- +-AC_MSG_RESULT($enable_text_conv) +-if test $enable_text_conv = yes; then +- DEF_KCODE=-DEUC ++# character encoding for archive ++if test "x${ac_cv_func_iconv}" == xyes ;then ++ AC_MSG_CHECKING(character encoding in archives) ++ AC_ARG_WITH(charenc, ++ AC_HELP_STRING([--with-charenc=NAME], ++ [character encoding in archives [[default=yes]]]), ++ [case $with_charenc in ++ no|yes) ;; ++ *) if ! iconv -l | grep -q "^$with_charenc//$" ; then ++ AC_MSG_ERROR([You must select a name in list (see iconv -l)]) ++ fi ;; ++ esac], ++ with_charenc=yes) ++ AC_MSG_RESULT($with_charenc) ++ case $with_charenc in ++ yes) AC_DEFINE(DEFAULT_CHARENC, NULL, ++ [Define name of character encoding it is used in archives.]) ;; ++ no) ;; ++ *) AC_DEFINE_UNQUOTED(DEFAULT_CHARENC, "$with_charenc", ++ [Define name of character encoding it is used in archives.]) ;; ++ esac + fi + + # force support -lh7- +@@ -173,20 +183,23 @@ + AC_DEFINE_UNQUOTED(DEFAULT_LZHUFF_METHOD, LZHUFF${with_default_method}_METHOD_NUM, [Define it to 5, 6 or 7 which you want to use -lhX- method, default]) + + # decide temporary path names +-AC_MSG_CHECKING(template of the temporary file) +-AC_ARG_WITH(tmp-file, +- AC_HELP_STRING([--with-tmp-file=TEMPLATE], +- [temporary file template [[default=/tmp/lhXXXXXX]]]), ++AC_MSG_CHECKING(default temporary path) ++AC_ARG_WITH(tmpdir, ++ AC_HELP_STRING([--with-tmpdir=DIR], ++ [temporary path [[default=/tmp]]]), + [case $withval in +- yes) with_tmp_file=/tmp/lhXXXXXX ;; ++ yes) with_tmpdir=/tmp ;; + no) ;; + esac], +- with_tmp_file=/tmp/lhXXXXXX) ++ with_tmpdir=/tmp) + +-AC_MSG_RESULT($with_tmp_file) +-if test x"$with_tmp_file" != xno; then +- AC_DEFINE_UNQUOTED(TMP_FILENAME_TEMPLATE, "$with_tmp_file", +- [temporary file template for mktemp/mkstemp]) ++AC_MSG_RESULT($with_tmpdir) ++if test x"$with_tmpdir" != xno; then ++ if ${with_tmpdir:0:1} != '/'; then ++ AC_MSG_ERROR([temporary path must be start with root directory.]) ++ fi ++ AC_DEFINE_UNQUOTED(LHA_TMPDIR, "$with_tmpdir", ++ [temporary path for mktemp/mkstemp]) + fi + + # incremental indicator +@@ -214,15 +227,26 @@ + + case $enable_multibyte_filename in + auto|yes) ++ if test x$with_charenc != xno; then ++ if test x$enable_multibyte_filename == xyes; then ++ AC_MSG_ERROR([can not set this option with --with-charenc. using it means this character encoding for system will be desided by locale in just executing.]) ++ else ++ AC_MSG_WARN([this option was disabled by --with-charenc.]) ++ enable_multibyte_filename=no ++ fi ++ else + AC_EGREP_CPP(SJIS,[ + #if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__hpux) + SJIS +-#endif], enable_multibyte_filename=CODE_SJIS, ++#endif], ++ enable_multibyte_filename=CODE_SJIS, + AC_EGREP_CPP(UTF8,[ + #if defined(__APPLE__) /* for Mac OS X */ + UTF8 +-#endif], enable_multibyte_filename=CODE_UTF8, +- enable_multibyte_filename=CODE_EUC));; ++#endif], ++ enable_multibyte_filename=CODE_UTF8, ++ enable_multibyte_filename=CODE_EUC)) ++ fi;; + sjis) enable_multibyte_filename=CODE_SJIS;; + euc) enable_multibyte_filename=CODE_EUC;; + utf8) enable_multibyte_filename=CODE_UTF8;; +@@ -232,6 +256,9 @@ + + AC_MSG_RESULT($enable_multibyte_filename) + if test x$enable_multibyte_filename != xno; then ++ if test x$with_charenc != xno; then ++ AC_MSG_ERROR([can not set this option with --with-charenc. using it means this character encoding for system will be desided by locale in just executing.]) ++ fi + AC_DEFINE_UNQUOTED(MULTIBYTE_FILENAME, $enable_multibyte_filename, + [Define to CODE_EUC or CODE_SJIS if you want to use multibyte filename]) + +diff -urbBN lha-1.14i-ac20050924p1.orig/man/Makefile.in lha-1.14i-ac20050924p1/man/Makefile.in +--- lha-1.14i-ac20050924p1.orig/man/Makefile.in 2006-10-16 23:50:09.000000000 +0900 ++++ lha-1.14i-ac20050924p1/man/Makefile.in 2006-12-26 13:53:44.000000000 +0900 +@@ -36,7 +36,6 @@ + build_triplet = @build@ + host_triplet = @host@ + target_triplet = @target@ +-LIBOBJDIR = + subdir = man + DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in + ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +@@ -68,7 +67,6 @@ + CPPFLAGS = @CPPFLAGS@ + CYGPATH_W = @CYGPATH_W@ + DEFS = @DEFS@ +-DEF_KCODE = @DEF_KCODE@ + DEPDIR = @DEPDIR@ + ECHO_C = @ECHO_C@ + ECHO_N = @ECHO_N@ +@@ -153,9 +151,9 @@ + exit 1;; \ + esac; \ + done; \ +- echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu man/Makefile'; \ ++ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign man/Makefile'; \ + cd $(top_srcdir) && \ +- $(AUTOMAKE) --gnu man/Makefile ++ $(AUTOMAKE) --foreign man/Makefile + .PRECIOUS: Makefile + Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ +diff -urbBN lha-1.14i-ac20050924p1.orig/olddoc/Makefile.in lha-1.14i-ac20050924p1/olddoc/Makefile.in +--- lha-1.14i-ac20050924p1.orig/olddoc/Makefile.in 2006-10-16 23:50:09.000000000 +0900 ++++ lha-1.14i-ac20050924p1/olddoc/Makefile.in 2006-12-26 13:53:44.000000000 +0900 +@@ -36,7 +36,6 @@ + build_triplet = @build@ + host_triplet = @host@ + target_triplet = @target@ +-LIBOBJDIR = + subdir = olddoc + DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in + ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +@@ -64,7 +63,6 @@ + CPPFLAGS = @CPPFLAGS@ + CYGPATH_W = @CYGPATH_W@ + DEFS = @DEFS@ +-DEF_KCODE = @DEF_KCODE@ + DEPDIR = @DEPDIR@ + ECHO_C = @ECHO_C@ + ECHO_N = @ECHO_N@ +@@ -153,9 +151,9 @@ + exit 1;; \ + esac; \ + done; \ +- echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu olddoc/Makefile'; \ ++ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign olddoc/Makefile'; \ + cd $(top_srcdir) && \ +- $(AUTOMAKE) --gnu olddoc/Makefile ++ $(AUTOMAKE) --foreign olddoc/Makefile + .PRECIOUS: Makefile + Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ +diff -urbBN lha-1.14i-ac20050924p1.orig/src/Makefile.in lha-1.14i-ac20050924p1/src/Makefile.in +--- lha-1.14i-ac20050924p1.orig/src/Makefile.in 2006-10-16 23:50:09.000000000 +0900 ++++ lha-1.14i-ac20050924p1/src/Makefile.in 2006-12-26 13:53:44.000000000 +0900 +@@ -37,7 +37,6 @@ + build_triplet = @build@ + host_triplet = @host@ + target_triplet = @target@ +-LIBOBJDIR = + bin_PROGRAMS = lha$(EXEEXT) + subdir = src + DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in fnmatch.c \ +@@ -88,7 +87,6 @@ + CPPFLAGS = @CPPFLAGS@ + CYGPATH_W = @CYGPATH_W@ + DEFS = @DEFS@ +-DEF_KCODE = @DEF_KCODE@ + DEPDIR = @DEPDIR@ + ECHO_C = @ECHO_C@ + ECHO_N = @ECHO_N@ +@@ -180,9 +178,9 @@ + exit 1;; \ + esac; \ + done; \ +- echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ ++ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ + cd $(top_srcdir) && \ +- $(AUTOMAKE) --gnu src/Makefile ++ $(AUTOMAKE) --foreign src/Makefile + .PRECIOUS: Makefile + Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ +diff -urbBN lha-1.14i-ac20050924p1.orig/src/append.c lha-1.14i-ac20050924p1/src/append.c +--- lha-1.14i-ac20050924p1.orig/src/append.c 2003-07-22 04:47:28.000000000 +0900 ++++ lha-1.14i-ac20050924p1/src/append.c 2006-12-25 18:45:21.000000000 +0900 +@@ -41,7 +41,7 @@ + *original_size_var = interface.original; + } else { + *packed_size_var = *original_size_var = +- copyfile(infp, outfp, size, 0, &crc); ++ copyfile(infp, outfp, size, &crc); + } + memcpy(hdr_method, "-lh -", 5); + hdr_method[3] = interface.method + '0'; +diff -urbBN lha-1.14i-ac20050924p1.orig/src/crcio.c lha-1.14i-ac20050924p1/src/crcio.c +--- lha-1.14i-ac20050924p1.orig/src/crcio.c 2006-10-11 01:27:51.000000000 +0900 ++++ lha-1.14i-ac20050924p1/src/crcio.c 2006-12-25 09:54:24.000000000 +0900 +@@ -9,12 +9,6 @@ + #include "lha.h" + + /* ------------------------------------------------------------------------ */ +-#ifdef EUC +-static int putc_euc_cache; +-#endif +-static int getc_euc_cache; +- +-/* ------------------------------------------------------------------------ */ + void + make_crctable( /* void */ ) + { +@@ -51,9 +45,6 @@ + int n; + FILE *fp; + { +- if (text_mode) +- n = fread_txt(p, n, fp); +- else + n = fread(p, 1, n, fp); + + *crcp = calccrc(*crcp, p, n); +@@ -79,145 +70,8 @@ + return; + + if (fp) { +- if (text_mode) { +- if (fwrite_txt(p, n, fp)) +- fatal_error("File write error"); +- } +- else { + if (fwrite(p, 1, n, fp) < n) + fatal_error("File write error"); + } +- } +-} +- +-/* ------------------------------------------------------------------------ */ +-void +-init_code_cache( /* void */ ) +-{ /* called from copyfile() in util.c */ +-#ifdef EUC +- putc_euc_cache = EOF; +-#endif +- getc_euc_cache = EOF; +-} +- +-/* ------------------------------------------------------------------------ */ +-#ifdef EUC +-int +-putc_euc(c, fd) +- int c; +- FILE *fd; +-{ +- int d; +- +- if (putc_euc_cache == EOF) { +- if (!euc_mode || c < 0x81 || c > 0xFC) { +- return putc(c, fd); +- } +- if (c >= 0xA0 && c < 0xE0) { +- if (putc(0x8E, fd) == EOF) return EOF; /* single shift */ +- return putc(c, fd); +- } +- putc_euc_cache = c; /* save first byte */ +- return c; +- } +- d = putc_euc_cache; +- putc_euc_cache = EOF; +- if (d >= 0xA0) +- d -= 0xE0 - 0xA0; +- if (c > 0x9E) { +- c = c - 0x9F + 0x21; +- d = (d - 0x81) * 2 + 0x22; +- } +- else { +- if (c > 0x7E) +- c--; +- c -= 0x1F; +- d = (d - 0x81) * 2 + 0x21; +- } +- if (putc(0x80 | d, fd) == EOF) return EOF; +- return putc(0x80 | c, fd); + } +-#endif + +-/* ------------------------------------------------------------------------ */ +-int +-fwrite_txt(p, n, fp) +- unsigned char *p; +- int n; +- FILE *fp; +-{ +- while (--n >= 0) { +- if (*p != '\015' && *p != '\032') { +-#ifdef EUC +- if (putc_euc(*p, fp) == EOF) +- break; +-#else +- if (putc(*p, fp) == EOF) +- break; +-#endif +- } +- p++; +- } +- return (ferror(fp)); +-} +- +-/* ------------------------------------------------------------------------ */ +-int +-fread_txt(p, n, fp) +- unsigned char *p; +- int n; +- FILE *fp; +-{ +- int c; +- int cnt = 0; +- +- while (cnt < n) { +- if (getc_euc_cache != EOF) { +- c = getc_euc_cache; +- getc_euc_cache = EOF; +- } +- else { +- if ((c = fgetc(fp)) == EOF) +- break; +- if (c == '\n') { +- getc_euc_cache = c; +- ++origsize; +- c = '\r'; +- } +-#ifdef EUC +- else if (euc_mode && (c == 0x8E || (0xA0 < c && c < 0xFF))) { +- int d = fgetc(fp); +- if (d == EOF) { +- *p++ = c; +- cnt++; +- break; +- } +- if (c == 0x8E) { /* single shift (KANA) */ +- if ((0x20 < d && d < 0x7F) || (0xA0 < d && d < 0xFF)) +- c = d | 0x80; +- else +- getc_euc_cache = d; +- } +- else { +- if (0xA0 < d && d < 0xFF) { /* if GR */ +- c &= 0x7F; /* convert to MS-kanji */ +- d &= 0x7F; +- if (!(c & 1)) { +- c--; +- d += 0x7F - 0x21; +- } +- if ((d += 0x40 - 0x21) > 0x7E) +- d++; +- if ((c = (c >> 1) + 0x71) >= 0xA0) +- c += 0xE0 - 0xA0; +- } +- getc_euc_cache = d; +- } +- } +-#endif +- } +- *p++ = c; +- cnt++; +- } +- return cnt; +-} +diff -urbBN lha-1.14i-ac20050924p1.orig/src/dhuf.c lha-1.14i-ac20050924p1/src/dhuf.c +--- lha-1.14i-ac20050924p1.orig/src/dhuf.c 2003-01-18 16:26:47.000000000 +0900 ++++ lha-1.14i-ac20050924p1/src/dhuf.c 2006-12-25 18:44:15.000000000 +0900 +@@ -76,7 +76,6 @@ + n_max = 286; + maxmatch = MAXMATCH; + init_getbits(); +- init_code_cache(); + start_c_dyn(); + start_p_dyn(); + } +diff -urbBN lha-1.14i-ac20050924p1.orig/src/extract.c lha-1.14i-ac20050924p1/src/extract.c +--- lha-1.14i-ac20050924p1.orig/src/extract.c 2003-07-22 04:47:28.000000000 +0900 ++++ lha-1.14i-ac20050924p1/src/extract.c 2006-12-25 18:45:29.000000000 +0900 +@@ -74,7 +74,7 @@ + verify_mode ? "Testing " : "Melting ", + 2048); + *read_sizep = copyfile(infp, (verify_mode ? NULL : outfp), +- original_size, 2, &crc); ++ original_size, &crc); + } + else { + start_indicator(name, +diff -urbBN lha-1.14i-ac20050924p1.orig/src/header.c lha-1.14i-ac20050924p1/src/header.c +--- lha-1.14i-ac20050924p1.orig/src/header.c 2006-10-11 01:27:51.000000000 +0900 ++++ lha-1.14i-ac20050924p1/src/header.c 2006-12-25 19:10:51.000000000 +0900 +@@ -15,6 +15,9 @@ + /* Ver. 1.14i autoconfiscated & rewritten 2003.02.23 Koji Arai */ + /* ------------------------------------------------------------------------ */ + #include "lha.h" ++#ifdef DEFAULT_CHARENC ++# include ++#endif + + #define DUMP_HEADER 1 /* for debugging */ + +@@ -43,16 +46,18 @@ + #define setup_put(PTR) (put_ptr = (PTR)) + #define put_byte(c) (*put_ptr++ = (char)(c)) + ++#ifndef DEFAULT_CHARENC + int optional_archive_kanji_code = NONE; + int optional_system_kanji_code = NONE; + char *optional_archive_delim = NULL; + char *optional_system_delim = NULL; + int optional_filename_case = NONE; + +-#ifdef MULTIBYTE_FILENAME ++# ifdef MULTIBYTE_FILENAME + int default_system_kanji_code = MULTIBYTE_FILENAME; +-#else ++# else + int default_system_kanji_code = NONE; ++# endif + #endif + + int +@@ -204,6 +209,116 @@ + put_byte(buf[i]); + } + ++#ifdef DEFAULT_CHARENC ++static char* ++strdup_iconv (const char *to_enc, ++ const char *from_enc, ++ char *str) ++{ ++ iconv_t cd; ++ char *outbuf, *outbufp, *inbufp; ++ size_t outbufsize, inbytesleft, outbytesleft, ret; ++ ++ inbufp = str; ++ inbytesleft = strlen (str); ++ outbytesleft = outbufsize = 8192; ++ outbufp = outbuf = malloc (outbufsize); ++ if (! outbuf) ++ return NULL; ++ ++ cd = iconv_open (to_enc, from_enc); ++ if (cd == (iconv_t) -1) ++ return NULL; ++ ++ while (inbytesleft) { ++ ret = iconv (cd, &inbufp, &inbytesleft, &outbufp, &outbytesleft); ++ if (ret == (size_t) -1) { ++ if (errno == E2BIG) { ++ size_t offset = (size_t) outbufp - (size_t) outbuf; ++ char *newbuf; ++ /* grow size of memory */ ++ outbufsize += 8192; ++ outbytesleft += 8192; ++ newbuf = realloc (outbuf, outbufsize); ++ if (! newbuf) { ++ iconv_close (cd); ++ free (outbuf); ++ return NULL; ++ } ++ outbuf = newbuf; ++ outbufp = outbuf + offset; ++ } else if (outbytesleft > 0 && inbytesleft > 0) { ++ /* error but force to go forward */ ++ *outbufp ++ = *inbufp ++; ++ inbytesleft --; ++ outbytesleft --; ++ } else break; ++ } ++ } ++ iconv_close (cd); ++ ++ outbufsize -= outbytesleft; ++ if (outbufsize < 1) { ++ free (outbuf); ++ return NULL; ++ } ++ ++ outbuf = realloc (outbuf, outbufsize + 1); ++ outbuf[outbufsize] = '\0'; ++ ++ return outbuf; ++} ++ ++ ++static void ++strtr (char *str, ++ const char *set1, ++ const char *set2) ++{ ++ while (*str) { ++ char *ptr; ++ int len = mblen (str, MB_CUR_MAX); ++ if (len > 1) { ++ str += len; ++ continue; ++ } ++ ptr = strchr (set1, (int) *str); ++ if (ptr) ++ *str = set2[(size_t) ptr - (size_t) set1]; ++ str ++; ++ } ++} ++ ++static void ++strtoupper (char *str) ++{ ++ while (*str) { ++ int len = mblen (str, MB_CUR_MAX); ++ if (len > 1) { ++ str += len; ++ continue; ++ } ++ if (len == 1) ++ *str = toupper ((int) *str); ++ str ++; ++ } ++} ++ ++static void ++strtolower (char *str) ++{ ++ while (*str) { ++ int len = mblen (str, MB_CUR_MAX); ++ if (len > 1) { ++ str += len; ++ continue; ++ } ++ if (len == 1) ++ *str = tolower ((int) *str); ++ str ++; ++ } ++} ++#else + /* added by Koji Arai */ + void + convert_filename(name, len, size, +@@ -367,6 +482,7 @@ + } + #endif /* MULTIBYTE_FILENAME */ + } ++#endif /* DEFAULT_CHARENC */ + + /* + * Generic (MS-DOS style) time stamp format (localtime): +@@ -1033,8 +1149,10 @@ + { + char data[LZHEADER_STORAGE]; + ++#ifndef DEFAULT_CHARENC + int archive_kanji_code = CODE_SJIS; + int system_kanji_code = default_system_kanji_code; ++#endif + char *archive_delim = "\377\\"; /* `\' is for level 0 header and + broken archive. */ + char *system_delim = "//"; +@@ -1102,6 +1220,20 @@ + break; + } + ++#ifdef DEFAULT_CHARENC ++ if (charenc_arch) { ++ char *tmp = strdup_iconv (charenc_sys, charenc_arch, hdr->name); ++ if (tmp) { ++ strncpy (hdr->name, tmp, sizeof hdr->name); ++ free (tmp); ++ } ++ } ++ strtr (hdr->name, archive_delim, system_delim); ++ if (filename_case == TO_UPPER) ++ strtoupper (hdr->name); ++ else if (filename_case == TO_LOWER) ++ strtolower (hdr->name); ++#else + if (optional_archive_kanji_code) + archive_kanji_code = optional_archive_kanji_code; + if (optional_system_kanji_code) +@@ -1118,6 +1250,7 @@ + archive_kanji_code, + system_kanji_code, + archive_delim, system_delim, filename_case); ++#endif /* DEFAULT_CHARENC */ + + if ((hdr->unix_mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK) { + char *p; +@@ -1581,17 +1713,21 @@ + size_t header_size; + char data[LZHEADER_STORAGE]; + ++#ifndef DEFAULT_CHARENC + int archive_kanji_code = CODE_SJIS; + int system_kanji_code = default_system_kanji_code; ++#endif + char *archive_delim = "\377"; + char *system_delim = "/"; + int filename_case = NONE; + char pathname[FILENAME_LENGTH]; + ++#ifndef DEFAULT_CHARENC + if (optional_archive_kanji_code) + archive_kanji_code = optional_archive_kanji_code; + if (optional_system_kanji_code) + system_kanji_code = optional_system_kanji_code; ++#endif + + if (generic_format) + filename_case = TO_UPPER; +@@ -1617,10 +1753,25 @@ + pathname[sizeof(pathname)-1] = 0; + } + ++#ifdef DEFAULT_CHARENC ++ strtr (pathname, system_delim, archive_delim); ++ if (filename_case == TO_UPPER) ++ strtoupper (pathname); ++ else if (filename_case == TO_LOWER) ++ strtolower (pathname); ++ if (charenc_arch) { ++ char *tmp = strdup_iconv (charenc_arch, charenc_sys, pathname); ++ if (tmp) { ++ strncpy (hdr->name, tmp, sizeof pathname); ++ free (tmp); ++ } ++ } ++#else + convert_filename(pathname, strlen(pathname), sizeof(pathname), + system_kanji_code, + archive_kanji_code, + system_delim, archive_delim, filename_case); ++#endif /* DEFAULT_CHARENC */ + + switch (hdr->header_level) { + case 0: +diff -urbBN lha-1.14i-ac20050924p1.orig/src/huf.c lha-1.14i-ac20050924p1/src/huf.c +--- lha-1.14i-ac20050924p1.orig/src/huf.c 2006-10-11 01:39:06.000000000 +0900 ++++ lha-1.14i-ac20050924p1/src/huf.c 2006-12-25 18:44:25.000000000 +0900 +@@ -302,7 +302,6 @@ + p_freq[i] = 0; + output_pos = output_mask = 0; + init_putbits(); +- init_code_cache(); + buf[0] = 0; + } + +@@ -485,6 +484,5 @@ + } + + init_getbits(); +- init_code_cache(); + blocksize = 0; + } +diff -urbBN lha-1.14i-ac20050924p1.orig/src/larc.c lha-1.14i-ac20050924p1/src/larc.c +--- lha-1.14i-ac20050924p1.orig/src/larc.c 2002-11-17 04:03:23.000000000 +0900 ++++ lha-1.14i-ac20050924p1/src/larc.c 2006-12-25 18:44:35.000000000 +0900 +@@ -38,7 +38,6 @@ + decode_start_lzs( /*void*/ ) + { + init_getbits(); +- init_code_cache(); + } + + /* ------------------------------------------------------------------------ */ +diff -urbBN lha-1.14i-ac20050924p1.orig/src/lha.h lha-1.14i-ac20050924p1/src/lha.h +--- lha-1.14i-ac20050924p1.orig/src/lha.h 2006-10-11 01:27:51.000000000 +0900 ++++ lha-1.14i-ac20050924p1/src/lha.h 2006-12-26 21:17:13.000000000 +0900 +@@ -286,7 +286,6 @@ + + /* command line options (common options) */ + EXTERN boolean quiet; +-EXTERN boolean text_mode; + EXTERN boolean verbose; + EXTERN boolean noexec; /* debugging option */ + EXTERN boolean force; +@@ -294,8 +293,8 @@ + EXTERN int compress_method; + EXTERN int header_level; + /* EXTERN int quiet_mode; */ /* 1996.8.13 t.okamoto */ +-#ifdef EUC +-EXTERN boolean euc_mode; ++#ifdef DEFAULT_CHARENC ++EXTERN char *charenc_sys, *charenc_arch; + #endif + + /* list command flags */ +@@ -334,6 +333,7 @@ + EXTERN char backup_archive_name[FILENAME_LENGTH]; + + EXTERN char *extract_directory; ++EXTERN char *temporary_directory; + EXTERN char *reading_filename, *writing_filename; + + EXTERN int archive_file_mode; +diff -urbBN lha-1.14i-ac20050924p1.orig/src/lhadd.c lha-1.14i-ac20050924p1/src/lhadd.c +--- lha-1.14i-ac20050924p1.orig/src/lhadd.c 2006-10-11 01:27:51.000000000 +0900 ++++ lha-1.14i-ac20050924p1/src/lhadd.c 2006-12-25 18:48:10.000000000 +0900 +@@ -332,7 +332,7 @@ + + oafp = xfopen(temporary_name, READ_BINARY); + reading_filename = temporary_name; +- copyfile(oafp, nafp, new_archive_size, 0, 0); ++ copyfile(oafp, nafp, new_archive_size, 0); + if (nafp != stdout) + fclose(nafp); + fclose(oafp); +diff -urbBN lha-1.14i-ac20050924p1.orig/src/lharc.c lha-1.14i-ac20050924p1/src/lharc.c +--- lha-1.14i-ac20050924p1.orig/src/lharc.c 2006-10-11 01:27:51.000000000 +0900 ++++ lha-1.14i-ac20050924p1/src/lharc.c 2006-12-26 22:04:34.000000000 +0900 +@@ -43,6 +43,10 @@ + #define LHA_MAIN_SRC + + #include "lha.h" ++#ifdef DEFAULT_CHARENC ++# include ++# include ++#endif + + static int cmd = CMD_UNKNOWN; + static int error_occurred; +@@ -51,8 +55,10 @@ + static void sort_files(); + static void print_version(); + ++#ifndef DEFAULT_CHARENC + extern int optional_archive_kanji_code; + extern int optional_system_kanji_code; ++#endif + + /* ------------------------------------------------------------------------ */ + static void +@@ -60,7 +66,6 @@ + { + /* options */ + quiet = FALSE; +- text_mode = FALSE; + verbose = 0; + noexec = FALSE; /* debugging option */ + force = FALSE; +@@ -70,8 +75,9 @@ + header_level = 2; /* level 2 */ + quiet_mode = 0; + +-#ifdef EUC +- euc_mode = FALSE; ++#ifdef DEFAULT_CHARENC ++ charenc_sys = nl_langinfo (CODESET); ++ charenc_arch = DEFAULT_CHARENC; + #endif + + /* view command flags */ +@@ -96,6 +102,12 @@ + noconvertcase = FALSE; + + extract_directory = NULL; ++ { char *tmp = getenv ("TMPDIR"); ++ if (tmp && tmp[0] == '/') ++ temporary_directory = tmp; ++ else ++ temporary_directory = LHA_TMPDIR; ++ } + temporary_fd = -1; + + #if BACKUP_OLD_ARCHIVE +@@ -108,40 +120,25 @@ + } + + /* ------------------------------------------------------------------------ */ +-/* NOTES : Text File Format */ +-/* GENERATOR NewLine */ +-/* [generic] 0D 0A */ +-/* [MS-DOS] 0D 0A */ +-/* [OS9][MacOS] 0D */ +-/* [UNIX] 0A */ +-/* ------------------------------------------------------------------------ */ + static void + print_tiny_usage() + { + fprintf(stderr, "\ + usage: lha [-][] [- ...] archive_file [file...]\n\ + commands: [axelvudmcpt]\n\ +- options: [q[012]vnfto[567]dizg012e[w=|x=]]\n\ +- long options: --system-kanji-code={euc,sjis,utf8,cap}\n\ +- --archive-kanji-code={euc,sjis,utf8,cap}\n\ +- --extract-broken-archive\n\ +- --help\n\ +- --version\n"); ++ options: [q[012]vnfto[567]dizg012e[w=|x=]]\n" ++#ifdef DEFAULT_CHARENC ++" long options: --charenc=, --no-charenc\n" ++#else ++" long options: --system-kanji-code={euc,sjis,utf8,cap}\n\ ++ --archive-kanji-code={euc,sjis,utf8,cap}\n" ++#endif ++" --extract-broken-archive, --help, --version\n"); + } + + static void + print_usage() + { +- fprintf(stderr, "\ +-LHarc for UNIX V 1.02 Copyright(C) 1989 Y.Tagawa\n\ +-LHx for MSDOS V C2.01 Copyright(C) 1990 H.Yoshizaki\n\ +-LHx(arc) for OSK V 2.01 Modified 1990 Momozou\n\ +-LHa for UNIX V 1.00 Copyright(C) 1992 Masaru Oki\n\ +-LHa for UNIX V 1.14 Modified 1995 Nobutaka Watazaki\n\ +-LHa for UNIX V 1.14i Modified 2000 Tsugio Okamoto\n\ +- Autoconfiscated 2001-2005 Koji Arai\n\ +-"); +- + print_tiny_usage(); + + fprintf(stderr, "\ +@@ -149,31 +146,25 @@ + a Add(or replace) to archive q{num} quiet (num:quiet mode)\n\ + x,e EXtract from archive v verbose\n\ + l,v List / Verbose List n not execute\n\ +- u Update newer files to archive f force (over write at extract)\n\ +- d Delete from archive t FILES are TEXT file\n"); ++ u Update newer files to archive f force (over write at extract)\n"); + #ifdef SUPPORT_LH7 + fprintf(stderr, "\ +- m Move to archive (means 'ad') o[567] compression method (a/u/c)\n\ ++ d Delete from archive o[567] compression method (a/u/c)\n\ + "); + #endif + #ifndef SUPPORT_LH7 + fprintf(stderr, "\ +- m Move to archive (means 'ad') o use LHarc compatible method (a/u/c)\n\ ++ d Delete from archive o use LHarc compatible method (a/u/c)\n\ + "); + #endif + fprintf(stderr, "\ +- c re-Construct new archive d delete FILES after (a/u/c)\n\ +- p Print to STDOUT from archive i ignore directory path (x/e)\n\ +- t Test file CRC in archive z files not compress (a/u/c)\n\ +- g Generic format (for compatibility)\n\ ++ m Move to archive (means 'ad') d delete FILES after (a/u/c)\n\ ++ c re-Construct new archive i ignore directory path (x/e)\n\ ++ p Print to STDOUT from archive z files not compress (a/u/c)\n\ ++ t Test file CRC in archive g Generic format (for compatibility)\n\ + or not convert case when extracting\n\ + 0/1/2 header level (a/u/c)\n\ + "); +-#ifdef EUC +- fprintf(stderr, "\ +- e TEXT code convert from/to EUC\n\ +-"); +-#endif + fprintf(stderr, "\ + w= specify extract directory (x/e)\n\ + x= eXclude files (a/u/c)\n\ +@@ -193,13 +184,15 @@ + static int + parse_suboption(int argc, char **argv) + { +- char *short_options = "q[012]vnfto[567]dizg012ew:x:"; ++ char *short_options = "q[012]vnfto[567]dizg012ew:x:E:"; + /* "[...]" means optional 1 byte argument (original extention) */ + enum { + HELP_OPTION = 256, + VERSION_OPTION, ++#ifndef DEFAULT_CHARENC + SYSTEM_KANJI_CODE_OPTION, + ARCHIVE_KANJI_CODE_OPTION, ++#endif + }; + + struct option long_options[] = { +@@ -207,8 +200,13 @@ + {"help", no_argument, 0, HELP_OPTION}, + {"version", no_argument, 0, VERSION_OPTION}, + ++#ifdef DEFAULT_CHARENC ++ { "no-charenc", no_argument, (int *) charenc_arch, (int) NULL }, ++ { "charenc", required_argument, NULL, (int) 'E' }, ++#else + {"system-kanji-code", required_argument, 0, SYSTEM_KANJI_CODE_OPTION}, + {"archive-kanji-code", required_argument, 0, ARCHIVE_KANJI_CODE_OPTION}, ++#endif + {"extract-broken-archive", no_argument, &extract_broken_archive, 1}, + {0, 0, 0, 0} + }; +@@ -265,15 +263,6 @@ + case 'v': + verbose++; + break; +- case 't': +- text_mode = TRUE; +- break; +-#ifdef EUC +- case 'e': +- text_mode = TRUE; +- euc_mode = TRUE; +- break; +-#endif + case 'n': + noexec = TRUE; + break; +@@ -361,6 +350,21 @@ + case '2': + header_level = 2; + break; ++#ifdef DEFAULT_CHARENC ++ case 'E': ++ if (!optarg) { ++ error ("option --%s required an argument", ++ long_options[option_index].name); ++ return -1; ++ } ++ if (optarg[0] == '=') ++ optarg ++; ++ if (optarg[0] != '\0') ++ charenc_arch = optarg; ++ else ++ charenc_arch = NULL; ++ break; ++#else + case SYSTEM_KANJI_CODE_OPTION: + if (!optarg) { + error("kanji code not specified for --%s", +@@ -408,6 +412,7 @@ + return -1; + } + break; ++#endif + + default: + error("unknown option `-%c'.", c); +@@ -542,6 +547,7 @@ + + int i; + ++ setlocale (LC_ALL, ""); + init_variable(); /* Added N.Watazaki */ + + if (parse_option(argc, argv) == -1) { +@@ -637,6 +643,16 @@ + defined in config.h by configure script */ + fprintf(stderr, "%s version %s (%s)\n", + PACKAGE_NAME, PACKAGE_VERSION, PLATFORM); ++ ++ fprintf(stderr, "\n\ ++LHarc for UNIX V 1.02 Copyright(C) 1989 Y.Tagawa\n\ ++LHx for MSDOS V C2.01 Copyright(C) 1990 H.Yoshizaki\n\ ++LHx(arc) for OSK V 2.01 Modified 1990 Momozou\n\ ++LHa for UNIX V 1.00 Copyright(C) 1992 Masaru Oki\n\ ++LHa for UNIX V 1.14 Modified 1995 Nobutaka Watazaki\n\ ++LHa for UNIX V 1.14i Modified 2000 Tsugio Okamoto\n\ ++ Autoconfiscated 2001-2005 Koji Arai\n\ ++"); + } + + void +@@ -1120,41 +1136,35 @@ + } + + /* ------------------------------------------------------------------------ */ ++/* #include */ ++/* #include */ ++#include ++char* ++get_username (void) ++{ ++ static char username[16] = { 0, }; ++ ++ if (! username[0]) { ++ uid_t uid = getuid (); ++ struct passwd *pw = getpwuid (uid); ++ if (pw) ++ strncpy (username, pw->pw_name, sizeof username); ++ else ++ xsnprintf (username, sizeof username, "%d", uid); ++ } ++ ++ return username; ++} ++ ++/* ------------------------------------------------------------------------ */ + /* */ + /* ------------------------------------------------------------------------ */ + /* Build temporary file name and store to TEMPORARY_NAME */ + int + build_temporary_name() + { +-#ifdef TMP_FILENAME_TEMPLATE +- /* "/tmp/lhXXXXXX" etc. */ +- if (extract_directory == NULL) { +- str_safe_copy(temporary_name, TMP_FILENAME_TEMPLATE, +- sizeof(temporary_name)); +- } +- else { +- xsnprintf(temporary_name, sizeof(temporary_name), +- "%s/lhXXXXXX", extract_directory); +- } +-#else +- char *s; +- +- str_safe_copy(temporary_name, archive_name, sizeof(temporary_name)); +- s = strrchr(temporary_name, '/'); +- if (s) { +- int len; +- len = s - temporary_name; +- if (len + strlen("lhXXXXXX") < sizeof(temporary_name)) +- /* use directory at archive file */ +- strcpy(s, "lhXXXXXX"); /* ok */ +- else +- /* use current directory */ +- str_safe_copy(temporary_name, "lhXXXXXX", sizeof(temporary_name)); +- } +- else +- /* use current directory */ +- str_safe_copy(temporary_name, "lhXXXXXX", sizeof(temporary_name)); +-#endif ++ xsnprintf (temporary_name, sizeof(temporary_name), ++ "%s/lha-%s.XXXXXX", temporary_directory, get_username()); + #ifdef HAVE_MKSTEMP + { + int old_umask, fd; +@@ -1381,7 +1391,7 @@ + else { + reading_filename = archive_name; + writing_filename = temporary_name; +- copyfile(oafp, nafp, hdr->header_size + hdr->packed_size, 0, 0); ++ copyfile(oafp, nafp, hdr->header_size + hdr->packed_size, 0); + } + } + +diff -urbBN lha-1.14i-ac20050924p1.orig/src/prototypes.h lha-1.14i-ac20050924p1/src/prototypes.h +--- lha-1.14i-ac20050924p1.orig/src/prototypes.h 2006-10-11 01:27:51.000000000 +0900 ++++ lha-1.14i-ac20050924p1/src/prototypes.h 2006-12-25 18:43:50.000000000 +0900 +@@ -19,7 +19,6 @@ + unsigned int calccrc P_((unsigned int crc, unsigned char *p, unsigned int n)); + int fread_crc P_((unsigned int *crcp, unsigned char *p, int n, FILE *fp)); + void fwrite_crc P_((unsigned int *crcp, unsigned char *p, int n, FILE *fp)); +-void init_code_cache P_((void)); + int fwrite_txt P_((unsigned char *p, int n, FILE *fp)); + int fread_txt P_((unsigned char *p, int n, FILE *fp)); + /* dhuf.c */ +@@ -33,7 +32,9 @@ + int decode_lzhuf P_((FILE *infp, FILE *outfp, size_t original_size, size_t packed_size, char *name, int method, size_t *read_sizep)); + /* header.c */ + int calc_sum P_((char *p, int len)); ++#ifndef DEFAULT_CHARENC + void convert_filename P_((char *name, int len, int size, int from_code, int to_code, char *from_delim, char *to_delim, int case_to)); ++#endif + boolean get_header P_((FILE *fp, LzHeader *hdr)); + int seek_lha_header P_((FILE *fp)); + void init_header P_((char *name, struct stat *v_stat, LzHeader *hdr)); +@@ -119,7 +120,7 @@ + unsigned int encode P_((struct interfacing *interface)); + unsigned int decode P_((struct interfacing *interface)); + /* util.c */ +-size_t copyfile P_((FILE *f1, FILE *f2, size_t size, int text_flg, unsigned int *crcp)); ++size_t copyfile P_((FILE *f1, FILE *f2, size_t size, unsigned int *crcp)); + int encode_stored_crc P_((FILE *ifp, FILE *ofp, size_t size, size_t *original_size_var, size_t *write_size_var)); + boolean archive_is_msdos_sfx1 P_((char *name)); + int xsnprintf P_((char *dest, size_t size, char *fmt, ...)); +diff -urbBN lha-1.14i-ac20050924p1.orig/src/shuf.c lha-1.14i-ac20050924p1/src/shuf.c +--- lha-1.14i-ac20050924p1.orig/src/shuf.c 2003-07-22 05:56:03.000000000 +0900 ++++ lha-1.14i-ac20050924p1/src/shuf.c 2006-12-25 18:44:49.000000000 +0900 +@@ -28,7 +28,6 @@ + n_max = 286; + maxmatch = MAXMATCH; + init_getbits(); +- init_code_cache(); + np = 1 << (LZHUFF3_DICBIT - 6); + } + +@@ -78,7 +77,6 @@ + maxmatch = 60; + np = 1 << (12 - 6); + init_putbits(); +- init_code_cache(); + start_c_dyn(); + ready_made(0); + } +@@ -135,7 +133,6 @@ + n_max = 314; + maxmatch = 60; + init_getbits(); +- init_code_cache(); + np = 1 << (LZHUFF1_DICBIT - 6); + start_c_dyn(); + ready_made(0); +diff -urbBN lha-1.14i-ac20050924p1.orig/src/util.c lha-1.14i-ac20050924p1/src/util.c +--- lha-1.14i-ac20050924p1.orig/src/util.c 2004-09-27 01:12:01.000000000 +0900 ++++ lha-1.14i-ac20050924p1/src/util.c 2006-12-25 18:48:39.000000000 +0900 +@@ -16,36 +16,21 @@ + #include + + size_t +-copyfile(f1, f2, size, text_flg, crcp) /* return: size of source file */ ++copyfile(f1, f2, size, crcp) /* return: size of source file */ + FILE *f1; + FILE *f2; + size_t size; +- int text_flg; /* 0: binary, 1: read text, 2: write text */ + unsigned int *crcp; + { + unsigned short xsize; + char *buf; + size_t rsize = 0; + +- if (!text_mode) +- text_flg = 0; +- + buf = (char *)xmalloc(BUFFERSIZE); + if (crcp) + INITIALIZE_CRC(*crcp); +- if (text_flg) +- init_code_cache(); + while (size > 0) { + /* read */ +- if (text_flg & 1) { +- xsize = fread_txt(buf, BUFFERSIZE, f1); +- if (xsize == 0) +- break; +- if (ferror(f1)) { +- fatal_error("file read error"); +- } +- } +- else { + xsize = (size > BUFFERSIZE) ? BUFFERSIZE : size; + if (fread(buf, 1, xsize, f1) != xsize) { + fatal_error("file read error"); +@@ -54,21 +39,13 @@ + size = 0; + else + size -= xsize; +- } + + /* write */ + if (f2) { +- if (text_flg & 2) { +- if (fwrite_txt(buf, xsize, f2)) { +- fatal_error("file write error"); +- } +- } +- else { + if (fwrite(buf, 1, xsize, f2) != xsize) { + fatal_error("file write error"); + } + } +- } + + /* calculate crc */ + if (crcp) { +@@ -95,7 +72,7 @@ + + save_quiet = quiet; + quiet = 1; +- size = copyfile(ifp, ofp, size, 1, &crc); ++ size = copyfile(ifp, ofp, size, &crc); + *original_size_var = *write_size_var = size; + quiet = save_quiet; + return crc; +diff -urbBN lha-1.14i-ac20050924p1.orig/tests/Makefile.in lha-1.14i-ac20050924p1/tests/Makefile.in +--- lha-1.14i-ac20050924p1.orig/tests/Makefile.in 2006-10-16 23:50:10.000000000 +0900 ++++ lha-1.14i-ac20050924p1/tests/Makefile.in 2006-12-26 23:03:04.000000000 +0900 +@@ -36,7 +36,6 @@ + build_triplet = @build@ + host_triplet = @host@ + target_triplet = @target@ +-LIBOBJDIR = + subdir = tests + DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(srcdir)/lha-test.in +@@ -65,7 +64,6 @@ + CPPFLAGS = @CPPFLAGS@ + CYGPATH_W = @CYGPATH_W@ + DEFS = @DEFS@ +-DEF_KCODE = @DEF_KCODE@ + DEPDIR = @DEPDIR@ + ECHO_C = @ECHO_C@ + ECHO_N = @ECHO_N@ +@@ -166,9 +164,9 @@ + exit 1;; \ + esac; \ + done; \ +- echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \ ++ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/Makefile'; \ + cd $(top_srcdir) && \ +- $(AUTOMAKE) --gnu tests/Makefile ++ $(AUTOMAKE) --foreign tests/Makefile + .PRECIOUS: Makefile + Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ diff -Nru lha-1.14i/debian/patches/series lha-1.14i-acc20050924p1/debian/patches/series --- lha-1.14i/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/patches/series 2011-02-18 16:56:20.000000000 +0000 @@ -0,0 +1 @@ +lha-1.14i-ac20050924p1-iconv.patch diff -Nru lha-1.14i/debian/patch.header-overflow lha-1.14i-acc20050924p1/debian/patch.header-overflow --- lha-1.14i/debian/patch.header-overflow 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/patch.header-overflow 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ ---- src/header.c 2002-07-19 17:23:58.000000000 +0900 -+++ src/header.c 2004-06-16 09:49:23.000000000 +0900 -@@ -648,8 +648,17 @@ - } - - if (dir_length) { -+ if ((dir_length + name_length) > sizeof(dirname)) { -+ fprintf(stderr, "Insufficient buffer size\n"); -+ exit(112); -+ } - strcat(dirname, hdr->name); -- strcpy(hdr->name, dirname); -+ -+ if ((dir_length + name_length) > sizeof(hdr->name)) { -+ fprintf(stderr, "Insufficient buffer size\n"); -+ exit(112); -+ } -+ strncpy(hdr->name, dirname, sizeof(hdr->name)); - name_length += dir_length; - } - diff -Nru lha-1.14i/debian/patch.multibyte lha-1.14i-acc20050924p1/debian/patch.multibyte --- lha-1.14i/debian/patch.multibyte 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/patch.multibyte 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ -diff -Nuar src.old/header.c src/header.c ---- src.old/header.c Fri Oct 6 02:36:03 2000 -+++ src/header.c Fri Jul 19 16:46:41 2002 -@@ -82,6 +82,7 @@ - register int i; - - #ifdef MULTIBYTE_CHAR -+ if (multibyte_mode == TRUE) { - for (i = 0; i < len; i++) { - if (MULTIBYTE_FIRST_P(name[i]) && - MULTIBYTE_SECOND_P(name[i + 1])) -@@ -91,6 +92,14 @@ - else if (!noconvertcase && isupper(name[i])) - name[i] = tolower(name[i]); - } -+ } else { -+ for (i = 0; i < len; i++) { -+ if (name[i] == '\\') -+ name[i] = '/'; -+ else if (!noconvertcase && isupper(name[i])) -+ name[i] = tolower(name[i]); -+ } -+ } - #else - for (i = 0; i < len; i++) { - if (name[i] == '\\') -@@ -111,6 +120,7 @@ - boolean lower_case_used = FALSE; - - #ifdef MULTIBYTE_CHAR -+ if (multibyte_mode == TRUE) { - for (i = 0; i < len; i++) { - if (MULTIBYTE_FIRST_P(name[i]) && - MULTIBYTE_SECOND_P(name[i + 1])) -@@ -128,6 +138,19 @@ - name[i] = '/'; - else if (!noconvertcase && !lower_case_used && isupper(name[i])) - name[i] = tolower(name[i]); -+ } -+ } else { -+ for (i = 0; i < len; i++) -+ if (islower(name[i])) { -+ lower_case_used = TRUE; -+ break; -+ } -+ for (i = 0; i < len; i++) { -+ if (name[i] == '\\') -+ name[i] = '/'; -+ else if (!noconvertcase && !lower_case_used && isupper(name[i])) -+ name[i] = tolower(name[i]); -+ } - } - #else - for (i = 0; i < len; i++) -diff -Nuar src.old/lha.h src/lha.h ---- src.old/lha.h Fri Jul 19 17:22:13 2002 -+++ src/lha.h Fri Jul 19 17:18:05 2002 -@@ -101,6 +101,9 @@ - #ifdef EUC - EXTERN boolean euc_mode; - #endif -+#ifdef MULTIBYTE_CHAR -+EXTERN boolean multibyte_mode; -+#endif - - /* list command flags */ - EXTERN boolean verbose_listing; -diff -Nuar src.old/lharc.c src/lharc.c ---- src.old/lharc.c Fri Oct 6 02:33:34 2000 -+++ src/lharc.c Fri Jul 19 16:56:03 2002 -@@ -101,6 +101,10 @@ - euc_mode = FALSE; - #endif - -+#ifdef MULTIBYTE_CHAR -+ multibyte_mode = FALSE; -+#endif -+ - /* view command flags */ - verbose_listing = FALSE; - -@@ -177,6 +181,11 @@ - e TEXT code convert from/to EUC\n\ - "); - #endif -+#ifdef MULTIBYTE_CHAR -+ fprintf(stderr, "\ -+ y filename multibyte convert\n\ -+"); -+#endif - exit(1); - } - -@@ -308,6 +317,11 @@ - case 'e': - text_mode = TRUE; - euc_mode = TRUE; -+ break; -+#endif -+#ifdef MULTIBYTE_CHAR -+ case 'y': -+ multibyte_mode = TRUE; - break; - #endif - case 'n': -diff -Nuar src.old/util.c src/util.c ---- src.old/util.c Wed Oct 4 23:57:38 2000 -+++ src/util.c Fri Jul 19 16:49:23 2002 -@@ -113,18 +113,29 @@ - #endif - for (p = path; (c = *p) != 0; p++) { - #ifdef MULTIBYTE_CHAR -- if (kflg) { -- kflg = 0; -+ if (multibyte_mode == TRUE) { -+ if (kflg) { -+ kflg = 0; -+ } else if (MULTIBYTE_FIRST_P(c)) { -+ kflg = 1; -+ } else { -+ if (c == '\\' || c == DELIM || c == DELIM2) { -+ *p = delim; -+ path = p + 1; -+ } -+ } -+ } else { -+ if (c == '\\' || c == DELIM || c == DELIM2) { -+ *p = delim; -+ path = p + 1; -+ } - } -- else if (MULTIBYTE_FIRST_P(c)) { -- kflg = 1; -- } -- else --#endif -+#else - if (c == '\\' || c == DELIM || c == DELIM2) { - *p = delim; - path = p + 1; - } -+#endif - } - return path; - } diff -Nru lha-1.14i/debian/patch.paul lha-1.14i-acc20050924p1/debian/patch.paul --- lha-1.14i/debian/patch.paul 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/patch.paul 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ ---- src/lha.h Thu Oct 5 19:35:38 2000 -+++ src/lha.h Wed Aug 22 15:49:55 2001 -@@ -16,6 +16,7 @@ - #include - #include - #include -+#include - - #include - diff -Nru lha-1.14i/debian/patch.redhat-sec2 lha-1.14i-acc20050924p1/debian/patch.redhat-sec2 --- lha-1.14i/debian/patch.redhat-sec2 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/patch.redhat-sec2 1970-01-01 00:00:00.000000000 +0000 @@ -1,196 +0,0 @@ -diff -urNp lha-114i.orig/src/lha_macro.h lha-114i/src/lha_macro.h ---- lha-114i.orig/src/lha_macro.h 2004-08-03 15:53:56.000000000 -0500 -+++ lha-114i/src/lha_macro.h 2004-08-03 15:54:05.000000000 -0500 -@@ -53,7 +53,7 @@ - #define SEEK_SET 0 - #define SEEK_CUR 1 - #define SEEK_END 2 --#endif /* SEEK_SET -+#endif /* SEEK_SET */ - - - /* non-integral functions */ -diff -urNp lha-114i.orig/src/lharc.c lha-114i/src/lharc.c ---- lha-114i.orig/src/lharc.c 2004-08-03 15:53:56.000000000 -0500 -+++ lha-114i/src/lharc.c 2004-08-03 15:54:05.000000000 -0500 -@@ -830,9 +830,10 @@ find_files(name, v_filec, v_filev) - DIRENTRY *dp; - struct stat tmp_stbuf, arc_stbuf, fil_stbuf; - -- strcpy(newname, name); -+ strncpy(newname, name, sizeof(newname)); -+ newname[sizeof(newname)-1] = 0; - len = strlen(name); -- if (len > 0 && newname[len - 1] != '/') -+ if (len > 0 && newname[len - 1] != '/' && len < (sizeof(newname)-1)) - newname[len++] = '/'; - - dirp = opendir(name); -@@ -846,6 +847,11 @@ find_files(name, v_filec, v_filev) - - for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) { - n = NAMLEN(dp); -+ if (len >= (sizeof(newname)-1) || -+ (len+n) >= (sizeof(newname)-1) || -+ n <= 0 || -+ (len+n) <= 0) -+ break; - strncpy(newname + len, dp->d_name, n); - newname[len + n] = '\0'; - if (GETSTAT(newname, &fil_stbuf) < 0) -@@ -903,7 +909,8 @@ build_temporary_name() - strcpy(temporary_name, TMP_FILENAME_TEMPLATE); - } - else { -- sprintf(temporary_name, "%s/lhXXXXXX", extract_directory); -+ snprintf(temporary_name, sizeof(temporary_name), -+ "%s/lhXXXXXX", extract_directory); - } - #ifdef MKSTEMP - mkstemp(temporary_name); -@@ -913,10 +920,16 @@ build_temporary_name() - #else - char *p, *s; - -- strcpy(temporary_name, archive_name); -+ strncpy(temporary_name, archive_name, sizeof(temporary_name)); -+ temporary_name[sizeof(temporary_name)-1] = 0; - for (p = temporary_name, s = (char *) 0; *p; p++) - if (*p == '/') - s = p; -+ -+ if( sizeof(temporary_name) - ((size_t) (s-temporary_name)) - 1 -+ <= strlen("lhXXXXXX")) -+ exit(-1); -+ - strcpy((s ? s + 1 : temporary_name), "lhXXXXXX"); - #ifdef MKSTEMP - mkstemp(temporary_name); -@@ -1052,7 +1065,8 @@ open_old_archive() - - if (open_old_archive_1(archive_name, &fp)) - return fp; -- sprintf(expanded_archive_name, "%s.lzh", archive_name); -+ snprintf(expanded_archive_name, sizeof(expanded_archive_name), -+ "%s.lzh", archive_name); - if (open_old_archive_1(expanded_archive_name, &fp)) { - archive_name = expanded_archive_name; - return fp; -@@ -1061,7 +1075,8 @@ open_old_archive() - * if ( (errno&0xffff)!=E_PNNF ) { archive_name = - * expanded_archive_name; return NULL; } - */ -- sprintf(expanded_archive_name, "%s.lzs", archive_name); -+ snprintf(expanded_archive_name, sizeof(expanded_archive_name), -+ "%s.lzs", archive_name); - if (open_old_archive_1(expanded_archive_name, &fp)) { - archive_name = expanded_archive_name; - return fp; -diff -urNp lha-114i.orig/src/lhext.c lha-114i/src/lhext.c ---- lha-114i.orig/src/lhext.c 2004-08-03 15:53:56.000000000 -0500 -+++ lha-114i/src/lhext.c 2004-08-03 15:55:40.000000000 -0500 -@@ -82,7 +82,8 @@ make_parent_path(name) - register char *p; - - /* make parent directory name into PATH for recursive call */ -- strcpy(path, name); -+ memset(path, 0, sizeof(path)); -+ strncpy(path, name, sizeof(path)-1); - for (p = path + strlen(path); p > path; p--) - if (p[-1] == '/') { - *--p = '\0'; -@@ -212,9 +213,11 @@ extract_one(afp, hdr) - } - - if (extract_directory) -- sprintf(name, "%s/%s", extract_directory, q); -- else -- strcpy(name, q); -+ snprintf(name, sizeof(name), "%s/%s", extract_directory, q); -+ else { -+ strncpy(name, q, sizeof(name)); -+ name[sizeof(name) - 1] = '\0'; -+ } - - - /* LZHDIRS_METHOD鐃緒申鐃緒申鐃縦ヘッワ申鐃緒申鐃緒申鐃緒申鐃獣ワ申鐃緒申鐃緒申 */ -@@ -335,7 +338,8 @@ extract_one(afp, hdr) - if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK) { - char buf[256], *bb1, *bb2; - int l_code; -- strcpy(buf, name); -+ strncpy(buf, name, sizeof(buf)); -+ buf[sizeof(buf)-1] = 0; - bb1 = strtok(buf, "|"); - bb2 = strtok(NULL, "|"); - -@@ -365,9 +369,10 @@ extract_one(afp, hdr) - if (quiet != TRUE) { - printf("Symbolic Link %s -> %s\n", bb1, bb2); - } -- strcpy(name, bb1); /* Symbolic's name set */ -+ strncpy(name, bb1, 255); /* Symbolic's name set */ -+ name[255] = 0; - #else -- sprintf(buf, "%s -> %s", bb1, bb2); -+ sprintf(buf, sizeof(buf), "%s -> %s", bb1, bb2); - warning("Can't make Symbolic Link", buf); - return; - #endif -diff -urNp lha-114i.orig/src/lhlist.c lha-114i/src/lhlist.c ---- lha-114i.orig/src/lhlist.c 2004-08-03 15:53:56.000000000 -0500 -+++ lha-114i/src/lhlist.c 2004-08-03 15:54:05.000000000 -0500 -@@ -250,7 +250,8 @@ list_one(hdr) - printf(" %s", hdr->name); - else { - char buf[256], *b1, *b2; -- strcpy(buf, hdr->name); -+ strncpy(buf, hdr->name, sizeof(buf)); -+ buf[sizeof(buf)-1] = 0; - b1 = strtok(buf, "|"); - b2 = strtok(NULL, "|"); - printf(" %s -> %s", b1, b2); -diff -urNp lha-114i.orig/src/util.c lha-114i/src/util.c ---- lha-114i.orig/src/util.c 2004-08-03 15:53:56.000000000 -0500 -+++ lha-114i/src/util.c 2004-08-03 15:54:05.000000000 -0500 -@@ -276,21 +276,27 @@ rmdir(path) - char *path; - { - int stat, rtn = 0; -- char *cmdname; -- if ((cmdname = (char *) malloc(strlen(RMDIRPATH) + 1 + strlen(path) + 1)) -- == 0) -+ pid_t child; -+ -+ -+ /* XXX thomas: shell meta chars in path could exec commands */ -+ /* therefore we should avoid using system() */ -+ if ((child = fork()) < 0) -+ return (-1); /* fork error */ -+ else if (child) { /* parent process */ -+ while (child != wait(&stat)) /* ignore signals */ -+ continue; -+ } -+ else { /* child process */ -+ execl(RMDIRPATH, "rmdir", path, (char *) 0); -+ /* never come here except execl is error */ - return (-1); -- strcpy(cmdname, RMDIRPATH); -- *(cmdname + strlen(RMDIRPATH)) = ' '; -- strcpy(cmdname + strlen(RMDIRPATH) + 1, path); -- if ((stat = system(cmdname)) < 0) -- rtn = -1; /* fork or exec error */ -- else if (stat) { /* RMDIR command error */ -- errno = EIO; -- rtn = -1; - } -- free(cmdname); -- return (rtn); -+ if (stat != 0) { -+ errno = EIO; /* cannot get error num. */ -+ return (-1); -+ } -+ return (0); - } - - /* ------------------------------------------------------------------------ */ diff -Nru lha-1.14i/debian/README.Debian lha-1.14i-acc20050924p1/debian/README.Debian --- lha-1.14i/debian/README.Debian 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/README.Debian 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -lha for DEBIAN ----------------------- - -LHa for UNIX - -Atsushi KAMOSHIDA , Sun, 13 Apr 1997 17:52:59 +0900 diff -Nru lha-1.14i/debian/rules lha-1.14i-acc20050924p1/debian/rules --- lha-1.14i/debian/rules 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/rules 2011-10-09 10:06:31.000000000 +0000 @@ -1,116 +1,28 @@ #!/usr/bin/make -f +# -*- makefile -*- # Sample debian/rules that uses debhelper. -# GNU copyright 1997 to 1999 by Joey Hess. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 -# This is the debhelper compatability version to use. -export DH_COMPAT=3 +%: + dh $@ -configure: configure-stamp -configure-stamp: - dh_testdir - # Add here commands to configure the package. - - patch -p0 < debian/patch.paul - patch -p0 < debian/patch.multibyte - patch -p0 < debian/patch.CAN-2004-0234_0235 - patch -p0 < debian/patch.header-overflow - patch -p1 < debian/patch.redhat-sec2 - patch -p1 < debian/patch.CVE-2006-4335-CVE-2006-4337-CVE-2006-4338 - patch -p1 < debian/patch.CVE-2007-2030.patch - - touch configure-stamp - -build: configure-stamp build-stamp -build-stamp: - dh_testdir - - # Add here commands to compile the package. - $(MAKE) - #/usr/bin/docbook-to-man debian/lha.sgml > lha.1 - - touch build-stamp - -clean: - dh_testdir - dh_testroot - rm -f build-stamp configure-stamp - - # Add here commands to clean up after the build process. - -$(MAKE) clean - - # delete copied docs. - rm -f MACHINES MACHINES2 PROBLEMS README - rm -f header.doc debian/lha.euc.1.gz debian/lha.1.gz - cp debian/org/lha.h src/lha.h - cp debian/org/header.c src/header.c - cp debian/org/lharc.c src/lharc.c - cp debian/org/util.c src/util.c - cp debian/org/lhext.c src/lhext.c - cp debian/org/lhlist.c src/lhlist.c - cp debian/org/lha_macro.h src/lha_macro.h - - dh_clean - -install: build - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs - - # Add here commands to install the package into debian/lha. - # $(MAKE) install BINDIR=$(CURDIR)/debian/lha/usr/bin \ - # MANDIR=$(CURDIR)/debian/lha/usr/share/man \ - # MANSECT=1 - install -m 755 src/lha $(CURDIR)/debian/lha/usr/bin - - # Copy the filenames without the .euc extension - cp MACHINES.euc MACHINES - cp MACHINES2.euc MACHINES2 - cp PROBLEMS.euc PROBLEMS - cp README.euc README - cp header.doc.euc header.doc - - gzip -9 -c man/lha.n > debian/lha.euc.1.gz - gzip -9 -c debian/lha.1 > debian/lha.1.gz - install -m 644 debian/lha.euc.1.gz $(CURDIR)/debian/lha/usr/share/man/ja/man1/lha.1.gz - install -m 644 debian/lha.1.gz $(CURDIR)/debian/lha/usr/share/man/man1/lha.1.gz - -# Build architecture-independent files here. -binary-indep: build install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: build install - dh_testdir - dh_testroot -# dh_installdebconf - dh_installdocs - dh_installexamples - dh_installmenu -# dh_installlogrotate -# dh_installemacsen -# dh_installpam -# dh_installmime -# dh_installinit -# dh_installcron -# dh_installman -# dh_installinfo -# dh_undocumented - dh_installchangelogs CHANGES.euc - dh_link - dh_strip - dh_compress - dh_fixperms -# dh_makeshlibs - dh_installdeb -# dh_perl - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb +override_dh_auto_configure: + dh_auto_configure -- --with-charenc=CP932 -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure +override_dh_auto_install: + $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install + cp debian/lha-1.14i-manpage-en.1 lha.1 + install -d $(CURDIR)/debian/lha-sjis/usr/share/man/ja/man1/ + iconv -f EUC-JP -t UTF-8 man/lha.n | gzip -9 > $(CURDIR)/debian/lha-sjis/usr/share/man/ja/man1/lha.1.gz + +override_dh_auto_test: + true + +override_dh_builddeb: + dh_builddeb -- -Z lzma diff -Nru lha-1.14i/debian/source/format lha-1.14i-acc20050924p1/debian/source/format --- lha-1.14i/debian/source/format 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/debian/source/format 2012-04-22 16:48:32.000000000 +0000 @@ -0,0 +1 @@ +3.0 (quilt) diff -Nru lha-1.14i/depcomp lha-1.14i-acc20050924p1/depcomp --- lha-1.14i/depcomp 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/depcomp 2005-08-29 05:53:16.000000000 +0000 @@ -0,0 +1,530 @@ +#! /bin/sh +# depcomp - compile a program generating dependencies as side-effects + +scriptversion=2005-07-09.11 + +# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva . + +case $1 in + '') + echo "$0: No command. Try \`$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: depcomp [--help] [--version] PROGRAM [ARGS] + +Run PROGRAMS ARGS to compile a file, generating dependencies +as side-effects. + +Environment variables: + depmode Dependency tracking mode. + source Source file read by `PROGRAMS ARGS'. + object Object file output by `PROGRAMS ARGS'. + DEPDIR directory where to store dependencies. + depfile Dependency file to output. + tmpdepfile Temporary file to use when outputing dependencies. + libtool Whether libtool is used (yes/no). + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "depcomp $scriptversion" + exit $? + ;; +esac + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi + +# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. +depfile=${depfile-`echo "$object" | + sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. + "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +## The second -e expression handles DOS-style file names with drive letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the `deleted header file' problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. + tr ' ' ' +' < "$tmpdepfile" | +## Some versions of gcc put a space before the `:'. On the theory +## that the space means something, we add a space to the output as +## well. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like `#:fec' to the end of the + # dependency line. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ + tr ' +' ' ' >> $depfile + echo >> $depfile + + # The second pass generates a dummy entry for each header file. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> $depfile + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. In older versions, this file always lives in the + # current directory. Also, the AIX compiler puts `$object:' at the + # start of each line; $object doesn't have directory information. + # Version 6 uses the directory in both cases. + stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` + tmpdepfile="$stripped.u" + if test "$libtool" = yes; then + "$@" -Wc,-M + else + "$@" -M + fi + stat=$? + + if test -f "$tmpdepfile"; then : + else + stripped=`echo "$stripped" | sed 's,^.*/,,'` + tmpdepfile="$stripped.u" + fi + + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + + if test -f "$tmpdepfile"; then + outname="$stripped.o" + # Each line is of the form `foo.o: dependent.h'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" + sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +icc) + # Intel's C compiler understands `-MD -MF file'. However on + # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c + # ICC 7.0 will fill foo.d with something like + # foo.o: sub/foo.c + # foo.o: sub/foo.h + # which is wrong. We want: + # sub/foo.o: sub/foo.c + # sub/foo.o: sub/foo.h + # sub/foo.c: + # sub/foo.h: + # ICC 7.1 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using \ : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | + sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in `foo.d' instead, so we check for that too. + # Subdirectories are respected. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + + if test "$libtool" = yes; then + # With Tru64 cc, shared objects can also be used to make a + # static library. This mecanism is used in libtool 1.4 series to + # handle both shared and static libraries in a single compilation. + # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. + # + # With libtool 1.5 this exception was removed, and libtool now + # generates 2 separate objects for the 2 libraries. These two + # compilations output dependencies in in $dir.libs/$base.o.d and + # in $dir$base.o.d. We have to check for both files, because + # one of the two compilations can be disabled. We should prefer + # $dir$base.o.d over $dir.libs/$base.o.d because the latter is + # automatically cleaned when .libs/ is deleted, while ignoring + # the former would cause a distcleancheck panic. + tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 + tmpdepfile2=$dir$base.o.d # libtool 1.5 + tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 + tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 + "$@" -Wc,-MD + else + tmpdepfile1=$dir$base.o.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + tmpdepfile4=$dir$base.d + "$@" -MD + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a tab and a space in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for `:' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. + "$@" $dashmflag | + sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tr ' ' ' +' < "$tmpdepfile" | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no + for arg in "$@"; do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix="`echo $object | sed 's/^.*\././'`" + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + sed '1,2d' "$tmpdepfile" | tr ' ' ' +' | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E | + sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + "$@" || exit $? + IFS=" " + for arg + do + case "$arg" in + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" + echo " " >> "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff -Nru lha-1.14i/Hacking_of_LHa lha-1.14i-acc20050924p1/Hacking_of_LHa --- lha-1.14i/Hacking_of_LHa 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/Hacking_of_LHa 2006-10-10 16:27:51.000000000 +0000 @@ -0,0 +1,5045 @@ +$Id: Hacking_of_LHa,v 1.2 2005/09/24 13:01:59 arai Exp $ + + The Hacking of LHa for UNIX (2nd draft) + ------------------------------------------- + + Koji Arai + +本書は、LHa for UNIX 1.14i のソースを解読し、その圧縮アルゴリズムの実 +装を確認するためのものだ。この成果は別の形でまとめなおされ資料になるか +もしれないし、このままの形で保管されるかもしれないし、新たにソースを書 +き起こす元になるかもしれない。とにかく、暇な正月休みを潰すためにやって +みただけのものだ。(休みが明けるとまた忙しくなるので、これ以上まったく +何もしないかもしれない) + +本書は、まだ未完成である。にもかかわらず公開するのはこれ以上続かないか +もしれないからである(気が向いたらまた続きを書くだろう。あるいは応援の +お手紙がくればやる気が出るかもしれない)。 + +本書はフリーである。複製、改変、再配布は自由であるということだ。ただし +本書により生じたあらゆる損害、不利益に対しては一切の保証はない。本書に +は嘘があるかもしれない。それに対して嘘を教えられたと著者を避難をしない +で頂きたい。しかし間違いの指摘は構わない(ぜひお願いしたい)、著者は圧縮 +処理に関しては無知である。用語の使い方等は適切でないかもしれないのでこ +の方面でも御指導頂ければ幸いである。 + +=============================================================================== +o 表記について + +* 関数は、その定義ソース file.c と関数名 func() を示すのに + file.c:func() + という記述を使う + +* 配列の添字は、Python言語のスライス演算子の記法に準じた + + a[m:n] は、m <= i < m+n の範囲の a[i] を意味する。 + +* 値の範囲は、Ruby言語の範囲演算子の記法に準じた。これを配列の + 添字に使用する場合もある。 + + m <= i <= n -> i = m..n + m <= i < n -> i = m...n + + a[m..n] は、m <= i <= n の範囲の a[i] を意味する。 + +* m の n 乗 は、m^n で表す。^ は、排他的論理和としても利用されるが + 文脈から判断してもらう。 + +* v{n} は、変数 v の値が n であることを表す。n は、サンプルの値であったり + 定数の値であったりする。 + + v=n は代入文 + + 配列の内容は、 + ary[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 } + のように書く + +o 用語について + +* 符号 + 符号化、符号語、圧縮文 + + 符号語は、1つの文字を符号化した結果。圧縮文は符号語の並び。 + +* 復号 + 復号化、復号語、復号文 + + 復号語は、圧縮文から1つの文字を復号化した結果。復号文は復号語の並び。 + +* 平文 + 圧縮前の文を示す。対して復号文は、復号した後の文を意味する。 + +* slide 辞書法 + +* Huffman 法 + 動的 Huffman 法、静的 Huffman 法 + +=============================================================================== + + +slide 辞書法 (slide.c) +---------------------- + +まず、構造について考える。 + +slide辞書法は、encoding にさまざまな工夫が凝らされるのでとても複雑だが、 +普通 decoding は単純である。decoding を解析することでどのような圧縮文 +を作っているのかを調べてみる。 + +decoding を行う処理は、slide.c の decode() である。この処理を見てみる +と思った通り簡単に解読できた(以下) + + 1. huffman coding により復号した文字を環状バッファ dtext に書き込む + 通常の文字 c は、c < 256 で表現されている(つまりそのまま) + + 2. 通常の文字でないものが現れたら、それは長さである。長さ len は、 + len > 255 で表現されている。len から 0xfd(253) を引いた値が + 実際の長さを表す(-lzs- method の場合は、0xfe(254)を引く) + 「長さ」が、現れたらその直後には「位置」が書かれているのでそれを + 読む。こうして、長さと位置のペアを得る + + dtext から pt+1 バイト前の len バイトを読み、dtext に追加で書き込む + + 3. dtext が一杯(dicsiz)になったらファイルに書き出す + +これの繰り返しである。つまり、slide 辞書法の圧縮文は、文字 c と の並びであることがわかる。例えば、文字列 c1 c2 c1 c2 は、以下のよ +うに表現されているはずである。(本当は、長さが 2 以下では圧縮が起こらな +いので平文のまま出力する。長さは最低でも 3 は必要) + + +----+----+--------+ + | c1 | c2 | <2, 1> | + +----+----+--------+ + +では、この構造を作成する圧縮処理について考える。slide 辞書法では、ファ +イルから読み込んだ文字列 token が、以前に読み込んだ辞書に存在すれば + のペアを出力し、存在しなければ token をそのまま出力する。読 +み込んだ token は、辞書に追加し、辞書の語が溢れたら古い情報を捨てる。 + +何も予備知識がない状態で書けば + + while (read_file(&token, tokensiz)) { + len = search_dict(dict, token, &pt); + if (len == -1) { + print_token(token); + else + print_pair(len, pt); + update_dict(dict, token); + } + +のようになるはず。ここで、tokensiz は token の最大サイズで、最長一致長 +を表す。この値が大きければ大きい程、圧縮効率は良くなるはずで、lha では、 +これは MAXMATCH{256}である。また、dict は辞書でこのサイズは lha の +-lh5- メソッドでは、8192 となっている。この辞書も大きければ大きい程良 +いはずだ。その方が一致文字列が見つかりやすい。(ただし、辞書が大きいと +一致位置を示す情報 の情報量が増えるはずだし、速度も遅くなる +だろう。後で検証する) + +で、実際にソースを見てみると(slide.c:encode())・・・、まったくこのよう +な構造にはなってないように見える。何やらややこしいことばかりでまったく +わからない。なぜここまでややこしいのかと泣きたくなってくるが、それは速 +度のためである(本当?)。上記のコードで、search_dict() は、単に dict か +ら token に一致する位置を検索するだけで良さそう(実際にそれでも良い)だ +が、これではまったく速度が出ない。このあたりの工夫が slide 辞書法のキ +モである。 + +そういうわけで、この部分を読み解くことにする。なお、予備知識として lha +では、辞書から token を探すのにハッシュが使われているらしいことを記し +ておく。 + +ここでは実際にデバッガで動作させながら解読するのではなく、ソースを読む +だけで理解できるかを試すことにする。また、本文は某書(謎)のノリをマネて +いると指摘する方がいるかもしれない・・・がまったくその通りだ。 + +まず、そのものずばりの encode() (slide.c) を見る。以下がこの関数だが +処理の要点だけに着目するために不要そうな部分は(現時点で予測で)削った。 + +unsigned int +encode() +{ + int lastmatchlen; + unsigned int lastmatchoffset; + + /* (A) */ + init_slide(); + + /* (B) */ + remainder = fread_crc(&text[dicsiz], txtsiz-dicsiz, infile); + encoded_origsize = remainder; + matchlen = THRESHOLD - 1; + + pos = dicsiz; + + if (matchlen > remainder) matchlen = remainder; + + /* (C) */ + hval = ((((text[dicsiz] << 5) ^ text[dicsiz + 1]) << 5) + ^ text[dicsiz + 2]) & (unsigned)(HSHSIZ - 1); + + /* (D) */ + insert(); + + while (remainder > 0 && ! unpackable) { + /* (E) */ + lastmatchlen = matchlen; lastmatchoffset = pos - matchpos - 1; + --matchlen; + + /* (F) */ /* (G) */ + get_next(); match_insert(); + if (matchlen > remainder) matchlen = remainder; + + /* (H) */ + if (matchlen > lastmatchlen || lastmatchlen < THRESHOLD) { + /* (H.1) */ + encode_set.output(text[pos - 1], 0); + count++; + } else { + /* (H.2) */ + encode_set.output(lastmatchlen + (UCHAR_MAX + 1 - THRESHOLD), + (lastmatchoffset) & (dicsiz-1) ); + --lastmatchlen; + + while (--lastmatchlen > 0) { + get_next(); insert(); + count++; + } + get_next(); + matchlen = THRESHOLD - 1; + match_insert(); + if (matchlen > remainder) matchlen = remainder; + } + } +} + +まず、この関数から概観を見てみると、ループの前に初期化処理として +以下が行われている。 + +(A) init_slide() 初期化する +(B) ファイルを読み込み text[] に格納する。 +(C) ハッシュ値 hval を計算する。 +(D) insert() する (きっと辞書に token を追加しているのだろう) + +そして、ループ処理では以下の処理が行われている + +(E) lastmatchlen, lastmatchoffset, matchlen を更新する。 +(F) get_next() (次の token を読む。たぶん) +(G) match_insert() (辞書に追加する。たぶん) + +(H) matchlen > lastmatchlen || lastmatchlen < THRESHOLD なら + +(H.1) output() する。(マッチしなかったらそのまま出力しているのだろう。たぶん) +(H.2) そうでなければ(マッチしたなら)、output()し、何かいろいろする。 + +現時点で、(H.2) の部分はよく解読できなかった。何やら再度 get_next() が +呼ばれていたりして思った通りの処理フローにはなっていない。だが、ここで +は焦らず放置することにして、ここまで予想で書いた部分の細部に触れること +にする(単にここまでの予想が間違っているだけかもしれないのだから、わか +らない部分を無理にわかるように頑張る必要はなかろう) + +関数の細部に触れる前にデータ構造について調べておく。データ構造に対して +の理解が深まればアルゴリズムの80%は分かったも同然だ(誇張)。slide.c で +使用されているデータ構造は以下の通りだ。(不要そうだと思うものは除いて +ある) + +static unsigned int *hash; +static unsigned int *prev; +unsigned char *too_flag; +static unsigned int txtsiz; +static unsigned long dicsiz; +static unsigned int hval; +static int matchlen; +static unsigned int matchpos; +static unsigned int pos; +static unsigned int remainder; + +too_flag だけ、static がついてないが、他のソースを grep してもこの変数 +を使っている箇所はない、単に static の付け忘れだろう。 + +これらの変数は、encode() の冒頭 init_slide() で初期化されている・・の +かと思ったら違った。slide.c:encode_alloc() で行われている。 + +int +encode_alloc(method) + int method; +{ + if (method == LZHUFF1_METHOD_NUM) { /* Changed N.Watazaki */ + encode_set = encode_define[0]; + maxmatch = 60; + dicbit = 12; /* 12 Changed N.Watazaki */ + } else { /* method LH4(12),LH5(13),LH6(15) */ + encode_set = encode_define[1]; + maxmatch = MAXMATCH; + if (method == LZHUFF7_METHOD_NUM) + dicbit = MAX_DICBIT; /* 16 bits */ + else if (method == LZHUFF6_METHOD_NUM) + dicbit = MAX_DICBIT-1; /* 15 bits */ + else /* LH5 LH4 is not used */ + dicbit = MAX_DICBIT - 3; /* 13 bits */ + } + + dicsiz = (((unsigned long)1) << dicbit); + txtsiz = dicsiz*2+maxmatch; + + if (hash) return method; + + if (alloc_buf() == NULL) exit(207); /* I don't know this 207. */ + + hash = (unsigned int*)malloc(HSHSIZ * sizeof(unsigned int)); + prev = (unsigned int*)malloc(DICSIZ * sizeof(unsigned int)); + text = (unsigned char*)malloc(TXTSIZ); + too_flag = (unsigned char*)malloc(HSHSIZ); + + if (hash == NULL || prev == NULL || text == NULL || too_flag == NULL) + exit(207); + + return method; +} + +引数に渡された method (これは、lh1, lh5, lh6, lh7 などを示す)によって、 +初期化される内容が変わる(encode_alloc()前半部分)。このことから各変数の +用途もわかる。 + + method maxmatch dicbit + ---------------------------- + -lh1- 60 12 + -lh5- 256 13 + -lh6- 256 15 + -lh7- 256 16 + +ということらしい。dicbit というのは辞書サイズのbitサイズで、辞書サイズ +は 2^dicbit で表されている。lh5 が 8KB(2^13)、lh6 が 32KB(2^15)、lh7 +が 64KB(2^16) の辞書サイズを利用すると言うのは予備知識である。maxmatch +というのは、token の最長一致長である。このことも予備知識として詳細には +触れない。(ところで、本書では当面、lh5, 6, 7 のことしか言及しない) + +encode_set, encode_define というのがあるが、method によって、Huffman +coding の方法を変えていることはちょっと見ればすぐにわかるし、大したこ +とではない。以降無視する。 + +encode_alloc() の後半では、他の変数の初期化(バッファの割り当て)が行われる。 + + dicsiz = (((unsigned long)1) << dicbit); + +dicsiz はそのものずばり辞書サイズである。 + + txtsiz = dicsiz*2+maxmatch; + +現時点で txtsiz が何なのかはわからない。 + + if (hash) return method; + +hash はこの直後で割り当てられる。つまり、一度割当を行ったら、 +encode_alloc() は、以降メモリの割当を行わない。ただそれだけだ。 + + if (alloc_buf() == NULL) exit(207); /* I don't know this 207. */ + +alloc_buf() は、huf.c で定義された関数。このことから Huffman coding の +ためのバッファを割り当てているのだろう。ここでは無視。(しかし、207 と +いうのは何なのだろう?) + + hash = (unsigned int*)malloc(HSHSIZ * sizeof(unsigned int)); + prev = (unsigned int*)malloc(DICSIZ * sizeof(unsigned int)); + text = (unsigned char*)malloc(TXTSIZ); + too_flag = (unsigned char*)malloc(HSHSIZ); + + if (hash == NULL || prev == NULL || text == NULL || too_flag == NULL) + exit(207); + +hash は、ハッシュ用の何か、HSHSIZ は、固定値で 2^15 である。 + +prev は、DICSIZから辞書だろう。要素の型が char でなく int であることに +も注目しておく。DICSIZ は dicsiz でも構わないはず。単に「大は小を兼ね +る」を実践しているだけであろう、TXTSIZ も同様である。おそらく、一度の +実行で複数の圧縮メソッドを使用した場合、そのメソッド毎に領域を割り当て +るよりは最大の値をあらかじめ一度だけ割り当てた方が良いと考えたのだろう。 +しかし、ソースを参照するときは繁雑になるので以降、 + DICSIZ == dicsiz + TXTSIZ == txtsiz +であるとする。これ重要。 + +text は、現時点では不明 + +too_flag も不明 + +っとなる。まだ、良く分からないが、以下の図を書いておこう。後で何度も見 +ることになるだろう。この図はスケールが lh7 の場合を想定しているが。こ +のことは大したことではないはずだ。また、too_flag と hash のスケールが +一緒だがこれはサイズ(領域のバイト数)が一緒なのではなく、要素数が一緒で +あることを示している。ほとんどの場合要素の型の違いというのは処理内容に +とって重要なことではないはずだ。 + +---------------------------------------------------------------------------- + + 0 2^15=32768 + +-------------+ + hash | | + +-------------+ dicsiz=2^dicbit + +-------------+-------------+ 2*2^dicbit + prev | | | | + +-------------+-------------+ v txtsiz + +-------------+-------------+-------------+-------------+---+ + text | | | | | | + +-------------+-------------+-------------+-------------+---+ + <---> + maxmatch{256} + too_flag 2^15 + +-------------+ + | | + +-------------+ +---------------------------------------------------------------------------- + + +先に示した変数の中でまだ初期化には現れていないものがある。列挙すると + +static unsigned int hval; +static int matchlen; +static unsigned int matchpos; +static unsigned int pos; +static unsigned int remainder; + +だ、ざっとソースを眺めると slide.c:insert() という関数に + hash[hval] = pos; +というのが現れているから、hval は、hash[] の位置を指し、hash には、pos +を格納すると推測される。同様に + prev[pos & (dicsiz - 1)] = hash[hval]; +というのも現れているから pos は、prev[] の位置を指し、prev には、 +hash[hval] つまり、pos を格納しているようだ。これは少し謎な処理だが、 +insert() の全貌は短い(というかこれだけ)なので、ちょっと横道にそれて詳 +細に見てみよう。(現在の解析の趣旨は、変数の用途の概要を予想すること) + +/* 現在の文字列をチェーンに追加する */ + +static void insert() +{ + prev[pos & (dicsiz - 1)] = hash[hval]; + hash[hval] = pos; +} + +コメントはまったく意味不明だが、無視して処理内容に着目する。prev[] の +インデックス pos & (dicsiz - 1) は、dicsiz が 2^n であることからdicsiz +はビットマスクであることがわかる。例えば仮に dicsiz が 2^8 だと +dicsiz - 1 は、 + + 8 7 6 5 4 3 2 1 0 bit + -------------------------- + dicsiz 1 0 0 0 0 0 0 0 0 + dicsiz-1 1 1 1 1 1 1 1 1 + +である。このすべて 1 が立ったビットマスクと pos を & すると、どのよう +な pos の値に対しても pos & (dicsiz - 1) は、prev[] のインデックスの範 +囲に納まる。もう少し言うと pos が仮にインデックスの最大値+1だった場合、 +pos & (dicsiz - 1) は、0 になる。これにより次の予想が立つ。 + + o pos が、prev[] の位置を指すのではなく、pos & (dicsiz - 1) が + prev[]の位置を指す。(pos は、このインデックスの範囲を越える可能性がある) + o それに反して、prev[] は環状バッファらしいという予想が立てばやはり + pos は、prev のインデックスである。 + +prev が環状バッファであると予想が付けば話が早い。pos & (dicsiz-1) は、 +pos と同義だと解釈可能だからである(prev が環状バッファでなく無限長のバッ +ファであると想像しよう)そして、pos & (dicsiz-1) を pos に置き換えて、 +再度処理内容に着目すると + + prev[pos] = hash[hval]; + hash[hval] = pos; + +ということから、 + 1. (この関数に来る前に) pos が更新される。(予想) + 2. prev[pos] に以前の hash[hval] (以前の pos)を格納する + 3. hash[hval] に新しい pos を書く。 +といった処理であることが予想される。コメントの「チェーン」もなんとなく +納得できる。新たな事実(まだ予想だが)が分かったので、図に書き記そう。 + +---------------------------------------------------------------------------- + 0 2^15=32768 + +-+---+-------+ + hash | |pos|... | + +-+---+-------+ + `-hval + + .-----------. + v | + +----+-----+-------------------- + prev | |pppos| |ppos| . . . + +----+-----+-------------------- + `- ppos `-pos + + * hash の取り得る値は pos その位置は hval + * ppos は以前の pos を示す。pppos はさらに以前の pos を指す。 + * prev は無限長のバッファ(本当は環状バッファ) +---------------------------------------------------------------------------- + +まだ、解析できてない変数が残っている。 + +static int matchlen; +static unsigned int matchpos; +static unsigned int remainder; + +しかしこれらはどうにもパッと見ではわからない。処理内容を追いかけないと +だめそうだ。仕方ないので変数名で予想しよう。(幸い前の変数名と違って予 +想しやすい)以下 + +---------------------------------------------------------------------------- + * matchlen 一致した文字列長 + * matchpos 一致した辞書上の位置 + * remainder token の残りサイズ +---------------------------------------------------------------------------- + +はたして、予想はあっているのか、今はまだ分からない。 + +slide.c を見る限りデータ構造は網羅できた。結局分かったのか分からないの +か良く分からないが少しずつでも前進はしているはずだ。ここで、再度 +encode() の処理を追いかけよう。今度は細部にも着目する。 + +前に、encode() のソースには (A) 〜 (H) までの記号を記した。この順番に +解析を進めよう。 + + /* (A) */ + init_slide(); + +まあ、初期化である。内容を見てみると + + for (i = 0; i < HSHSIZ; i++) { + hash[i] = NIL; + too_flag[i] = 0; + } + +だけである。NIL というのは、0 であると slide.c で定義されている。普通 +このような初期値は、通常の値が取り得ない値を示している。NIL が 0 なら +hash[] に格納される pos は 0 にならない可能性がある。まあ、予想ばかり +書いても仕方ないので、この関数は終ろう。余談だが、nil は null と同じで。 +「ない」の意味だが、NULL がC言語ではポインタだから。別のマクロ名にした +のかも知れない。いずれにしてもこの程度はマクロにする必要もなかろうとは +思うのは、余計なお世話かもしれない。 + + /* (B) */ + remainder = fread_crc(&text[dicsiz], txtsiz-dicsiz, infile); + encoded_origsize = remainder; + matchlen = THRESHOLD - 1; + + pos = dicsiz; + + if (matchlen > remainder) matchlen = remainder; + +ファイルを読み込み、各変数の初期値を設定している。注目すべきはファイル +を読み込んだバッファの位置である。fread_crc() は、crcio.c で定義された +汎用関数で、CRC値を計算したり漢字コード変換をしたりを除けば、fread() +と同じである。つまり、ファイルは最初、 + + &text[dicsiz] の位置に、txtsiz-dicsiz 分だけ読まれる。 + +ことを示す。図示しよう。 + +---------------------------------------------------------------------------- +< 初期状態 > + + dicsiz=2^dicbit 2*2^dicbit + v v txtsiz + +-------------+-------------+-------------+-------------+---+ + text | | | | | | + +-------------+-------------+-------------+-------------+---+ + `-pos <---> + maxmatch{256} + + <------ remainder --------------> + + |--- この位置に最初の ---------| + データが読まれている +---------------------------------------------------------------------------- + +ますます、text[] の用途が不明だが、slide 辞書法の典型的な読み込み処理 +のことを考えるとある程度予想がつく(それを先に示した方が良いか?)。まあ、 +ここではフーンっと鼻で納得して済まそう。 + +fread_crc() は、読み込んだバッファ長を返す。remainder がその値で、既に +図示してある。encoded_origsize は、ソースを見ると、元のファイルのサイ +ズを表すためだけの変数のようだ。以降は無視しよう。 + +ところで、ファイルサイズが小さい場合図の通りにならないっと考えるかも知 +れない。その通りなのだが、例外条件は少ない方がソースは理解しやすい。単 +純な場合だけを考えた方が、あれこれ考えをめぐらす必要がないからだ。なに +しろ既に動くソースを見ているのだから、細かいことに目をつぶってもエンバ +グすることはないのである。そういうわけで、当面はこの図が唯一の初期状態 +であると考える。 + +(B) の部分はもう少し注目すべき箇所がある。 + + matchlen = THRESHOLD - 1; + +matchlen は、「一致した文字列長」であると予想したが THRESHOLD の値は 3 +(固定値)であるから、matchlen の初期値は 2 だ。いきなり予想がはずれた気 +がする。予想を立て直そう。2 という謎な数値と match*len* について考える +と、冒頭で のペアの len は 2 であることはないと説明した。無 +意味だからであるが、matchlen の初期値はこの 2 と関連するかもしれない。 +そこで、matchlen の用途を以下のように予想しなおすことにする。以下のよ +うにメモを更新しよう。THRESHOLD(threshold は閾値の意)も一緒に予想した。 + +---------------------------------------------------------------------------- +* matchlen 最低限一致しなければならない長さ-1 +* THRESHOLD 最低限一致しなければならない長さ +---------------------------------------------------------------------------- + +うーん、本当だろうか? + +(B) の残りの部分を片付けよう + + pos = dicsiz; + + if (matchlen > remainder) matchlen = remainder; + +pos が dicsiz であることからどうやら、pos は、text[] のインデックスら +しい。前の予想で pos は、prev[] のインデックスでもあり、hash[] の値で +もあると予想したのだが(これはもちろん間違いではなかろうが)。どうやら +本当の意味は、処理するテキストの先頭を示しているのではないかとも思える。 +まあ、ここでは無難に「text[] のインデックス(でもある)」とだけ理解しよう。 +既に図には書き込んである。 + +次の if だが、remainder が matchlen よりも小さい場合の条件だ。また、 +matchlen の予想が覆されそうな予感がしないでもないが、この if 文は*例外 +条件*なので無視することにした。都合の悪いことは見ない方が良いのだ。 + + /* (C) */ + hval = ((((text[dicsiz] << 5) ^ text[dicsiz + 1]) << 5) + ^ text[dicsiz + 2]) & (unsigned)(HSHSIZ - 1); + +(C) である。これは難解である。複雑な数式は苦手であるが、じっくり考えよ +う。まず求める値は hval である。これは hash[] のインデックスなのだが、 +このような複雑な式で求まるインデックスなんて想像もつかない。まず、最初 +のインスピレーションを大事にすることにしよう。冒頭で、(C) の処理は「ハッ +シュ値 hval を計算する。」っと苦もなく予想した。そしてこれは間違いでは +ないだろう(きっと)。hash[] との関連をここで考えてもわからないから、こ +のハッシュ値の計算だけを考えることにしよう。 + +式をじっくり見てみる。。。じっくり見てみると以下のことがわかる。 + + x(i) = text[dicsiz + i] +とすると + hval = (( x(0) << 5 + ^ x(1) ) << 5 + ^ x(2) ) + & (unsigned)(HSHSIZ - 1); + +である。演算子 << は、演算子 ^ よりも優先順位が低いので余計な括弧は省 +略した。最後の & (unsigned)(HSHSIZ - 1) は、前にも似たような式が出たが +これはある範囲の数値(ここでは、0 〜 HSHSIZ{2^15}-1)を抽出するためのビッ +トマスクである。ハッシュ関数と言うのはある符号をある集合の符号に写像す +る関数であるからこのようなビットマスクは当然必要だし、良く行われる事だ +(普通は mod 素数を行うんだけど)。また、hval は、hash[] のインデックス +なのだから、写像する集合とは hash[] のインデックスだ。おっ、案外簡単に +わかった。x(i) が text[dicsiz + i] で、ハッシュ関数の変数は x(0), +x(1), x(2) だから、先頭の 3 バイトの文字列(平文)のハッシュ値を求めてい +るわけだ。その他の計算(<< 5 とか ^ とか) は大したことではない。無視し +よう。また、続けて (D) の処理も見るが、 + + /* (D) */ + insert(); + +insert() は、幸い解読ずみである pos を hash[] に格納する処理だ。 +予想の段階では、(C) と (D) を別個の処理と考えていたのだがこれは +どうやらセットである。 + + (C) pos の位置の 3 文字のハッシュ値を計算し + (D) hash[ハッシュ値] = pos を行う + +もう少し注意深く検討すると「posの位置の3文字」と、求めた「ハッシュ値」 +は論理的には = である。 + +つまり、(C) (D) の処理は + + hash[文字列] = 位置 + +という処理を行っている。ハッシュ値の衝突はここでは考えない。slide 辞書 +法では、ある文字列に対し以前その文字列が現れたかどうかを検索し、その位 +置を求める必要があるのだが、この最初の 3 文字に関しては現時点でその用 +件(位置を求める)を満たす事ができている。ここまでで自ずと encode() の全 +体像も予想がつきそうな気がする。 + +衝突は考えないっとしたが、ちょっと考えたらすぐわかった。prev[] には、 +以前のハッシュ値で求めた文字列の位置が入っている。つまり、prev[] はハッ +シュが衝突したときのためのバッファだ。このハッシュはチェーン法だ。 + +例えば、insert() で、 + prev[pos] = hash[hval]; + hash[hval] = pos; +っと処理をしているのだから + + hash[hval] = pos1 + | + v + prev[pos1] = pos2 + | + v + prev[pos2] = pos3 + ... + +といった値が入る事になる。ある文字列(のハッシュ値) hval に対して、その +辞書上の位置は pos1, pos2, pos3 という候補があるわけだ。実際にどの pos +を選ぶかは比較によって行われるのだろう。 + +# それにつけても、(C) と (D) の部分を見るだけでもこのソースがちょっと +# 汚いことがわかる。もう少し、引数とか戻り値とか考えてくれても良かっ +# たはずだ。ハッシュ関数にしても少なくともマクロぐらいにはしようよ。 + +(E) 〜 (H) に移ろうこれはループの中身で、処理の本題だ。まずループの脱 +出条件を見てみると + + while (remainder > 0 && ! unpackable) { + +remainder は、バッファ上に読み込んだ平文の長さであるからこれがなくなる +までループすることになる。さらに unpackable というのは、crcio.c の +putcode() でその値を設定している箇所が出て来るのだが、符号化した出力サ +イズが元のサイズを越えたときに真になる。つまり、これ以上処理しても圧縮 +の意味がないとわかったらループを抜けるわけだ。 + +では、(E)を見よう。 + + /* (E) */ + lastmatchlen = matchlen; lastmatchoffset = pos - matchpos - 1; + --matchlen; + +ちょっと見ただけではやはりわからない。これらの変数はまだ予想しかしてな +いからである。が、わかるだけの情報は書きしるそう。 + +---------------------------------------------------------------------------- +* lastmatchlen 以前の matchlen の値 (変数名から) +* lastmatchoffset 以前マッチした位置 (変数名から) +---------------------------------------------------------------------------- + +以前の値をlast〜に退避し、新たな値を設定する準備をしているわけだ。そし +て、「新たな値の設定」は、--matchlen で早速行われている。しかし、「マッ +チした長さ」をまだ何もしてないのに -1 するというのはいったいどういうこ +とだろう? matchlen はループの頭で 2 に設定されている。これが 1 になっ +た。本当の初期値は 1 なのか? + +---------------------------------------------------------------------------- +< 各変数の初期値 > + + matchlen = 1 + matchpos = 0 + pos = dicsiz + + lastmatchlen = 2 + lastmatchoffset = dicsiz - 1 (pos - matchpos - 1) +---------------------------------------------------------------------------- + +この (E) はまた後で見る事になるだろう。 + +(F) (G) である。また、その直後には以前にも見た境界条件がある。 + + /* (F) */ /* (G) */ + get_next(); match_insert(); + if (matchlen > remainder) matchlen = remainder; + +if 文 は無視して関数の中身だけを追いかけてみよう。まず、get_next() こ +れは 次の token を取ってくる処理だと予想してある。はたしてどうだろうか? + +static void get_next() +{ + remainder--; + if (++pos >= txtsiz - maxmatch) { + update(); + } + hval = ((hval << 5) ^ text[pos + 2]) & (unsigned)(HSHSIZ - 1); +} + +remainder を消費し、pos を進めている。予想通りだ。ひとまず if の条件は +無視すると、直後で hash 値を求め直している。このハッシュ関数は、以前のハッ +シュ値を利用しているが、これは pos が以前より + 1 されていることを考え +ると関連が見えて来る。以前のhash関数を pos の関数として書き直すと + + x(pos+i) = text[pos + i] + + hval(pos) = (( x(pos+0) << 5 + ^ x(pos+1) ) << 5 + ^ x(pos+2) ) + & (unsigned)(HSHSIZ - 1); + +であり、また、今度のハッシュ関数は、 + + hval(pos+1) = ( hval(pos) << 5 + ^ x(pos+1 + 2) ) + & (unsigned)(HSHSIZ - 1); + +だ、繁雑なので & (HSHSIZE-1) を外すと、 + + hval(pos+1) = (( x(pos+0) << 5 + ^ x(pos+1) ) << 5 + ^ x(pos+2) ) << 5 + ^ x(pos+3) + +っとなる。この次 get_next() が呼び出されれば、 + + hval(pos+2) = ((( x(pos+0) << 5 + ^ x(pos+1) ) << 5 + ^ x(pos+2) ) << 5 + ^ x(pos+3) ) << 5 + ^ x(pos+4) + +である。順にハッシュ値を求める文字列長を増やしている。とにかく、 +get_next() は、pos を進め、remainder を縮め、新たな(以前より1文字長い) +文字列のハッシュ値 hval を求める関数のようだ。 + +しかし、いつまでも hash 値の元となる文字列を伸ばしてもしょうがないだろ +う。hval はどこかでまたリセットされるはずだ。っと思ってソースを探して +みたがそのような箇所は見当たらない。なぜだろう?考えてみる・・・最初は +わからなかったが数式をよく見てみたらわかった。<< 5 が鍵だ、hval(pos+2) +の式を見ると x(pos+0) は、<< 5 が、4回も行われているつまり、20ビットの +シフトだ。hval(pos+3) なら、25ビット、hval(pos+4) なら 30 ビットのシフ +トだ。さすがにこれだけシフトすれば、x(pos+0)の情報は消えてもいいだろう。 + +実際、hval は何文字分の情報を持つのだろう?hval は、unsigned int で、 +普通 32 bit であるから、6.4 文字分だろうか?いや、実際にはハッシュ値の +計算時にHSHSIZ (15bit) でマスクをかけているから 15 bit の情報しか持た +ない。つまり、3文字だ。ビット計算は苦手なので図示して確認しよう。 + + 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + hval |--| | | | | | | | | | | | | | | | + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +最初の hval(0) は、x(0), x(1), x(2) に対して、 + + <--- 5 -----> <--- 5 -----> <--- 5 -----> + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + x(0) <<10 -- x x x x x + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + x(1) << 5 -- x x x x x x x x + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + x(2) -- x x x x x x x x + +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +の排他的論理和である。hval(0) の時点で x(0) の情報は 5 ビット残ってい +るが hval(1) になれば消えてしまうのは自明である。どうにも最初の文字に +関しては 5 ビットしか情報を使用しないと言うのが気持悪いのだが、15 bit +サイズの変数 hval には、過去 3 文字分の情報しか保持されないのは間違い +ない。get_next() の処理を見れば、位置 pos に対して、hval は常に pos, +pos+1, pos+2 の情報しか持たないわけだ。これは重要だ。メモしよう + +---------------------------------------------------------------------------- + * hval hash[]のインデックス。現在位置 pos に対して、 + text[pos], text[pos+1], text[pos+2] のハッシュ値で、論理的には + hval == text[pos] + text[pos+1] + text[pos+2] + と同義 +---------------------------------------------------------------------------- + +ところで、前回、hval の計算とinsert() はセットだと言った。今回はどうだ +ろう?次の match_insert() を見てみる。 + +static void match_insert() +{ + ... 省略 ... + + prev[pos & (dicsiz - 1)] = hash[hval]; + hash[hval] = pos; +} + +・・・強敵であった。強敵すぎたので逃げて、最後の2 行だけに着目した。こ +れは、insert()と同じだ。予想は当たっている。get_next() で hval を更新 +した後は、この match_insert() で、prev[] と hash[] を更新するわけだ。 +そして、match_insert() の省略した部分は、どうやら matchpos, matchlen, +too_flag を更新しているだけのようだ。これが本当なら match_insert()で、 +insert()の処理をせず、関数を分けるかした方が良さそうだ。(真偽の程は詳 +細を見てからになる) + +おもむろに後続の処理 (H) を見ると、 + + /* (H) */ + if (matchlen > lastmatchlen || lastmatchlen < THRESHOLD) { + +これが真なら「見つからなかった状態」と予想した(なぜだろ?)。そして、 +lastmatchlen は初期状態では 2 である。予想した条件は逆か? matchlen ま +わりは予想ばかりで進めすぎた。そしてどうやら match_insert() を読みとか +なければこの先も分からずじまいになりそうだ。 + +このまま match_insert() を詳細に解析する事にしよう。match_insert() +をすべて再掲する。 + +/* 現在の文字列と最長一致する文字列を検索し、チェーンに追加する */ + +static void match_insert() +{ + unsigned int scan_pos, scan_end, len; + unsigned char *a, *b; + unsigned int chain, off, h, max; + + max = maxmatch; /* MAXMATCH; */ + if (matchlen < THRESHOLD - 1) matchlen = THRESHOLD - 1; + matchpos = pos; + + off = 0; + for (h = hval; too_flag[h] && off < maxmatch - THRESHOLD; ) { + h = ((h << 5) ^ text[pos + (++off) + 2]) & (unsigned)(HSHSIZ - 1); + } + if (off == maxmatch - THRESHOLD) off = 0; + for (;;) { + chain = 0; + scan_pos = hash[h]; + scan_end = (pos > dicsiz) ? pos + off - dicsiz : off; + while (scan_pos > scan_end) { + chain++; + + if (text[scan_pos + matchlen - off] == text[pos + matchlen]) { + { + a = text + scan_pos - off; b = text + pos; + for (len = 0; len < max && *a++ == *b++; len++); + } + + if (len > matchlen) { + matchpos = scan_pos - off; + if ((matchlen = len) == max) { + break; + } + } + } + scan_pos = prev[scan_pos & (dicsiz - 1)]; + } + + if (chain >= LIMIT) + too_flag[h] = 1; + + if (matchlen > off + 2 || off == 0) + break; + max = off + 2; + off = 0; + h = hval; + } + prev[pos & (dicsiz - 1)] = hash[hval]; + hash[hval] = pos; +} + +まず、初期化部分の前半 + + max = maxmatch; /* MAXMATCH; */ + if (matchlen < THRESHOLD - 1) matchlen = THRESHOLD - 1; + matchpos = pos; + + off = 0; + +maxmatch は、固定値で 256 だ、だから max も 256 +2行目の if 文は、これまでしつこいくらいに出て来た条件に似ているが、今 +回は条件を満たすらしい。これまでは、 + + if (matchlen > remainder) matchlen = remainder; + +という条件だった。そして今回は、 + + if (matchlen < THRESHOLD - 1) matchlen = THRESHOLD - 1; + +だから、全体的に matchlen の値は、 + + THRESHOLD-1 <= matchlen <= remainder + +つまり、 + + 2 <= matchlen <= バッファに残ったテキスト長 + +の範囲に納められるようだ。ここでは、matchlen は下限値を下回るので2 に +設定される。次に matchpos, off が初期化され。以下の図の状態になる。 +(pos, remainder は、get_next() で更新されていることに注意) + +---------------------------------------------------------------------------- + + dicsiz=2^dicbit 2*2^dicbit + v v txtsiz + +-------------+-------------+-------------+-------------+---+ + text | | | | | | + +-------------+-------------+-------------+-------------+---+ + `-pos(=dicsiz+1) <---> + matchpos(=pos) maxmatch{256} + off(=0) + + <------ remainder ------------> + + |--- この位置に最初の ---------| + データが読まれている +---------------------------------------------------------------------------- + +初期化部分の後半 + + for (h = hval; too_flag[h] && off < maxmatch - THRESHOLD; ) { + h = ((h << 5) ^ text[pos + (++off) + 2]) & (unsigned)(HSHSIZ - 1); + } + if (off == maxmatch - THRESHOLD) off = 0; + +h は、too_flag[] が今のところすべて0だから hval だ。(too_flag は、h つ +まり hval をインデックスに取るらしい。hash[] と同じだ。再掲はしないが +メモに書き加えておこう) + +off は、pos の位置からのオフセットのようだ(h を更新する for 文の中身か +ら)。図もその位置に書いた。最後の if 文は off が上限に達した場合に0 に +再初期化している。よくわからないので無視しよう。for 文の中身からh や +off の用途はどうも先読みしたハッシュ値とその先読みの位置なのではないか +と想像する。too_flag[] の状態によって先読みすべき値が変わるのだろうか? + +とにかく処理の本題に入る事にしよう。まず、この関数に現れる局所変数を列 +挙しておこう + + unsigned int scan_pos, scan_end, len; + unsigned char *a, *b; + unsigned int chain, off, h, max; + +off, h, max はすでに出て来たので残りは + + scan_pos, scan_end, len, a, b, chain + +だ、これだけの変数の意味を解読しなくてはならない。変数は状態を表すから、 +その数が多いと言うのはそれだけ複雑な処理だということだ。めげる。 + +この関数のメインとなるループの中をざっと眺めてみるさらに内部にループが +ある。ひとまず、二重ループの中身を省略しよう。 + + for (;;) { + chain = 0; + scan_pos = hash[h]; + scan_end = (pos > dicsiz) ? pos + off - dicsiz : off; + + while (scan_pos > scan_end) { + chain++; + ... 略 ... + } + + if (chain >= LIMIT) + too_flag[h] = 1; + + if (matchlen > off + 2 || off == 0) + break; + max = off + 2; + off = 0; + h = hval; + } + +まず、前半部分から + + chain = 0; + scan_pos = hash[h]; + scan_end = (pos > dicsiz) ? pos + off - dicsiz : off; + +chain, scan_pos, scan_end はすべて while ループに渡されるべき変数だ。 +さらに、while の後には、scan_pos, scan_end は現れないから(仮に while +ループが1つの関数だったとすると)これらは while ループ部の引数(入力)だ。 +この2つの変数はどうやりくりしようとも、while ループ部内の状態しか表さ +ないので、ここでは無視しよう。 + +while ループの後を見てみると + + if (chain >= LIMIT) + too_flag[h] = 1; + + if (matchlen > off + 2 || off == 0) + break; + max = off + 2; + off = 0; + h = hval; + +chain が LIMITを越えた場合、too_flag[h] = 1 としている。chain は、ざっ +と見て、while ループのカウンタらしいが、LIMIT は 0x100 だ。どうにも例 +外条件っぽい(LIMITという名前や数値がそう思わせる)のでここでは無視しよ +う。while ループが 256以上回る可能性がある点だけ心にとどめておこう。 + +次の条件では、matchlen と off が条件判断されている。ということはこのど +ちらか、あるいは両方は while ループの返り値(出力)だ。ざっと +match_insert()全体を見てみると off は最初とこの直後でしか更新されない +らしい。つまり、while ループ部の返り値はmatchlen の方だ。 +この条件は for () ループの脱出条件でもある。心にとどめて、次に進む。 + + max = off + 2; + off = 0; + h = hval; + +ふむ。よくわからない。しかし注目すべき点はある。off はここで、0 になる +がこれ以降は off の値は変わらない。つまり、off は最初は何らかの値で +while ループ部に渡されるが、その次からは、0 だ。この for ループが何度 +回ろうとも 0 だ。h も同じで最初は何らかの値を持つが、2回目のループ以降、 +h は hval だ。max は、off を 0 にする直前に更新しているから、h や off +と事なり、3つの状態を持つ、すなわち。maxmatch, off+2, 2 だ。 + +いや、脱出条件を見てみると off == 0 なら break とある。つまり、この +for ループはどんなに頑張っても2回しか回らないらしい。やっぱり max も 2 +つの状態しか持たないようだ。 + +これで、1 回目、2回目に while ループ部に入る直前の状態が書ける。この関 +数 match_insert() は、while ループ部を1回か2回実行する処理と言うわけだ。 + +ここで無視していた。while ループ部の入力となる scan_pos, scan_end +もそれぞれどのような状態になるか書いておく + +---------------------------------------------------------------------------- +< 1回目 > + h = 何か + off = 何か + max = maxmatch + + scan_pos = hash[h] + scan_end = pos + off - dicsiz (あるいは、off) + + matchlen = 2 + matchpos = pos +< 2回目 > + h = hval + off = 0 + max = 前の off + 2 + + scan_pos = hash[hval] + scan_end = pos - dicsiz (あるいは、0) + + matchlen = ? + matchpos = ? +---------------------------------------------------------------------------- + +上記は一般化した場合だが、今回(初回)の場合、h や off の値は、hval であ +り、0 だった。2回目ループのときの状態と同じである。2回のループの違いは +max の値がmatchpos であるか off+2 (すなわち2)であるかの違いしかないようだ。 + +ここは、条件を少なくするためにこの場合だけにしぼって処理を考えよう。 +while ループの2回の呼び出しを行う際の状態は以下の通りに書き直せる。 + +---------------------------------------------------------------------------- +< 1回目 > + h = hval + off = 0 + max = maxmatch + + scan_pos = hash[hval] + scan_end = pos - dicsiz (あるいは、0) + + matchlen = 2 + matchpos = pos +< 2回目 > + h = hval + off = 0 + max = 2 + + scan_pos = hash[hval] + scan_end = pos - dicsiz (あるいは、0) + + matchlen = ? + matchpos = ? +---------------------------------------------------------------------------- + +うーん、まだ、すっきりしない。何がすっきりしないかというと scan_end の +値だ。これが何を意味するのかがよくわからない。scan_pos は、わかるのか? +というと、わかる。hash[hval]だから現在の文字列と同じ文字列の辞書上の位 +置だ。さらに、現時点では get_next() で、hval を更新してから insert() +を行っていないので、hash[hval] には何も入っていない。すなわち 0 だ。 + + scan_end = (pos > dicsiz) ? pos + off - dicsiz : off; + +を考えよう。off は、0 だから + + scan_end = (pos > dicsiz) ? pos - dicsiz : 0; + +なわけだ。さらに、posは現時点で dicbit+1 であるから、1 だ。図に書こう。 + +---------------------------------------------------------------------------- + + dicsiz=2^dicbit 2*2^dicbit + v v txtsiz + +-------------+-------------+-------------+-------------+---+ + text | | | | | | + +-------------+-------------+-------------+-------------+---+ + ^ ^ `-pos(=dicsiz+1) + | | + | scan_end はこの辺(1) + scan_pos はこの辺(0) + + h = hval + off = 0 + max = 2 + +---------------------------------------------------------------------------- + +ついに、text[] バッファの左半分に指しかかる。これが何なのかは現時点で +は明確に書いてなかったが予想するとこの左半分はズバリ辞書だ。言い切って +やろう。今まで辞書らしい(dicsizのサイズを持つ)バッファは hash[] や +prev[] があったが、hash[], prev[] の用途はもう明確である。辞書となり得 +るバッファはもうこの text[] しかないのだ。 + +さらに、左半分に限らずこの text[] 全体が辞書であろうと予想する。これは +ただの勘だが text[] は環状バッファなのではなかろうかと考えている。 + +# 最初の方で prev[] が辞書だと予想したが間違った予想をしていたことにこ +# の時点で気づいた。prev[] が辞書と同じサイズを持つ理由はまだよくわか +# らない。 + +この時点ではまだ scan_pos や scan_end の真の意味はわからない。off のこ +とを無視しているから予想も立ちにくいが、ひとまず初期状態がどういったも +のかはわかったのでこのまま、while ループ部を見てみたいと思う。 + + while (scan_pos > scan_end) { + chain++; + + if (text[scan_pos + matchlen - off] == text[pos + matchlen]) { + { + a = text + scan_pos - off; b = text + pos; + for (len = 0; len < max && *a++ == *b++; len++); + } + + if (len > matchlen) { + matchpos = scan_pos - off; + if ((matchlen = len) == max) { + break; + } + } + } + scan_pos = prev[scan_pos & (dicsiz - 1)]; + } + +まず、if 文の条件を満たさない場合だけを考える。 + + while (scan_pos > scan_end) { + chain++; + + if (text[scan_pos + matchlen - off] == text[pos + matchlen]) { + ... + } + scan_pos = prev[scan_pos & (dicsiz - 1)]; + } + + +offは 0 なので、text[scan_pos + matchlen] != text[pos + matchlen] とい +う条件の場合を想定するわけだが、 + +text[scan_pos + matchlen] + +と + +text[pos + matchlen] + +を比べている + +text[scan_pos] 辞書上の文字列の*先頭* +text[pos] 現在の文字列の*先頭* + +を比べないのは matchlen が前に予想した「最低限一致しなければならない長さ-1」 +だからであろう。現時点で、matchlen が 2 だから + +text[scan_pos + 0] == text[pos + 0] +text[scan_pos + 1] == text[pos + 1] + +であったとしても、 + +text[scan_pos + 2] != text[pos + 2] + +であれば、「最低限一致しなければならない長さ」という条件を満たさないの +である。なので matchlen の位置から先に比較して無駄な比較をしないように +している。後でちゃんとした比較の処理が出て来るだろう。このような処理は +処理としては効率が良いのだが、ことソース理解と言う点では冗長である。わ +かりにくいのだ。仕方ないのだけど。 + +# matchlen の意味の予想はどうやら当たっているようだ。matchlen は最短一 +# 致長で、minmatchlen っと名付けても良さそうな変数だ。 + +そして、比較に失敗したら scan_pos を更新する。 + + scan_pos = prev[scan_pos & (dicsiz - 1)]; + +ハッシュのチェーンをたどっている、つまり次の候補を辞書から取り出してい +るわけだ。ここまでで、while ループの処理内容の想像はついた。このループ +は辞書から(最長)一致する文字列を探しているのだろう。 + +順番が前後したが、while ループの脱出条件を見てみる + + while (scan_pos > scan_end) { + +これはどういうことだろう? scan_pos は、ハッシュのチェーンをたどって同 +じハッシュ値を持つ文字列の位置を探す、この値はだんだんと小さくなって行 +くものなのだろうか? +その通りである。hash[] への格納はファイルから取って来た文字列を順に格 +納して行くのでチェーンの奥には、より前の方の位置が書かれているはずだ。 +逆にチェーンの浅い部分にはより現在位置に近い位置が書かれているのだろ +う。では、その境界 scan_end はどうやってわかるのだろうか?これは後でま +た検証しよう。 + +では、処理の本質 if 文の中を見る事にしよう + + if (text[scan_pos + matchlen - off] == text[pos + matchlen]) { + { + a = text + scan_pos - off; b = text + pos; + for (len = 0; len < max && *a++ == *b++; len++); + } + + if (len > matchlen) { + matchpos = scan_pos - off; + if ((matchlen = len) == max) { + break; + } + } + } + +最初の意味もなくブロックになっている部分を見る、 + + { + a = text + scan_pos - off; b = text + pos; + for (len = 0; len < max && *a++ == *b++; len++); + } + +この処理では a, b といういかにも局所な名前の変数が使われている。これは、 +本当にこのブロック内で局所的なもののようだ。ならば定義位置もこのブロッ +ク内にして本当に局所的にして欲しかった。 + +さらに、この処理は単に文字列 a, b を比較しているだけのようだ。memcmp() +ではまずいのかと言うとここで求めているものが「どこまで一致したか(len)」 +のようなので、memcmp() では役不足だ。 + +その次の処理、 + + if (len > matchlen) { + matchpos = scan_pos - off; + if ((matchlen = len) == max) { + break; + } + } + +で、matchlen (最低一致長)より大きい場合に条件を満たす。条件を満たさな +ければ、scan_pos を更新し、次のループに移る。では、条件を満たす場合を +見てみよう。まず最短一致長の一致条件を満たした場合、matchpos と +matchlen を更新する。 + +matchpos はマッチした位置、 +matchlen はマッチした長さ + +で、matchlen が max なら最長一致長に達しているので、これ以上探索はしな +い。matchlen は最短一致長でありながら、一致長でもある変数のようだ。 +(どうやら以前の2つの予想はどちらも当たっていた模様) + +とにかく while ループ部の出力は、この matchpos と matchlen のようだ。 +前に書いた通りこのループは「最長一致文字列を求める処理」だ。 + +match_insert() の全体をもう一度見てみよう。ただし、以下の書き換えを行う。 + +o while ループ部は search_dict(pos, scan_pos, scan_end, max) という関数 + に置き換えたものとする。 + +o 末尾の insert() と同等の処理を行っている部分も insert() の呼び出しに + すり替えよう。(match_insert() 関数の中で insert() 処理を本当に行うべ + きものなのかどうかが疑問だが) + +o chain という変数にかかわる処理も隠した(search_dict内で行う) + +o for ループは、2回しかまわらないので、2 度の search_dict() の呼び出し + に書き換える + +static void match_insert() +{ + unsigned int off, h; + unsigned int scan_end; + + if (matchlen < THRESHOLD - 1) matchlen = THRESHOLD - 1; + matchpos = pos; + + off = 0; + for (h = hval; too_flag[h] && off < maxmatch - THRESHOLD; ) { + h = ((h << 5) ^ text[pos + (++off) + 2]) & (unsigned)(HSHSIZ - 1); + } + if (off == maxmatch - THRESHOLD) + off = 0; + + scan_end = (pos > dicsiz) ? pos + off - dicsiz : off; + search_dict(pos, hash[h], scan_end, maxmatch); + + if (off > 0 && matchlen <= off + 2) { + off = 0; + + scan_end = (pos > dicsiz) ? pos + off - dicsiz : off; + search_dict(pos, hash[hval], scan_end, off+2); + } + + insert(); +} + +だいぶすっきりした(が、まだ繁雑だ)。まだ、off にかかわる部分がよく分か +らないが、ひとまず良いだろう。この関数の解析はこれで終って良いだろうか。 + +いや、良くない。肝心の match_insert() の出力がよくわからない。この関数 +は「最長一致文字列を探し、hash を更新する処理」(くどいようだが、hashを +更新するは余計に思う)なのだろうが、最長一致文字列が見つからなかったと +いうのはどう判断されるのだろう? + +まず、search_dict() で見つからなかった場合、matchlen は更新されない +(matchpos は、pos になる)。そして、おそらく 2 度目の search_dict() の +呼び出しが行われる。が、too_flag[] というので、判断できそうな気もする +がこれはむしろハッシュのチェーンをたどりすぎるのを止めるためのフラグで +あるように思える。 + +2度目の search_dict()で、max の値が変わるのが鍵だろうか?。今回の場合、 +max は 256 から 2 になる。最長一致長として 2 が限界値になると、 +search_dict() の動作は変わるだろうか?いや、やはり変わらない。どうにも +この関数だけでは見つかったか見つからなかったかという判断はできないよう +だ。(本当はわかっているはずなのにその情報を直接外に持ち出していない) + +気持悪いがやはりこの関数の解析を終え、次に移る事にしよう。 + +(H) である。以前、 + +(H) matchlen > lastmatchlen || lastmatchlen < THRESHOLD なら + +(H.1) output() する。(マッチしなかったらそのまま出力しているのだろう。たぶん) +(H.2) そうでなければ(マッチしたなら)、output()し、何かいろいろする。 + +っと予想した部分だ。今や match_insert() は、解析済みだからこれの真偽が +わかるか?というとやっぱり、わからない。ただ、 + matchlen > lastmatchlen +というのは、辞書から文字列が見つかった場合の条件になりそうだから、やはり +これは予想が逆だろうか?とにかく、比較的簡単そうな、(H.1) から見よう。 + + if (matchlen > lastmatchlen || lastmatchlen < THRESHOLD) { + /* (H.1) */ + encode_set.output(text[pos - 1], 0); + count++; + } else { + +どうも、文字 text[pos-1] を出力しているだけのように思える。文字の出力 +は、slide 辞書法では「辞書から見つからなかった場合」を意味するから、や +はり最初の予想はあってそうなのだが・・・仕方ないので、output()の処理を +覗いて見よう。これは、lh5, 6, 7 の場合、huf.c:output_st1(c, p) である。 +現時点で処理の内容を見てもわけがわからないが、結論から言うと第一引数 c +は、文字で、第二引数 p は、位置である。冒頭の decode 処理で、文字 c は +長さも兼ねていると説明済みなので、(そして、text[pos-1] には現時点で文 +字そのものしか書かれていない)これはやはり文字を出力している処理だ。つ +まり「見つからなかった場合」の処理だ。 + +なぜ、pos-1 なのだろう?確かに Huffman coding に文字を渡すのはこれが初 +めてで、現在 pos の位置はバッファの1文字進んだ位置にある。pos-1 は出力 +しなければならないのは当然だ。ということは pos は常に「未出力文字の位 +置 + 1」なのかもしれない。 + +次の count++ を見る。count はどうやらこの関数の変数ではないらしい、困っ +た事に局所変数の名前っぽいがグローバル変数だ。これはよろしくない。ちょっ +と grep しただけでは、他にどこでこの変数を使っているのかわからなかった。 +まあ、今 1 文字を渡した所なので、入力文字数なのだと仮定しておこう。こ +の変数が大勢に影響を与える事はないだろうからこれ以上は見ないと言うのも +アリだ。 + +# その後、dhuf.c:decode_p_dyn() でのみ count を使用している事がわかった。 + +次は (H.2) である。これがまた難解なのだがゆっくり片付けよう。 + + } else { + /* (H.2) */ + encode_set.output(lastmatchlen + (UCHAR_MAX + 1 - THRESHOLD), + (lastmatchoffset) & (dicsiz-1) ); + --lastmatchlen; + + while (--lastmatchlen > 0) { + get_next(); insert(); + count++; + } + get_next(); + matchlen = THRESHOLD - 1; + match_insert(); + if (matchlen > remainder) matchlen = remainder; + } + +まず、output() に渡している引数は、それぞれ「長さ」と「位置」であろう +ことは予想済みだ。さらに UCHAR_MAX{255} + 1 - THRESHOLD{3} だから + + 長さ lastmatchlen + 253 + 位置 lastmatchoffset & (dicsiz-1) + +となっている。冒頭の decode() の解析で、長さは 253 を足す事は確認済み +だ(-lhs- の場合 254 を足すという動作が、encoding 部分では考慮され +てないのは、-lhs- の encoding 機能がないからだ)。ところで、一致長 +lastmatchlen は 3 以上で初めて 255 を越えることができる。以前予想した、 +THRESHOLD の意味「最低限一致しなければならない長さ」はあっているらしい。 + +もう一点、注意しなくてはならないのは、出力しているのが lastmatchlen と +lastmatchoffset である。これらは、match_insert() のときには更新してい +ない(last〜の更新は次のループの先頭 (E) で行われる)。先程 (H.1) のとき +も書き出していたのは、text[pos-1] であった。pos 位置は一歩先読みした位 +置を指すらしい。このような処理を行う場合、最後に調整が必要なはずだ(で +ないと最後の文字が出力されない)。その調整はどこで行われるのだろう? + +さて、後続の処理だが、<長さ、位置>のペアを出力した後は、 + + --lastmatchlen; + + while (--lastmatchlen > 0) { + get_next(); insert(); + count++; + } + +という処理を行っている。get_next() は、pos を進める処理、insert() は辞 +書に登録する処理だから、これは文字列を読み飛ばしている処理だ。確かに +lastmatchlen 分の情報は出力済みだから、これは納得である。lastmatchlen +を 1 余分に引いているのが謎だがこれは pos が一歩先に進んでいるからであ +ろうと予想する。つまり、この後は pos の位置はまた「現在位置」に戻る。 +なるほど、先程調整が必要と書いたがここで行われているらしい。細部は不明 +だが少なくとも辞書に文字列が見つかった場合は最後まで出力されるようだ。 + +次に進もう + + get_next(); + matchlen = THRESHOLD - 1; + match_insert(); + if (matchlen > remainder) matchlen = remainder; + +せっかく pos が現在の位置に戻ったのに、get_next() でまた先読みされた。 +うーむ。そして、matchlen は初期化される。一致情報はすでに出力済みだか +らこれはうなずける。そして、match_insert() が呼ばれる。この時点で再度 +辞書が検索される。pos はまた1文字進んでいるのだから、これは先程(初期状 +態)のmatch_insert() と大差ない処理だ。(その直後のif文は境界条件なので +無視) + +そうして、また次のループに移る。このとき続けざま get_next(), +match_insert() が行われる。どうやら pos は次のループからは、 2 文字文 +先に進んでしまうようだ。なぜだろう? + +# 後でわかった事だが、while (--lastmatchlen > 0) のループ回数を読み間 +# 違えた。例えば、lastmatchlen が 1 なら、この while ループ内では +# get_next() は1回も呼ばれない。 + +どうにもソースを見ただけで解読するには、このあたりが限界のようだ。どう +しても細部がわからないし、事実が見えないから予想の積み重ねがたまって不 +安になる。 + +実は、もう少しマメに図を起こして読み進んで行けばもっとわかることがあっ +ただろうと思うのだが、それは面倒だし、間違える可能性がある(ここまでで +何度か痛い思いをした)。以降は、いくつかのデータを実際に圧縮させその動 +きをデバッガで追うことで、これまでの解析結果を検証してみよう。 + +・・・っと、その前に、ここまでですべての関数を網羅してしまったと思って +いたのだが、一つ忘れていたものがあった。update() だ。この関数は、 +get_next() で呼び出されていたのだが、以前は無視していた。先にここを見 +ておこう。 + +まず、get_next() を再掲する。 + +static void get_next() +{ + remainder--; + if (++pos >= txtsiz - maxmatch) { + update(); + } + hval = ((hval << 5) ^ text[pos + 2]) & (unsigned)(HSHSIZ - 1); +} + +remainder と pos を進めた後、pos が txtsiz - maxmatch に達してしまった +場合(pos == 2 * 2^dicbit の場合)に呼び出されるようだ。つまり、以下の図 +の状態だ。これが、update() を呼び出す時の初期状態だ。 + +---------------------------------------------------------------------------- + + dicsiz=2^dicbit 2*2^dicbit + v v txtsiz + +-------------+-------------+-------------+-------------+---+ + text | | | | | | + +-------------+-------------+-------------+-------------+---+ + /<---> + / maxmatch{256} + pos + + <--> + remainder + +---------------------------------------------------------------------------- + +では、update() に入る。 + +static void update() +{ + unsigned int i, j; + unsigned int k; + long n; + +#if 0 + memmove(&text[0], &text[dicsiz], (unsigned)(txtsiz - dicsiz)); +#else + { + int m; + i = 0; j = dicsiz; m = txtsiz-dicsiz; + while (m-- > 0) { + text[i++] = text[j++]; + } + } +#endif + n = fread_crc(&text[(unsigned)(txtsiz - dicsiz)], + (unsigned)dicsiz, infile); + + remainder += n; + encoded_origsize += n; + + pos -= dicsiz; + for (i = 0; i < HSHSIZ; i++) { + j = hash[i]; + hash[i] = (j > dicsiz) ? j - dicsiz : NIL; + too_flag[i] = 0; + } + for (i = 0; i < dicsiz; i++) { + j = prev[i]; + prev[i] = (j > dicsiz) ? j - dicsiz : NIL; + } +} + +先頭で、なぜか memmove() を for ループで書き換えている。なぜこのような +ことを行っているのだろう。for ループを見てみてもやっていることは変わら +ない。謎だが、とにかく、text[] の右半分(maxmatch 部分も含む) を左に移 +している。 + +次に fread_crc() で、新たにファイルを読み込む。今度の読み込み位置は +&text[txtsiz - dicsiz] で、長さは dicsiz である。当然、remainder も更 +新している。encoded_origsize は以前と同様無視。pos は dicsiz 分減らさ +れている。これはつまり図示すると、以下の状態になると言う事だ + +---------------------------------------------------------------------------- + + dicsiz=2^dicbit 2*2^dicbit + v v txtsiz + +-------------+-------------+---+---------+-------------+---+ + text | | | | | | | + +-------------+-------------+---+---------+-------------+---+ + /<---> <---> + / maxmatch{256} maxmatch{256} + pos + + <-------------------------------> + remainder + + |------- 以前のデータ ---------|--- 新しいデータ ---------| + +---------------------------------------------------------------------------- + +以降、ファイルの読み込みは常にこの update()でしか行われない。pos は、 +初期状態と同じ位置なので、初期状態が再現されている。ここまでで、 +maxmatch の領域はなんだろうと思うが、おそらく先読みのためだろう。それ +らしい処理は、match_insert() の冒頭にあった(が、現時点で詳細には触れて +いない)。 + +# maxmatch 分の余分な領域は、pos の位置から最大 maxmatch 長の文字列照 +# 合を行うために必要な領域。先読みとはまた見当外れなことを書いたものだ。 +# ちょっと考えればわかることなのに・・ + +update() の残りを見る。 + + for (i = 0; i < HSHSIZ; i++) { + j = hash[i]; + hash[i] = (j > dicsiz) ? j - dicsiz : NIL; + too_flag[i] = 0; + } + for (i = 0; i < dicsiz; i++) { + j = prev[i]; + prev[i] = (j > dicsiz) ? j - dicsiz : NIL; + } + +内容は、想像がつくので詳細は省略しよう。単に以前のデータが移動したので、 +ハッシュ値を更新しているだけだ。しかし、これはなかなか無駄な処理だ。 + +以前、text[] は環状バッファだろうと予想したが予想がはずれたことがわかっ +た。環状バッファにしていれば、このハッシュの書き換えは不要にできただろ +うと思うのだが・・・ +# そのかわり、位置の大小比較が繁雑にならないので、これはこれで良いのか +# もしれない。どちらが優れているかは実験してみなければわからないだろう。 + +これで、一応は slide.c を網羅する事ができた。まだ不明な点は多いが、デ +バッガで実際の処理を追いかければまたわかることがあるだろう。 + +・・・しばし、休息・・・ + +さて、デバッガでと以前は考えていたのだが、あきらめるのはまだ早い(元気 +が出たらしい)、そもそも最初に「デバッガを使わずにどこまで解読できるか」っ +と冒頭に書いてたのにたった2回の通読でもうあきらめようとしていた。が、 +ここまで書いてきた本書を何度か読み返したが、まだまだ検討の余地はある。 + +まず、match_insert() の処理でわからなかった部分を解読しよう。実は、こ +れに関してはどうしてもわからず悩んでいたところ、Lha for UNIX のメンテ +ナである岡本さんに教えてもらうことができた(ありがとうございます)その内 +容を確認しつつ match_insert() を見ることにする。 + +まずは、復習だ。通常の状態に関しては match_insert() の解読は済んでいる。 +match_insert() は、text[pos] から始まる文字列を辞書から検索し、見つかっ +た位置と一致長を matchpos, matchlen に設定する処理だ。そして、ついでに +insert() で、text[pos] の位置をハッシュ配列に記録し、次回の検索に備え +ることもしている。 + +では、不明な部分はなんだったかというと too_flag[] まわりである。 +too_flag のフラグが立っていると。辞書検索の頼りとなるハッシュ値を変更 +している。この部分がまったく皆目検討がつかなかったのだ。これに関してソー +スを読み進めよう。以下ソースを再掲する。 + +static void match_insert() +{ + unsigned int scan_pos, scan_end, len; + unsigned char *a, *b; + unsigned int chain, off, h, max; + + max = maxmatch; /* MAXMATCH; */ + if (matchlen < THRESHOLD - 1) matchlen = THRESHOLD - 1; + matchpos = pos; + + off = 0; + for (h = hval; too_flag[h] && off < maxmatch - THRESHOLD; ) { + h = ((h << 5) ^ text[pos + (++off) + 2]) & (unsigned)(HSHSIZ - 1); + } + if (off == maxmatch - THRESHOLD) off = 0; + for (;;) { + chain = 0; + scan_pos = hash[h]; + scan_end = (pos > dicsiz) ? pos + off - dicsiz : off; + while (scan_pos > scan_end) { + chain++; + + if (text[scan_pos + matchlen - off] == text[pos + matchlen]) { + { + a = text + scan_pos - off; b = text + pos; + for (len = 0; len < max && *a++ == *b++; len++); + } + + if (len > matchlen) { + matchpos = scan_pos - off; + if ((matchlen = len) == max) { + break; + } + } + } + scan_pos = prev[scan_pos & (dicsiz - 1)]; + } + + if (chain >= LIMIT) + too_flag[h] = 1; + + if (matchlen > off + 2 || off == 0) + break; + max = off + 2; + off = 0; + h = hval; + } + prev[pos & (dicsiz - 1)] = hash[hval]; + hash[hval] = pos; +} + +まず、too_flag[] は、最初すべての要素が 0 である。そして、新たにファイ +ルを読むとき(update())も 0 に再初期化されるのだった。このフラグが立つ +条件はというと、この match_insert() の中だけである。その処理は + + if (chain >= LIMIT) + too_flag[h] = 1; + +この部分だけだ。chain が LIMIT以上になったら h (これは検索対象のハッシュ +値だ)に関して、フラグを立てる。chain は while ループ(これは文字列の照 +合を行う処理)のループ回数だ。h に関しての検索が LIMIT{256} 以上の場合 +に too_flag[h] のフラグが立っている。 + +while ループは一致文字列の一致長が最長一致長に達するか、辞書を最後まで +探索するまでループする。つまり、あるハッシュ h に関してそのチェーンが +256 以上のものに関しては、too_flag[h] が 1 になっている。 + +では、そのような h に関して、match_insert() がどのような処理になってい +るかを見る。まず初期化部分 + + max = maxmatch; /* MAXMATCH; */ + if (matchlen < THRESHOLD - 1) matchlen = THRESHOLD - 1; + matchpos = pos; + +これは、とりあえず無視。 + + off = 0; + for (h = hval; too_flag[h] && off < maxmatch - THRESHOLD; ) { + h = ((h << 5) ^ text[pos + (++off) + 2]) & (unsigned)(HSHSIZ - 1); + } + if (off == maxmatch - THRESHOLD) off = 0; + +通常 off は、0 なのだが、too_flag[h] が 1 であるものに関しては値が変わ +る。検索対象となる文字列 text[pos](のハッシュ値) hval に関して、 +too_flag[h] が立っていれば、(このハッシュのチェーンが 256 以上であるこ +とが事前にわかっていれば) + + h = ((h << 5) ^ text[pos + (++off) + 2]) & (unsigned)(HSHSIZ - 1); + +で、検索対象となるハッシュ値を変更している。このハッシュ値が示すのは元 +の検索対象文字列の 1 文字先だ。 + +---------------------------------------------------------------------------- + + |--- c --| + |--- b --| | + |-- a ---| | | + +-------------+--------+--------+ +text | | | | | | | | + +-------------+--------+--------+ + \ \ + pos pos+1(off=1) + +---------------------------------------------------------------------------- + +元の検索対象文字列が図の a だとすると、これを図の b にしている。初期化 +部のループは、もしこの b のハッシュチェーンに関して too_flag[h] がさら +に 1 であるならさらに 先の文字列をハッシュ値とするようになっている。 +(これは元の pos の 2 文字先を示す。図の c の部分だ) h は、pos+off から +の3文字のハッシュ値を示すものと言う事だ。 + +ただし、h があまりにも先の方を見るようなハメになれば(off が maxmatch - +THRESHOLD) off は 0 に再設定されるが、このとき h はそのままだ。この意 +味はまだわからないが、バグなのではないかと想像している(h = hval に再設 +定する必要があるだろう) + +では off = 1 だとして本処理を見ることにしよう。外側の for ループに関し +ては、while ループを2回実行するかどうかだけのものだった。なので、 +while ループ部だけを見てみよう。 + + chain = 0; + scan_pos = hash[h]; + scan_end = (pos > dicsiz) ? pos + off - dicsiz : off; + while (scan_pos > scan_end) { + chain++; + + if (text[scan_pos + matchlen - off] == text[pos + matchlen]) { + { + a = text + scan_pos - off; b = text + pos; + for (len = 0; len < max && *a++ == *b++; len++); + } + + if (len > matchlen) { + matchpos = scan_pos - off; + if ((matchlen = len) == max) { + break; + } + } + } + scan_pos = prev[scan_pos & (dicsiz - 1)]; + } + + if (chain >= LIMIT) + too_flag[h] = 1; + +scan_pos, scan_end に関しては検索開始位置と終了位置と言う事でもう良い +だろう。で、最初の if の条件に着目する。 + + if (text[scan_pos + matchlen - off] == text[pos + matchlen]) { + +これが真となる状態を図示しよう。 + +---------------------------------------------------------------------------- + + |-- c ---| + |-- a ---| |--- b --| + +---------------+--------+--------------------+--------+--------+ +text | | |x'| | | | |x | | | | + +---------------+--------+--------------------+--------+--------+ + ^ \ \ + scan_pos pos pos+1(off=1) + +---------------------------------------------------------------------------- + +まず、if 条件の左辺 + + text[scan_pos + matchlen - off] + +matchlen は、match_insert() に入る直前に 2 に初期化されている(最初は) +ので、照合するのは図の x' だ。 + +if 条件の右辺 + + text[pos + matchlen] + +これは、図の x の位置だ。x' == x ならば本格的に照合を開始する。 + + { + a = text + scan_pos - off; b = text + pos; + for (len = 0; len < max && *a++ == *b++; len++); + } + +ここで比較しているのは、図の a と b だ。b は、off がどのような場合でも +変わらないが、a は、off が大きければ大きい程左側を指す。off が例えば +3 であるときの場合も見てみよう。 + +---------------------------------------------------------------------------- + + |-- a ---| |--- b --|-- c ---| + +---------------+--------+--------------------+--------+--------+ +text | x'| | | | | | |x | | | | + +---------------+--------+--------------------+--------+--------+ + ^ \ \ + scan_pos pos pos+3(off=3) + +---------------------------------------------------------------------------- + +結局比較しているのは、pos からの文字列のハッシュ値を求めた場合と何も変 +わらない。off でいくら先を見ようとも比較するのは pos の位置だ。なぜこ +のようなことをするのだろうか?これは最初どうしてもわからなかったのだが、 +説明を受けて納得した。 + +これは単に効率(速度)のためということだ。もし、図の b に関して照合文字 +列の候補があまりにも多い場合(too_flag[h]=1)、ハッシュのチェーンを何度 +もたどる事になるので効率が悪い。しかし、辞書検索のキーを何文字か進める +事で、この可能性を減らす事ができる。少なくとも最悪の 256 よりはマシに +なるようなものを選んでいる。そうして、この while ループのループ回数を +減らしているのだ。どうせ探したいのは最長一致文字列なので先の方の文字列 +が一致しないと話にならないのだからこれは合理的だ。 + +これで、外側の for ループも納得だ。これは while ループをある条件でやり +直す処理だった。 + + if (matchlen > off + 2 || off == 0) + break; + +最長一致長が見つかるか、あるいは off が 0 であればさっさとこの処理は終 +るのだが、もし off を進めて照合を行っていたとして、最長一致文字列が見 +つからなかったとすると + + max = off + 2; + off = 0; + h = hval; + +という条件で照合をやり直す。これは元の文字列で照合をやり直すということ +だからつまりは、最悪のハッシュチェーンを仕方ないから辿り直そうと言う事 +だ。さらに、pos から pos+off+3 までの文字列が、辞書から見つからなかっ +たので、最大一致長を off + 2 として条件を緩めている(なぜこれが条件を緩 +める事になるかと言うと while ループは最大一致長の文字列が見つかったら +すぐに抜けるからだ)。 + +ところで、match_insert() の先の処理は以下の書き換えを行うともう少し見 +やすくなる。(と思う)。 + +o scan_beg という変数を用意し、これを scan_pos - off にする。 +o scan_end は、pos - dicsiz にする。 +o while 条件を while (scan_pos != NIL && scan_beg > scan_end) にする。 + +以下 + + unsigned int scan_pos = hash[h]; + int scan_beg = scan_pos - off; + int scan_end = pos - dicsiz; + + chain = 0; + while (scan_pos != NIL && scan_beg > scan_end) { + chain++; + + if (text[scan_beg + matchlen] == text[pos + matchlen]) { + { + unsigned char *a = &text[scan_beg]; + unsigned char *b = &text[pos]; + + for (len = 0; len < max && *a++ == *b++; len++); + } + + if (len > matchlen) { + matchpos = scan_beg; + if ((matchlen = len) == max) { + break; + } + } + } + scan_pos = prev[scan_pos & (dicsiz - 1)]; + scan_beg = scan_pos - off; + } + + if (chain >= LIMIT) + too_flag[h] = 1; + +---------------------------------------------------------------------------- + + |-- a ---| |--- b --| + +---------------+--------+--------------------+--------+--------+ +text | | x'| | | | | | |x | | | | + +---------------+--------+--------------------+--------+--------+ + ^ \ \ \ \ + | scan_beg scan_pos pos pos+off + scan_end + + |----| + scan_beg の有効範囲 + + |----------------- dicsiz ------------------| + +---------------------------------------------------------------------------- + +scan_beg, scan_end の範囲もわかりやすいし、hash[h] が NIL の場合の処理 +も明示的だ。この書き換えを行う場合、scan_beg が負の値になる可能性があ +る。元もとの処理では scan_end 等の変数を unsigned にしているので、これ +らを int にして while 条件で負の scan_beg をはじかなければならないこと +に注意。そうすると、scan_pos != NIL は必要なくなるのだがわかりやすさを +追求した。 + +これで match_insert() の解読は終りだ。match_insert() の処理とは以下の +通りだ。 + +---------------------------------------------------------------------------- + match_insert() は、text[pos] から始まる文字列に一致する文字列を辞書 + から検索し、見つかった位置と一致長を matchpos, matchlen に設定する。 + + もし、最長一致文字列が見つからなければ matchpos は、pos に設定され、 + matchlen は更新されない。(実は、matchpos = pos の情報は特に使われてない) + + 見つかった場合、matchlen は呼び出し前の matchlen よりも大きくなる。 + (呼び出し前では matchlen の意味は最低限一致しなくてはならない文字列 + 長で、照合条件の一つになっている) + + この関数の入力は + + matchlen + pos + + 出力は + + matchlen + matchpos + + といったところ。 + + さらに、insert() と同様の処理で、pos の位置をハッシュ配列に記録し、 + 次回の検索に備える。これはついでの処理。 +---------------------------------------------------------------------------- + +これを踏まえた上で処理内容を再読しよう。(E) 〜 (H) だ。 + + /* (E) */ + lastmatchlen = matchlen; lastmatchoffset = pos - matchpos - 1; + --matchlen; + + /* (F) */ /* (G) */ + get_next(); match_insert(); + if (matchlen > remainder) matchlen = remainder; + + /* (H) */ + if (matchlen > lastmatchlen || lastmatchlen < THRESHOLD) { + /* (H.1) */ + encode_set.output(text[pos - 1], 0); + count++; + } else { + +(H) の条件とは何なのかを見る。この条件が真なら、文字列をそのまま出力す +るのだが、素直に slide 辞書法の処理を考えればこの条件は「辞書から見つ +からなかった場合」となる。が、実際にはもう少し複雑だ。 + + /* (H) */ + if (matchlen > lastmatchlen || lastmatchlen < THRESHOLD) { + +matchlen は、pos の位置の文字列が見つかった辞書上の長さ +lastmatchlen は、pos-1 の位置の文字列が見つかった辞書上の長さ + +であるとすると、この条件は、「pos の位置で見つかった長さが、pos-1 の位 +置で見つかった長さよりも長ければ」っとなる。 + +これはつまり、pos-1 と pos のニ箇所に関して辞書を検索して、より長くマッ +チする方を選ぼうとしているわけだ。matchlen の方が長いなら 1 つ前 +(pos-1)の文字はそのまま出力し、次のループに移る(もし、次の文字が +さらに長くマッチするなら。またそのまま出力される) + +この条件で「見つからなかった場合」というのはどう表されているかを考える。 +もし、pos の文字列が辞書になければ pos - 1 の文字列は、どうすべきかと +いうと「pos-1 の文字列が見つかってなければ。そのまま出力。辞書にあった +なら のペアを出力」っとならなければな +らない。 + +lastmatchlen は、初期状態では THRESHOLD - 1 であったので、見つからなかっ +たという条件は (H) の右側の条件 lastmatchlen < THRESHOLD でまず表され +ている。 + +では、例えば lastmatchlen が 5 であったとしよう。このとき (E) の処理で +matchlen は lastmatchlen - 1 つまり、4 に設定される。そして、match_insert() +で次の文字列がもし辞書から見つからなければ matchlen は更新されないので + matchlen < lastmatchlen +となる。このような条件(前回見つかり、今回見つからない)場合に限り、(H.2) +の処理が実行されるようになっている。では、(H.2) の処理を追いかけよう。 + +まず、この状態を図示する。 + +---------------------------------------------------------------------------- + + lastmatchlen lastmatchlen + |-- --| |-- --| + +---------------+--------------+--------------+--------------+--+ +text | | | | | | | | | | | | | | + +---------------+--------------+--------------+--------------+--+ + ^ | \ \ + matchpos pos-1 pos pos2 + + |--------------------------| + lastmatchoffset + +---------------------------------------------------------------------------- + + + /* (H.2) */ + encode_set.output(lastmatchlen + (UCHAR_MAX + 1 - THRESHOLD), + (lastmatchoffset) & (dicsiz-1) ); + --lastmatchlen; + + while (--lastmatchlen > 0) { + get_next(); insert(); + count++; + } + get_next(); + matchlen = THRESHOLD - 1; + match_insert(); + if (matchlen > remainder) matchlen = remainder; + } + +まず、<長さ, 位置> のペアを出力する。これはいいだろう。出力する「位置」 +は0 なら 1 文字前を表すので、実際のオフセット pos - 1 - matchpos より +も 1 小さい値になっていることに注意しておこう。 + +そして、lastmatchlen は 1 引かれる。この場合例えば 4 になる。したがっ +て、次のループでは 3 文字 pos が先送りされる(4 ではない)。pos は既に 1 +文字先に進んでいるので、最初に 1 引くのはこのことを考慮している。while +ループが終った後はpos の位置は実際に出力した文字列の最後の文字 pos2-1 +を指していることになる。 + +そして、get_next() でまた 1 文字先に送る。pos は図の pos2 の位置になる。 +そして、match_insert() で、この位置の文字列を照合する。matchlen は、 +THRESHOLD - 1 に初期化されるので pos2 の位置の文字列が辞書から見つから +なければ matchlen は、THRESHOLD-1 だ。これは初期状態と同じ状態を示すの +で、次のループの処理も想像がつく((H) の条件の右側 lastmatchlen < THRESHOLD +が有効になる)。では、見つかった場合はというと、次のループでさらに先 +pos2+1 の照合結果と比較されるのでこの処理も想像がつく。 + +最初、どうにもこの処理内容が理解できなかったのだが「現在の文字列と、次 +の文字列のそれぞれで辞書を検索し、より長く見つかった方を使う」という最 +適化を行っている事がわかってしまった後は解読は簡単だった。(実はこの事 +実も教えてもらった事だ。全然ダメじゃん) + +さて、これで一通りの解析は済んだわけだが、ここまでの解析内容を読み直し +てみると、以下の点がまだひっかかる。 + +1. ハッシュ関数は最適なのか?特に HSHSIZ{2^15} は最適なのか? +2. too_flag[] は、実際に照合を行いループがLIMITを越えた場合に + 設定される。しかし、ハッシュのチェーンを作る際にチェーンの + 個数をあらかじめ数えておけば一度の探索すらも行われず。より + 早く処理されないだろうか? + +現状、1, 2 とも実施してみたところ特に速度の改善は見られなかった。特に +1 は、微妙なところがありほとんどの書き換えは性能を悪くするだけだった。 +なかなか興味深いものがある。 + +これは今後の課題としていずれまた検証しよう。そろそろ slide.c も飽きて +きたのでひとまずはこれで終りにしたい。 + + +bit 入出力ルーチン (crcio.c) +--------------------------- + +これから Huffman 法の解読に移るのだが、その前準備として bit 入出力ルー +チンの解読を行う。Huffman 法の実装では必ず bit 入出力処理が必要になる。 +LHa for UNIX ももちろん例外ではなく、Huffman 法の実装を解読するにあた +りこの部分の処理内容ははっきりさせておいた方が良いと考えたのだ。 + +LHa for UNIX version 1.14i では bit 入出力ルーチンは crcio.c で定義さ +れている。(このようなファイル名に存在するのは意外な事だ。最近の LHa +for UNIX では、私が bitio.c というファイルを設け、bit 入出力ルーチンは +そこに切り出した) + +crcio.c のうち bit 入出力ルーチンは fillbuf(), getbits(), putcode(), +putbits(), init_getbits(), init_putbits() の 6 関数だ。 + +まず、初期化用の init_getbits(), init_putbits() を見よう。 + +void +init_getbits( /* void */ ) +{ + bitbuf = 0; + subbitbuf = 0; + bitcount = 0; + fillbuf(2 * CHAR_BIT); +#ifdef EUC + putc_euc_cache = EOF; +#endif +} + +void +init_putbits( /* void */ ) +{ + bitcount = CHAR_BIT; + subbitbuf = 0; + getc_euc_cache = EOF; +} + +それぞれ bit 入力、bit 出力を行うための初期化処理だ。CHAR_BIT というの +は 8 で、char 型の bit サイズを表しているらしい。詳細はわからないが初期 +状態はとにかくこれだ。ここで使用されている変数は、 + +static unsigned char subbitbuf, bitcount; + +が、crcio.c で定義されており、 + +EXTERN unsigned short bitbuf; + +が、lha.h で定義されている(EUC なんたらは本質ではない無視しよう)。グロー +バル変数と言うのは忌むべきものだが、とにかく使用されている変数と初期値 +を確認したので次に移ろう。init_getbits() で、早速 fillbuf() が呼ばれて +いる。この処理内容を見る。 + +void +fillbuf(n) /* Shift bitbuf n bits left, read n bits */ + unsigned char n; +{ + /* (A) */ + while (n > bitcount) { + n -= bitcount; + /* (B) */ + bitbuf = (bitbuf << bitcount) + (subbitbuf >> (CHAR_BIT - bitcount)); + /* (C) */ + if (compsize != 0) { + compsize--; + subbitbuf = (unsigned char) getc(infile); + } + else + subbitbuf = 0; + bitcount = CHAR_BIT; + } + /* (D) */ + bitcount -= n; + bitbuf = (bitbuf << n) + (subbitbuf >> (CHAR_BIT - n)); + subbitbuf <<= n; +} + +まず、初期状態として + + bitbuf = 0; + subbitbuf = 0; + bitcount = 0; + +であり、fillbuf の引数 n には 2 * CHAR_BIT が与えられたのだった。いき +なり while 条件を満たすのでループ部の解析を行わなくてはならなくなるが、 +ひとまずこれを無視して最後の 3 行 (D) に着目する。条件は少ない方が良い +のだ。 + + /* (D) */ + bitcount -= n; + bitbuf = (bitbuf << n) + (subbitbuf >> (CHAR_BIT - n)); + subbitbuf <<= n; + +bitbuf << n, subbitbuf << n されているので、bitbuf, subbitbuf を n ビッ +ト左にずらす処理のようだ。さらに bitbuf には、subbitbuf を n ビットず +らしたときに溢れた部分を bitbuf にセットしている。っと、 + + (subbitbuf >> (CHAR_BIT - n)) + +の部分を軽く説明したが、図示して確認しておこう。 + +subbitbuf は unsigned char なので 8 bit の変数だ。 + +---------------------------------------------------------------------------- + 7 6 5 4 3 2 1 0 + +--+--+--+--+--+--+--+--+ + subbitbuf | | + +--+--+--+--+--+--+--+--+ + <-- n --> +---------------------------------------------------------------------------- + +n が例えば 3 の場合、CHAR_BIT - n は、5 だから subbitbuf を 5 ビット右 +にずらした値を取っている。つまり、図の 7, 6, 5 ビット目が一番右に来る +ようになっており、この値を bitbuf に足している。(C言語では、unsigned +な変数を右にシフトすると上位ビットには 0 が入る) + +fillbuf() の後半 3 行(いや、後半2行か)は。結局 bitbuf と subbitbuf を +一つの bitbuf とみなして n ビット左にずらしていることがわかる。 + +---------------------------------------------------------------------------- +<ビットバッファ全体図 (予想)> + + 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + bitbuf | | x y z| + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + \ <-- n -> + subbitbuf + <-------------- bitcount -------------> + +---------------------------------------------------------------------------- + +このとき、当然図の x, y, z の部分(n = 3 は例としての値だ)が空く事になる。 +bitcount という変数が n 引かれていたが、これは bit バッファ全体の有効 +なビット数を表しているのではないかと予想しておく。すなわち図の状態なら +21 だ。while ループは(関数名から)この空き部分を埋める処理なのではない +かと適当に予想できる。では、while ループを見よう。もう一度初期値を確認 +し、最初に行われる処理内容を見よう。 + +最初、 + + bitbuf = 0; + subbitbuf = 0; + bitcount = 0; + +であるから、bitバッファは空っぽだ。当然 fillbuf(2 * CHAR_BIT) されると +while 条件を満たす。きっと 16 bit だけ bitバッファが補充されるはず(つ +まり、bitbuf いっぱい、subbitbuf 空)だ。 + + /* (A) */ + while (n > bitcount) { + n -= bitcount; + +で、ビットバッファが保持する bit 数以上を要求されたので、ループに入る。 +n -= bitcount で、本当に足りない部分が何ビットなのかを得ている。ここで +は 16 だ。次の行 + + /* (B) */ + bitbuf = (bitbuf << bitcount) + (subbitbuf >> (CHAR_BIT - bitcount)); + +これは先程も出て来た処理だ。ビットバッファ全体を bitcount 分左にずらし +ている(ただし、まだ subbitbuf はずらされていない)。この時点で予想が少 +し覆された。8 - bitcount で subbitbuf をずらしているから bitcount は最 +大 8 の値しか持たないだろうということだ。どういうことか、考えてみる・・・ +考えてもわからなかったので次に進もう。 + + /* (C) */ + if (compsize != 0) { + compsize--; + subbitbuf = (unsigned char) getc(infile); + } + else + subbitbuf = 0; + bitcount = CHAR_BIT; + +compsize というのが出て来たが、この値がどうあろうとも subbitbuf は8 ビッ +ト埋められ。bitcount は 8 に設定されている。わかった bitcount は、 +subbitbuf に保持する bit 数だ。図を訂正しよう。 + +---------------------------------------------------------------------------- +<ビットバッファ全体図> + + 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + bitbuf | | x y z| + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + / <-- n -> + subbitbuf + <--------> + bitcount + +---------------------------------------------------------------------------- + +この図を踏まえてもう一度初期状態での処理内容を追いかける。 + +まず、(A) で、subbitbuf は空なので、bitcount は 0 だ。要求した bit 数 +n{16} より小さいのでループに入る。n は 16 のままだ。 + +(B) で、subbitbuf に残っている bit を bitbuf にずらしている。今はまだ +空なのでbitbuf はここでもまだ空だ。 + +(C) で、ファイルからデータを8 ビット読む(compsize は常に0ではないと考え +る)。bitcount は 8 になる。この時点で bitバッファ全体は subbitbuf だけ +値が入った状態になる。 + +次のループに移ろう。(A) で、subbitbuf はいっぱいであるが要求した n{16} +よりは小さいので、まだループは続く。n はここで 8 になる。 + +(B) で、subbitbuf に残っている bit (8 bit だ)を bitbuf にずらしている。 +今度は subbitbuf 全体が bitbuf に移っているのと同じだ。(つまり、bitbuf += subbitbuf) + +(C) で、また subbitbuf は 8 bit 補充される。 + +(A) で、n{8} > bitcount{8} は偽なのでループが終る。 + +(D) で、subbitbuf に残っている bit はすべて bitbuf に移る。bitbuf は 16 +bit いっぱいになる。bitcount は 0 だ。 + +この処理結果から fillbuf(n) は、bitbuf に n ビット読み込む処理だと言え +る。引数に指定できる n が最大 16 ビットであることにも気づいて良いだろ +う。処理内容を確認してみればわかる。 + +ここで、subbitbuf の用途に気づいた。ファイルからの読み込みが 8 ビット +単位でしかできないので、それを補うための保存用バッファであろう。例えば +1 ビットだけ bitbuf を fill したければ subbitbuf に 7 bit 残し、1 bit +だけ bitbuf に設定される(確認してみればわかる) + +fillbuf() がわかったので、それを利用している getbits() の内容を確認し +よう。 + +unsigned short +getbits(n) + unsigned char n; +{ + unsigned short x; + + x = bitbuf >> (2 * CHAR_BIT - n); + fillbuf(n); + return x; +} + + x = bitbuf >> (2 * CHAR_BIT - n); + +は、3 度も出て来たので + + buf >> (sizeof(buf)*8 - n) + +を buf の上位 n ビットを得る式だとしてマクロにしても良いだろう。(が、 +良い名前が思い付かないのでそうはしない)。とにかく、bitbuf の上位 n ビット +を下位 n ビットとして x に代入している。その後で、 + + fillbuf(n); + +している。n bit を x に渡したので bitbuf から上位 n ビットを捨てて、n +ビット補充する。ここで、bitbuf は常にいっぱいの状態になっていることが +わかる。(ファイルの末尾付近の場合、正確に bitbuf に何ビット残っている +かが判断できないが、種明かしをするとこのことは LHa の処理内容にとって +はどうでもいいことだ。getbits() は decode 処理で使われるのだが、decode +処理は何ビットの情報を decode する必要があるかを他の情報からあらかじめ +得ている) + +次に移ろう今度は putcode() だ。put の場合まずは、init_putbits() で +初期化が行われている。その値は以下だ。 + + bitcount = CHAR_BIT; + subbitbuf = 0; + getc_euc_cache = EOF; + +getc_euc_cache は無視だ。bitcount と subbitbuf の値が設定され、bitbuf +は利用されない。先程とは違い subbitbuf が空なのにbitcount が 8 なので、 +bitcount の使われ方が多少異なるようだ。get の場合は、bitcount は、 +subbitbuf に保持する bit 数だったが今度は subbitbuf の空き bit 数だろ +うと予想しておこう。 + +そして、putcode(n, x) を見る。実はソースを見るとわかるのだが、もう一つ +の出力ルーチン putbits() は、putcode() の呼び出しに書き換え可能だ。 +putbits() は、 + +void +putbits(n, x) /* Write rightmost n bits of x */ + unsigned char n; + unsigned short x; +{ + x <<= USHRT_BIT - n; + putcode(n, x); +} + +っと書き換えられるのだ。なので、putcode() の内容を先に確認するわけだ。 + +void +putcode(n, x) /* Write rightmost n bits of x */ + unsigned char n; + unsigned short x; +{ + /* (A) */ + while (n >= bitcount) { + n -= bitcount; + /* (B) */ + subbitbuf += x >> (USHRT_BIT - bitcount); + x <<= bitcount; + /* (C) */ + if (compsize < origsize) { + if (fwrite(&subbitbuf, 1, 1, outfile) == 0) { + /* fileerror(WTERR, outfile); */ + fatal_error("Write error in crcio.c(putcode)\n"); + /* exit(errno); */ + } + compsize++; + } + else + unpackable = 1; + subbitbuf = 0; + bitcount = CHAR_BIT; + } + /* (D) */ + subbitbuf += x >> (USHRT_BIT - bitcount); + bitcount -= n; +} + +処理内容が fillbuf() のときと似ている。まずは、先程と同様に while 条件 +を無視して考えてみる。(D) だ。 + + /* (D) */ + subbitbuf += x >> (USHRT_BIT - bitcount); + bitcount -= n; + +この式はもう 4 度目だ。まず、x の上位 bitcount ビットを得て、subbitbuf +に足している。bitcount は、先程 subbitbuf の空きであろうと予想したが、 +n 引かれているので、埋めた分空きが減っているわけだ。予想は当たっている +だろう。この時点でこの関数が x の上位ビットを利用することがわかる。コ +メントに rightmost n bits of x と書かれているが惑わされてはいけない。 +多くの場合、コメントはせいぜいヒントとしての情報でしかない。信用しては +いけないものなのだ。(コメントはあまりデバッグされない。コメントが詳し +ければ詳しい程コメントはエンバグしやすい。疑ってかかろう。これは本書に +も言える。すべてを鵜のみにしてはいけないのだ) + +では、処理内容に移る。まずは (A) + + /* (A) */ + while (n >= bitcount) { + n -= bitcount; + +subbitbuf の空きが n 以下であればループに入る。subbitbuf 一つではn ビッ +ト全部は賄えないからループで小刻みに処理しようということだろう(もう全 +体の処理内容の予想はついている) +n から bitcount 引いているので、n ビットのうちこれから bitcount 分は +処理されることをここでさっさと記録して次のループに備えている。 + + /* (B) */ + subbitbuf += x >> (USHRT_BIT - bitcount); + x <<= bitcount; + +x の上位 bitcount ビットを subbitbuf に足している。subbitbuf の空きが +これで埋まった。subbitbuf はもういっぱいだ。x を bitcount シフトするこ +とで subbitbuf に渡した x の上位ビットを捨てている。 + + /* (C) */ + if (compsize < origsize) { + if (fwrite(&subbitbuf, 1, 1, outfile) == 0) { + /* fileerror(WTERR, outfile); */ + fatal_error("Write error in crcio.c(putcode)\n"); + /* exit(errno); */ + } + compsize++; + } + else + unpackable = 1; + subbitbuf = 0; + bitcount = CHAR_BIT; + +compsize は無視しても良い。処理の本質ではないからだが、すぐにわかるので +一応説明すると、 + if (compsize < origsize) { + ... + else + unpackable = 1; +で、圧縮ファイルサイズが元のファイルサイズを上回ったときに +処理を終るようになっている(unpackable = 1 して、他の箇所でこの変数を監視する。 +unpackable == 1 なら処理を中断する) + +とにかく (C) の時点では必ず subbitbuf がいっぱいになるので 1 バイトを +ファイルに書き出している。その後、subbitbuf = 0, bitcount = 8 として +subbitbuf を空けて次のループに備えている。 + +もういいだろう。putcode() は、論理的には x のうち上位 n ビットを出力す +る処理だ。引数 n の上限が x の最大ビットサイズ 16 になるのは説明するま +でもないだろう。 + +putcode() は実装として、subbitbuf と x を一つに繋げて n bit 左にずらし +ている処理だと考えても良い。そうして、subbitbuf がいっぱいになったらそ +の都度(1 バイトずつ)ファイルに書き出すのだ。 + +---------------------------------------------------------------------------- +<ビットバッファ全体図> + + <--- 左にずらす + + 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |* * * |x y z | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + / / <-n-> + subbitbuf x + <--------> + bitcount + +---------------------------------------------------------------------------- + +putbits() も見よう。先程 putcode() の呼び出しに書き換えたコードを見ると +すぐわかるが、 + + x <<= USHRT_BIT - n; + putcode(n, x); + +最初の式で、x の下位 n ビットを x の上位 n ビットにしている。 +そうして、putcode() を呼び出しているので、putbits(n, x) は、x +の下位 n ビットを出力する処理だ。 + +以上でビット入出力ルーチンは終りだ。出力に関して一つ捕捉しておくと +putcode(), putbits() では最後の最後で subbitbuf に情報が残ったままファ +イルに書き出されない状態になる。これを吐き出すために利用者は + + putcode(7, 0) + +を行う必要がある。 + +まとめよう + +---------------------------------------------------------------------------- +fillbuf(n) + bitbuf から上位 n ビットを捨てて、下位 n ビットをファイルから読み込 + み埋める。 + +getbits(n) + bitbuf の上位 n ビットを下位 n ビットとして返す。bitbuf は n ビット + 補充される。 + +putcode(n, x) + x の上位 n ビットをファイルに出力する。最後の出力時は putcode(7, 0) + する必要がある。 + +putbits(n, x) + x の下位 n ビットをファイルに出力する。最後の出力時は putcode(7, 0) + する必要がある。 + +init_getbits() + 入力処理の初期化 + +init_putbits() + 出力処理の初期化 +---------------------------------------------------------------------------- + +読み込みに関して、bitbuf のサイズが 16 ビットで常にその状態が保持され +ているのは LHa にとって重要な事だ。decode 処理では直接 bitbuf を参照す +る箇所がある。 + +Huffman 法 (huf.c) +------------------ + +LHa for UNIX では、静的 Huffman 法として、shuf.c、動的 Huffman 法とし +て dhuf.c があるらしいが、これらに関しては触れない。LHa では、これらは +過去の版のアーカイブを解凍できるように decode のみサポートしているよう +だ。そこで、まずは -lh4-, -lh5-, -lh6-, -lh7- で利用されている huf.c +の解析を中心に行うこととしたい。 + +ところで、本書では Huffman 法がどういったものかは予備知識として既に知っ +ているものとするが、いちおう概要を簡単に説明しておこう。 + +以下の内容のテキストファイルがあったとする。 + + abcabcaba + +このテキストは 9 バイトあるわけだが、このファイルで使われている文字は3 +種類しかない、a, b, c だ。だからこのファイルだけに関して言えば 1 文字 +は 2 ビットあれば表現可能である。例えば各文字に対して以下のビットを +割り当てたとすると + + 文字 ビット表現 + a 00 + b 01 + c 10 + +先のテキストファイルの内容 abcabcaba は、18ビットあれば表現可能となる。 + +さらに、出現頻度の高い文字を少ないビット数で表現し、まれにしか現れない +文字を長いビット数で表すようにすればよりビット数を少なくできる。例えば + + 文字 ビット表現 + a 0 + b 10 + c 11 + +であるとすると a は 4回、bは3回、cは2回現れるので、全体は 4 + 2*3 + +2*2 = 14 ビットで表現できることになる。これが Huffman 法の圧縮原理であ +る。このように Huffman 法では文字をビット単位で扱うためビット入出力ルー +チンを先に解読したわけだ。また、符号化の際はあらかじめ各文字の出現頻度 +を求めておく必要があり、復号化の際はどのビット列がどの文字に対応するか +をあらかじめ知る必要がある。 + +文字毎にビット長のばらつきがあるような可変長符号には以下の条件がある。 + + ある符号のビットパターンは、他の符号のビットパターンの開始にはなら + ない。 + +というものだ。これを「語頭条件」と言うらしい。例えば、先の例では a に +0 を割り当てたので他の文字は必ず 1 から始まるようになっている。この条 +件を満たさなければならない理由はちょっと考えればわかる。仮に以下の間違っ +た割当を行ったとする。 + + 文字 ビット表現 + a 0 + b 10 + c 01 + +これだと、ビットパターン 010 が ab なのか ca なのか曖昧になるのがわか +るだろう。 + +文字に対応する語頭条件を満たす(最適な)ビット列を求める方法、それがハフ +マン法だ。ハフマン法ではハフマン木という木構造を構築するのだが、そのア +ルゴリズムは以下のとおりだ。 + +まず、圧縮対象であるテキストに関して各文字の出現回数を数える。例えば +abcabcaba というテキストでは、a は 4回、bは3回、cは2回なので、 + + 4 3 2 + | | | + a b c + +となる。次に、出現回数の低いもの同士を一つの節に束ねる。この節は 3+2=5 +という出現回数を持つものと考える。 + + 4 5 + | / \ + a b c + +以降さらに出現回数の低いもの同士を一つの節に束ねる操作を繰り返す。この +例では、もう一度束ねれば終りだ。 + + 9 + /\ + / \ + / / \ + a b c + +ここで、木の左側が 0 右側が 1 であるとすると。a は根から左に1つ進むだ +けなので 0。b は、右(1)→左(0) なので、10。c は右(1)→右(1) なので、11 +となる。実際の符号化の際は文字からビット列を求めるので葉から根にむかっ +て逆順に辿ることになる。また、復号の際は入力のビット列に沿ってこの木を +根から辿ることで対応する文字を求める(なので圧縮文にはこの木構造が一緒 +に情報として格納されることになる)。 + +このようなハフマン木を作成する箇所があるかどうかを探してみたところ +maketree.c:make_tree() が見つかった。これは「C言語による最新アルゴリズ +ム辞典」(奥村晴彦著、技術評論社)に載っているものとほとんど同じだ。では、 +この関数の解読から始めよう(今回の解析はボトムアップ式に行うことにしよ +うと思う。というのもデータ構造から攻めようにもグローバル変数がたくさん +出て来るし、処理順に追っても正直よくわからなかったからだ) + +この関数のあるファイル maketree.c で使用しているデータ構造は以下だ。 + +static short n, heapsize, heap[NC + 1]; +static unsigned short *freq, *sort; +static unsigned char *len; +static unsigned short len_cnt[17]; + +make_tree() は以下。 + +short +make_tree(nparm, freqparm, lenparm, codeparm) +/* make tree, calculate len[], return root */ + int nparm; + unsigned short freqparm[]; + unsigned char lenparm[]; + unsigned short codeparm[]; +{ + short i, j, k, avail; + + /* (A) */ + n = nparm; + freq = freqparm; + len = lenparm; + avail = n; + /* (B) */ + heapsize = 0; + heap[1] = 0; + for (i = 0; i < n; i++) { + len[i] = 0; + if (freq[i]) + heap[++heapsize] = i; + } + /* (C) */ + if (heapsize < 2) { + codeparm[heap[1]] = 0; + return heap[1]; + } + /* (D) */ + for (i = heapsize / 2; i >= 1; i--) + downheap(i); /* make priority queue */ + /* (E) */ + sort = codeparm; + do { /* while queue has at least two entries */ + i = heap[1]; /* take out least-freq entry */ + if (i < n) + *sort++ = i; + heap[1] = heap[heapsize--]; + downheap(1); + j = heap[1]; /* next least-freq entry */ + if (j < n) + *sort++ = j; + k = avail++; /* generate new node */ + freq[k] = freq[i] + freq[j]; + heap[1] = k; + downheap(1); /* put into queue */ + left[k] = i; + right[k] = j; + } while (heapsize > 1); + /* (F) */ + sort = codeparm; + make_len(k); + make_code(nparm, lenparm, codeparm); + return k; /* return root */ +} + +この関数の引数に、nparm, freqparm, lenparm, codeparm というのがある。 +これがなんなのかいきなりではわからないだろう。実は私にもわからない。今 +回の解析で特殊なのは、処理内容については私は(アルゴリズム辞典で)知って +いることだ。強引に無視しても処理内容から想像がつくだろうことを期待して +いる。 + +とりあえず、冒頭の初期化部分 (A) で + + /* (A) */ + n = nparm; + freq = freqparm; + len = lenparm; + avail = n; + +としている。引数で受けた入力をこのファイルの static 変数にセットし、他 +のルーチンとデータ共有しているようだ。avail は後で説明しよう。 + + /* (B) */ + heapsize = 0; + heap[1] = 0; + for (i = 0; i < n; i++) { + len[i] = 0; + if (freq[i]) + heap[++heapsize] = i; + } + +ここで、heap[] を初期化している。heapsize は、heap の要素数となる。こ +の処理は優先待ち行列 heap[] を作る部分なのだが、なぜ優先待ち行列が必要 +なのかというと先の説明で Huffman 法のアルゴリズムに出現回数の少ない順 +に葉を節に束ねるという部分があった。優先待ち行列はこのためのものだ。と +りあえず、heap[] の要素は圧縮する文字であるということだけを書いておく。 +詳細はすぐ後で出るだろう。freq[i] (すなわち引数 freqparm) は、文字 i +の出現回数を表している。だから、n (nparm)は、符号化するモデル上の文字 +の種類の数を表していることになる。たとえば通常のファイルなら nparm は +256 だろう。まあ、結局は freq[] の要素数だ。 + + nparm 最大要素数 + freqparm[0:nparm] 添字が文字で、その要素が出現回数 + +注意すべきなのは heap[] の要素は 1 以降を使用していることだろう。 +heap[0] は使われない。 + + /* (C) */ + if (heapsize < 2) { + codeparm[heap[1]] = 0; + return heap[1]; + } + +これは、heapsize が 0 か 1 の場合を表している。符号化する文字の種類が +0 または 1 つしかない場合だ。heap[1] は、(B) で 0 に初期化していたので、 +codeparm[0] = 0 として、0 を返している。これは特殊な条件を示している。 +簡単に想像がつくことだが、出現する文字の種類が1種類しかない場合、ハフ +マン木を作る必要がない。LHa ではこのような場合に特殊な構造あるいは方法 +を用いていることが想像できる。 + + /* (D) */ + for (i = heapsize / 2; i >= 1; i--) + downheap(i); /* make priority queue */ + +優先待ち行列 heap[] を構築する。downheap() がなんなのか、これがどういっ +た処理なのかの詳細は省略しよう。アルゴリズム辞典の「ヒープソート」の項 +に詳しいが、heap[] は木構造を示しており、この木構造(2分木)には「親は子 +より優先順位が同じか高い」という規則だけがある。この木構造は、 + + 1. heap[n] の左の子は heap[2*n]、右の子は heap[2*n + 1] + +で、表現されており、このような半順序木 (partial ordered tree) には、以 +下の特徴がある + + 2. heap[n] の親は heap[n/2] + 3. heap[1.. heapsize/2] は節で、heap[heapsize/2 .. heapsize] は葉 + +この heap[] が最初ばらばらに要素が格納されているとき、葉に近い節から順 +に downheap() という操作を行う((D)の処理)と、ヒープを構築できるように +なっている。downheap(i) は、節 heap[i] とその子 heap[2*i], heap[2*i+1] +で要素を比較し、子の優先順位の方が高ければ位置を交換する、という処理を +葉に向かって繰り返す関数だ。以下、参考までに maketree.c:downheap() の +内容を示す。 + +static void +downheap(i) +/* priority queue; send i-th entry down heap */ + int i; +{ + short j, k; + + k = heap[i]; + while ((j = 2 * i) <= heapsize) { + if (j < heapsize && freq[heap[j]] > freq[heap[j + 1]]) + j++; + if (freq[k] <= freq[heap[j]]) + break; + heap[i] = heap[j]; + i = j; + } + heap[i] = k; +} + +とにかく (D) により、最も優先順位の高い(出現回数の少ない)要素が +heap[1] に来るようになる。この優先待ち行列はなかなか面白い(と私は思っ +た)のでいろいろと調べてみるのもよいだろう。 + +さて、続けよう (E) だ。 + + /* (E) */ + sort = codeparm; + do { /* while queue has at least two entries */ + i = heap[1]; /* take out least-freq entry */ + if (i < n) + *sort++ = i; + heap[1] = heap[heapsize--]; + downheap(1); + j = heap[1]; /* next least-freq entry */ + if (j < n) + *sort++ = j; + k = avail++; /* generate new node */ + freq[k] = freq[i] + freq[j]; + heap[1] = k; + downheap(1); /* put into queue */ + left[k] = i; + right[k] = j; + } while (heapsize > 1); + +最初に、 + + i = heap[1]; /* take out least-freq entry */ + if (i < n) + *sort++ = i; + +で、最も出現回数の少ない文字を取って来る。if の部分はひとまず無視しよう。 + + heap[1] = heap[heapsize--]; + downheap(1); + +で、heap[] の最後尾の要素を先頭に持って来て downheap(1) を行っている。 +こうすると、ヒープが再構築され「親は子より優先順位が同じか高い」という +条件をまた満たすようになる。heap[] の要素は1つ減っている。結局、ここま +での処理は論理的には「優先待ち行列から優先度の高い要素を1つ取り出す」 +と言う処理だ。 + + j = heap[1]; /* next least-freq entry */ + if (j < n) + *sort++ = j; + +続けて、2番目に優先度の高い要素を取り出す。また、if は無視しておこう。 + + k = avail++; /* generate new node */ + freq[k] = freq[i] + freq[j]; + heap[1] = k; + downheap(1); /* put into queue */ + +avail は最初 n (nparm)だった。freq[] は、文字の出現回数なので最初文字 +の種類数分(nparm)の要素しかないがハフマン木の節の出現回数(というか優先 +順位)を格納するために freq[] は、nparm * 2 - 1 の格納域が必要となるこ +とがわかる。(葉が n 個ある 2 分木には、節が n - 1 個ある) + +---------------------------------------------------------------------------- + + +-----------------------+-----------------------+ +freq | | | + +-----------------------+-----------------------+ + 0 nparm nparm * 2 - 1 + + |-----------------------|-----------------------| + 文字(ハフマン木の葉) ハフマン木の節の優先順位 + の優先順位 + + + 例: + . ... freq[4] + / \ + . \ ... freq[3] + /\ \ + a b c ... freq[0 .. 2] + +---------------------------------------------------------------------------- + +ここまでで、出現回数の低い2つの要素を取り出しその出現回数の和を +freq[k] に設定することになる。出現回数の和は heap[] に再設定され、 +downheap(1) で、優先待ち行列をまた再構築する。これは「葉を束ね節を作る」 +というハフマン木の構築アルゴリズムの実装だ。新しく作成した節が k でそ +の最大値が最終的に avail-1 である。 + +最後に + + left[k] = i; + right[k] = j; + +で、ハフマン木を構造 left[]、right[] で作成する。 + +この (E) を抽象度の高いコードで示してみよう。ハフマン木は + struct huffman { + ... + } huff; + +で表し、ハフマン木の1つの節は、 + make_huff(huff, node, left, right) +で作成できるとする。また、優先順位つき待ち行列を heap とし、heap から +要素を取り出す処理、要素を格納する処理をそれぞれ仮に + n = delete_pqueue(heap) + insert_pqueue(heap, n) +とすると、 + + /* (E) */ + do { + left = delete_pqueue(heap); + right = delete_pqueue(heap); + + node = avail++; + freq[node] = freq[left] + freq[right]; + + insert_pqueue(heap, freq[node]); + + make_huff(&huff, node, left, right); + } while (heapsize > 1); + +こんなところだろうか。元の処理ではヒープからの要素の取り出しと挿入で無 +駄な処理を無くすために少し複雑になっている。(そしてデータ構造に依存し +た処理になっている)。どちらがよりすぐれているかは微妙な所だ。私は多少 +の処理の無駄も目をつぶってよりわかりやすい方を優先するのが好きなのだが。 +これはちょっと考えさせられるところだ。 + +ループを抜けた所で k (avail - 1) は、ハフマン木の根を表している。 +left[0:avail], right[0:avail] でハフマン木を表し、そのうち +left[nparm...avail], right[nparm...avail] が節の子を示している。 +left[0...nparm], right[0...nparm] は使われないようだ。 + +---------------------------------------------------------------------------- + 例: + . -- k (= avail-1) + / \ + left[k] -- . \ + /\ \ + a b c -- right[k] + | \ + | right[left[k]] + left[left[k]] + +---------------------------------------------------------------------------- + +これで、ハフマン木の構築は終りなのだが、ハフマン法の符号化ではハフマン +木の葉から根に向かって木を辿る必要があるはずなのに、left[]、right[] の +構造では根から葉に向かってしか木を辿ることができないはずだ。これはどう +いうことだろう?make_tree() ではまだ処理が続いている。 + + /* (F) */ + sort = codeparm; + make_len(k); + make_code(nparm, lenparm, codeparm); + return k; /* return root */ + +どうやら、木構造の他にもなにやら構造を作成しているようだ。これは先程無 +視した if 文にも関連する。そしてこれは「アルゴリズム辞典」には載ってい +ない部分だ。どうやら LHa なりの工夫があるようだ。 + +まず、maketree.c:make_len(root) から見てみようと思うが、その前にこの関 +数は maketree.c:count_len(root) という関数を呼び出している。こちらから +先に見ることにした。 + +static void +count_len(i) /* call with i = root */ + int i; +{ + static unsigned char depth = 0; + + if (i < n) + len_cnt[depth < 16 ? depth : 16]++; + else { + depth++; + count_len(left[i]); + count_len(right[i]); + depth--; + } +} + +この関数に渡される i は、最初ハフマン木の根を指す値だ。この関数の全体 +を見れば、i が節や葉を示すことはすぐわかる。最初の if 文に出てくる n +は何かというとなんとこのファイル内の static 変数で、make_tree() の冒頭 +で nparm で初期化していた。先程は気にもとめなかったのだが、変数名の選 +び方がどうにもよろしくない。とにかく n は、nparm で、freqparm の最初の +要素数で、文字の種類の数を表していたものだ。ここではハフマン木の節や葉 +となる i と比較していることから、i がハフマン木の節を示すか葉を示すか +の判断に使用しているらしい。if 文の条件が真の場合(i < n)、i は葉である。 +偽の場合 i は節である。偽の場合は、depth を足して二つの子に対して再帰 +的にこの関数を呼び出している。で、結局この関数が何をしているかというと、 +先ほど構築したハフマン木に関して、ある深さの葉の数を数えているようだ。 + +len_cnt[1] は、深さ 1 (根の子)の葉の数で 0 〜 2 の値になる。len_cnt[2] +は、深さ 2 (根の孫)の葉の数で 0 〜 4 の値を持つだろう。そして、深さ 16 +以上の層に関しては len_cnt[16] にすべて計上されるようだ。とにかくその +ような処理だということでこの関数を終え、make_len() を見よう。 + +static void +make_len(root) + int root; +{ + int i, k; + unsigned int cum; + + /* (A) */ + for (i = 0; i <= 16; i++) + len_cnt[i] = 0; + count_len(root); + /* (B) */ + cum = 0; + for (i = 16; i > 0; i--) { + cum += len_cnt[i] << (16 - i); + } +#if (UINT_MAX != 0xffff) + cum &= 0xffff; +#endif + /* (C) */ + /* adjust len */ + if (cum) { + fprintf(stderr, "17"); + len_cnt[16] -= cum; /* always len_cnt[16] > cum */ + do { + for (i = 15; i > 0; i--) { + if (len_cnt[i]) { + len_cnt[i]--; + len_cnt[i + 1] += 2; + break; + } + } + } while (--cum); + } + /* (D) */ + /* make len */ + for (i = 16; i > 0; i--) { + k = len_cnt[i]; + while (k > 0) { + len[*sort++] = i; + k--; + } + } +} + +ちょっと複雑だがゆっくり見ていこう。まず (A) の初期化部分は先ほどの +count_len() を呼び出すだけのものなのでもうよいだろう。 + + /* (A) */ + for (i = 0; i <= 16; i++) + len_cnt[i] = 0; + count_len(root); + +これで、len_cnt[1..16] にはハフマン木の各層の葉の数が計上される。続いて (B) + + /* (B) */ + cum = 0; + for (i = 16; i > 0; i--) { + cum += len_cnt[i] << (16 - i); + } +#if (UINT_MAX != 0xffff) + cum &= 0xffff; +#endif + +これは、どういうことだろう?len_cnt[] は short の配列だが、とにかく以 +下のような計算(len_cnt[] の要素を 1 ビットずらしながら足す)をしている。 +最後に int 型のサイズが 2 でない場合 0xffff で論理積をしているので 2バ +イトの符号なし整数を結果として欲しいらしい。 + +---------------------------------------------------------------------------- + f e d c b a 9 8 7 6 5 4 3 2 1 0 bit + len_cnt[16] |x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x| (下位 16ビット) ++ len_cnt[15] |x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|0| (下位 15ビット) ++ len_cnt[14] |x|x|x|x|x|x|x|x|x|x|x|x|x|x|0|0| (下位 14ビット) ++ : : ++ len_cnt[ 2] |x|x|0|0|0|0|0|0|0|0|0|0|0|0|0|0| (下位 2 ビット) ++ len_cnt[ 1] |x|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0| (下位 1 ビット) +& 0xffff |1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1| +------------------------------------------------ += cum x x x x x x x x x x x x x x x x +---------------------------------------------------------------------------- + +ここで、len_cnt[] の各要素の値が各層の葉の数であることを考えると、各要 +素で使用するビット数との関連が見える。 + + 取り得る + 値の範囲 使用ビット数 + ----------------------------------------- + len_cnt[16] 0.. 2^16以上 17ビット以上 + len_cnt[15] 0.. 2^15 16ビット + len_cnt[14] 0.. 2^14 15ビット + : + len_cnt[ 3] 0.. 2^3 4 ビット + len_cnt[ 2] 0.. 2^2 3 ビット + len_cnt[ 1] 0.. 2^1 2 ビット + +先の計算式では len_cnt[] の各要素で使用し得るビット数から 1 引いたビッ +ト数が計算に使用されている。例えば根の子がすべて葉なら len_cnt[1] は、 +2 になり、2進で、00000000 00000010 だが、cum の計算にはこの下位 1 ビッ +トしか使用されない。 + + /\ + a b .. len_cnt[1] = 00000000 00000010 + | + v + cum = x0000000 00000000 + +根の孫がすべて葉なら len_cnt[2] は、4 になり、2進で、00000000 00000100 +だが、cum の計算にはこの下位 2 ビットしか使用されない。 + + / \ .. len_cnt[1] = 00000000 00000000 + /\ /\ + a b c d .. len_cnt[2] = 00000000 00000100 + || + vv + cum = xx000000 00000000 + +このようにある層のすべてが葉であるようなバランスのよいハフマン木に +対しては先の計算結果 cum は 0 になるらしい。 + +また、 + /\ + a /\ .. len_cnt[1] = 00000000 00000001 + b c .. len_cnt[2] = 00000000 00000010 + || + vv + cum = xx000000 00000000 + +のような木に対しても計算結果はオーバーフローされ cum は 0 になる。 + + /\ + a /\ .. len_cnt[1] = 00000000 00000001 + b /\ .. len_cnt[2] = 00000000 00000001 + c d .. len_cnt[3] = 00000000 00000010 + ||| + vvv + cum = xxx00000 00000000 + +も同様に cum は 0 だ。結局 cum が 0 にならない木とはある節が 1 つの葉 +しかもたないような場合であるらしい。 + + /\ + a /\ .. len_cnt[1] = 00000000 00000001 + b \ .. len_cnt[2] = 00000000 00000001 + d .. len_cnt[3] = 00000000 00000001 + ||| + vvv + cum = 11100000 00000000 + +そして、ハフマン木の作り方からこのようなことは起こりえないのではないか +と思える。 + +(C) では、if (cum) で、この起こりえないハフマン木の場合になにか処理を +行っている。まったく謎であるが、まず、この (C) を特殊条件とみなして先 +に (D) の方を見ることにしよう。 + + /* (D) */ + /* make len */ + for (i = 16; i > 0; i--) { + k = len_cnt[i]; + while (k > 0) { + len[*sort++] = i; + k--; + } + } + +sort は何かというと、make_tree() の引数に渡された codeparm を指してい +る。この配列の中には(ハフマン木を構築する際に設定されていたのだが)、出 +現頻度の低い順で平文の文字コードが入っている。make_tree() で、sort に +値を設定する際、 + + if (j < n) + *sort++ = j; + +のように条件判断があったので、sort[] にはハフマン木の節は入っていない。 +そしてハフマン木はその構築の仕方から出現頻度の低い文字は木のより深い場 +所に位置づけられている。これらのことから make_len()で求めようとしてい +るものが何なのかがわかる。make_len() は、 + len[文字] = ハフマン木の深さ +といった対応表を作成する処理だ。さらに言うとハフマン木の深さは文字を符 +号化した結果のビット数を表すことから + lenparm[文字] = 符号語のビット数 +といった対応表を作成する処理であると言った方が正解だろう。 +len[] は、make_tree() の冒頭で、lenparm を指すように設定された変数なの +で、そのように置き換えておいた。 + +では、謎の (C) を見よう。その前に cum != 0 は起こりえないと書いたがよ +く考えたら len_cnt[16] だけは深さ16以上の葉すべての数を計上しているた +め、どのような値もあり得る。つまり、この (C) の処理はハフマン木が深さ +17 以上になったときに処理されるものだと言えそうだ。思い切って図示しよ +う例えばこんな木は、(C)の処理対象となる。 + + /\ + a /\ .. len_cnt[ 1] = 0000000000000001 + b /\ .. len_cnt[ 2] = 0000000000000001 + c /\ .. len_cnt[ 3] = 0000000000000001 + d /\ .. len_cnt[ 4] = 0000000000000001 + e /\ .. len_cnt[ 5] = 0000000000000001 + f /\ .. len_cnt[ 6] = 0000000000000001 + g /\ .. len_cnt[ 7] = 0000000000000001 + h /\ .. len_cnt[ 8] = 0000000000000001 + i /\ .. len_cnt[ 9] = 0000000000000001 + j /\ .. len_cnt[10] = 0000000000000001 + k /\ .. len_cnt[11] = 0000000000000001 + l /\ .. len_cnt[12] = 0000000000000001 + m /\ .. len_cnt[13] = 0000000000000001 + n /\ .. len_cnt[14] = 0000000000000001 + o /\ .. len_cnt[15] = 0000000000000001 + p /\ .. len_cnt[16] = 0000000000000011 + q r |||||||||||||||| + vvvvvvvvvvvvvvvv + cum = 0000000000000001 + +このような木は例えば各文字が以下の出現頻度となるファイルを作成すると起 +こる(実際には、LHA の場合、slide 辞書法の処理もあるのでこれほど単純で +はない)。 + + 文字 頻度 文字 頻度 + ------------ ------------ + r 1 i 256 + q 1 h 512 + p 2 g 1024 + o 4 f 2048 + n 8 e 4096 + m 16 d 8129 + l 32 c 16384 + k 64 b 32768 + j 128 a 65535 + +ところで、cum の値は何なのかというと、 + + : + .. len_cnt[15] = 0000000000000001 + p /\ .. len_cnt[16] = 0000000000000100 + q /\ |||||||||||||||| + r s vvvvvvvvvvvvvvvv + cum = 0000000000000010 + +この場合は cum = 2 だ。 + : + .. len_cnt[15] = 0000000000000001 + p /\ .. len_cnt[16] = 0000000000000101 + q /\ |||||||||||||||| + r /\ vvvvvvvvvvvvvvvv + s t cum = 0000000000000011 + +この場合は cum = 3 だ。少なくともこの例では深さ 16 以上の葉の数 - 2に +なるらしい(そうか、11111111 11111110 = -2 を足しているのだから当然だ)。 + +では、今度こそ (C) を見る。 + + /* (C) */ + /* adjust len */ + if (cum) { + fprintf(stderr, "17"); + len_cnt[16] -= cum; /* always len_cnt[16] > cum */ + do { + for (i = 15; i > 0; i--) { + if (len_cnt[i]) { + len_cnt[i]--; + len_cnt[i + 1] += 2; + break; + } + } + } while (--cum); + } + +である。いきなり fprintf() しているところがすごい。デバッグ用の出力が +残っているのだろう。LHa for UNIX で 17 という出力を見たことがある人は +教えて欲しい。 + +で・・・、結局この (C) の部分は見てもよくわからなかった。ここまで書い +ておいてなんだが、気持ちよく無視することにした。 + +では、make_tree() から呼び出される最後の関数、maketree.c:make_code() +を見よう。make_code() は、make_tree() の(F) の部分で以下のように呼ばれ +ていた。 + + make_code(nparm, lenparm, codeparm); + +この引数のうち、lenparm[] は先ほどの make_len[] で値が作られたものだが、 + lenparm[文字] = 符号語のビット数 +という対応表だった。codeparm[] は、先ほども出たが make_tree() の中で設 +定されているものだった。出現頻度の低い順で平文の文字コードが入った配列 +だ。 + +void +make_code(n, len, code) + int n; + unsigned char len[]; + unsigned short code[]; +{ + unsigned short weight[17]; /* 0x10000ul >> bitlen */ + unsigned short start[17]; /* start code */ + unsigned short j, k; + int i; + + j = 0; + k = 1 << (16 - 1); + for (i = 1; i <= 16; i++) { + start[i] = j; + j += (weight[i] = k) * len_cnt[i]; + k >>= 1; + } + for (i = 0; i < n; i++) { + j = len[i]; + code[i] = start[j]; + start[j] += weight[j]; + } +} + +# 後で気がついたことだが、あらかじめ設定していた codeparm[] の内容はこ +# こでは使用されない。つまり、codeparm[] は先程はワーク用のバッファと +# して利用されていたが、ここでの codeparm[] は処理結果を表すという二つ +# の役割がある + +最初の for 文では、変数 i に対して、weight[i] が下のように設定される + + weight[i=1..16] = 2^(16-i) + +そして、start[i] は、 + + start[1] = 0 + start[n] = start[n-1] + weight[n-1] * len_cnt[n-1] (n > 1) + +という漸化式だ。starr[] の添字 i は、len_cnt[i](深さ i の葉の数)の添字 +でもあることから、ハフマン木の深さを表している。start が実際にどのよう +な値を取るかと言うと、例えば len_cnt[i] の各要素が Li であった場合、 + + i len_cnt[i] weight[i] start[i] + -------------------------------------------- + 1 L1 2^15 0 + 2 L2 2^14 2^15 * L1 + 3 L3 2^13 2^15 * L1 + 2^14 * L2 + 4 L4 2^12 2^15 * L1 + 2^14 * L2 + 2^13 * L3 + +こんな感じだ。これはいったい何だろうか?続く for 文を見てみよう。 + + for (i = 0; i < n; i++) { + j = len[i]; + code[i] = start[j]; + start[j] += weight[j]; + } + +ここでの i は、0...n の範囲であることから平文の文字を示す。紛らわしい +ので、i は、c に書き換え、j を i にしよう。(これで、i は前の for 文の +i と同じ意味になる) + + int c; + + for (c = 0; c < n; c++) { + i = len[c]; + code[c] = start[i]; + start[i] += weight[i]; + } + +i = len[c] は文字 c のビット長で、ハフマン木の深さを示す。 +code[c] には、start[i] が設定されるが、一度 start[i] が参照されると +start[i] は、weight[i] を足した値が次回使われる。例えば、ある文字 +a, b, c がそれぞれ以下のハフマン木で表現されたとする。 + + /\ a: 0 + a /\ b: 10 + b c c: 11 + + + i len_cnt[i] weight[i] start[i] + -------------------------------------------- + 1 1 2^15 0 + 2 2 2^14 2^15 + + c len[c] i len_cnt[i] weight[i] code[c] + --------------------------------------------------- + a 1 1 1 2^15 0 + b 2 2 2 2^14 2^15 + c 2 2 2 2^14 2^15 + 2^14 + +こんな感じになる。別のハフマン木の場合も見てみよう。 + + /\ a: 00 + /\ /\ b: 01 + a b c d c: 10 + d: 11 + + i len_cnt[i] weight[i] start[i] + -------------------------------------------- + 1 0 2^15 0 + 2 4 2^14 0 + 3 0 2^13 2^14 * 4 + + c len[c] i len_cnt[i] weight[i] code[c] + --------------------------------------------------- + a 2 2 4 2^14 0 + b 2 2 4 2^14 2^14 + c 2 2 4 2^14 2^14 * 2 + d 2 2 4 2^14 2^14 * 3 + +これで、ピント来ると凄いのだが code[c] には文字 c に対応する符号化した +ビット列が設定されるようになっていることに気づくだろうか?つまりは、 + + c len[c] i len_cnt[i] weight[i] code[c] + ----------------------------------------------------------- + a 2 2 4 2^14 00000000 00000000 + b 2 2 4 2^14 01000000 00000000 + c 2 2 4 2^14 10000000 00000000 + d 2 2 4 2^14 11000000 00000000 + ^^ <- ハフマン符号 + +だ。以降、code[] (実際には codeparm) を利用することで表引きで文字 c に +対応するハフマン符号を得ることができるようになっている(code[c]のうち上 +位 len[c] ビットだけを見る)。符号化の際に木を辿る必要はなく、高速な符号 +化が可能になる(と期待される。どの程度効果があるかはいずれ検証してみた +い。そういえば、葉から根に向かって木を辿るための情報が必要なかったこと +もこれでわかった)。 + +結局 make_tree(nparm, freqparm, lenparm, codeparm) は、lenparm[c] と +codeparm[c] を作成する関数だったわけだ(ハフマン表とでも言うのだろう +か?)。実は、このことは make_tree() を呼び出し、 codeparm を使用してい +る箇所(huf.c)を見るまでまるでわからなかった。しかも、まだちゃんと理解 +したわけではない。 + +ふと思ったのだが、上記の表作成は文字コード順に依存している(コードの若 +い方が左の子になる)が、木を作成する場合はそのようなことはなかったはず +だ。ハフマン木を辿った場合と表を参照した場合とでは得られる符号語は異な +るのではないだろうか?ということは圧縮文に埋め込まれるのは木ではなくこ +の表の方だということも想像がつく。木の構造を表す left[]、right[] はグ +ローバル変数だが、実際には make_tree() 内でしか使われないのかも知れな +い(少なくとも符号化に関してはそのようだ。huf.c を眺めるとどうやら復号 +時は left[]、right[]は使われるらしい)。 + +さらにふと思い付いた。謎の (C) のコードだが 深さ 17 以上の木が作成され +た場合に木を再構築する処理だということがわかった。最初、len_cnt[] (あ +る深さの葉の数) だけが、操作されていたからよくわからなかったのだ、 + + /* (C) */ + /* adjust len */ + if (cum) { + fprintf(stderr, "17"); + len_cnt[16] -= cum; /* always len_cnt[16] > cum */ + do { + for (i = 15; i > 0; i--) { + if (len_cnt[i]) { + len_cnt[i]--; + len_cnt[i + 1] += 2; + break; + } + } + } while (--cum); + } + +深さ n の葉の数を 1 つ減らして、その下の葉の数を 2 足している。 +これが、cum の数だけ繰り返される。例えば、前にも出た + + : + n /\ .. len_cnt[14] = 0000000000000001 + o /\ .. len_cnt[15] = 0000000000000001 + p /\ .. len_cnt[16] = 0000000000000011 + q r |||||||||||||||| + vvvvvvvvvvvvvvvv + cum = 0000000000000001 + +の例では、最初に len_cnt[16] から cum {1} が引かれ、 + + : + n /\ .. len_cnt[14] = 0000000000000001 + o /\ .. len_cnt[15] = 0000000000000001 + p / .. len_cnt[16] = 0000000000000010 + q + +続いて、深さ 15 より上の葉のある節から 1 つ子を取り、 + + : + n /\ .. len_cnt[14] = 0000000000000001 + /\ .. len_cnt[15] = 0000000000000000 + p / .. len_cnt[16] = 0000000000000010 + q + +下の葉の数(この例では、len_cnt[16])を 2 足している。 + + / \ + n / \ .. len_cnt[14] = 0000000000000001 + /\ /\ .. len_cnt[15] = 0000000000000000 + o r p / .. len_cnt[16] = 0000000000000100 + q + +cum は、この例では 0 になるので、これで木の平滑化は終る。テキストだと +ちょっと見にくいが、そういう処理ということで間違いないだろう。 +lenparm[] の値はこの後の (D) で、この木を元に計算されている。 + +ところで、本当の所は以下のような文字の対応になる(表を作成するときに文 +字コード順になっているため)のだが、結果的に元の木から p を含む節を取り +除き o の位置に挿入する処理になっている。なんだか面白い。 + + / \ + n / \ .. len_cnt[14] = 0000000000000001 + /\ /\ .. len_cnt[15] = 0000000000000000 + o p q r .. len_cnt[16] = 0000000000000100 + +文字から Huffman 符号が得られるようになったので、圧縮処理を行う道具は +揃った。いよいよ Huffman 法による圧縮処理全般 (huf.c) を見ることにしよ +う。 + +まず huf.c で定義されているデータ構造から確認しよう。データ構造がわかっ +てしまえばアルゴリズムの 90% はわかったも同然だ(誇張)。 + +huf.c には以下の変数が定義されている。 + +unsigned short left[2 * NC - 1], right[2 * NC - 1]; +unsigned char c_len[NC], pt_len[NPT]; +unsigned short c_freq[2 * NC - 1], c_table[4096], c_code[NC], p_freq[2 * NP - 1], + pt_table[256], pt_code[NPT], t_freq[2 * NT - 1]; + +static unsigned char *buf; +static unsigned int bufsiz; +static unsigned short blocksize; +static unsigned short output_pos, output_mask; +static int pbit; +static int np; + +使用されている定数も確認する lha_macro.h だ。 + +#define NP (MAX_DICBIT + 1) +#define NT (USHRT_BIT + 3) +#define PBIT 5 /* smallest integer such that (1 << PBIT) > * NP */ +#define TBIT 5 /* smallest integer such that (1 << TBIT) > * NT */ +#define NC (UCHAR_MAX + MAXMATCH + 2 - THRESHOLD) +/* #if NT > NP #define NPT NT #else #define NPT NP #endif */ +#define NPT 0x80 +#define CBIT 9 /* $\lfloor \log_2 NC \rfloor + 1$ */ + +たくさんある。たくさんありすぎてくじけそうだが(事実、くじけた)、現時点 +でわかる変数もある。left[] や right[] は Huffman 木を構築するのに使用 +した変数だった。そこから NC は文字種の最大数であることがわかる。NC に +MAXMATCH{256} 等の値が使用されているのは謎だが、現時点では無視しておこ +う。 + +c_freq[] や c_len[], p_freq[], pt_len[] も make_tree() で出て来た変数 +名に似ている。おそらく make_tree() に渡す変数だろう。確認してみたとこ +ろ huf.c から make_tree() の呼び出しを行っている部分を抜き出すと、 + + root = make_tree(NC, c_freq, c_len, c_code); + root = make_tree(NT, t_freq, pt_len, pt_code); + root = make_tree(np, p_freq, pt_len, pt_code); + +の 3 箇所が出て来た。つまり、 + + 文字種の数 文字の出現回数 符号化した文字 文字に対応する + の bit 長 Huffman 符号表 + ----------------------------------------------------------- + NC c_freq c_len c_code + NT t_freq pt_len pt_code + np p_freq pt_len pt_code + +という関係のようだ。どうやら c_code、pt_code という 2 種類の +Huffman 符号表を使用するらしい。 + +その他の変数に関しても予想を立てたい所だが、もうくじけたので、処理内容 +から攻めることにした。 + +slide 辞書法の解読で Huffman 法に関連した処理の呼び出しがいくつかあっ +た。 + + /* initialize */ + alloc_buf() + + /* encoder */ + encode_set.encode_start() + encode_set.output(c, off) + encode_set.encode_end() + + /* decoder */ + decode_set.decode_start() + decode_set.decode_c() + decode_set.decode_p() + +以上だ。lh4, 5, 6, 7 では、上記のそれぞれは、huf.c の以下の関数の呼び +出しに対応している。これは、slide.c の冒頭部分で定義されている。 + + /* encoder */ + encode_start() -> encode_start_st1() + output() -> output_st1() + encode_end() -> encode_end_st1() + + /* decoder */ + decode_start() -> decode_start_st1() + decode_c() -> decode_c_st1() + decode_p() -> decode_p_st1() + +このうちの圧縮処理にあたる部分 encode_start_st1(), output_st1(), +encode_end_st1() を見ていこう。まずは、初期化処理である +encode_start_st1() から、 + +void +encode_start_st1( /* void */ ) +{ + int i; + + if (dicbit <= 13) { + pbit = 4; /* lh4,5 etc. */ + np = 14; + } else { + pbit = 5; /* lh6,7 */ + if (dicbit == 16) + np = 17; + else + np = 16; + } + + for (i = 0; i < NC; i++) + c_freq[i] = 0; + for (i = 0; i < np; i++) + p_freq[i] = 0; + output_pos = output_mask = 0; + init_putbits(); + buf[0] = 0; +} + +dicbit (これは辞書の bit サイズだった)によって、np, pbit の値が変わる。 +dicbit の違いというのは LHa の encoding メソッドの違いだ。それぞれ以下 +の対応になる。 + + method dicbit np pbit + -------------------------- + -lh4- 12 14 4 + -lh5- 13 14 4 + -lh6- 15 16 5 + -lh7- 16 17 5 + +np というのは、先程 make_tree() を呼び出している箇所の洗い出しで見かけ +た変数だった。まだ、この関連はよくわからない。 + +処理の後半では、文字の出現頻度を表す c_freq[]、p_freq[] の初期化を +行っている。さらに + + output_pos + output_mask + buf[] + +という初出の変数も 0 に初期化している。(buf は、buf[0] のみ初期化して +いる) init_putbits() の呼び出しは bit 出力ルーチンの初期化処理だった。 +以降、putbits(), putcode() を使用できる。 + +次に output_st1(c, p) を見る。slide.c でこの関数は以下のように使用され +ていた。 + + output_st1(c, 0) 文字 c を出力 + output_st1(len, off) のペアを出力 + +このことを踏まえた上で、処理内容を見てみよう。 + +void +output_st1(c, p) + unsigned short c; + unsigned short p; +{ + static unsigned short cpos; + + /* (A) */ + output_mask >>= 1; + if (output_mask == 0) { + output_mask = 1 << (CHAR_BIT - 1); + if (output_pos >= bufsiz - 3 * CHAR_BIT) { + send_block(); + if (unpackable) + return; + output_pos = 0; + } + cpos = output_pos++; + buf[cpos] = 0; + } + /* (B) */ + buf[output_pos++] = (unsigned char) c; + c_freq[c]++; + /* (C) */ + if (c >= (1 << CHAR_BIT)) { + buf[cpos] |= output_mask; + buf[output_pos++] = (unsigned char) (p >> CHAR_BIT); + buf[output_pos++] = (unsigned char) p; + c = 0; + while (p) { + p >>= 1; + c++; + } + p_freq[c]++; + } +} + +(A) は、output_mask の値に応じて処理を行うようだ。初期化で output_mask +は 0 だから (A) の処理は最初から実行されるが、ひとまず無視しよう。 + +(B) は、buf に引数で渡された文字 c を格納し、c_freq[c] の値(文字の出現 +頻度)を足している。どうやら基本は渡された文字 c を延々と buf に格納し、 +後で圧縮を行う(おそらく (A) だろう)ようだ。 + +この buf のサイズはと言うと、これは alloc_buf() で割り当てられていた。 + +unsigned char * +alloc_buf( /* void */ ) +{ + bufsiz = 16 * 1024 *2; /* 65408U; */ /* t.okamoto */ + while ((buf = (unsigned char *) malloc(bufsiz)) == NULL) { + bufsiz = (bufsiz / 10) * 9; + if (bufsiz < 4 * 1024) + break; + } + return buf; +} + +bufsiz が buf のサイズらしい。これはできるだけ大きく取るようにしている +が、大きく取れなければそれはそれで良いようだ。 + +さらに、(C) の処理を行うかどうかは、c >= (1 << CHAR_BIT) という条件で +判断されている。この条件が真となる場合は何かと言うと c が「長さ」を表 +す場合だ。このとき引数 p で「位置」が渡されているのでこれも buf にセッ +トしている。その具体的内容はというと、何やら cpos というこの関数内で +static な変数が使用されている。よくわからないが文字 c や の +ペアは、buf 上で以下のように表されるらしい。 + +---------------------------------------------------------------------------- + +output_st1(c1, 0) +output_st1(c2, 0) +output_st1(len, off) + +と呼び出した場合の buf の状態 + + +-----+-----+-----+-----+-----+ +buf | c1 | c2 | len | off | + +-----+-----+-----+-----+-----+ + +---------------------------------------------------------------------------- + +(C) の処理の最後の部分 + + c = 0; + while (p) { + p >>= 1; + c++; + } + p_freq[c]++; + +は、出現頻度 p_freq[] を求める処理だが、p_freq は、off 値の出現頻度を +表しているらしい。ここでの c は、p (off) の bit 長になっている。off の +値は大きい(辞書サイズだから最大(lh7)で、64KB)ので、代わりに bit 長を利 +用しているといったところか。そういえば、np という変数があり、 +make_tree() の第一引数に渡されることから、これは、p_freq[] の要素数を +表す。p_freq[] の要素数とは、 の bit 長の最大値+1なので、lh7 で、 +64KB。つまり 16 bit + 1 が np になる。 + +ついでに言うと、「長さ」はそのまま c_freq[] で頻度が計上されていた。同 +じく make_tree() の第一引数に渡される NC の値が + +#define NC (UCHAR_MAX + MAXMATCH + 2 - THRESHOLD) + +なのは、そういうことだ(長さを考えなければ文字の最大値{255}+1となるとこ +ろだが、長さの最大値が、256 + MAXMATCH - THRESHOLD だから上の式になっ +ているのだろうと思う。ちょっとわかりにくいが) + +ここまでで、圧縮を行う処理は現われなかった。やはり (A) の部分が圧縮処 +理だ。 + + /* (A) */ + output_mask >>= 1; + if (output_mask == 0) { + output_mask = 1 << (CHAR_BIT - 1); + if (output_pos >= bufsiz - 3 * CHAR_BIT) { + send_block(); + if (unpackable) + return; + output_pos = 0; + } + cpos = output_pos++; + buf[cpos] = 0; + } + +最初、output_mask は、0 なので if 条件を満たす。そして、output_mask は、 +(1 << (CHAR_BIT - 1)) つまり、128 になる。(A) の冒頭で、>>= 1 している +ので、output_mask は、128, 64, 32, ..., 1, 128 という値を取るらしい。そ +して、本当の初期値は 128 だ。 + +次の条件 + + output_pos >= bufsiz - 3 * CHAR_BIT + +というのは、buf が bufsiz - 24 よりも大きくなったときの値だ。ひとまず +無視しよう。そして、cpos = output_pos++ として、buf[cpos] = 0 にセット +されている。どうやら、先にこちらを見るべきだったようだ。cpos の値 +と output_pos++ が (A) で行われていることを踏まえてもう一度 (B)、(C) +の処理を見ると、buf は以下のように使用されているらしい。 + +---------------------------------------------------------------------------- + +output_st1(c1, 0) +output_st1(c2, 0) +output_st1(len, off) + +と呼び出した場合の buf の状態 + + + +-----+-----+-----+-----+-----+-----+-- +buf | 32 | c1 | c2 | len | off | ... + +-----+-----+-----+-----+-----+-----+-- + cpos output_pos + +---------------------------------------------------------------------------- + + のペアを出力するとき buf[cpos] には以下のような値が設定され +ていたことも図に書いてある。 + + buf[cpos] |= output_mask; + +もう少し注意深くこのあたりを考えよう。output_mask は、この関数が呼ばれ +るたびに 128, 64, 32, ..., 1, 128, 64, ... という値になる。そして、buf +は、呼ばれるたびに c (1バイト)、あるいは (3バイト)の値が設 +定されるが、output_mask が 128 になったときは、余分に 1 バイト空きがで +きる(これは、buf[cpos]で示される)。この空きには が設定される +たびにその時点の output_mask 値が設定されるようだ。(A) が呼ばれるとき +と言うのは、一番最初の output_mask = 0 の場合を除けば、 + +---------------------------------------------------------------------------- + +output_mask 128 64 32 16 8 4 2 1 + +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+ +buf | 32 | c1 | c2 | len | off | c3 | c4 | c5 | c6 | c7 | + +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+ + cpos / + / + output_pos + +---------------------------------------------------------------------------- + +このような状態になったときということだ。さらに、buf[cpos] には、 + が格納されている位置を表している。この状態を 1 ブロックとし +てこのブロック単位に情報が buf に格納され、buf がいっぱいになったら +(A) の処理の無視したif 文の中身で + + if (output_pos >= bufsiz - 3 * CHAR_BIT) { + send_block(); + if (unpackable) + return; + output_pos = 0; + } + +のように send_block() が呼ばれるようになっているようだ。この if の条件 +で、3 * CHAR_BIT というのは の格納バイト数を示している。 +(と思ったが、3 * CHAR_BIT ではビット数だ。一方、bufsiz はバイト数だ。 +計算に使用している単位が違う。何やらバグっぽい雰囲気があるが、バグだと +してもバッファをちょっとだけ無駄にしているだけなので大したことはないの +だろう) + +output_pos = 0 としていることからこの時点の buf の中身がすべて +send_block() で圧縮されファイルに出力されるだろうことが想像できる。 + +この 1 ブロックに満たない状態でファイルの終りが来た場合、後処理 +encode_end_st1() で send_block() が呼ばれるであろうことも想像できる。 + +encode_end_st1( /* void */ ) +{ + if (!unpackable) { + send_block(); + putbits(CHAR_BIT - 1, 0); /* flush remaining bits */ + } +} + +思った通りである。putbits(7, 0) というは、bitbuf に残った bit を吐き出す +ためであることは、bit 入出力ルーチンの解読で確認済みだ。 + +そういうわけで、send_block() が圧縮のメインルーチンである。 +send_block() の入力とは先に示した図の状態の buf だ。huf.c:send_block() +を見てみよう。 + +static void +send_block( /* void */ ) +{ + unsigned char flags; + unsigned short i, k, root, pos, size; + + /* (A) */ + root = make_tree(NC, c_freq, c_len, c_code); + size = c_freq[root]; + putbits(16, size); + /* (B) */ + if (root >= NC) { + count_t_freq(); + root = make_tree(NT, t_freq, pt_len, pt_code); + if (root >= NT) { + write_pt_len(NT, TBIT, 3); + } else { + putbits(TBIT, 0); + putbits(TBIT, root); + } + write_c_len(); + } else { + putbits(TBIT, 0); + putbits(TBIT, 0); + putbits(CBIT, 0); + putbits(CBIT, root); + } + /* (C) */ + root = make_tree(np, p_freq, pt_len, pt_code); + if (root >= np) { + write_pt_len(np, pbit, -1); + } + else { + putbits(pbit, 0); + putbits(pbit, root); + } + /* (D) */ + pos = 0; + for (i = 0; i < size; i++) { + if (i % CHAR_BIT == 0) + flags = buf[pos++]; + else + flags <<= 1; + if (flags & (1 << (CHAR_BIT - 1))) { + encode_c(buf[pos++] + (1 << CHAR_BIT)); + k = buf[pos++] << CHAR_BIT; + k += buf[pos++]; + encode_p(k); + } else + encode_c(buf[pos++]); + if (unpackable) + return; + } + /* (E) */ + for (i = 0; i < NC; i++) + c_freq[i] = 0; + for (i = 0; i < np; i++) + p_freq[i] = 0; +} + +なかなか大きな関数であるが、それほど難しいことはない。まず、(A) + + /* (A) */ + root = make_tree(NC, c_freq, c_len, c_code); + size = c_freq[root]; + putbits(16, size); + +make_tree() で Huffman 表 c_len[], c_code[] を構築する。戻り値の root +は、Huffman 木の根を示し、c_freq[root] は、文字の出現回数の総和である +から、size は、平文の総バイト数だ(size に の分のサイズは含まれな +い。c_freq[] が、 の出現頻度を数えなかったから)。ファイルには、こ +の size がまず書き出されている(そういえば、この bit 入出力ルーチンを使 +用するとバイトオーダーに関して考慮する必要がなくなる)。 + +---------------------------------------------------------------------------- + + 16bit + |---------| + +----+----+ + | size | + +----+----+ + +---------------------------------------------------------------------------- + +続いて、(B) + + if (root >= NC) { + count_t_freq(); + root = make_tree(NT, t_freq, pt_len, pt_code); + if (root >= NT) { + write_pt_len(NT, TBIT, 3); + } else { + putbits(TBIT, 0); + putbits(TBIT, root); + } + write_c_len(); + } else { + putbits(TBIT, 0); + putbits(TBIT, 0); + putbits(CBIT, 0); + putbits(CBIT, root); + } + +root が NC よりも大きい場合を判断しているが、ハフマン木の根は必ず NC よ +りも大きい(make_tree() の avail の初期値を確認しよう)。では、この +条件を満たさない場合と言うのは何かと言うと、同じく make_tree() を確認すると、 + + if (heapsize < 2) { + codeparm[heap[1]] = 0; + return heap[1]; + } + +という例外条件があった。これは、圧縮する文字がない、あるいは1種類しか +ない場合の処理だ。圧縮する文字がない場合に send_block() が呼ばれること +はないだろうから、(B) の処理の else は 1 ブロック中に圧縮する文字が 1 +種類しかない場合の処理である(この 1 種類の文字とは、make_tree() の戻り +値 root だ)。このとき以下のような出力になる。(TBIT{5}, CBIT{9} である) + +---------------------------------------------------------------------------- + TBIT CBIT + TBIT CBIT + |--|--|----|----| TBIT: 5 + +--+--+----+----+ CBIT: 9 + | 0| 0| 0|root| + +--+--+----+----+ + +---------------------------------------------------------------------------- + +これが、1ブロックに1種類しか文字がない場合の出力だ(offの情報はまだ含ま +ない)。(B)の if が真のときがどうなるかは複雑そうなので後で見ることにし +よう。 + +続いて (C) + + root = make_tree(np, p_freq, pt_len, pt_code); + if (root >= np) { + write_pt_len(np, pbit, -1); + } + else { + putbits(pbit, 0); + putbits(pbit, root); + } + +p_freq[] を見ていることから今度は の情報の Huffman 木を構築して +いることがわかる。先程と同様に、 の値がすべて同じ場合は、else の +条件になり、以下の出力が行われる。(np の値は、-lh7- の場合で、17 だ) + +---------------------------------------------------------------------------- + + np bit np bit method np + |---------|---------| ---------- + +----+----+---------+ -lh4- 14 + | 0 | root | -lh5- 14 + +----+----+---------+ -lh6- 16 + -lh7- 17 + +---------------------------------------------------------------------------- + +ここまでに出力した情報が何を示すかわかるだろうか?Huffman 法の符号化処 +理は文字を bit 列に変換する。これを復号する場合は bit 列に対応する文字 +を知る必要がある。すなわち Huffman 木である(実際には Huffman 表)。図示 +したのは、Huffman 木を構築する必要がない(構築できない)場合の情報になる +が、現在解読を飛ばしている処理は Huffman 表をファイルに出力している箇 +所であることは容易に想像がつく。ということは残りの (D) が本当の圧縮文 +を出力する箇所だ。 + + /* (D) */ + pos = 0; + for (i = 0; i < size; i++) { + if (i % CHAR_BIT == 0) + flags = buf[pos++]; + else + flags <<= 1; + if (flags & (1 << (CHAR_BIT - 1))) { + encode_c(buf[pos++] + (1 << CHAR_BIT)); + k = buf[pos++] << CHAR_BIT; + k += buf[pos++]; + encode_p(k); + } else + encode_c(buf[pos++]); + if (unpackable) + return; + } + +size 数分ループしている。size は、 を除いた buf の文字数を示して +いると前に書いたが、どうやら を 1 文字と数えたときの buf の +文字数を示していると考えた方が良さそうだ。 + +最初の if で、 + + if (i % CHAR_BIT == 0) + flags = buf[pos++]; + else + flags <<= 1; + +これが真になる条件は buf[pos] が buf[cpos] である場合だ(output_mask が +128, 64, ..., 1 と 8 つの値を巡回していたことを思い出そう)。 +flags は、 の buf 上の位置を示す bit マスクになる。 + + if (flags & (1 << (CHAR_BIT - 1))) { + encode_c(buf[pos++] + (1 << CHAR_BIT)); + k = buf[pos++] << CHAR_BIT; + k += buf[pos++]; + encode_p(k); + } else + encode_c(buf[pos++]); + +flags が、127 であるとき buf[pos] は、 を指し、 + + encode_c(len + 256) + encode_p(off) + +で、圧縮を行うようだ。len に 256 を足しているのは、buf[] に len を格納 +するとき(output_st1() の (B) の処理)に + + buf[output_pos++] = (unsigned char) c; + +のように最上位 bit を捨てていたからだ。len は常に 256 以上なので、256 +を足すことで元の len の値を圧縮ルーチンに渡している。 + +通常の文字は + + encode_c(buf[pos]) + +で圧縮されている。encode_c() の処理内容は簡単なので見てみよう。 + +static void +encode_c(c) + short c; +{ + putcode(c_len[c], c_code[c]); +} + +c_len[], c_code[] が文字 c に対応する Huffman 符号の bit 長と符号を示 +しているので、それをそのまま出力している。簡単だ。 + +encode_p() はもう少し複雑だ。 + +static void +encode_p(p) + unsigned short p; +{ + unsigned short c, q; + + c = 0; + q = p; + while (q) { + q >>= 1; + c++; + } + putcode(pt_len[c], pt_code[c]); + if (c > 1) + putbits(c - 1, p); +} + +最初の while 文で、 の bit 長を求め、その bit 長の情報を +Huffman 符号化している。その後、putbits() で、必要 bit 数だけ +出力する。つまり、 は以下のように符号化される。 + +---------------------------------------------------------------------------- +off = 64 の圧縮 + + |---- 16 bit -------| + +----+----+----+----+ +off |0000 0000 0100 0000| + +----+----+----+----+ + |-7 bit-| + +この圧縮文は以下(長さが 7 bit であるという情報(Huffman符号化)と値のペア) + + |-6 bit-| + +-----------------+-------+ + | 7 のHuffman符号 |00 0000| + +-----------------+-------+ + +---------------------------------------------------------------------------- + +ここで、値を 6 bit しか出力しない(putbits() で c-1 を渡している)のは、 +7 bit 目が 1 であることが自明だからである。常に off != 0 だから、書き +出す情報を 1 bit 削減できるわけだ。したがって、off=1 のときは bit 長が +1 という情報しか書き出さない。 + +最後の (E) は頻度表をクリアしているだけだ。 + + /* (E) */ + for (i = 0; i < NC; i++) + c_freq[i] = 0; + for (i = 0; i < np; i++) + p_freq[i] = 0; + +以上で、圧縮処理全体の概要がわかった。後は無視していた Huffman 表を出 +力する箇所だけだ。 + + /* (B) */ + if (root >= NC) { + count_t_freq(); + root = make_tree(NT, t_freq, pt_len, pt_code); + if (root >= NT) { + write_pt_len(NT, TBIT, 3); + } else { + putbits(TBIT, 0); + putbits(TBIT, root); + } + write_c_len(); + +ここでは、c_len[], c_code[] という Huffman 表を出力するだけのはずだが、 +さらに Huffman 表 pt_len[], pt_code[] の構築を行っている。これは、 + の bit 長の Huffman 符号表でもあった変数だが、単に変数を使い回し +ているだけだ。ここでの pt_len[], pt_code[] が何の符号表かは、 +count_t_freq() を見る必要がある。 + +static void +count_t_freq(/*void*/) +{ + short i, k, n, count; + + for (i = 0; i < NT; i++) + t_freq[i] = 0; + n = NC; + while (n > 0 && c_len[n - 1] == 0) + n--; + i = 0; + while (i < n) { + k = c_len[i++]; + if (k == 0) { + count = 1; + while (i < n && c_len[i] == 0) { + i++; + count++; + } + if (count <= 2) + t_freq[0] += count; + else if (count <= 18) + t_freq[1]++; + else if (count == 19) { + t_freq[0]++; + t_freq[1]++; + } + else + t_freq[2]++; + } else + t_freq[k + 2]++; + } +} + +最初に頻度表 t_freq[] を初期化する。続いて、 + + n = NC; + while (n > 0 && c_len[n - 1] == 0) + n--; + +で、c_len[n] != 0 である最大の n を求めている。 + + i = 0; + while (i < n) { + k = c_len[i++]; + if (k == 0) { + count = 1; + while (i < n && c_len[i] == 0) { + i++; + count++; + } + if (count <= 2) + t_freq[0] += count; + else if (count <= 18) + t_freq[1]++; + else if (count == 19) { + t_freq[0]++; + t_freq[1]++; + } + else + t_freq[2]++; + } else + t_freq[k + 2]++; + } + +c_len[i] は、文字 i の Huffman 符号での bit 長であった。この +c_len[i] の値を以下の場合分けで t_freq[] に頻度計算している。 +count は、c_len[i] が連続で何回 0 であるかの数だ。 + + c_len[i] count t_freq[] + ------------------------------------------- + 0 0 .. 2 t_freq[0] += count + 0 3 ..18 t_freq[1]++ + 0 19 t_freq[0]++, t_freq[1]++ + 0 20以上 t_freq[2]++ + 0以外 t_freq[c_len[i]+2]++; + +これがどういう理屈であるかはよくわからないが、とにかく頻度計算を行う場 +合に t_freq[0], t_freq[1], t_freq[2] を特別扱いしている。そして、頻度 +計算の対象が c_len[] であることから (B) の処理は、c_len[] に関して +Huffman 符号化を行う処理のようだ。 + +そうして、make_tree() で、t_freq[] に関して Huffman 符号表を作成し、 +write_pt_len() で、この符号表(文字の Huffman 符号のビット長 c_len の +Huffman 符号のビット長) pt_len[] を出力する。 + +static void +write_pt_len(n, nbit, i_special) + short n; + short nbit; + short i_special; +{ + short i, k; + + while (n > 0 && pt_len[n - 1] == 0) + n--; + putbits(nbit, n); + i = 0; + while (i < n) { + k = pt_len[i++]; + if (k <= 6) + putbits(3, k); + else + putbits(k - 3, USHRT_MAX << 1); + if (i == i_special) { + while (i < 6 && pt_len[i] == 0) + i++; + putbits(2, i - 3); + } + } +} + +最初に pt_len[] の要素数を nbit 出力し、続けて符号 bit 長 pt_len[] の +要素を出力している。nbit は、n を格納するのに必要な bit 数を表している +ようだ。ここでは、n (NT{19}) を出力するのに TBIT{5} bit 必要であるとい +うことだ。 + +pt_len[] を出力するときは、その値が 6 より大きいかどうかで形式を変えて +出力している。6 以下であればそのまま 3 bit で出力し、7 bit 以上であれ +ば、bit 数で表現するらしい。例えば pt_len[i] == 7 なら、1110 となる。 +最初の 3 bit は必ず 1 になり、最初の形式と区別がつくようになっている。 + +さらに、i_special 番目の pt_len[i] を出力後は、i_special ... 6 の範囲 +で pt_len[i] == 0 が続くことを 2 bit で、表現している。i_special は +write_pt_len() の 3 番目の引数で、今回の場合は 3 だ。例えば +pt_len[3..5] がすべて 0 なら pt_len[3] を出力後、i - 3 (= 3) を 2 bit +出力する。つまり、11 が出力される。このようなことをしている意味はこれ +またよくわからない。ちょっと複雑なので図示してみた。 + +---------------------------------------------------------------------------- +< pt_len[] の出力フォーマット > + + 0 TBIT{5} + +-------+-----------+-----------+-- --+-----------+ + | n | pt_len[0] | pt_len[1] | ... pt_len[n-1]| + +-------+-----------+-----------+-- --+-----------+ + +pt_len[i] <= 6 の場合 + + 0 3bit + +-----+ + pt_len[i] | | | | + +-----+ + +pt_len[i] >= 7 の場合 + + 0 pt_len[i] - 3 + +----------------+ + pt_len[i] |1 1 1 1 ... 1 0 | + +----------------+ + +pt_len[i_special] の直後は 2 bit の情報が付加される。この値を x とする +と、pt_len[i_special .. x + 3] の範囲で 0 が続くことを意味する。 + +---------------------------------------------------------------------------- + +最後に、write_c_len() で、符号表 c_len[] と pt_code[] を出力する。 + +static void +write_c_len(/*void*/) +{ + short i, k, n, count; + + n = NC; + while (n > 0 && c_len[n - 1] == 0) + n--; + putbits(CBIT, n); + i = 0; + while (i < n) { + k = c_len[i++]; + if (k == 0) { + count = 1; + while (i < n && c_len[i] == 0) { + i++; + count++; + } + if (count <= 2) { + for (k = 0; k < count; k++) + putcode(pt_len[0], pt_code[0]); + } + else if (count <= 18) { + putcode(pt_len[1], pt_code[1]); + putbits(4, count - 3); + } + else if (count == 19) { + putcode(pt_len[0], pt_code[0]); + putcode(pt_len[1], pt_code[1]); + putbits(4, 15); + } + else { + putcode(pt_len[2], pt_code[2]); + putbits(CBIT, count - 20); + } + } + else + putcode(pt_len[k + 2], pt_code[k + 2]); + } +} + +前に、頻度を数えたときと同様の条件で出力形式が変わっている。処理内容は +簡単なので、以下の図を示すだけにする(理屈はよくわからない)。 + +---------------------------------------------------------------------------- +< c_len[] の出力フォーマット > + + 0 CBIT{9} + +-------+-----------+-----------+-- --+-----------+ + | n | c_len[0] | c_len[1] | ... c_len[n-1]| + +-------+-----------+-----------+-- --+-----------+ + +c_len[i] == 0 の場合 + + 0 が続く数を count とすると、 + + count == 0..2 の場合 + + pt_len[0] + <----------> + +------------+ + | pt_code[0] | + +------------+ + + count == 3..18 の場合 + + pt_len[1] 4 bit + <----------> <------> + +------------+-------+ + | pt_code[1] |count-3| + +------------+-------+ + + count == 19 の場合 + + pt_len[0] pt_len[1] 4 bit + <----------> <----------> <------> + +------------+------------+-------+ + | pt_code[0] | pt_code[1] |count-3| + +------------+------------+-------+ + + count >= 20 の場合 + + pt_len[2] CBIT{9} + <----------> <------> + +------------+--------+ + | pt_code[2] |count-20| + +------------+--------+ + +c_len[i] != 0 の場合 + + pt_len[c_len[i]+2] + +-------------------+ + |pt_code[c_len[i]+2]| + +-------------------+ + +---------------------------------------------------------------------------- + +こうして、文字の Huffman 符号表は、pt_len[] と pt_code[](pt_code[] は +つまり c_len[] の Huffman 符号)を出力することで表現される。c_code[] が +出力されてないと思うかもしれないが、おそらく、decode 処理が c_len[] の値 +から計算して求めているのではないかと思われる。これは decode 処理の解読 +で明らかになるだろう。 + +この後、send_block() は、(C) で、 の Huffman 符号表を出力するのだ +が、 + + write_pt_len(np, pbit, -1); + +これは、先の pt_len[] の出力フォーマットと同じなので詳細ははしょろう。 +ただし、今度の pt_len[] の出力では write_pt_len() の第三引数 i_special +が -1 で指定されていて、i_special 番目の pt_len[i_special..6] に関して +特別扱いがなくなっているところが異なる。 + +np や pbit の意味もこの時点でわかるので一応説明しておく。np, pbit そし +て、LHA の圧縮 method との関係は以下の表の通りなのだが、np は、の +最大bit長+1 だ。 の最大bit長はすなわち dicbit なので、np は、 +dicbit + 1 である。-lh4- のときにdicbit + 2 なのが不思議だが、これは歴 +史的な理由だろうと思われる。pbit は、値 np を出力するのに必要な bit 数 +なので表の通りになる。 + + method dicbit np pbit + -------------------------- + -lh4- 12 14 4 + -lh5- 13 14 4 + -lh6- 15 16 5 + -lh7- 16 17 5 + +まとめると LHA における圧縮ファイルの構造は以下の連続であると言えるよ +うだ。 + +---------------------------------------------------------------------------- +< LHA ファイルの構造(1 ブロック分) > + + +-----------+ + | blocksize | + +-----------+ + 16bit + + +-----+--------------------+ + | len | pt_len | c_lenのハフマン符号表 + +-----+--------------------+ + 5bit ?? bit + TBIT + + +-------+------------------+ + | len | c_len | 文字と長さのハフマン符号表 + +-------+------------------+ + 9bit ?? bit + CBIT + + +---------+--------------------+ + | len | pt_len | 位置のハフマン符号表 + +---------+--------------------+ + pbit ?? bit + (pbit=4bit(lh4,5) or 5bit(lh6,7)) + + +---------------------+ + | 圧縮文 | + +---------------------+ + +---------------------------------------------------------------------------- + +ここまでの解読では細部をかなりはしょったが、decode 処理を見ればわかる +こともあるであろうことを期待している。以降、decode 処理の内容を処理の +流れを追うことで確認しよう。 + +では、いよいよ decode 処理の解読に入る。これが終れば LHA の処理の全貌 +を一応は網羅したことになるので、気合いを入れて進めよう。 + +decode 処理は以下の関数から成っている。これらは、slide.c の decode 関 +数から呼ばれている。 + +huf.c:decode_c_st1() /* 文字、長さの decode 処理 */ +huf.c:decode_p_st1() /* 位置の decode 処理 */ +huf.c:decode_start_st1() /* decode 処理の初期化 */ + + (実際には、struct decode_option の decode_c, + decode_p, decode_start を介して呼ばれる) + +decode_start_st1() は、以下の通りだ。これは encode_start_st1() のとき +と特別変わる所はない。特に説明の必要はないだろう。 + +void +decode_start_st1( /* void */ ) +{ + if (dicbit <= 13) { + np = 14; + pbit = 4; + } else { + if (dicbit == 16) { + np = 17; /* for -lh7- */ + } else { + np = 16; + } + pbit = 5; + } + + init_getbits(); + blocksize = 0; +} + +では、decode_c_st1() を見よう。 + +unsigned short +decode_c_st1( /*void*/ ) +{ + unsigned short j, mask; + + if (blocksize == 0) { + blocksize = getbits(16); + read_pt_len(NT, TBIT, 3); + read_c_len(); + read_pt_len(np, pbit, -1); + } + blocksize--; + j = c_table[bitbuf >> 4]; + if (j < NC) + fillbuf(c_len[j]); + else { + fillbuf(12); + mask = 1 << (16 - 1); + do { + if (bitbuf & mask) + j = right[j]; + else + j = left[j]; + mask >>= 1; + } while (j >= NC); + fillbuf(c_len[j] - 12); + } + return j; +} + +blocksize == 0 の場合に + + if (blocksize == 0) { + blocksize = getbits(16); + read_pt_len(NT, TBIT, 3); + read_c_len(); + read_pt_len(np, pbit, -1); + } + +と、いろいろとやっているがこの部分はすぐ想像がつく。< LHA ファイルの構 +造 > のハフマン符号表を読み込んでいるのだろう。そうして、一度読み込ん +だ後は後続の処理で 1 ブロック分(blocksize 分)完了するまで decode を行 +うだけだ。 + + blocksize--; + j = c_table[bitbuf >> 4]; + +decode 処理はハフマン符号表を表引きするだけなので単純だ。bitbuf >> 4 +は、bitbuf >> (16 - 12) と読み変えた方がわかりやすい。これは以前何度も +出た形だが bitbuf の上位 12 bit を取り出している。そうしてその値(ハフ +マン符号)を元に表引きした結果 j が復号した文字となる。なぜ 12 bit なのか +はよくわからない後で考えよう。この後の部分で、 + + if (j < NC) + fillbuf(c_len[j]); + else { + fillbuf(12); + mask = 1 << (16 - 1); + do { + if (bitbuf & mask) + j = right[j]; + else + j = left[j]; + mask >>= 1; + } while (j >= NC); + fillbuf(c_len[j] - 12); + } + return j; + +j < NC の場合は c_len[j] でハフマン符号のビット長分を fillbuf() してい +る。つまり先程表引きした 12 bit のうち c_len[j] bit が本当のハフマン符 +号なのだが、表引きの際に実際のビット長を気にする必要がないのが特徴的だ。 + +else の部分は、j を求め直していることから、どうやら符号表からの表引き +では復号できない場合を表しているらしい。この場合、表引きに使用した 12 +bit を捨て(fillbuf(12))、ハフマン木(left[], right[])を辿る事で、復号を +行っている。この後、fillbuf(c_len[j] - 12) していることから、符号長は +12 bit 以上あるのだろう。 + +decode_c_st1() が decode する圧縮文の構造は図で表すと以下のようになる + +---------------------------------------------------------------------------- + +j < NC の場合 (c_len[j] < 12 の場合) + + <- c_len[j] -> + <----- 12 -------> + +--------------+---------- +圧縮文 | ハフマン符号 | + +--------------+---------- + +j >= NC の場合 (c_len[j] > 12 の場合) + + <------------ c_len[j] ---------> + <------ 12 ------> + +------------------+--------------+-------- +圧縮文 | root | ハフマン符号 | + +------------------+--------------+-------- + + root: ハフマン木の根 + +---------------------------------------------------------------------------- + +はたして、圧縮処理のときにこのような構造を作った覚えはないのだがどうい +うことだろう?課題を残しつつ今度は decode_p_st1() (位置の復号処理)を見 +る。 + +unsigned short +decode_p_st1( /* void */ ) +{ + unsigned short j, mask; + + j = pt_table[bitbuf >> (16 - 8)]; + if (j < np) + fillbuf(pt_len[j]); + else { + fillbuf(8); + mask = 1 << (16 - 1); + do { + if (bitbuf & mask) + j = right[j]; + else + j = left[j]; + mask >>= 1; + } while (j >= np); + fillbuf(pt_len[j] - 8); + } + if (j != 0) + j = (1 << (j - 1)) + getbits(j - 1); + return j; +} + +先程と同じだ。今度は、bitbuf のうち 8 bit を使用して表引きを行い、 +j < np なら pt_len[j] を詰め、そうでなければハフマン木を辿っている。 +復号した j は位置を表す値の bit 長なので最後に + + j = (1 << (j - 1)) + getbits(j - 1); + +で、本当の位置の値を読んでいる(encode_p() がそういう処理だった事を思い +出そう)。 + +decode_p_st1() が decode する圧縮文の構造は図で表すと以下のようになる + +---------------------------------------------------------------------------- + +j < np の場合 (pt_len[j] < 8 の場合) + + <- pt_len[j] -> + <------ 8 -------> + +--------------+---------- +圧縮文 | ハフマン符号 | + +--------------+---------- + +j >= np の場合 (pt_len[j] > 8 の場合) + + <----------- pt_len[j] ---------> + <------ 8 -------> + +------------------+--------------+----------+---------- +圧縮文 | root | ハフマン符号 | 位置の値 | + +------------------+--------------+----------+---------- + + root: ハフマン木の根 + +---------------------------------------------------------------------------- + +以上が、decode 処理の概要だ。ここまでの処理は別にどうという事もないだ +ろう。decode 処理のキモは、圧縮文に埋め込んだハフマン符号表の読み込み +にある。blocksize == 0 のときに、decode_c_st1() で呼ばれる +read_pt_len(), read_c_len() だ。これにより、decode 処理で使用するテーブル + +c_table[] ハフマン符号 -> 文字の変換テーブル +c_len[] ハフマン符号 -> ハフマン符号のビット長の対応 +pt_table[] ハフマン符号 -> 位置のビット長の変換テーブル +pt_len[] ハフマン符号 -> ハフマン符号のビット長の対応 +left[] ハフマン木(左のノード) +right[] ハフマン木(右のノード) + +が構築される。この部分の方が decode 処理本体よりややこしそうだ。 +では、これらを見て行こう。 + + if (blocksize == 0) { + blocksize = getbits(16); + read_pt_len(NT, TBIT, 3); + read_c_len(); + read_pt_len(np, pbit, -1); + } + +最初は、read_pt_len(NT, TBIT, 3) から + +static void +read_pt_len(nn, nbit, i_special) + short nn; + short nbit; + short i_special; +{ + int i, c, n; + + n = getbits(nbit); + if (n == 0) { + c = getbits(nbit); + for (i = 0; i < nn; i++) + pt_len[i] = 0; + for (i = 0; i < 256; i++) + pt_table[i] = c; + } + else { + i = 0; + while (i < n) { + c = bitbuf >> (16 - 3); + if (c == 7) { + unsigned short mask = 1 << (16 - 4); + while (mask & bitbuf) { + mask >>= 1; + c++; + } + } + fillbuf((c < 7) ? 3 : c - 3); + pt_len[i++] = c; + if (i == i_special) { + c = getbits(2); + while (--c >= 0) + pt_len[i++] = 0; + } + } + while (i < nn) + pt_len[i++] = 0; + make_table(nn, pt_len, 8, pt_table); + } +} + +実際、大した事はない。< pt_len[] の出力フォーマット > にしたがって、 +pt_len[] を読み直しているだけだ。read_c_len() も見よう。 + +static void +read_c_len( /* void */ ) +{ + short i, c, n; + + n = getbits(CBIT); + if (n == 0) { + c = getbits(CBIT); + for (i = 0; i < NC; i++) + c_len[i] = 0; + for (i = 0; i < 4096; i++) + c_table[i] = c; + } else { + i = 0; + while (i < n) { + c = pt_table[bitbuf >> (16 - 8)]; + if (c >= NT) { + unsigned short mask = 1 << (16 - 9); + do { + if (bitbuf & mask) + c = right[c]; + else + c = left[c]; + mask >>= 1; + } while (c >= NT); + } + fillbuf(pt_len[c]); + if (c <= 2) { + if (c == 0) + c = 1; + else if (c == 1) + c = getbits(4) + 3; + else + c = getbits(CBIT) + 20; + while (--c >= 0) + c_len[i++] = 0; + } + else + c_len[i++] = c - 2; + } + while (i < NC) + c_len[i++] = 0; + make_table(NC, c_len, 12, c_table); + } +} + +こちらも、< c_len[] の出力フォーマット > にしたがって、c_len[] を読み +直しているだけだ。結局キモとなるのは、make_table() にあるらしい。この +関数により、読み込んだ pt_len[], c_len[] から pt_table[], c_table[] +(そして、ハフマン木 left[], right[])を構築しているのだろう。 + +結局、decode 処理 read_c_len(), read_pt_len() を読んでもなぜこのような +符号化を行っているのかよくわからなかった。何か統計的な根拠でもあるのだ +ろうか?それとも LHA にとって歴史的な事情でもあるのか?これに関しては +別途検証の必要があるだろう。 + +では、最後の関数 make_table() を解読しよう。これは、maketbl.c で定義さ +れている。 + +void +make_table(nchar, bitlen, tablebits, table) + short nchar; + unsigned char bitlen[]; + short tablebits; + unsigned short table[]; +{ + unsigned short count[17]; /* count of bitlen */ + unsigned short weight[17]; /* 0x10000ul >> bitlen */ + unsigned short start[17]; /* first code of bitlen */ + unsigned short total; + unsigned int i, l; + int j, k, m, n, avail; + unsigned short *p; + + /* (A) */ + avail = nchar; + + /* initialize */ + for (i = 1; i <= 16; i++) { + count[i] = 0; + weight[i] = 1 << (16 - i); + } + + /* (B) */ + /* count */ + for (i = 0; i < nchar; i++) + count[bitlen[i]]++; + + /* (C) */ + /* calculate first code */ + total = 0; + for (i = 1; i <= 16; i++) { + start[i] = total; + total += weight[i] * count[i]; + } + if ((total & 0xffff) != 0) + error("make_table()", "Bad table (5)\n"); + + /* (D) */ + /* shift data for make table. */ + m = 16 - tablebits; + for (i = 1; i <= tablebits; i++) { + start[i] >>= m; + weight[i] >>= m; + } + + /* (E) */ + /* initialize */ + j = start[tablebits + 1] >> m; + k = 1 << tablebits; + if (j != 0) + for (i = j; i < k; i++) + table[i] = 0; + + /* (F) */ + /* create table and tree */ + for (j = 0; j < nchar; j++) { + k = bitlen[j]; + if (k == 0) + continue; + l = start[k] + weight[k]; + if (k <= tablebits) { + /* code in table */ + for (i = start[k]; i < l; i++) + table[i] = j; + } + else { + /* code not in table */ + p = &table[(i = start[k]) >> m]; + i <<= tablebits; + n = k - tablebits; + /* make tree (n length) */ + while (--n >= 0) { + if (*p == 0) { + right[avail] = left[avail] = 0; + *p = avail++; + } + if (i & 0x8000) + p = &right[*p]; + else + p = &left[*p]; + i <<= 1; + } + *p = j; + } + start[k] = l; + } +} + +順に見て行こう。 + + /* (A) */ + avail = nchar; + + /* initialize */ + for (i = 1; i <= 16; i++) { + count[i] = 0; + weight[i] = 1 << (16 - i); + } + +avail はおそらく maketree.c:make_tree() でそうであったように、木の節の +初期値だろうと予想しておく。count[], weight[] も、maketree.c での +len_cnt[] weight[] と同義だろう(すなわち、count[i] は、木の深さ i 番目 +の葉の数、weight[i] は重み) + + /* (B) */ + /* count */ + for (i = 0; i < nchar; i++) + count[bitlen[i]]++; + +count[] を求めている。bitlen[i] は、文字 i のハフマン符号での bit 長で +あった。やはり count[] は予想通りだ。 + + /* (C) */ + /* calculate first code */ + total = 0; + for (i = 1; i <= 16; i++) { + start[i] = total; + total += weight[i] * count[i]; + } + if ((total & 0xffff) != 0) + error("make_table()", "Bad table (5)\n"); + +これは、maketree.c:make_code() の前半部分とまったく同じだ。これにより、 +深さ i に対して、以下の対応表ができる(これは前にも書いた。Li は、 +count[i] の値を表している)。 + + i count[i] weight[i] start[i] + -------------------------------------------- + 1 L1 2^15 0 + 2 L2 2^14 2^15 * L1 + 3 L3 2^13 2^15 * L1 + 2^14 * L2 + 4 L4 2^12 2^15 * L1 + 2^14 * L2 + 2^13 * L3 + +これが何を表すかと言うと深さ i の符号(つまり bit 長 i の符号)は、 +start[i] から start[i+1]-1 の範囲の値を持つと言う事を意味する。再度、 +例で示そう。 + + /\ a: 0 + a /\ b: 10 + b c c: 11 + + i count[i] weight[i] start[i] + -------------------------------------------- + 1 1 2^15 0 + 2 2 2^14 2^15 + 3 0 2^13 2^15 + 2^14 * 2 + +これより、深さ 1 の葉 a は、start[1] .. start[2]-1 つまり、 +00000000 00000000 .. 01111111 11111111 の範囲の符号となる。 +深さ 2 の葉 b, c は、start[2] .. start[3]-1 つまり、 +10000000 00000000 ... 11111111 11111111 となる。 + + /* (D) */ + /* shift data for make table. */ + m = 16 - tablebits; + for (i = 1; i <= tablebits; i++) { + start[i] >>= m; + weight[i] >>= m; + } + +理由はわからないが、作成するテーブルを引数で渡された bit 数のテーブル +になるよう写像している。つまり、値の範囲の初期値 start[] と weight[] +を 16 - tablebits でシフトすることで、 + + 01111111 11111111 + +というテーブルの値は(tablebits が 12 であるとすると)、 + + 00000111 11111111 + +の値にする。encode するときは、16 bit のテーブルをそのまま使用していた +にも関わらず decode のときにはテーブルの bit 数を減らしているのだ。まっ +たく理由がわからない。 + +当然、encode で使用していたときのテーブルより情報量が減っているので、 +すべてをテーブル参照で decode することはできない。そこで、足りない部分 +は後の処理で木を作ることで補っているようだ。 + +ちょっと気分的にノらないのではしょるが、後の (E), (F) は木を同時に作っ +ていることを除けば、maketree.c:make_code() の後半部分と同じだと考えて +いいだろう。 + +# Local Variables: +# mode : indented-text +# indent-tabs-mode: nil +# End: diff -Nru lha-1.14i/header.doc.euc lha-1.14i-acc20050924p1/header.doc.euc --- lha-1.14i/header.doc.euc 2000-12-15 12:13:16.000000000 +0000 +++ lha-1.14i-acc20050924p1/header.doc.euc 2002-06-03 22:12:53.000000000 +0000 @@ -175,6 +175,12 @@ (3)のグループ名、ユーザ名の情報を含む書庫を作成すること はなく、展開時には無視する。 また、(4)はヘッダレベル1の書庫にのみ含まれる。 + + (3) を作成するようにしてみました。展開と一覧表示のときに (3) + の情報があれば ID に優先します。 + 作成は configure オプション --enable-user-name-header を指定して + build したときに有効になります。(2002-06-04 新井) + ---------------------------------------------------------------- 以上。 diff -Nru lha-1.14i/install-sh lha-1.14i-acc20050924p1/install-sh --- lha-1.14i/install-sh 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/install-sh 2005-08-29 05:53:16.000000000 +0000 @@ -0,0 +1,323 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2005-05-14.22 + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +chmodcmd="$chmodprog 0755" +chowncmd= +chgrpcmd= +stripcmd= +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src= +dst= +dir_arg= +dstarg= +no_target_directory= + +usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: +-c (ignored) +-d create directories instead of installing files. +-g GROUP $chgrpprog installed files to GROUP. +-m MODE $chmodprog installed files to MODE. +-o USER $chownprog installed files to USER. +-s $stripprog installed files. +-t DIRECTORY install into DIRECTORY. +-T report an error if DSTFILE is a directory. +--help display this help and exit. +--version display version info and exit. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG +" + +while test -n "$1"; do + case $1 in + -c) shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + --help) echo "$usage"; exit $?;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -s) stripcmd=$stripprog + shift + continue;; + + -t) dstarg=$2 + shift + shift + continue;; + + -T) no_target_directory=true + shift + continue;; + + --version) echo "$0 $scriptversion"; exit $?;; + + *) # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + test -n "$dir_arg$dstarg" && break + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dstarg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dstarg" + shift # fnord + fi + shift # arg + dstarg=$arg + done + break;; + esac +done + +if test -z "$1"; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src ;; + esac + + if test -n "$dir_arg"; then + dst=$src + src= + + if test -d "$dst"; then + mkdircmd=: + chmodcmd= + else + mkdircmd=$mkdirprog + fi + else + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dstarg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dstarg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst ;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dstarg: Is a directory" >&2 + exit 1 + fi + dst=$dst/`basename "$src"` + fi + fi + + # This sed command emulates the dirname command. + dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'` + + # Make sure that the destination directory exists. + + # Skip lots of stat calls in the usual case. + if test ! -d "$dstdir"; then + defaultIFS=' + ' + IFS="${IFS-$defaultIFS}" + + oIFS=$IFS + # Some sh's can't handle IFS=/ for some reason. + IFS='%' + set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` + shift + IFS=$oIFS + + pathcomp= + + while test $# -ne 0 ; do + pathcomp=$pathcomp$1 + shift + if test ! -d "$pathcomp"; then + $mkdirprog "$pathcomp" + # mkdir can fail with a `File exist' error in case several + # install-sh are creating the directory concurrently. This + # is OK. + test -d "$pathcomp" || exit + fi + pathcomp=$pathcomp/ + done + fi + + if test -n "$dir_arg"; then + $doit $mkdircmd "$dst" \ + && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; } + + else + dstfile=`basename "$dst"` + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + trap '(exit $?); exit' 1 2 13 15 + + # Copy the file name to the temp name. + $doit $cpprog "$src" "$dsttmp" && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && + + # Now rename the file to the real destination. + { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \ + || { + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + if test -f "$dstdir/$dstfile"; then + $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ + || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ + || { + echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 + (exit 1); exit 1 + } + else + : + fi + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" + } + } + fi || { (exit 1); exit 1; } +done + +# The final little trick to "correctly" pass the exit status to the exit trap. +{ + (exit 0); exit 0 +} + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff -Nru lha-1.14i/MACHINES2.euc lha-1.14i-acc20050924p1/MACHINES2.euc --- lha-1.14i/MACHINES2.euc 2000-12-15 12:13:16.000000000 +0000 +++ lha-1.14i-acc20050924p1/MACHINES2.euc 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ ----------------------------------------------------------------- -マシン AT互換機 (Pentium 133MHz) -OS FreeBSD 2.0.5 -Compiler gcc 2.6.3 -変更事項 特になし -備考 Ver.1.14d製作環境 - Ver.1.14dのコンパイル ----------------------------------------------------------------- -マシン AT互換機 (Pentium 100MHz) -OS Linux 2.0.20 (POSIX) -Compiler gcc version 2.7.2 -変更事項 MACHINE に -DSYSV_SYSTEM_DIR を追加 - OPTIMIZE に -m486 を追加 -備考 Slackware-3.0.0ベースで kernel version 2.0.XX - が動くようにしたシステム (libc version 5.2.18) - コンパイルした日: 1996/09/17(火) ----------------------------------------------------------------- --- 以下、1.14d公開以後報告 ----------------------------------------------------------------- - NeXT - NeXTStationTurbo Color - NeXTSTEP Release 3.3J - cc ( システム標準 gcc 2.4.5相当) - SWITHESに -DNOSTRDUP -DUSESTRCASECMP を追加 - また、4way-MAB作成の為、 CC に - -arch m68k -arch i386 -arch hppa -arch sparcを追加 - ( 試してはいませんが、このバイナリで Intel, PA-RISC, SPARC用の - NeXTSTEP/OPENSTEP for Machでも稼動するはずです ) ----------------------------------------------------------------- - NEC - EWS4800/320PX ( and 310PX ) - EWS-UX/V R11.4 - /usr/abiccs/bin/cc - SWITCHES に -DNOINDEX -DMKTIME -DSYSV_SYSTEM_DIR を追加 - また OPTIMIZEを -O -Kmips2に設定 - -Kmips2は mips2に最適化するため、R3000系のCPUを使ったマシンでは - 稼動しないバイナリを作成します。 ----------------------------------------------------------------- -メーカー: 不明 -マシン : SGI CRAY Origin 2000 -OS : IRIX 6.4 -オプション MACHINEから-DHAVE_TM_ZONEを除きました。 ----------------------------------------------------------------- -マシン SGI O2 -OS IRIX 6.5 + WorldView Japanese 6.5 -SWITCHES = -DEUC -MACHINE = -DNOINDEX -DSYSTIME_HAS_NO_TM -DSYSV_SYSTEM_DIR -n32 -mips3 -OPTIMIZE = -O2 -備考 -DNOINDEX を付けないとデリミタを含むパスがうまく書けません。 ----------------------------------------------------------------- -マシン AT互換機 (Pentium III 500MHz) -OS Solaris 2.7 (x86) -Compiler gcc version 2.8.1 -変更事項 SWITCHES に -DFTIME - -DUSESTRCASECMP を追加 - MACHINE に -DSYSV_SYSTEM_DIR を追加 - OPTIMIZE に -m486 を追加 -備考 make install 時に - "/usr/sbin/install"ではエラー。 - "/usr/ucb/install"を使用。 - これは Solaris 全般のインストール時の問題。 ----------------------------------------------------------------- -マシン ? -OS Linux 2.2.x -Compiler gcc version egcs-2.91.66 19990314 (egcs-1.1.2 rel) -変更事項 -DHAVE_TM_ZONE を消して -DMKTIME を入れる - ----------------------------------------------------------------- -社名 Sun Microsystems -マシン Ultra -OS Solaris2.5 -Compiler cc,gcc -変更事項 MACHINEを-DSYSTIME_HAS_NO_TM - -DEUC -DSYSV_SYSTEM_DIRに変更 ---------------------------------------------------------------- -社名 Sun Microsystems -マシン Sun Ultra 1/170 -OS Solaris2.6 (SunOS5.6) -Compiler egcs-1.1 release (egcs-2.91.57 19980901)(gcc-2.8.*相当?) -変更事項 MACHINE=-DNOBSTRING -DNOINDEX -DTZSET -DSYSV_SYSTEM_DIR - -DSYSTIME_HAS_NO_TM - MANDIR=/usr/local/man/ja - INSTALL=/usr/ucb/install - MANSECT=1 (お好みに応じて) -備考 sun solaris SVR4 - SunOSには伝統的に?struct tmにtimezoneがないので注意 ----------------------------------------------------------------- -社名:    IBM -マシン:   RS/6000-25T -OS :   AIX Version 3.2.5 -コンパイラ: /bin/cc -変更 :   SWITCHESに-DSYSV_SYSTEM_DIR -BSD_INCLUDES -DAIXを追加 - MACHINEを-DSYSTIME_HAS_NO_TM -DTZSETに変更 ----------------------------------------------------------------- -社名 Hewlett Packard -マシン HP9000 C240 -OS HP-UX 10.20 -Compiler cc -変更事項 SWITCHES に -DUSESTRCASECMP を追加。 - SWITCHES に -DNOBSTRING を追加。 - Shift-JIS を使用するので -DEUCを削除し, - source内のEUCコードをShift-JISコードに変換。 - OPTIMIZEに -Y -O +DAportable +DSportableを指定 - portable指定はPA7000シリーズに対応するため ----------------------------------------------------------------- - - diff -Nru lha-1.14i/MACHINES.euc lha-1.14i-acc20050924p1/MACHINES.euc --- lha-1.14i/MACHINES.euc 2000-12-15 12:13:16.000000000 +0000 +++ lha-1.14i-acc20050924p1/MACHINES.euc 1970-01-01 00:00:00.000000000 +0000 @@ -1,454 +0,0 @@ ----------------------------------------------------------------- -社名 Sun Microsystems -マシン Sun3/80,SPARCstation -OS SunOS 4.0.3, 4.1.1, 4.1.2, 4.1.3(+JLE) -Compiler cc,gcc -traditional -変更事項 SWITCHES に -DFTIME -DUSESTRCASECMP を追加 -備考 sun ---------------------------------------------------------------- -社名 東芝 -マシン AS3000 -OS AS3.3(SunOS 3.3) -Compiler /bin/cc -変更事項 SWITCHES に -DSTRDUP を追加 -備考 sun ----------------------------------------------------------------- -社名 SONY -マシン NWS-1460/1750 -OS NEWS-OS 3.3a, 3.4 -Compiler cc,gcc -traditional -変更事項 SWITCHES に -DNOSTRDUP を追加 -備考 sony_news ----------------------------------------------------------------- -社名 SONY -マシン NWS-1830/1850 -OS NEWS-OS 4.0.1C/4.1C -Compiler cc,gcc -変更事項 SWITCHES に -DNOSTRDUP を追加 -備考 sony_news ----------------------------------------------------------------- -社名 SONY -マシン NWS-3260/3460/3860 -OS NEWS-OS 3.91R/4.1R -Compiler cc,gcc version 1.40 -変更事項 SWITCHES に -DNOSTRDUP を追加 -備考 sony_news ---------------------------------------------------------------- -社名 OMRON -マシン SX-9100 Mr. -OS UniOS-U/Sigma 1.40 -Compiler /bin/cc -変更事項 SWITCHES に -DUSG -DSYSTIME_HAS_NO_TM -DNOBSTRING -DNOINDEX - -DNOSTRDUP -DNODIRECTORY -DNOFTRUNCATE -Zu を追加 -備考 ----------------------------------------------------------------- -社名 OMRON -マシン LUNA (SX-9100/DT) -OS UNIOS-B 1.50,2.00 -Compiler /bin/cc,gcc version 1.40 -変更事項 SWITCHES に -DFTIME -DNOSTRDUP を追加 -備考 ---------------------------------------------------------------- -社名 OMRON -マシン LUNA-II -OS Mach 2.5 Vers 1.40 -Compiler /bin/cc -変更事項 SWITCHES に -DNOSTRDUP -DFTIME -DUSESTRCASECMP を追加 -備考 ----------------------------------------------------------------- -社名 OMRON -マシン LUNA-88K -OS Mach 2.5 vers 1.33 -Compiler /bin/cc,gcc-1.40 -変更事項 SWITCHES に -DFTIME -DNOSTRDUP を追加 -備考 ----------------------------------------------------------------- -社名 OMRON -マシン LUNA(SX-9100DT) -OS UniOS-U/Sigma 2.01 -Compiler /bin/cc -変更事項 SWITCHES に -Zu -DSYSV_SYSTEM_DIR -DSYSTIME_HAS_NO_TM - -DNOFTRUNCATE -DNOSTRDUP -DNOBSTRING -DUSG -DNOINDEX を追加 -備考 uniosu ----------------------------------------------------------------- -社名 OMRON -マシン SX-9100Σ -OS OMRONIX-Σ -Compiler /bin/cc -変更事項 SWITCHES に -Zu -DNONSYSTEM_DIR_LIBRARY -DSYSTIME_HAS_NO_TM - -DNOFTRUNCATE -DNOBSTRING -DUSG -DNOINDEX を追加,LIBRARYOBJS - に lhdir.o を追加 -備考 ----------------------------------------------------------------- -社名 NeXT -マシン NeXT station/Cube -OS NeXT OS 2.1, 2.1J -Compiler /bin/cc NeXT Release 2.0 -変更事項 SWITCHES に -DNOSTRDUP を追加 -備考 ----------------------------------------------------------------- -社名 DEC -マシン DEC5100,DEC Station 3100,MicroVAX-3600 -OS ULTRIX V4.0, 4.1, 4.2 -Compiler cc -変更事項 SWITCHES に -DUSESTRCASECMP -DNOSTRDUP を追加 -備考 ultrix ----------------------------------------------------------------- -社名 Panasonic -マシン BE -OS BE-OS 1.3 -Compiler gcc version 1.37.1 -変更事項 SWITCHES に -DSYSV_SYSTEM_DIR -DSYSTIME_HAS_NO_TM -DTZSET - -DNOFTRUNCATE を追加 -備考 ----------------------------------------------------------------- -社名 MIPS -マシン RS3230/3330 -OS RISC/os 4.51,4.52 -Compiler /bsd43/bin/cc -変更事項 SWITCHES に -DNOSTRDUP を追加 -備考 ----------------------------------------------------------------- -社名 Sequent Computer Systems, Inc. -マシン Symmetry -OS DYNIX(R) V3.0.17.v3 NFS #2() -Compiler cc -変更事項 SWITCHES に -DJIS -DNOSTRDUP -DNOMEMSET を追加 -備考 ----------------------------------------------------------------- -社名 Solbourne -マシン Series 5/600 -OS OS/MP 4.0D_Export -Compiler cc,gcc -traditional -変更事項 -備考 ----------------------------------------------------------------- -社名 三菱電機 -マシン ME100/200/250/350/400/520/550 -OS ME/UX C00,C10,C20 (System V/68 Release R3V4) -Compiler cc -変更事項 SWITCHES に -DSYSV_SYSTEM_DIR -DNOFTRUNCATE を追加 -備考 ----------------------------------------------------------------- -社名 三菱電機 -マシン ME1100/1200/1300/1500 -OS ME/UX (68020) C01版 (SYSV R2) -Compiler cc -変更事項 SWITCHES に -DNONSYSTEM_DIR_LIBRARY -DNOFTRUNCATE - -DSYSTIME_HAS_NO_TM -DNOBSTRING -DUSG -DNOSTRDUP -DNOMKDIR - -DTZSET -DNOINDEX を追加,LIBRARYOBJS に lhdir.o を追加 -備考 ----------------------------------------------------------------- -社名 三菱電機 -マシン FAS350(FA-workstation) -OS ISI-4.3BSD -Compiler /bin/cc -変更事項 SWITCHES に -DFTIME -DNOSTRDUP を追加 -備考 ----------------------------------------------------------------- -社名 NEC -マシン EWS4800/10,20,30,50,60 -OS EWS-UX/V R8.1 -Compiler cc,gcc -traditional -変更事項 SWITCHES に -I/usr/ucbinclude -DSYSTIME_HAS_NO_TM -DTZSET - -DUSG -DNOINDEX を追加,LDFLAGS=-ldir を追加 -備考 ----------------------------------------------------------------- -社名 NEC -マシン EWS4800/220 -OS EWS-UX/V (Rel 4.0)R2.1 -Compiler /bin/cc -変更事項 SWITCHES に -DMKTIME -DNOINDEX -DSYSV_SYSTEM_DIR -DUSG を追加 -備考 ----------------------------------------------------------------- -社名 NEC -マシン EWS4800/220 -OS EWS-UX/V (Rel 4.0)R2.1 -Compiler /usr/ucb/cc -変更事項 SWITCHES に -DMKTIME を追加 -備考 ----------------------------------------------------------------- -社名 NEC -マシン PC-9801 -OS PC-UX/V R3.2 -Compiler cc -変更事項 SWITCHES に -DNOFTRUNCATE -DTZSET -DSYSV_SYSTEM_DIR - -DSYSTIME_HAS_NO_TM -DNOBSTRING -DUSG -DNOINDEX を追加 -備考 ----------------------------------------------------------------- -社名 NEC -マシン PC-9801 -OS PC-UX/V R3.0B -Compiler cc および gcc-2.0 -変更事項 SWITCHES に -DUSG -DSYSV_SYSTEM_DIR -DSYSTIME_HAS_NO_TM - -DTZSET -DNOBSTRING -DNOFTRUNCATE -DNOINDEX を追加 -備考 gcc でコンパイルする場合は、-traditional オプションを - つける。 ----------------------------------------------------------------- -社名 Hewlett Packard -マシン HP9000 s300/s400 -OS HP-UX7.03 -Compiler cc -変更事項 EUC を使用する場合は SWITCHES に -DNOBSTRING を追加。 - Shift-JIS を使用する場合はSWITCHESに -DNOBSTRING を追加し - -DEUC を削除。 -備考 hpux ----------------------------------------------------------------- -社名 Hewlett Packard -マシン HP9000 s800 -OS HP-UX7.00 -Compiler cc -変更事項 EUC を使用する場合は SWITCHES に -DNOBSTRING を追加。 - Shift-JIS を使用する場合はSWITCHESに -DNOBSTRING を追加し - -DEUC を削除。 -備考 hpux ----------------------------------------------------------------- -社名 Hewlett Packard -マシン HP9000 s300/s400 -OS HP-UX8.0 -Compiler cc -変更事項 SWITCHES に -DUSESTRCASECMP を追加。Shift-JIS を使用する場合 - はさらに -DEUCを削除。 -備考 hpux ----------------------------------------------------------------- -社名 Hewlett Packard -マシン HP9000 s700 -OS HP-UX 8.05,8.07 -Compiler cc -変更事項 SWITCHES に -DUSESTRCASECMP を追加。Shift-JIS を使用する場合 - はさらに -DEUCを削除。 -備考 hpux ----------------------------------------------------------------- -社名 Hewlett Packard -マシン HP apollo s400t,s25t -OS DOMAIN/OS SR10.3 -Compiler cc Ver 6.8 -変更事項 (SYSTYPE=bsd4.3,ENVIRON=bsd) -備考 ----------------------------------------------------------------- -社名 DOMAIN -マシン DN4500F -OS DOMAIN/OS SR10.2 -Compiler cc Ver 6.7 -変更事項 SWITCHES に -U__STDC__ を追加(SYSTYPE=bsd4.3,ENVIRON=bsd) -備考 ----------------------------------------------------------------- -社名 DOMAIN -マシン DSP10000 -OS DOMAIN/OS SR10.2p -Compiler cc Ver 6.7p (PRISM) -変更事項 SWITCHES に -U__STDC__ を追加(SYSTYPE=bsd4.3,ENVIRON=bsd) -備考 ----------------------------------------------------------------- -社名 日立 -マシン HIDIC V90/45 -OS RENIX-V -Compiler /bin/cc -変更事項 SWITCHES に -DTZSET -DSYSTIME_HAS_NO_TM -DSYSV_SYSTEM_DIR - -DNOBSTRING -DUSG -DNOINDEX -DNOFTRUNCATE を追加 -備考 ----------------------------------------------------------------- -社名 日立 -マシン 2050/32E -OS HI-UX (ver.不明) -Compiler cc -変更事項 SWITCHES に -DTZSET -DSYSTIME_HAS_NO_TM -DSYSV_SYSTEM_DIR - -DNOBSTRING -DUSG -DNOINDEX を追加 -備考 ----------------------------------------------------------------- -社名 東芝 -マシン J3100SGT -OS UX/386 (SysVR3) -Compiler /bin/cc -変更事項 SWITCHES に -DTZSET -DSYSV_SYSTEM_DIR -DNOBSTRING -DUSG - -DNOINDEX -DNOFTRUNCATE を追加 -備考 ----------------------------------------------------------------- -社名 富士通 -マシン G150/160 -OS SX/G E14 -Compiler cc -変更事項 SWITCHIES に -DNONSYSTEM_DIR_LIBRARY -DNOSTRDUP -DTZSET - -DNOBSTRING -DUSG -DNOINDEX -DNOFTRUNCATE -DSYSTIME_HAS_NO_TM - を追加,LDFLAGS=-lu を追加 -備考 ----------------------------------------------------------------- -社名 富士通 -マシン VP2200 MODEL 10 -OS UXP/M V10L10 -Compiler BSD Compatibility Package の cc (/usr/ucb/cc) -変更事項 LDFLAGS=-lucb を追加 -備考 ----------------------------------------------------------------- -社名 富士通 -マシン Mシリーズ -OS UTS/M V22L20 -Compiler cc -変更事項 SWITCHIES に -DNODIRECTORY -DNOSTRDUP -DTZSET -DNOBSTRING - -DUSG -DNOINDEX -DNOFTRUNCATE -DSYSTIME_HAS_NO_TMを追加 -備考 ----------------------------------------------------------------- -社名 PFU -マシン Astation 240 -OS SX/A E60B -Compiler /bin/cc -変更事項 SWITCHES に -DSYSV_SYSTEM_DIR -DSYSTEM_HAS_NO_TM -DUSG - -DNOINDEX を追加 -備考 SXA ----------------------------------------------------------------- -社名 PFU -マシン A60 / Astation 350 -OS SX/A E50/E60B -Compiler /bin/cc -変更事項 SWITCHES に -DSYSV_SYSTEM_DIR -DNOBSTRING -DNOFTRUNCATE - -DUSG -DEUC -DNEED_INCREMENTAL_INDICATOR を追加 -備考 本当は -DNOFTRUNCATE はE50でのみ必要 ----------------------------------------------------------------- -社名 EPSON/NEC/IBM -マシン PC-386GE/PC-9801NS/IBM PC-AT -OS MINIX 1.5.10 + MIX 386 patch -Compiler MIX版gcc -変更事項 SWITCHES を -DEUC -DNOSTRDUP -D_MINIX -D_POSIX_SOURCE - -DSYSTIME_HAS_NO_TM -DSYSV_SYSTEM_DIR -DNOFTRUNCATE - -DNOBSTRING -DUSG -DNOINDEX -DTZSET に変更 - CC を gcc に変更 - OPTIMIZE から -g を削除 -備考 (1) maketree.cでUINT_MAXの評価がCPPエラーになったら - /usr/local/lib/include/gcc-limits.hを - /usr/local/lib/include/limits.hにmvまたはlnするか、 - その部分の#if #endifをコメントアウトすること - (これは、MIX版gccの問題です。 最新版gccでは解決されています。) - (2) コンパイル後以下のコマンドを実行し、メモリサイズを - 変更すること - chmem =500000 lha ----------------------------------------------------------------- -社名 Silicon Graphics -マシン IRIS200 -OS IRIX 2.2 -Compiler /usr/bin/cc -変更事項 -備考 ---------------------------------------------------------------------- -社名 Silicon Graphics -マシン IRIS 4D/25GT,4D/310GTX -OS IRIX System V Release 3.3.1 -Compiler /usr/bin/cc -変更事項 SWITCHES に -DSYSV_SYSTEM_DIR -DNOBSTRING -DNOINDEX を追加 ----------------------------------------------------------------- -社名 クボタコンピュータ -マシン TITAN3000 -OS OS 3.0.3,OS 4.1 -Compiler /bin/cc -変更事項 SWITCHES に -DNOINDEX -DSYSV_SYSTEM_DIR を追加 -備考 titan ----------------------------------------------------------------- -社名 クボタコンピュータ -マシン TITAN1500 -OS OS 2.5 -Compiler cc -変更事項 SWITCHES に -DNOINDEX -DSYSV_SYSTEM_DIR -DSYSTIME_HAS_NO_TM - を追加 -備考 titan ----------------------------------------------------------------- -社名 クボタコンピュータ -マシン TITAN VISTRA800ex/VISTRA800b -OS 2.0 -Compiler /usr/ucb/cc -変更事項 SWITCHES に -DSYSV_SYSTEM_DIR -DSYSTIME_HAS_NO_TM を追加 -備考 titan ----------------------------------------------------------------- -社名 IBM -マシン RISC System/6000 POWERstation 530 -OS AIX version 3.1 -Compiler /bin/cc -変更事項 SWITCHES に -DSYSV_SYSTEM_DIR -D_BSD_INCLUDES -DAIX を追加 -備考 ----------------------------------------------------------------- -社名 Convex -マシン Mini Super Computer C-201,C-230,C-240 -OS ConvexOS V.8.1, v9.1.6 (BSD 4.2) -Compiler /bin/cc V4.0 -変更事項 SWITCHES に -DSYSV_SYSTEM_DIR を追加, CC に -pcc を追加 -備考 __convexc__ ----------------------------------------------------------------- -社名 電産 -マシン WORKS-3000, idea 2010 -OS DEVOS V3 (4.3 More/bsd/NFS) -Compiler gcc -traditional (gcc 1.40) -変更事項 SWITCHES に -DFTIME -DNOSTRDUP を追加 -備考 ------------------------------------------------------------------------- -社名 SONY -マシン NWS-1860 -OS NEWS-OS 4.2.1C -Compiler cc -変更事項 SWITCHES に -DNOSTRDUP を追加 -備考 sony_news ------------------------------------------------------------------------- -社名 SONY -マシン NWS-3870 -OS NEWS-OS 4.2.1R -Compiler cc -変更事項 SWITCHES に -DNOSTRDUP を追加 -備考 sony_news ------------------------------------------------------------------------- -社名 富士通 -マシン DS/90 7750 (Single CPU type) -OS UNIX_System_V 4.0.0 V10L20 Y92121 -Compiler cc -変更事項 SWITCHES に -DEUC -DUSG -DSYSV_SYSTEM_DIR -DNOBSTRING - -DSYSTIME_HAS_NO_TM -DNOINDEX を追加 -備考 ----------------------------------------------------------------- -社名 DEC -マシン DECstation 5000/25 -OS ULTRIX V4.3 -Compiler cc -変更事項 SWITCHES に -DUSESTRCASECMP -DNOSTRDUP -DNOINDEX - -DNOBSTRING を追加 -備考 ultrix ----------------------------------------------------------------- -社名 DEC -マシン DEC 3000/300 -OS DEC OSF/1 V1.3A -Compiler cc -変更事項 SWITCHES に -DSYSV_SYSTEM_DIR -DNOINDEX -DNOBSTRING を追加 -備考 osf ----------------------------------------------------------------- -社名 Silicon Graphics -マシン INDY, INDIGO, ONYX -OS IRIX Release 5.1 -Compiler cc -変更事項 SWITCHES に -DSYSV_SYSTEM_DIR -DNOBSTRING -DNOINDEX を追加 ----------------------------------------------------------------- -社名 Apple -マシン Quadra 950 -OS A/UX 3.0 -Compiler cc -変更事項 SWITCHES に -DNOSTRDUP -DTZSET を追加 ----------------------------------------------------------------- -マシン 不明(Pentium133MHz) -OS BSDI BSD/OS 2.0 -Compiler cc(gcc) -変更事項 SWITCHES から -DFTIME を削除する。 ----------------------------------------------------------------- -マシン IBM-PC/AT 互換機(Pentium133MHz) -OS FreeBSD 2.1.0 Release -Compiler gcc -変更事項 SWITCHES から -DFTIME を削除し、 - -DHAVE_TM_ZONE を追加する。 ----------------------------------------------------------------- -マシン 不明(Pentium99MHz) -OS Linux 1.2.13(POSIX) -Compiler cc(gcc) -変更事項 特に変更なし。 ----------------------------------------------------------------- -社名 Hewlett Packard -マシン HP9000 s720 -OS HP-UX 9.01 -Compiler c89 -変更事項 SWITCHES に -DUSESTRCASECMP を追加。 - SWITCHES に -D_HPUX_SOURCE を追加。 - Shift-JIS を使用する場合はさらに -DEUCを削除。 - OPTIMIZE には -O だけを指定 ----------------------------------------------------------------- diff -Nru lha-1.14i/Makefile lha-1.14i-acc20050924p1/Makefile --- lha-1.14i/Makefile 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -################################################################ -# Makefile for LHa topdir -# Mar. 2, 1992, written by Masaru Oki. -# AUG. 22,1994, modified by Nobutaka Watazaki -# Jun. 7,1999, modified by Tsugio Okamoto -################################################################ - -#----------------------------------------------------------------------- -# CONFIGURATION -# SWITCHES macro definitions ... see config.eng or config.jpn. -#----------------------------------------------------------------------- - -SHELL=/bin/sh -MAKE = make - -#CC = cc -CC = gcc -SWITCHES = -DNEED_INCREMENTAL_INDICATOR \ - -DTMP_FILENAME_TEMPLATE="\"/tmp/lhXXXXXX\"" - -#MACHINE = -DSYSTIME_HAS_NO_TM -DFTIME -DEUC -#MACHINE = -DSYSTIME_HAS_NO_TM -DEUC -DHAVE_TM_ZONE -DSYSV_SYSTEM_DIR -MACHINE = -DSYSTIME_HAS_NO_TM -DEUC -DSYSV_SYSTEM_DIR -DMKTIME -DMULTIBYTE_CHAR - -#OPTIMIZE = -O2 -fstrength-reduce -fomit-frame-pointer -OPTIMIZE = -O2 -DSUPPORT_LH7 -DMKSTEMP - -BINDIR = /usr/local/bin -MANDIR = /usr/local/man -MANSECT = n - -INSTALL = install -INSTALLBIN = -s -m 755 -INSTALLMAN = -m 644 - -SUBDIRS = src man - -O = .o - -# missing library objects. -# memset$(O) lhdir$(O) -LIBRARYOBJS = patmatch$(O) - -MYMAKEFLAGS = 'BINDIR=$(BINDIR)' 'MANDIR=$(MANDIR)' 'MANSECT=$(MANSECT)'\ - 'INSTALL=$(INSTALL)' 'INSTALLBIN=$(INSTALLBIN)' 'INSTALLMAN=$(INSTALLMAN)'\ - 'CC=$(CC)' 'SWITCHES=$(SWITCHES)' 'O=$(O)' 'LIBRARYOBJS=$(LIBRARYOBJS)' \ - 'OPTIMIZE=$(OPTIMIZE)' 'MACHINE=$(MACHINE)' - -all: - @for i in $(SUBDIRS); do \ - echo "make all in $$i..."; \ - (cd $$i; $(MAKE) $(MFLAGS) $(MYMAKEFLAGS) all); done - -install: - @for i in $(SUBDIRS); do \ - echo "Installing in $$i..."; \ - (cd $$i; $(MAKE) $(MFLAGS) $(MYMAKEFLAGS) install); done - -clean: - @for i in $(SUBDIRS); do \ - echo "Clearing in $$i..."; \ - (cd $$i; $(MAKE) $(MFLAGS) $(MYMAKEFLAGS) clean); done - -moreclean: - @for i in $(SUBDIRS); do \ - echo "Clearing in $$i..."; \ - (cd $$i; $(MAKE) $(MFLAGS) $(MYMAKEFLAGS) moreclean); done - diff -Nru lha-1.14i/Makefile.am lha-1.14i-acc20050924p1/Makefile.am --- lha-1.14i/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/Makefile.am 2004-09-28 16:04:14.000000000 +0000 @@ -0,0 +1,5 @@ +## Process this file with automake to produce Makefile.in + +AUTOMAKE_OPTIONS = foreign +EXTRA_DIST = 00readme.autoconf header.doc.euc Hacking_of_LHa +SUBDIRS= man olddoc src tests diff -Nru lha-1.14i/Makefile.in lha-1.14i-acc20050924p1/Makefile.in --- lha-1.14i/Makefile.in 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/Makefile.in 2006-10-16 14:50:10.000000000 +0000 @@ -0,0 +1,592 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = . +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +LIBOBJDIR = +DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(srcdir)/config.h.in \ + $(top_srcdir)/configure ChangeLog config.guess config.sub \ + depcomp install-sh missing +subdir = . +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno configure.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-exec-recursive install-info-recursive \ + install-recursive installcheck-recursive installdirs-recursive \ + pdf-recursive ps-recursive uninstall-info-recursive \ + uninstall-recursive +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + { test ! -d $(distdir) \ + || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr $(distdir); }; } +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +distuninstallcheck_listfiles = find . -type f -print +distcleancheck_listfiles = find . -type f -print +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEF_KCODE = @DEF_KCODE@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SUPPORT_LZHUFF_METHOD = @SUPPORT_LZHUFF_METHOD@ +U = @U@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +AUTOMAKE_OPTIONS = foreign +EXTRA_DIST = 00readme.autoconf header.doc.euc Hacking_of_LHa +SUBDIRS = man olddoc src tests +all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: +am--refresh: + @: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \ + cd $(srcdir) && $(AUTOMAKE) --foreign \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) + +config.h: stamp-h1 + @if test ! -f $@; then \ + rm -f stamp-h1; \ + $(MAKE) stamp-h1; \ + else :; fi + +stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status config.h +$(srcdir)/config.h.in: $(am__configure_deps) + cd $(top_srcdir) && $(AUTOHEADER) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 +uninstall-info-am: + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(am__remove_distdir) + mkdir $(distdir) + $(mkdir_p) $(distdir)/tests + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(mkdir_p) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + distdir) \ + || exit 1; \ + fi; \ + done + -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r $(distdir) +dist-gzip: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) + +dist-tarZ: distdir + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__remove_distdir) + +dist-shar: distdir + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +dist dist-all: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst + chmod a-w $(distdir) + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && cd $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck + $(am__remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}' +distuninstallcheck: + @cd $(distuninstallcheck_dir) \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am +check: check-recursive +all-am: Makefile config.h +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-hdr distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-info-am + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am am--refresh check \ + check-am clean clean-generic clean-recursive ctags \ + ctags-recursive dist dist-all dist-bzip2 dist-gzip dist-shar \ + dist-tarZ dist-zip distcheck distclean distclean-generic \ + distclean-hdr distclean-recursive distclean-tags \ + distcleancheck distdir distuninstallcheck dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic maintainer-clean-recursive \ + mostlyclean mostlyclean-generic mostlyclean-recursive pdf \ + pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff -Nru lha-1.14i/man/lha.man lha-1.14i-acc20050924p1/man/lha.man --- lha-1.14i/man/lha.man 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/man/lha.man 1999-08-28 16:36:20.000000000 +0000 @@ -1,224 +1,324 @@ -LHA(N) LHa for UNIX Users Manual LHA(N) +LHA(N) Unix Programmer's Manual LHA(N) -NNAAMMEE 名名称称 - LHa - 高圧縮アーカイバ -SSYYNNOOPPSSIISS 形形式式 - llhhaa kkeeyy [ mmooddiiffiieerrss ] _a_r_c_h_i_v_e___f_i_l_e [ _f_i_l_e ... ] - llhhaa _a_r_c_h_i_v_e___f_i_l_e +NNNAAAMMMEEE 名名名称称称 + LHa - 高圧縮アーカイバ -DDEESSCCRRIIPPTTIIOONN 解解説説 - LLHHaa は効率の高い圧縮機能を持つファイルアーカイバです。 - kkeeyy に機能文字を指定し、file の追加、更新、抽出、削除、一覧表示などを行 - ないます。引数に archive_file のみを指定した場合には、機能文字に l を指 - 定したのと同等の動作を行ないます。 - 機能文字は以下の通りです。 +SSSYYYNNNOOOPPPSSSIIISSS 形形形式式式 + lllhhhaaa kkkeeeyyy [ mmmooodddiiifffiiieeerrrsss ] _a_r_c_h_i_v_e__f_i_l_e [ _f_l_i_e ... ] + lllhhhaaa _a_r_c_h_i_v_e__f_i_l_e - aa 追加。file を archive_file に追加します。 file がディレクトリで - あれば、そのディレクトリに含まれるファイルをすべて追加します。 +DDDEEESSSCCCRRRIIIPPPTTTIIIOOONNN 解解解説説説 + LLLHHHaaa は効率の高い圧縮機能を持つファイルアーカイバです。 + kkkeeeyyy に機能文字を指定し、file の追加、更新、抽出、削除、一 + 覧表示などを行ないます。引数に archive_file のみを指定した + 場合には、機能文字に l を指定したのと同等の動作を行ないま + す。 + 機能文字は以下の通りです。 - uu 更新。file が archive_file に格納されていないか、もしくは格納さ - れているものが古ければ、file を archive_file に追加します。 + aaa 追加。file を archive_file に追加します。file がデ + ィレクトリであれば、そのディレクトリに含まれるファ + イルをすべて追加します。 - ll ままたたはは vv - 一覧表示。archive_file に格納されている file の情報を一覧表示し - ます。file の指定がなければ archive_file 内の全てのファイルの情 - 報 を 表 示します。 v を指定すると l よりも詳しい情報を表示しま - す。 + uuu 更新。file が archive_file に格納されていないか、 + もしくは格納されているものが古ければ、file を + archive_file に追加します。 - xx ままたたはは ee - 抽出。archive_file から file を抽出します。file の指定がなけ れ - ば archive_file 内の全てのファイルを抽出します。抽出すべきファ - イルがすでに存在している場合には、重ね書きしていいかの問い合 わ - せを行ないます。 + lll まままたたたははは vvv + 一覧表示。archive_file に格納されている file の情 + 報を一覧表示します。file の指定がなければ + archive_file 内の全てのファイルの情報を表示します + 。v を指定すると l よりも詳しい情報を表示します。 - pp 内容表示。archive_file から file の内容を取り出し、標準出力へと - 出力します。file の指定がなければ、全ての内容を出力します。 + xxx まままたたたははは eee + 抽出。archive_file から file を抽出します。file の + 指定がなければ archive_file 内の全てのファイルを抽 + 出します。抽出すべきファイルがすでに存在している場 + 合には、重ね書きしていいかの問い合わせを行ないます + 。 - dd 削除。archive_file から file を削除します。 + ppp 内容表示。archive_file から file の内容を取り出し + 、標準出力へと出力します。file の指定がなければ、 + 全ての内容を出力します。 - mm 移動。file を archive_file に追加した後、file を削除します。 こ - れ は、key に a を、modifiers に d を指定した時と同じ動作を行な - います。 + ddd 削除。archive_file から file を削除します。 - cc 新規作成。archive_file を新たに作成し、file を追加します。 + mmm 移動。file を archive_file に追加した後、file を削 + 除します。これは、key に a を、modifiers に d を指 + 定した時と同じ動作を行ないます。 - 機能変更文字 modifiers を指定することによって key の動作の詳細を変更 す - る こ と ができます。modifiers は、以下の中から複数指定することができま - す。 + January 14,1997 1 - qq<> 表示の抑制。対話的なメッセージの表示を抑制します。 の値に - よって、INDICATOR の表示方法を変更できます。 - qq00 oooo........ のの表表示示をを行行ななうう。。 +LHA(N) Unix Programmer's Manual LHA(N) - qq11 フファァイイルル名名表表示示ののみみ行行ななうう。。 - qq22 何何もも表表示示ししなないい。。 + ccc 新規作成。archive_file を新たに作成し、file を追加 + します。 - なお、値を入力しなかった際には、q2 と同等になります。 + 機能変更文字 modifiers を指定することによって key の動作の + 詳細を変更することができます。modifiers は、以下の中から複 + 数指定することができます。 - vv 表示の冗長化。表示するメッセージを冗長にします。 - nn 実行しない。実際の更新や抽出の動作を行ないません。実行内容の確 - 認のために用意されています。 - ff 強制的な実行。ファイルの抽出時に、存在するファイルの削除確認 を - 行なわず強制的に削除を行ないます。 + qqq<<>> 表示の抑制。対話的なメッセージの表示を抑制します。 + の値によって、INDICATOR の表示方法を変更でき + ます。 - tt テキストモードによる格納,抽出。アーカイブファイルへのファイルの - 格納時には、 UNIX から MS-DOS への改行コード変換を行ないま す。 - ファイルの抽出時には逆に、MS-DOS から UNIX への改行コード変換を - 行ないます。 + qqq000 oooooo............ ののの表表表示示示ををを行行行なななううう。。。 - oo{{nnuumm}} LHarc 互換アーカイブの生成、または圧縮アルゴリズムを指定す る。 - 機能文字 a, u, m と共に指定し、抽出時には無視されます。 + qqq111 フフファァァイイイルルル名名名表表表示示示のののみみみ行行行なななううう。。。 - oo LLHHaarrcc 互互換換アアーーカカイイブブのの生生成成をを行行うう。。 + qqq222 何何何ももも表表表示示示しししななないいい。。。 - 古 い 形 式 の アー カイブを生成します。圧縮アルゴリズム - は-lh1-を使用します。 + なお、値を入力しなかった際には、q2 と同等になりま + す。 - oo55 圧圧縮縮アアルルゴゴリリズズムムにに --llhh55-- をを使使用用すするる。。 + vvv 表示の冗長化。表示するメッセージを冗長にします。 - oo66 圧圧縮縮アアルルゴゴリリズズムムにに --llhh66-- をを使使用用すするる。。 + nnn 実行しない。実際の更新や抽出の動作を行ないません。 + 実行内容の確認のために用意されています。 - LHAの種類によっては、-lh6-で生成されたアーカイブは抽出できな い - 恐 れ が あるので、アーカイブを配布する際には注意してください。 - MSDOS版の正規配布版では -lh6- の生成は行いません。また、MSDOS版 - LHA version 2.5x 以降のバージョンでは -lh6- の抽出のみできま - す。 + fff 強制的な実行。ファイルの抽出時に、存在するファイル + の削除確認を行なわず強制的に削除を行ないます。 - ww==<> - 格納および抽出時のワーク用ディレクトリ 指 定。 デ フォ ル ト で - は、/tmp ですが、/tmp の大きさ以上のファイルを格納する際には必 - 要です。 + ttt テキストモードによる格納,抽出。アーカイブファイル + へのファイルの格納時には、UNIX から MS-DOS への改 + 行コード変換を行ないます。ファイルの抽出時には逆に + 、MS-DOS から UNIX への改行コード変換を行ないます + 。 - dd ファイル格納後のファイルの削除。機能文字 a, もしくは u と共に用 - い、 アーカイブファイルへのファイルの格納の後にファイルを削除し - ます。 u に付加した場合、アーカイブファイルの内容の方が新しい時 - に ファ イ ルが格納されずに削除されることになるので注意して下さ - い。 + ooo{{{nnnuuummm}}} LHarc 互換アーカイブの生成、または圧縮アルゴリズム + を指定する。機能文字 a, u, m と共に指定し、抽出時 + には無視されます。 - ii 抽出時のディレクトリ名の無効化。抽出時にディレクトリ名を無効 に - します。 + ooo LLLHHHaaarrrccc 互互互換換換アアアーーーカカカイイイブブブののの生生生成成成ををを行行行ううう。。。 - zz 非 圧 縮格納。アーカイブへのファイルの格納時に圧縮を行ないませ - ん。すでに圧縮を行なっていて圧縮効率を望めない場合などに使用 し - ます。抽出時には無視されます。 + 古い形式のアーカイブを生成します。圧縮アルゴ + リズムは-lh1-を使用します。 - gg [generic]アーカイブの作成。 UNIX 用の付加情報を持たないアーカイ - ブファイルを生成します。抽出時には無視されます。 - 00//11//22 ヘッダレベル指定。アーカイブの内部表現の形式を指定し ま す。 デ - フォ ルトでは 1 です。0 は LHarc で用意されていた古い形式です。 - 将来は 2 の形式に統一されるようです。これはファイルの格納時のみ - 有効です。ファイルの抽出時には自動的に形式を判断し処理します。 - _a_r_c_h_i_v_e___f_i_l_e にはアーカイブファイルを指定します。 + January 14,1997 2 - _a_r_c_h_i_v_e___f_i_l_e に _- と書くことによって、アーカイブファイルを標準入出力に - することが可能です。 ttaarr(1) のように、アーカイブの作成、更新時には標 準 - 出力に、アーカイブからのファイルの抽出時には標準入力になります。 - 抽 出時に _a_r_c_h_i_v_e___f_i_l_e が存在しない時にはサフィックス ..llzzhh をファイル名 - の後ろに付加して抽出を試みます。 - 特に規定はありませんが、運用上サフィックスとして ..llzzhh を用いるのが望 ま - し いと思います。日本以外では ..llhhaa を使用しているケースがあるそうですの - で、適宜調整して下さい。:-) - サフィックスが ccoomm もしくは ..eexxee の場合には、MS-DOS 版で作成された _S_F_X( - 自己展開機能付きの圧縮ファイル) 形式かどうかをチェックし、対応します。 - サ フィックスが ..xx の場合には、日本製 SHARP X68000 の OS, Human68k 版で - 作成された SFX 形式かどうかをチェックし対応します。 - SFX 形式のアーカイブファイルに対して追加や削除を行った 場 合 に は、 サ - フィックスを ..llzzhh に変更し、SFX の情報を削除します。 +LHA(N) Unix Programmer's Manual LHA(N) -FFIILLEESS フファァイイルル - *.lzh - LHa/LHarc アーカイブファイル - *.bak - バックアップファイル - /tmp/lh* - テンポラリファイル - *.com *.exe - MS-DOS SFX ファイル - *.x - Human68k SFX ファイル + ooo555 圧圧圧縮縮縮アアアルルルゴゴゴリリリズズズムムムににに ---lllhhh555- ををを使使使用用用すすするるる。。。 -SSEEEE AALLSSOO 関関連連項項目目 - ttaarr(1), aarr(1), ccoommpprreessss(1) + ooo666 圧圧圧縮縮縮アアアルルルゴゴゴリリリズズズムムムににに ---lllhhh666- ををを使使使用用用すすするるる。。。 -DDIISSTTRRIIBBUUTTIIOONN 再再配配布布ににつついいてて - 以下の条件で、再配布、転載、改変を許可します。 + LHAの種類によっては、-lh6-で生成されたアーカイブは + 抽出できない恐れがあるので、アーカイブを配布する際 + には注意してください。MSDOS版の正規配布版では -lh6- + の生成は行いません。また、MSDOS版 LHA version 2.5x + 以降のバージョンでは -lh6- の抽出のみできます。 - 1. 著作権表示を削除しないこと。 + www===<<>> + 格納および抽出時のワーク用ディレクトリ指定。デフォ + ルトでは、/tmp ですが、/tmp の大きさ以上のファイル + を格納する際には必要です。 - 2. 配布内容については、 + ddd ファイル格納後のファイルの削除。機能文字 a, もしく + は u と共に用い、アーカイブファイルへのファイルの + 格納の後にファイルを削除します。u に付加した場合、 + アーカイブファイルの内容の方が新しい時にファイルが + 格納されずに削除されることになるので注意して下さい + 。 - a. 配 布の際に存在する内容(すなわちソースコード、ドキュメン - ト、プログラマーへの手引きなど)が再配布されたものの中に必 - ず 存 在 すること。改変されているならば、それを明示したド - キュメントを用意すること。 + iii 抽出時のディレクトリ名の無効化。抽出時にディレクト + リ名を無効にします。 - b. LHa に対する付加価値が付けられて再配布される場合にはそ れ - ら もできるだけ含めるよう努力すること。また、その際には付 - 加価値が付けられていることを明示したドキュメントを用意 す - ること。 + zzz 非圧縮格納。アーカイブへのファイルの格納時に圧縮を + 行ないません。すでに圧縮を行なっていて圧縮効率を望 + めない場合などに使用します。抽出時には無視されます + 。 - c. バイナリのみの配布は許されない。(付加価値のものも含む) + ggg [generic]アーカイブの作成。UNIX 用の付加情報を持た + ないアーカイブファイルを生成します。抽出時には無視 + されます。 - 3. 最新版の配布に務めること。(義務はない) + 000///111///222 ヘッダレベル指定。アーカイブの内部表現の形式を指定 + します。デフォルトでは 1 です。0 は LHarc で用意さ + れていた古い形式です。将来は 2 の形式に統一される + ようです。これはファイルの格納時のみ有効です。ファ + イルの抽出時には自動的に形式を判断し処理します。 - 注. なお、ネットでの配付は自由であるが、ネットにアクセスでき - ない方(雑誌および、 CD-ROM などによる)配付は、配付前 に - こ ちらに E-Mail をお願いします。配付前に出来ない際には、 - 後日必ず E-Mail をお願いします。 + _a_r_c_h_i_v_e__f_i_l_e にはアーカイブファイルを指定します。 - 4. このプログラムの存在や使用したことによって生じた損害は全く保証し - ない。 + _a_r_c_h_i_v_e__f_i_l_e に- と書くことによって、アーカイブファイルを + 標準入出力にすることが可能です。tttaaarrr(1) のように、アーカイ + ブの作成、更新時には標準出力に、アーカイブからのファイルの - 5. 作者は、このプログラムに不備があっても、それを訂正する義務を負わ - ない。 - 6. このプログラムの一部、または全部を他のプログラムに組み込んで利用 - し てもかまわない。この場合、そのプログラムは LHa ではなく、 LHa - と名乗ってはいけない。 + January 14,1997 3 - 7. 商利用に関しては、上記の条件に加え、下記の条件のもとにこれを認め - る。 - a. このプログラムをメインとする商利用は禁止する。 - b. 商利用の相手がこのプログラムの使用者として不適切と判断し - た場合には配布しない。 +LHA(N) Unix Programmer's Manual LHA(N) - c. インストールの手段として使用する場合、このプログラムを 使 - う こ と を相手に強制しない。この場合、商利用者が作業を行 - う。また、そのときの損害は、商利用者が全責任を負う。 - d. 商利用を付加価値として行いこのプログラムを使用する場 合、 - 商利用者は、そのサポートを行う。 + 抽出時には標準入力になります。 + 抽出時に_a_r_c_h_i_v_e__f_i_l_e が存在しない時にはサフィックス...lllzzzhhh を + ファイル名の後ろに付加して抽出を試みます。 + 特に規定はありませんが、運用上サフィックスとして...lllzzzhhh を用 + いるのが望ましいと思います。日本以外では ...lllhhhaaa を使用してい + るケースがあるそうですので、適宜調整して下さい。:-) + サフィックスがcccooommm もしくは...eeexxxeee の場合には、MS-DOS 版で作成 + された_S_F_X(自己展開機能付きの圧縮ファイル) 形式かどうかをチ + ェックし、対応します。 + サフィックスが...xxx の場合には、日本製 SHARP X68000 の OS, + Human68k 版で作成された SFX 形式かどうかをチェックし対応し + ます。 + SFX 形式のアーカイブファイルに対して追加や削除を行った場合 + には、サフィックスを...lllzzzhhh に変更し、SFX の情報を削除します + 。 -最最後後にに((FFrroomm YY..TTaaggaawwaa)) - LZHUF 法の基礎となった LZARI 法を発表してくださった奥村晴彦氏、それを - NIFTY-Serve に紹介し、また、LArc の作者でもある三木和彦氏、また、これら - の 要 因 から LZHUF 法及び、MS-DOS 版 LHarc を作成した吉崎栄泰氏、LHarc - UNIX の開発に協力した人達、こころよくメッセージの橋渡しをしてくれた石崎 - 一明氏(MIX ID:k.ishi)、また、いろいろなレポートをくれたみなさん、それを - 中継してくださった森公一郎氏 (MIX ID:kmori)に感謝します。 +FFFIIILLLEEESSS フフファァァイイイルルル + *.lzh - LHa/LHarc アーカイブファイル + *.bak - バックアップファイル + /tmp/lh* - テンポラリファイル + *.com *.exe - MS-DOS SFX ファイル + *.x - Human68k SFX ファイル +SSSEEEEEE AAALLLSSSOOO 関関関連連連項項項目目目 + tttaaarrr(1), aaarrr(1), cccooommmppprrreeessssss(1) -最最後後にに((FFrroomm MMaassaarruu OOkkii)) - 上記の方々はもちろん、加えて LHarc UNIX を作成した Y.Tagawa 氏、それ を - OSK に移植し吉崎氏の LHx のアルゴリズムを組み込んだ H.S 氏、 JUNET の - LHa for UNIX MailingList にて協力してくださったみなさんに感謝致します。 +DDDIIISSSTTTRRRIIIBBBUUUTTTIIIOOONNN 再再再配配配布布布にににつつついいいててて -最最後後にに((FFrroomm NNoobbuuttaakkaa WWaattaazzaakkii)) - このプログラムの作成にかかわった方々、さらにここまで LHa を仕上げてくだ - さった 沖勝氏に感謝致します。 + 以下の条件で、再配布、転載、改変を許可します。 + 1. 著作権表示を削除しないこと。 + 2. 配布内容については、 + + a. 配布の際に存在する内容(すなわちソースコード、ドキ + ュメント、プログラマーへの手引きなど)が再配布され + たものの中に必ず存在すること。改変されているならば + 、それを明示したドキュメントを用意すること。 + + b. LHa に対する付加価値が付けられて再配布される場合に + はそれらもできるだけ含めるよう努力すること。また、 + その際には付加価値が付けられていることを明示したド + キュメントを用意すること。 + + + + January 14,1997 4 + + + +LHA(N) Unix Programmer's Manual LHA(N) + + + c. バイナリのみの配布は許されない。(付加価値のものも + 含む) + + 3. 最新版の配布に務めること。(義務はない) + + 注. なお、ネットでの配付は自由であるが、ネットにアクセ + スできない方(雑誌および、CD-ROM などによる)配付 + は、配付前にこちらに E-Mail をお願いします。配付前 + に出来ない際には、後日必ず E-Mail をお願いします。 + + 4. このプログラムの存在や使用したことによって生じた損 + 害は全く保証しない。 + + 5. 作者は、このプログラムに不備があっても、それを訂正 + する義務を負わない。 + + 6. このプログラムの一部、または全部を他のプログラムに + 組み込んで利用してもかまわない。この場合、そのプロ + グラムは LHa ではなく、LHa と名乗ってはいけない。 + + 7. 商利用に関しては、上記の条件に加え、下記の条件のも + とにこれを認める。 + + a. このプログラムをメインとする商利用は禁止する。 + + b. 商利用の相手がこのプログラムの使用者として不適切と + 判断した場合には配布しない。 + + c. インストールの手段として使用する場合、このプログラ + ムを使うことを相手に強制しない。この場合、商利用者 + が作業を行う。また、そのときの損害は、商利用者が全 + 責任を負う。 + + d. 商利用を付加価値として行いこのプログラムを使用する + 場合、商利用者は、そのサポートを行う。 + +最最最後後後ににに(((FFFrrrooommm YYY...TTTaaagggaaawwwaaa))) + LZHUF 法の基礎となった LZARI 法を発表してくださった奥村晴 + 彦氏、それを NIFTY-Serve に紹介し、また、LArc の作者でもあ + る三木和彦氏、また、これらの要因から LZHUF 法及び、MS-DOS + 版 LHarc を作成した吉崎栄泰氏、LHarc UNIX の開発に協力した + 人達、こころよくメッセージの橋渡しをしてくれた石崎一明氏(MIX + ID:k.ishi)、また、いろいろなレポートをくれたみなさん、それ + を中継してくださった森公一郎氏 (MIX ID:kmori)に感謝します + 。 + + + January 14,1997 5 + + + +LHA(N) Unix Programmer's Manual LHA(N) + + +最最最後後後ににに(((FFFrrrooommm MMMaaasssaaarrruuu OOOkkkiii))) + 上記の方々はもちろん、加えて LHarc UNIX を作成した Y.Tagawa + 氏、それを OSK に移植し吉崎氏の LHx のアルゴリズムを組み込 + んだ H.S 氏、JUNET の LHa for UNIX MailingList にて協力し + てくださったみなさんに感謝致します。 + +最最最後後後ににに(((FFFrrrooommm NNNooobbbuuutttaaakkkaaa WWWaaatttaaazzzaaakkkiii))) + このプログラムの作成にかかわった方々、さらにここまで LHa + を仕上げてくださった 沖勝氏に感謝致します。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + January 14,1997 6 - January 14,1997 LHA(N) diff -Nru lha-1.14i/man/lha.n lha-1.14i-acc20050924p1/man/lha.n --- lha-1.14i/man/lha.n 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/man/lha.n 1999-08-28 16:36:20.000000000 +0000 @@ -9,7 +9,7 @@ ] .I archive_file [ -.I file +.I flie \&.\|.\|. ] .br .B lha diff -Nru lha-1.14i/man/Makefile lha-1.14i-acc20050924p1/man/Makefile --- lha-1.14i/man/Makefile 2000-12-15 12:13:16.000000000 +0000 +++ lha-1.14i-acc20050924p1/man/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -################################################################ -# Makefile for LHa man directory -################################################################ - -NROFF = nroff -#NROFF = jman - -all: lha.man - -lha.man: lha.n - $(NROFF) -man lha.n > lha.man - -install: - $(INSTALL) $(INSTALLMAN) lha.n $(MANDIR)/man$(MANSECT)/lha.$(MANSECT) - -clean: - rm -f *~ - -moreclean: - rm -f lha.man core *~ *.orig diff -Nru lha-1.14i/man/Makefile.am lha-1.14i-acc20050924p1/man/Makefile.am --- lha-1.14i/man/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/man/Makefile.am 1999-09-30 14:41:18.000000000 +0000 @@ -0,0 +1,6 @@ +## Process this file with automake to produce Makefile.in +man_MANS = lha.n +EXTRA_DIST = $(man_MANS) lha.man + +#lha.man: lha.n +# $(NROFF) -man lha.n > lha.man diff -Nru lha-1.14i/man/Makefile.in lha-1.14i-acc20050924p1/man/Makefile.in --- lha-1.14i/man/Makefile.in 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/man/Makefile.in 2006-10-16 14:50:09.000000000 +0000 @@ -0,0 +1,349 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +LIBOBJDIR = +subdir = man +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +manndir = $(mandir)/mann +am__installdirs = "$(DESTDIR)$(manndir)" +NROFF = nroff +MANS = $(man_MANS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEF_KCODE = @DEF_KCODE@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SUPPORT_LZHUFF_METHOD = @SUPPORT_LZHUFF_METHOD@ +U = @U@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +man_MANS = lha.n +EXTRA_DIST = $(man_MANS) lha.man +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu man/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu man/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +uninstall-info-am: +install-mann: $(mann_MANS) $(man_MANS) + @$(NORMAL_INSTALL) + test -z "$(manndir)" || $(mkdir_p) "$(DESTDIR)$(manndir)" + @list='$(mann_MANS) $(dist_mann_MANS) $(nodist_mann_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.n*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ + else file=$$i; fi; \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + n*) ;; \ + *) ext='n' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(manndir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(manndir)/$$inst"; \ + done +uninstall-mann: + @$(NORMAL_UNINSTALL) + @list='$(mann_MANS) $(dist_mann_MANS) $(nodist_mann_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.n*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + n*) ;; \ + *) ext='n' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f '$(DESTDIR)$(manndir)/$$inst'"; \ + rm -f "$(DESTDIR)$(manndir)/$$inst"; \ + done +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(MANS) +installdirs: + for dir in "$(DESTDIR)$(manndir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-man + +install-exec-am: + +install-info: install-info-am + +install-man: install-mann + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am uninstall-man + +uninstall-man: uninstall-mann + +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-mann install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \ + uninstall-am uninstall-info-am uninstall-man uninstall-mann + + +#lha.man: lha.n +# $(NROFF) -man lha.n > lha.man +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff -Nru lha-1.14i/missing lha-1.14i-acc20050924p1/missing --- lha-1.14i/missing 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/missing 2005-08-29 05:53:16.000000000 +0000 @@ -0,0 +1,360 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. + +scriptversion=2005-06-08.21 + +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# Originally by Fran,cois Pinard , 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +run=: + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +msg="missing on your system" + +case "$1" in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + # Exit code 63 means version mismatch. This often happens + # when the user try to use an ancient version of a tool on + # a file that requires a minimum version. In this case we + # we should proceed has if the program had been absent, or + # if --run hadn't been passed. + if test $? = 63; then + run=: + msg="probably too old" + fi + ;; + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + tar try tar, gnutar, gtar, then tar without non-portable flags + yacc create \`y.tab.[ch]', if possible, from existing .[ch] + +Send bug reports to ." + exit $? + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + exit $? + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + +esac + +# Now exit if we have it, but it failed. Also exit now if we +# don't have it and --version was passed (most likely to detect +# the program). +case "$1" in + lex|yacc) + # Not GNU programs, they don't have --version. + ;; + + tar) + if test -n "$run"; then + echo 1>&2 "ERROR: \`tar' requires --run" + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + exit 1 + fi + ;; + + *) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + # Could not run --version or --help. This is probably someone + # running `$TOOL --version' or `$TOOL --help' to check whether + # $TOOL exists and not knowing $TOOL uses missing. + exit 1 + fi + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +case "$1" in + aclocal*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acinclude.m4' or \`${configure_ac}'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`${configure_ac}'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acconfig.h' or \`${configure_ac}'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case "$f" in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + autom4te) + echo 1>&2 "\ +WARNING: \`$1' is needed, but is $msg. + You might have modified some files without having the + proper tools for further handling them. + You can get \`$1' as part of \`Autoconf' from any GNU + archive site." + + file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` + test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo "#! /bin/sh" + echo "# Created by GNU Automake missing as a replacement of" + echo "# $ $@" + echo "exit 0" + chmod +x $file + exit 1 + fi + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' $msg. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if [ ! -f y.tab.h ]; then + echo >y.tab.h + fi + if [ ! -f y.tab.c ]; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if [ ! -f lex.yy.c ]; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` + fi + if [ -f "$file" ]; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit 1 + fi + ;; + + makeinfo) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + # The file to touch is that specified with -o ... + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + # ... or it is the one specified with @setfilename ... + infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile` + # ... or it is derived from the source name (dir/f.texi becomes f.info) + test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info + fi + # If the file does not exist, the user really needs makeinfo; + # let's fail without touching anything. + test -f $file || exit 1 + touch $file + ;; + + tar) + shift + + # We have already tried tar in the generic part. + # Look for gnutar/gtar before invocation to avoid ugly error + # messages. + if (gnutar --version > /dev/null 2>&1); then + gnutar "$@" && exit 0 + fi + if (gtar --version > /dev/null 2>&1); then + gtar "$@" && exit 0 + fi + firstarg="$1" + if shift; then + case "$firstarg" in + *o*) + firstarg=`echo "$firstarg" | sed s/o//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + case "$firstarg" in + *h*) + firstarg=`echo "$firstarg" | sed s/h//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + fi + + echo 1>&2 "\ +WARNING: I can't seem to be able to run \`tar' with the given arguments. + You may want to install GNU tar or Free paxutils, or check the + command line arguments." + exit 1 + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and is $msg. + You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequisites for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff -Nru lha-1.14i/olddoc/change-114e.txt lha-1.14i-acc20050924p1/olddoc/change-114e.txt --- lha-1.14i/olddoc/change-114e.txt 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/olddoc/change-114e.txt 2002-11-14 19:40:54.000000000 +0000 @@ -0,0 +1,203 @@ + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(1) + +ヘッダ-lhd-を持つ書庫を展開できない。 + +■原因 +directoryの展開はunixのファイル属性を見て +行うようになっていました。 +したがって、windows等のUNIXではないOSで +展開しようとすると、ファイル属性が無いため +directoryを示したヘッダを認識できなかった +ためだと思われます。 + +■対処 +ヘッダ-lhd-をみて展開するようにしました。 +1999.4.30 +■確認 +済 + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(2) + +Windowsで作成した自己展開実行ファイルの書庫を +展開できない。 + +■原因 +LHa for unixでは、.exeのついたファイルは +ms-dos版のlhaで作成されたsfxファイルであると認識 +するため。また、レベル2のヘッダに対応していなか +ったため。 + +■対処 1999.5.28 +圧縮されたファイルの前に付加されている +サフィックスコードをms-dos版lhaで作成された +サイズよりも多く読むようにした。 +レベル2ヘッダにも対応した。 + +■確認 +済 + + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(3) + +AIX 3.2でcgiを使ってlhaを起動したときに、正常終了 +しない不都合。lhaのe,fコマンドを利用したときのみ +この現象が発生する。main()関数のexit(0)まで処理が +終了しているが、lhaは終了しない。 + +■現象の確認 +試みたが確認できていない。 +■対処 +未 +■確認 +未 + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(4) + +IBM RS/6000-25T AIX Version 3.2.5(/bin/cc) +SWITCHESに-DSYSV_SYSTEM_DIR -BSD_INCLUDES -DAIXを追加 +MACHINEを-DSYSTIME_HAS_NO_TM -DTZSETに変更 + +slide.c内のtextと、lha.hのEXTERN unsigned char *textが +衝突している。 + +■説明 +slide.c内でローカルに定義されている*textは +グローバルに定義されている*textを利用しても +問題がない。 + +■対処 +slide.cでのローカル定義のtextをコメントアウトした。 + +■確認 +未 + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(5) + +Makefile 5行目の年が2995になっている。 +■対処 +1995に直した + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(6) + +slide.cでstatic unsigned char *textとなっていて、 +src/larc.cでも使っている。 +使い方が変である。 +(4)と関係ありと思われる。 + +■対処 +(4)の対処で大丈夫では? + + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(7) + +src/INSTALLが無い + +■対処 +とりあえず、src/INSTALLが存在するという記述を +無くした。 + + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(8) +EWS4800/360PXに関係するSWITCHESの +例がない。 + +■対処 +探します。 + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(9) + +Windows版lhaツールで作成されたレベル0の +アーカイブされたファイルが認識できない。 +拡張領域部分が1バイトのみ。 + +■原因 +レベル0の拡張可能部分の認識方法が間違えている。 +#CRCが含まれないレベル1の書庫がちょっと自身無し +■対処 +新しいロジックに入れ換えた。 + +■確認 +済 + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(10) + +標準入力がtty以外にリダイレクトされていて、 +かつ展開ファイル指定が無いときは、標準入力から +展開するファイルを受け取ることになっている。 +(展開動作のときのみ) + +IBMの新島智之さん(poortom@apmisc.ibm.co.jp)から +の情報です。 + +■tips +コマンドラインと同様の動作を期待するときは明示的に、 + lha -ex hogehoge.lzh < /dev/null +とすると良い様です。 + + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(11) + +閏年の計算方法が不十分で、2000年3月以降の +日付のファイルを展開すると1日ずれる恐れがある。 + +■対処 +2000年も閏年と扱うようにした。 +(奈良女子大学の新出氏のパッチを利用しました) + +■確認 +未 + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(12) +ファイルを一つだけ含むファイルから一つファイルを +削除すると、1バイトのゴミを含んだアーカイブファイル +ができてしまう。 + +■対処 +lhadd.cのcmd_delete()関数内のbuild_backup_file()関数呼び出し後に + +if(!noexec && new_archive_size <= 1){ + unlink(temporary_name); + printf("New archive file \"%s\" is not created because it would be empty.\n", new_archive_name); + return; +} + +を追加(修正)した。 + +■確認 +未 + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(13) + +シンボリックリンクファイルに対して時刻の修正、 +ファイル属性の修正をすると、シンボリックリンク +ではなくて、リンク先のファイルが修正されて +しまう。 + +■対処 +lhext.cのadjust_info()関数内で時刻・属性を修正している +箇所に、シンボリックリンクの場合は修正を行わない様な +条件をつけた。 + +■確認 +未 + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(14) + +■変更 +SUPPORT_LH6オプションをつけないと +圧縮method -lh6-を選択できないようにした。 diff -Nru lha-1.14i/olddoc/change-114f.txt lha-1.14i-acc20050924p1/olddoc/change-114f.txt --- lha-1.14i/olddoc/change-114f.txt 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/olddoc/change-114f.txt 2002-11-14 19:40:54.000000000 +0000 @@ -0,0 +1,116 @@ +lha for unix ver 1.14e bugs + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(15) + +■問題 +ls config.* | lha a arc.lzhで圧縮ができない。 + +■原因 +標準入力からfgetsで文字列を取り出しているため、 +文字列の最後に'\n'が含まれていた。この結果 +比較が正常に行えなかった。 + +■対処 +'\n'を取り除くようにプログラムソースを変更した。 +1999.7.18 + +■対処確認 +ls *.c | lha a tst.lzh で圧縮また、 +ls *.c | lha l tst.lzh でリストできることを確認 +した。 + + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(16) + +■問題 +展開できないwindowsのsuffixファイルが +まだ存在する。 + +■原因 +SFXコードが16KB以上のファイルが多く +存在するらしく、lha for unixでは +16KB以内しか対応していなかった。 + +■対処 +64KBまで読み込むようにした。 +lha_macro.hのMAXSFXCODEの箇所 + +■その他 +64KBでダメなら、もっと大きな +値を設定して試してみてください。 +それでもダメだと別の問題かもしれませんが。。。 + + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(17) + +■問題 +change-114e.txtの(13)番と同じ原因による問題点で、 +lchown()システムコールをchown()とは別に持っている +システムで起きる問題があるらしい。 + +■対処 +lchownがあればlchownを使うことにした。1999.7.19 +lchownが無い時はHAVE_NO_LCHOWNを定義してください。 + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(18) + +■問題 +lha filenameがlha l filenameの挙動と同じではない + +■原因 +ファイルfilenameを参照する箇所の間違い。 + +■対処 +修正した。 +1999.7.18 + + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(19) + +■問題 +main関数がvoidになっている。 +warningがでることがある。 +■対処 +intにしました。 + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(20) + +■問題 +tabがサイズ4で、読みにくい環境がある可能性がある。 + +■対処 +未対処 + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(21) + +■問題 +ある種のファイルがCRCエラーになる。 + +■原因 +圧縮辞書の初期化の範囲に不都合があった。 + +■対処 +初期時の辞書を適切にした。 +1999.7.19 + +■対処確認 +不都合が起きるサンプルを入手し、 +不都合が発生しないことを確認した。 + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(22) + +■問題 +util.cでiskanji()を使っている部分が存在した。 + +■対処 +iskanji()の代わりにMULTIBYTE_FIRST_Pを +使う事にした。1999.7.19 + diff -Nru lha-1.14i/olddoc/change-114g.txt lha-1.14i-acc20050924p1/olddoc/change-114g.txt --- lha-1.14i/olddoc/change-114g.txt 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/olddoc/change-114g.txt 2002-11-14 19:40:54.000000000 +0000 @@ -0,0 +1,104 @@ +lha for unix ver 1.14gで対処 + +lha for unix ver 1.14f bugs + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(23) + +■問題 +chown,lchownの使い方が間違っていた。 +lchownのあるシステムでは、symbolic link先の +ファイルのownerを変更しようとしていた。 + +■原因 +chown()はlchwon()があるシステムと無いシステムで +挙動が異なる。展開したファイルがsymbolic link +のファイルである場合、下記のようにしなくては +いけなかったが、逆にしていた。 + + lchown()があるシステム:lchown()を使う + lchown()がないシステム:chown()を使う + +■対処 +原因はlchown()かchown()を選択するかの条件が逆に +なっていたので、lhext.cの条件を逆にした。 + +■対処確認 + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(24) + +■場所 +#define SJC_SECOND_P +のunsigned charのスペルを間違えていた。 + +■対処 +ungigned→unsignedに直した。 + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(25) + +■問題 +Header Level 2で作成したファイルの場合に、 +ファイルの長さを正常に計算していなかった。 + +■対処 +level2ヘッダでfilenameを取得している箇所に + name_length = header_size - 3; +を追加した。 + +■■■■■■■■■■ 不都合 ■■■■■■■■■■ +(26) + +■場所 +Header Level 2で作成した書庫のヘッダの読み込み時に +正常にヘッダ長の計算が行われていなかった。 +下位バイトしか計算していなかった。 + +■対処 +上位バイトもヘッダ長に含めて計算することにした。 + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(27) + +■問題 +level2ヘッダのappendがうまくいかず、エラーが +発生する。 + +■原因 +Header Level 2で作成した書庫のヘッダの読み込み時に +正常にヘッダ長の計算が行われていなかった。 +書庫への追加の際に、コピーするサイズの計算が +level 0,1と異なることを考慮していなかった。 + +■対処 +level0,1とlevel2のヘッダ長計算の箇所を場合わけした。 + +■■■■■■■■■■ 報告 ■■■■■■■■■■ +(28) + +■問題 +書庫内のsymbolic linkのファイルと、 +同じ名前のsymbolic linkファイルのappendが +うまくいかず、重なってしまう。 + +■原因 +ファイル名比較で、symbolic linkファイル名どうしの +比較アルゴリズムが間違えていた。 + +■対処 +正常に計算できるように修正した。 + +■■■■■■■■■■ 追加 ■■■■■■■■■■ +(29) + +■機能 +-lh7-の書庫を生成/展開ができる機能を追加した。 + +■その他 +Makefileで-DSUPPORT_LH7のオプションを追加して +コンパイルすることで-lh7-の書庫が操作できるように +なる。 + + + diff -Nru lha-1.14i/olddoc/change-114h.txt lha-1.14i-acc20050924p1/olddoc/change-114h.txt --- lha-1.14i/olddoc/change-114h.txt 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/olddoc/change-114h.txt 2002-11-14 19:40:54.000000000 +0000 @@ -0,0 +1,15 @@ +lha for unix ver 1.14hで対処 + +lha for unix ver 1.14g bugs + +■■■■■■■■■■ 追加 ■■■■■■■■■■ +(30) + +■問題 +壊れた-lh7-の書庫を生成してしまう。 +展開時にBad table (5)が出て、展開に失敗する。 + +■原因 +huf.cに-lh7-に対応していない箇所があった。 + + diff -Nru lha-1.14i/olddoc/change-114i.txt lha-1.14i-acc20050924p1/olddoc/change-114i.txt --- lha-1.14i/olddoc/change-114i.txt 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/olddoc/change-114i.txt 2002-11-14 19:40:54.000000000 +0000 @@ -0,0 +1,42 @@ +lha for unix ver 1.14iで対処 + +lha for unix ver 1.14h bugs + +■■■■■■■■■■ 不都合 ■■■■■■■■■■ +(31) + +■問題 +macで生成した書庫(OSTYPEがMAC)のディレクトリの +区切りを正しく認識していなかった。 + +Lha failed to convert a delimitor used at Macintiosh. + +■原因 +一度拡張ヘッダのディレクトリを取得したときに +0xffから/への変換を行ったあと、ディレクトリと +ファイルネームを結合した文字列に対して、 +mac-unixの変換(:を/に、:を/に)をしていたため、 +区切りが:に変わっていた。 + +■対処 +変換後のディレクトリ名に対しては +mac-unix変換を行わないことにした。 + +■■■■■■■■■■ 追加 ■■■■■■■■■■ + +■内容 +OSがMSDOSのときは無差別にファイル名を小文字に +していたが、windowsでは小文字と大文字の混在が +あり得るため、この対処を行う。 + +Lha always converted upper-case into lower-case. +Modified that lha don't convert case when using +'g' option. + +■修正点 +展開時にオプションgを指定すると、小文字の変換は +行わないようにするオプションを追加した。 + +--- 以上 +(誰か英語直して〜) + diff -Nru lha-1.14i/olddoc/CHANGES.euc lha-1.14i-acc20050924p1/olddoc/CHANGES.euc --- lha-1.14i/olddoc/CHANGES.euc 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/olddoc/CHANGES.euc 2002-11-14 19:40:54.000000000 +0000 @@ -0,0 +1,169 @@ +/* CHANGES (In Japanese) */ +LHx 0.01 -> 0.02 + + Usage の f オプションの説明表示がずれるのを直した。 + lhadd.c の 49 行目の Warning (&hdr->method)を修正した。 + strucmp.c の toupper() を static 関数に変更した。 + lharc.h の malloc(),realloc() の返り値の宣言(Warning)を修正。 + lhadd.c の 336 行目の copyfile() に第4引数 0 を追加。 + malloc 関連の Warning を修正(cast)した。 + patmatch.c の toupper を行なう条件に islower() を追加。 + stdlib.h をインクルードする箇所に || defined(sony_news) を追加。 + -lh0- のファイルをテストすると内容を表示するバグを修正。 + 展開時ヘッダレベル1に対応した。 + crcio.c で putc() の代わりに fwrite() を使用するよう変更。 + _errmsg() を使用しないよう変更。 + 石川@三菱電機さんの rename.c を付属。 + memset() のないマシンのために memset.c を追加。(書き下ろし) + +LHx 0.02 -> LHa 0.03 + 名称を LHx から LHa に変更。 + owner が root のときのみ chown() するよう変更。 + 本間隆之さんの timezone 関係のパッチを含めた。 + lharc.c の135 行目を #endif /* MULTIBYTE_CHAR */ に変更。 + g option 使用時にディレクトリ以下を圧縮できないバグを修正。 + z option なしで標準入力からファイル名を読み込むように変更。 + put_indicator() を append.c から crcio.c に移した。 + crcio.c で fwrite() の返り値の比較対象を EOF から 0 に修正。 + アーカイブ名に - を使用することで標準入出力を利用可能にした。 + 倉島@東大さんの EUC パッチを含めた。 + ヘッダ関係を lharc.c から分離し header.c とした。 + archive_is_msdos_sfx1() と skip_msdos_sfx1_code() を util.c に移した。 + 圧縮および展開をヘッダレベル1,2 に対応。 + デフォルトのヘッダレベルを 1 に変更。 + デフォルトの圧縮方式を -lh5- に変更。h オプションを廃止。 + 無圧縮格納(z)オプションを追加。 + LHarc 互換形式圧縮(o)オプションを追加。 + 標準入力のリダイレクト時にオーバーライト確認をしないよう変更。 + uchar,ushort,uint,ulong を使用しないよう変更。typedef.h を削除。 + +LHa 0.03 -> LHa 0.04 (beta) + -lh0- file で e, t option を有効にした。(by 倉島@東大さん) + 引数にアーカイブのみ指定時に list 表示するよう変更。(by 倉島@東大さん) + -DMKTIME でタイムスタンプが正常でないバグを修正。(by 渡邊@東北大さん) + NEED_INCREMENTAL_INDICATOR 設定時の変数宣言を追加した。 + lhadd.c の encode_stored_crc() の宣言の綴を修正した。(by 本間隆之さん) + NULL が 0 でなくても動作するよう slide.c を変更した。 + header.c の fwrite() で返り値を NULL ではなく 0 と比較するよう変更。 + 圧縮形式が正しくない時 Segmentation fault するバグを修正。 + ディレクトリの圧縮形式を -lhd- にするよう変更。 + strdup.c の strlib.h 読み込みの条件を修正。 + header level 2 で圧縮できないバグを修正した。 + 386MINIX に対応。(by youchan@日経MIX さん) + サブディレクトリのアーカイブと同名のファイルを圧縮できるようにした。 + -DNOFTRUNCATE で石川@三菱電機さんの rename() を使うよう変更。 + TITAN でコンパイルできるよう(?) lharc.h を変更。 + +LHa 0.04 -> LHa 0.05 + append.c で使用していた ushort を unsigned short に修正。 + 日付の年を 1991 から 1992 に修正。 + -DFTIME, -DTIMELOCAL パッチを追加。(by 本間隆之さん) + オブジェクトファイルのサフィックスを選択可能にした。 + -DNOMKDIR パッチを追加。(by 石川@三菱電機さん) + 標準入力からのファイル名の入力数を無制限にした。(by 佐藤 治@PFUさん) + rename.c, strdup,c, strucmp.c, memmove.c を util.c に集めた。 + archive file の suffix が .lzh に束縛されないようにした。 + slidehuf.h の __STDC__ の部分に AIX の判定を追加した。 + slidehuf.h,intrface.h の関数宣言に extern を追加した。 + +LHa 0.05 -> LHa 0.06 + USESTRCASECMP を追加し、strucmp の定義を #ifndef で括った。 + #elif などを使用しないよう変更。 + Makefile をトップディレクトリに用意。 + NEED_INCREMENT_INDICATOR 定義で z option 使用時のバグを退治。 + header level 2 のヘッダサイズが食い違うバグを修正。 + maketree.c で defined(_MINIX) が無駄とのことなので削除。 + +LHa 0.06 -> LHa 1.00 + 圧縮サイズの判定ルーチンのバグを修正。 + NOMEMSET を用意し、memset() を util.c に移した。 + +LHa 1.00 -> LHa 1.10 + lharc.h の FILE ATTRIBUTES に is_symlink を追加。 + lhadd.c の append_it()関数 の stat を lstat に変更し、処理を追加して + シンボリック・リンクに対応した。 + (シンボリック・リンクはディレクトリと同じ扱いになってます。) + シンボリック・リンクに対応させるため lhlist.c を変更して、圧縮ファイル内 + のリスト表示の際に、ls -al と同じような表示に変更。 + 圧縮ファイル内のファイルを削除する際に、デフォルトでファイル名を表示 + するように変更。 (quiet オプション可) + w オプション(ワークディレクトリの指定)を圧縮の際のワークディレクトリ + を指定可能に変更。 + +LHa 1.10 -> LHa 1.11 + lhext.c の inquire_extract() の関数に 'S'(Skip) を追加。 + 展開時のタイムスタンプ一応比較対応。 + +LHa 1.11 -> LHa 1.12 + タイムスタンプ対応のため、extract_one() の関数の展開時の処理を大幅追加。 + ローカル変数、skip_flg (FALSE..No Skip , TRUE..Skip)を追加。 + +LHa 1.12 -> LHa 1.13 + S_IFLNK のマクロがあったので対応するように変更。 このことに関連して + lhadd.c の append_it()関数 の lstat を GETSTAT に変更した。 + 長いファイル名の時に、core dump するのは append.c の MAX_INDICATOR_COUNT + の m の値が0になっていたので、if 文の (m<0) を (m<1) に修正。 + +LHa 1.13 -> LHa 1.13a + シンボリックリンクファイルがターゲットとなった場合に、append_it の + fclose(fp) が、fp == NULL となっていたために core dump するバグを修正。 + シンボリックリンクが、ターゲットファイルをなった際にうまく削除できない + Bug を修正。(by あにぃ さん) + +LHa 1.13a -> LHa 1.13b + 圧縮の際に更新してないのに、Symblic Link のファイル名のみ常時表示して + いた. + シンボリックリンクファイルをアーカイブファイルからリンク名で削除できなか + った. + Symbolic Link 先のファイル名を取得する際に、失敗していた. + 展開時に、Symbolic Link ファイルのみタイムスタンプ比較を忘れていた. + 以上のシンボリックリンクファイル関係の Bug を修正した. + + q Option で、INDICATOR を可変に出来るように変更. + t option を使用すると CRC Error で Test と extract ができない Bug と + Header Level 2 の書庫が MS_DOS 版 LHa で解凍できない Bug と + -1 -2 と -g Option の併用が出来ない Bug を修正. (by 岡本@北大) + + また、Makefile 中の 機種異存マクロの記述場所を SWITCHES から MACHINE + に変更しました. + +LHa 1.13b -> LHa 1.13c + 展開の際に、ファイルが存在していると確認のメッセージが表示されるが + そのファイルのどの項目を選んでも一つ目は展開されてしまう Bug を + 修正. + +LHa 1.13c -> LHa 1.14 + 気まぐれで、-lh6- の展開のみ出来るように処理を追加。 + ソースリストの見直しを行った。 + +LHa 1.14 -> LHa 1.14a (以下 t.okamoto) + 圧縮書庫を作れないバグを修正。 + +LHa 1.14a -> LHa 1.14b + シンボリックリンクの先が存在しない時、書庫に追加できないバグを + 修正した。書庫に存在するシンボリックリンクのファイルと同名のファ + イルを書庫に追加しようとしても、追加できないバグを修正。 + また、いくつかのシンボリックリンク関係のバグを修正した。 + +LHa 1.14b -> LHa 1.14c + 前バージョンのバグ修正の際に、新たなバグを付加してしまった点を + 修正した(lhadd.c)。 + 書庫内のファイル表示の際、setuid してある場合 's' のフラグを + 見えるようにした。 + 一部ソースの void をコメントに直して改良を行なった。 + LHa 1.00 に入っていた config.eng を入れ直した。 + +LHa 1.14c -> LHa 1.14d + FreeBSD でのバグの修正。MS-DOS で作成した書庫のファイルスタンプが + ずれて表示されるバグを修正した(header.c)。SWITCHES に HAVE_TM_ZONE + を追加することでバグは修正される。(by yav さん) + 二重定義をしていた部分を修正。二重定義を発見できるコンパイラーで + エラーまたは警告がたくさん出るということは、無くなったと思います。 + + -lh6- 圧縮形式の圧縮を可能にしました。圧縮アルゴリズムに hash 法 + を使った物に変更しました。 + + 開発環境を FreeBSD にしました。 + +LHa 1.14d -> LHa 1.14e + change-114e.txtに記述しています。 diff -Nru lha-1.14i/olddoc/config.eng lha-1.14i-acc20050924p1/olddoc/config.eng --- lha-1.14i/olddoc/config.eng 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/olddoc/config.eng 2002-11-14 19:40:54.000000000 +0000 @@ -0,0 +1,46 @@ +configration of LHa for UNIX ver 1.14g (see Makefile, SWITCHES macro.) + +machine independed macros + + NEED_INCREMENTAL_INDICATOR + EUC if you want to convert kanji-code, define this. + ARCHIVENAME_EXTENTION your default archive suffix. default is ".lzh". + BACKUPNAME_EXTENTION back up archive suffix. default is ".bak". + TMP_FILENAME_TEMPLATE temporary file template. default is "/tmp/lhXXXXXX". + SUPPORT_LH7 to use the -lh7- method, define SUPPORT_LH7 + +machine depended macros + +--include files + USG if your machine has no , define this. + SYSTIME_HAS_NO_TM if your sys/time.h has no struct tm, define this. + +--string stuff + NOBSTRING if your machine has no bstring(3), define this. + NOINDEX if your machine has no index(3), define this. + NOSTRDUP if your machine has no strdup(3), define this. + USESTRCASECMP if your machine has strcasecmp(3), define this. + NOMEMSET if your machine has no memset(3), define this. + +--timezone stuff + FTIME if your machine use ftime(3C), define this. + GETTIMEOFDAY if your machine use gettimeofday(2), define this. + MKTIME if your machine use mktime(3C), define this. + TIMELOCAL if your machine use timelocal(3V), define this. + TZSET if your machine use tzset(3C), define this. + TIMEZONE_HOOK + +--directory stuff + NONSYSTEM_DIR_LIBRARY if your machine has no directory manipulate + functions, define this. and you should add + lhdir$(O) to LIBRARYOBJS in Makefile. + SYSV_SYSTEM_DIR if your machine has struct dirent, define this. + NODIRECTORY otherwise. (give up..) + +--other stuff + NOFTRUNCATE if your machine has no ftruncate(2), define this. + NOMKDIR if your machine has no mkdir(2), define this. + MKDIRPATH to use external mkdir command, define with NOMKDIR. + RMDIRPATH to use external rmdir command, define with NOMKDIR. + NOT_COMPATIBLE_MODE + HAVE_NO_LCHOWN if your machine has no lchown(2), define this. diff -Nru lha-1.14i/olddoc/config.jpn.euc lha-1.14i-acc20050924p1/olddoc/config.jpn.euc --- lha-1.14i/olddoc/config.jpn.euc 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/olddoc/config.jpn.euc 2002-11-14 19:40:54.000000000 +0000 @@ -0,0 +1,51 @@ +LHa for UNIX ver 1.14g コンフィグレーション (Makefile, SWITCHESマクロ参照) + +機種依存マクロは、MACHINES ファイルに設定例がありますので参照願います。 + + +機種非依存のマクロ + + NEED_INCREMENTAL_INDICATOR 経過表示グラフを表示するようにします。 + EUC 漢字コード変換を行なう e オプションを用意します。 + ARCHIVENAME_EXTENTION デフォルトのアーカイブ拡張子。デフォルトは ".lzh" 。 + BACKUPNAME_EXTENTION バックアップアーカイブの拡張子。デフォルトは ".bak" 。 + TMP_FILENAME_TEMPLATE 作業ファイルのテンプレート。 + SUPPORT_LH7 -lh7- methodをサポートするときに定義します。 + +機種依存マクロ + +--インクルードファイル関係 + USG がないときに定義します。 + SYSTIME_HAS_NO_TM に struct tm がないときに定義します。 + +--文字列関係 + NOBSTRING bstring(3) がないときに定義します。 + NOINDEX index(3) がないときに定義します。 + NOSTRDUP strdup(3) がないときに定義します。 + USESTRCASECMP strcasecmp(3) があるときに定義します。 + NOMEMSET memset(3)がないときに定義します。 + +--timezone 情報の取得関係 + FTIME ftime(3C) を使用した変換を行なう時に定義します。 + GETTIMEOFDAY gettimeofday(2) を使用した変換を行なう時に定義します。 + MKTIME mktime(3C) を使用した変換を行なう時に定義します。 + TIMELOCAL timelocal(3V) を使用した変換を行なう時に定義します。 + TZSET tzset(3C) を使用した変換を行なう時に定義します。 + TIMEZONE_HOOK + +--ディレクトリ操作関係 + NONSYSTEM_DIR_LIBRARY ディレクトリ操作関数(opendir,readdir,closedir)が + ないときに定義します。Makefile の LIBRARYOBJS に + lhdir$(O) を追加してください。 + SYSV_SYSTEM_DIR struct dirent (direct ではない)があるときに定義します。 + NODIRECTORY 上記マクロを使用しても失敗する時に定義します。 + +--その他 + NOFTRUNCATE ftruncate(2) がない時に定義します。 + NOMKDIR mkdir(2) がないときに定義します。 + MKDIRPATH mkdir の外部コマンド名を定義します。NOMKDIR と + 同時に機能します。デフォルトは "/bin/mkdir" です。 + RMDIRPATH rmdir の外部コマンド名を定義します。NOMKDIR と + 同時に機能します。デフォルトは "/bin/rmdir" です。 + NOT_COMPATIBLE_MODE + HAVE_NO_LCHOWN lchown(2)が無いときに定義します。 diff -Nru lha-1.14i/olddoc/IFNAMES lha-1.14i-acc20050924p1/olddoc/IFNAMES --- lha-1.14i/olddoc/IFNAMES 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/olddoc/IFNAMES 2002-11-14 19:40:54.000000000 +0000 @@ -0,0 +1,63 @@ +# -*- text -*- +# this file was generated by `ifnames' utility. + +AIX lha.h lha_macro.h slide.c +ARCHIVENAME_EXTENTION lha_macro.h +BACKUPNAME_EXTENTION lha_macro.h +CHAR_BIT lha_macro.h +DEBUG slide.c +DIRBLKSIZ lhdir.h +DIRSIZ lhdir.c +# EUC crcio.c lha.h lharc.c --enable-text-conv +EXTEND_TOWNSOS lhlist.c +# FTIME header.c replace with HAVE_FTIME +# GETTIMEOFDAY header.c replace with HAVE_GETTIMEOFDAY +# SYSV_SYSTEM_DIR lha_macro.h replace with HAVE_DIRENT_H +# HAVE_TM_ZONE header.c replace with HAVE_STRUCT_TM_TM_GMTOFF +LHA_MAIN_SRC lha.h lha_macro.h +# LONG_MAX lha_macro.h +# LONG_MIN lha_macro.h +MKDIRPATH util.c +# MKSTEMP lharc.c replace with HAVE_MKSTEMP +# MKTIME header.c replace with HAVE_MKTIME +# MSDOS lha_macro.h removed +# MULTIBYTE_CHAR header.c lha_macro.h util.c --enable-multibyte-filename + (defined MULTIBYTE_FILENAME) +# NEED_INCREMENTAL_INDICATOR append.c crcio.c lha.h --enable-indicator +# NEWSOS huf.c use STDC_HEADERS +# NOBSTRING lha_macro.h util.c use memset(), memcpy() +# NODIRECTORY lha_macro.h lharc.c removed +# NOFTRUNCATE lhadd.c util.c replace with !HAVE_FTRUNCATE +# NOINDEX lha_macro.h use strchr(), strrchr() +# NOMEMSET util.c replace with !HAVE_MEMSET +# NOMKDIR util.c replace with !HAVE_MKDIR +NONSYSTEM_DIR_LIBRARY lha_macro.h no use (???) +# NOSTRDUP util.c replace with !HAVE_STRDUP +NOT_COMPATIBLE_MODE header.c lhext.c +NOT_USED header.c +# NOVOID lha_macro.h removed +# NO_INODE lharc.c replace with !HAVE_STRUCT_STAT_ST_INO +# HAVE_NO_LCHOWN lhext.c replace with !HAVE_LCHOWN +NULL lha_macro.h +OSK header.c +O_RDONLY lhdir.c +RMDIRPATH util.c +SEEK_SET lha_macro.h +SHRT_MAX lha_macro.h +SHRT_MIN lha_macro.h +# SUPPORT_LH6 lharc.c use configure --enable-lh6 +S_IFLNK header.c lha_macro.h lhadd.c lharc.c lhext.c +# TIMELOCAL header.c replace with HAVE_TIMELOCAL +TIMEZONE_HOOK header.c +# TMP_FILENAME_TEMPLATE lha_macro.h lhadd.c lharc.c --with-tmp-file +# SYSTIME_HAS_NO_TM lha_macro.h replace with TM_IN_SYS_TIME +# TZSET header.c replace with HAVE_TZSET +UCHAR_MAX lha_macro.h +UINT_MAX maketree.c +ULONG_MAX lha_macro.h +# USESTRCASECMP lha_macro.h util.c replace with HAVE_STRCASECMP +USE_PROF lharc.c +# USHRT_MAX lha_macro.h +# _MINIX header.c lha_macro.h util.c use AC_MINIX in configure.in +__STDC__ huf.c lha.h lha_macro.h slide.c util.c +# sony_news huf.c use HAVE_SYS_PARAM_H diff -Nru lha-1.14i/olddoc/MACHINES2.euc lha-1.14i-acc20050924p1/olddoc/MACHINES2.euc --- lha-1.14i/olddoc/MACHINES2.euc 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/olddoc/MACHINES2.euc 2002-11-14 19:40:54.000000000 +0000 @@ -0,0 +1,107 @@ +---------------------------------------------------------------- +マシン AT互換機 (Pentium 133MHz) +OS FreeBSD 2.0.5 +Compiler gcc 2.6.3 +変更事項 特になし +備考 Ver.1.14d製作環境 + Ver.1.14dのコンパイル +---------------------------------------------------------------- +マシン AT互換機 (Pentium 100MHz) +OS Linux 2.0.20 (POSIX) +Compiler gcc version 2.7.2 +変更事項 MACHINE に -DSYSV_SYSTEM_DIR を追加 + OPTIMIZE に -m486 を追加 +備考 Slackware-3.0.0ベースで kernel version 2.0.XX + が動くようにしたシステム (libc version 5.2.18) + コンパイルした日: 1996/09/17(火) +---------------------------------------------------------------- +-- 以下、1.14d公開以後報告 +---------------------------------------------------------------- + NeXT + NeXTStationTurbo Color + NeXTSTEP Release 3.3J + cc ( システム標準 gcc 2.4.5相当) + SWITHESに -DNOSTRDUP -DUSESTRCASECMP を追加 + また、4way-MAB作成の為、 CC に + -arch m68k -arch i386 -arch hppa -arch sparcを追加 + ( 試してはいませんが、このバイナリで Intel, PA-RISC, SPARC用の + NeXTSTEP/OPENSTEP for Machでも稼動するはずです ) +---------------------------------------------------------------- + NEC + EWS4800/320PX ( and 310PX ) + EWS-UX/V R11.4 + /usr/abiccs/bin/cc + SWITCHES に -DNOINDEX -DMKTIME -DSYSV_SYSTEM_DIR を追加 + また OPTIMIZEを -O -Kmips2に設定 + -Kmips2は mips2に最適化するため、R3000系のCPUを使ったマシンでは + 稼動しないバイナリを作成します。 +---------------------------------------------------------------- +メーカー: 不明 +マシン : SGI CRAY Origin 2000 +OS : IRIX 6.4 +オプション MACHINEから-DHAVE_TM_ZONEを除きました。 +---------------------------------------------------------------- +マシン SGI O2 +OS IRIX 6.5 + WorldView Japanese 6.5 +SWITCHES = -DEUC +MACHINE = -DNOINDEX -DSYSTIME_HAS_NO_TM -DSYSV_SYSTEM_DIR -n32 -mips3 +OPTIMIZE = -O2 +備考 -DNOINDEX を付けないとデリミタを含むパスがうまく書けません。 +---------------------------------------------------------------- +マシン AT互換機 (Pentium III 500MHz) +OS Solaris 2.7 (x86) +Compiler gcc version 2.8.1 +変更事項 SWITCHES に -DFTIME + -DUSESTRCASECMP を追加 + MACHINE に -DSYSV_SYSTEM_DIR を追加 + OPTIMIZE に -m486 を追加 +備考 make install 時に + "/usr/sbin/install"ではエラー。 + "/usr/ucb/install"を使用。 + これは Solaris 全般のインストール時の問題。 +---------------------------------------------------------------- +マシン ? +OS Linux 2.2.x +Compiler gcc version egcs-2.91.66 19990314 (egcs-1.1.2 rel) +変更事項 -DHAVE_TM_ZONE を消して -DMKTIME を入れる + +---------------------------------------------------------------- +社名 Sun Microsystems +マシン Ultra +OS Solaris2.5 +Compiler cc,gcc +変更事項 MACHINEを-DSYSTIME_HAS_NO_TM + -DEUC -DSYSV_SYSTEM_DIRに変更 +--------------------------------------------------------------- +社名 Sun Microsystems +マシン Sun Ultra 1/170 +OS Solaris2.6 (SunOS5.6) +Compiler egcs-1.1 release (egcs-2.91.57 19980901)(gcc-2.8.*相当?) +変更事項 MACHINE=-DNOBSTRING -DNOINDEX -DTZSET -DSYSV_SYSTEM_DIR + -DSYSTIME_HAS_NO_TM + MANDIR=/usr/local/man/ja + INSTALL=/usr/ucb/install + MANSECT=1 (お好みに応じて) +備考 sun solaris SVR4 + SunOSには伝統的に?struct tmにtimezoneがないので注意 +---------------------------------------------------------------- +社名:    IBM +マシン:   RS/6000-25T +OS :   AIX Version 3.2.5 +コンパイラ: /bin/cc +変更 :   SWITCHESに-DSYSV_SYSTEM_DIR -BSD_INCLUDES -DAIXを追加 + MACHINEを-DSYSTIME_HAS_NO_TM -DTZSETに変更 +---------------------------------------------------------------- +社名 Hewlett Packard +マシン HP9000 C240 +OS HP-UX 10.20 +Compiler cc +変更事項 SWITCHES に -DUSESTRCASECMP を追加。 + SWITCHES に -DNOBSTRING を追加。 + Shift-JIS を使用するので -DEUCを削除し, + source内のEUCコードをShift-JISコードに変換。 + OPTIMIZEに -Y -O +DAportable +DSportableを指定 + portable指定はPA7000シリーズに対応するため +---------------------------------------------------------------- + + diff -Nru lha-1.14i/olddoc/MACHINES.euc lha-1.14i-acc20050924p1/olddoc/MACHINES.euc --- lha-1.14i/olddoc/MACHINES.euc 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/olddoc/MACHINES.euc 2002-11-14 19:40:54.000000000 +0000 @@ -0,0 +1,454 @@ +---------------------------------------------------------------- +社名 Sun Microsystems +マシン Sun3/80,SPARCstation +OS SunOS 4.0.3, 4.1.1, 4.1.2, 4.1.3(+JLE) +Compiler cc,gcc -traditional +変更事項 SWITCHES に -DFTIME -DUSESTRCASECMP を追加 +備考 sun +--------------------------------------------------------------- +社名 東芝 +マシン AS3000 +OS AS3.3(SunOS 3.3) +Compiler /bin/cc +変更事項 SWITCHES に -DSTRDUP を追加 +備考 sun +---------------------------------------------------------------- +社名 SONY +マシン NWS-1460/1750 +OS NEWS-OS 3.3a, 3.4 +Compiler cc,gcc -traditional +変更事項 SWITCHES に -DNOSTRDUP を追加 +備考 sony_news +---------------------------------------------------------------- +社名 SONY +マシン NWS-1830/1850 +OS NEWS-OS 4.0.1C/4.1C +Compiler cc,gcc +変更事項 SWITCHES に -DNOSTRDUP を追加 +備考 sony_news +---------------------------------------------------------------- +社名 SONY +マシン NWS-3260/3460/3860 +OS NEWS-OS 3.91R/4.1R +Compiler cc,gcc version 1.40 +変更事項 SWITCHES に -DNOSTRDUP を追加 +備考 sony_news +--------------------------------------------------------------- +社名 OMRON +マシン SX-9100 Mr. +OS UniOS-U/Sigma 1.40 +Compiler /bin/cc +変更事項 SWITCHES に -DUSG -DSYSTIME_HAS_NO_TM -DNOBSTRING -DNOINDEX + -DNOSTRDUP -DNODIRECTORY -DNOFTRUNCATE -Zu を追加 +備考 +---------------------------------------------------------------- +社名 OMRON +マシン LUNA (SX-9100/DT) +OS UNIOS-B 1.50,2.00 +Compiler /bin/cc,gcc version 1.40 +変更事項 SWITCHES に -DFTIME -DNOSTRDUP を追加 +備考 +--------------------------------------------------------------- +社名 OMRON +マシン LUNA-II +OS Mach 2.5 Vers 1.40 +Compiler /bin/cc +変更事項 SWITCHES に -DNOSTRDUP -DFTIME -DUSESTRCASECMP を追加 +備考 +---------------------------------------------------------------- +社名 OMRON +マシン LUNA-88K +OS Mach 2.5 vers 1.33 +Compiler /bin/cc,gcc-1.40 +変更事項 SWITCHES に -DFTIME -DNOSTRDUP を追加 +備考 +---------------------------------------------------------------- +社名 OMRON +マシン LUNA(SX-9100DT) +OS UniOS-U/Sigma 2.01 +Compiler /bin/cc +変更事項 SWITCHES に -Zu -DSYSV_SYSTEM_DIR -DSYSTIME_HAS_NO_TM + -DNOFTRUNCATE -DNOSTRDUP -DNOBSTRING -DUSG -DNOINDEX を追加 +備考 uniosu +---------------------------------------------------------------- +社名 OMRON +マシン SX-9100Σ +OS OMRONIX-Σ +Compiler /bin/cc +変更事項 SWITCHES に -Zu -DNONSYSTEM_DIR_LIBRARY -DSYSTIME_HAS_NO_TM + -DNOFTRUNCATE -DNOBSTRING -DUSG -DNOINDEX を追加,LIBRARYOBJS + に lhdir.o を追加 +備考 +---------------------------------------------------------------- +社名 NeXT +マシン NeXT station/Cube +OS NeXT OS 2.1, 2.1J +Compiler /bin/cc NeXT Release 2.0 +変更事項 SWITCHES に -DNOSTRDUP を追加 +備考 +---------------------------------------------------------------- +社名 DEC +マシン DEC5100,DEC Station 3100,MicroVAX-3600 +OS ULTRIX V4.0, 4.1, 4.2 +Compiler cc +変更事項 SWITCHES に -DUSESTRCASECMP -DNOSTRDUP を追加 +備考 ultrix +---------------------------------------------------------------- +社名 Panasonic +マシン BE +OS BE-OS 1.3 +Compiler gcc version 1.37.1 +変更事項 SWITCHES に -DSYSV_SYSTEM_DIR -DSYSTIME_HAS_NO_TM -DTZSET + -DNOFTRUNCATE を追加 +備考 +---------------------------------------------------------------- +社名 MIPS +マシン RS3230/3330 +OS RISC/os 4.51,4.52 +Compiler /bsd43/bin/cc +変更事項 SWITCHES に -DNOSTRDUP を追加 +備考 +---------------------------------------------------------------- +社名 Sequent Computer Systems, Inc. +マシン Symmetry +OS DYNIX(R) V3.0.17.v3 NFS #2() +Compiler cc +変更事項 SWITCHES に -DJIS -DNOSTRDUP -DNOMEMSET を追加 +備考 +---------------------------------------------------------------- +社名 Solbourne +マシン Series 5/600 +OS OS/MP 4.0D_Export +Compiler cc,gcc -traditional +変更事項 +備考 +---------------------------------------------------------------- +社名 三菱電機 +マシン ME100/200/250/350/400/520/550 +OS ME/UX C00,C10,C20 (System V/68 Release R3V4) +Compiler cc +変更事項 SWITCHES に -DSYSV_SYSTEM_DIR -DNOFTRUNCATE を追加 +備考 +---------------------------------------------------------------- +社名 三菱電機 +マシン ME1100/1200/1300/1500 +OS ME/UX (68020) C01版 (SYSV R2) +Compiler cc +変更事項 SWITCHES に -DNONSYSTEM_DIR_LIBRARY -DNOFTRUNCATE + -DSYSTIME_HAS_NO_TM -DNOBSTRING -DUSG -DNOSTRDUP -DNOMKDIR + -DTZSET -DNOINDEX を追加,LIBRARYOBJS に lhdir.o を追加 +備考 +---------------------------------------------------------------- +社名 三菱電機 +マシン FAS350(FA-workstation) +OS ISI-4.3BSD +Compiler /bin/cc +変更事項 SWITCHES に -DFTIME -DNOSTRDUP を追加 +備考 +---------------------------------------------------------------- +社名 NEC +マシン EWS4800/10,20,30,50,60 +OS EWS-UX/V R8.1 +Compiler cc,gcc -traditional +変更事項 SWITCHES に -I/usr/ucbinclude -DSYSTIME_HAS_NO_TM -DTZSET + -DUSG -DNOINDEX を追加,LDFLAGS=-ldir を追加 +備考 +---------------------------------------------------------------- +社名 NEC +マシン EWS4800/220 +OS EWS-UX/V (Rel 4.0)R2.1 +Compiler /bin/cc +変更事項 SWITCHES に -DMKTIME -DNOINDEX -DSYSV_SYSTEM_DIR -DUSG を追加 +備考 +---------------------------------------------------------------- +社名 NEC +マシン EWS4800/220 +OS EWS-UX/V (Rel 4.0)R2.1 +Compiler /usr/ucb/cc +変更事項 SWITCHES に -DMKTIME を追加 +備考 +---------------------------------------------------------------- +社名 NEC +マシン PC-9801 +OS PC-UX/V R3.2 +Compiler cc +変更事項 SWITCHES に -DNOFTRUNCATE -DTZSET -DSYSV_SYSTEM_DIR + -DSYSTIME_HAS_NO_TM -DNOBSTRING -DUSG -DNOINDEX を追加 +備考 +---------------------------------------------------------------- +社名 NEC +マシン PC-9801 +OS PC-UX/V R3.0B +Compiler cc および gcc-2.0 +変更事項 SWITCHES に -DUSG -DSYSV_SYSTEM_DIR -DSYSTIME_HAS_NO_TM + -DTZSET -DNOBSTRING -DNOFTRUNCATE -DNOINDEX を追加 +備考 gcc でコンパイルする場合は、-traditional オプションを + つける。 +---------------------------------------------------------------- +社名 Hewlett Packard +マシン HP9000 s300/s400 +OS HP-UX7.03 +Compiler cc +変更事項 EUC を使用する場合は SWITCHES に -DNOBSTRING を追加。 + Shift-JIS を使用する場合はSWITCHESに -DNOBSTRING を追加し + -DEUC を削除。 +備考 hpux +---------------------------------------------------------------- +社名 Hewlett Packard +マシン HP9000 s800 +OS HP-UX7.00 +Compiler cc +変更事項 EUC を使用する場合は SWITCHES に -DNOBSTRING を追加。 + Shift-JIS を使用する場合はSWITCHESに -DNOBSTRING を追加し + -DEUC を削除。 +備考 hpux +---------------------------------------------------------------- +社名 Hewlett Packard +マシン HP9000 s300/s400 +OS HP-UX8.0 +Compiler cc +変更事項 SWITCHES に -DUSESTRCASECMP を追加。Shift-JIS を使用する場合 + はさらに -DEUCを削除。 +備考 hpux +---------------------------------------------------------------- +社名 Hewlett Packard +マシン HP9000 s700 +OS HP-UX 8.05,8.07 +Compiler cc +変更事項 SWITCHES に -DUSESTRCASECMP を追加。Shift-JIS を使用する場合 + はさらに -DEUCを削除。 +備考 hpux +---------------------------------------------------------------- +社名 Hewlett Packard +マシン HP apollo s400t,s25t +OS DOMAIN/OS SR10.3 +Compiler cc Ver 6.8 +変更事項 (SYSTYPE=bsd4.3,ENVIRON=bsd) +備考 +---------------------------------------------------------------- +社名 DOMAIN +マシン DN4500F +OS DOMAIN/OS SR10.2 +Compiler cc Ver 6.7 +変更事項 SWITCHES に -U__STDC__ を追加(SYSTYPE=bsd4.3,ENVIRON=bsd) +備考 +---------------------------------------------------------------- +社名 DOMAIN +マシン DSP10000 +OS DOMAIN/OS SR10.2p +Compiler cc Ver 6.7p (PRISM) +変更事項 SWITCHES に -U__STDC__ を追加(SYSTYPE=bsd4.3,ENVIRON=bsd) +備考 +---------------------------------------------------------------- +社名 日立 +マシン HIDIC V90/45 +OS RENIX-V +Compiler /bin/cc +変更事項 SWITCHES に -DTZSET -DSYSTIME_HAS_NO_TM -DSYSV_SYSTEM_DIR + -DNOBSTRING -DUSG -DNOINDEX -DNOFTRUNCATE を追加 +備考 +---------------------------------------------------------------- +社名 日立 +マシン 2050/32E +OS HI-UX (ver.不明) +Compiler cc +変更事項 SWITCHES に -DTZSET -DSYSTIME_HAS_NO_TM -DSYSV_SYSTEM_DIR + -DNOBSTRING -DUSG -DNOINDEX を追加 +備考 +---------------------------------------------------------------- +社名 東芝 +マシン J3100SGT +OS UX/386 (SysVR3) +Compiler /bin/cc +変更事項 SWITCHES に -DTZSET -DSYSV_SYSTEM_DIR -DNOBSTRING -DUSG + -DNOINDEX -DNOFTRUNCATE を追加 +備考 +---------------------------------------------------------------- +社名 富士通 +マシン G150/160 +OS SX/G E14 +Compiler cc +変更事項 SWITCHIES に -DNONSYSTEM_DIR_LIBRARY -DNOSTRDUP -DTZSET + -DNOBSTRING -DUSG -DNOINDEX -DNOFTRUNCATE -DSYSTIME_HAS_NO_TM + を追加,LDFLAGS=-lu を追加 +備考 +---------------------------------------------------------------- +社名 富士通 +マシン VP2200 MODEL 10 +OS UXP/M V10L10 +Compiler BSD Compatibility Package の cc (/usr/ucb/cc) +変更事項 LDFLAGS=-lucb を追加 +備考 +---------------------------------------------------------------- +社名 富士通 +マシン Mシリーズ +OS UTS/M V22L20 +Compiler cc +変更事項 SWITCHIES に -DNODIRECTORY -DNOSTRDUP -DTZSET -DNOBSTRING + -DUSG -DNOINDEX -DNOFTRUNCATE -DSYSTIME_HAS_NO_TMを追加 +備考 +---------------------------------------------------------------- +社名 PFU +マシン Astation 240 +OS SX/A E60B +Compiler /bin/cc +変更事項 SWITCHES に -DSYSV_SYSTEM_DIR -DSYSTEM_HAS_NO_TM -DUSG + -DNOINDEX を追加 +備考 SXA +---------------------------------------------------------------- +社名 PFU +マシン A60 / Astation 350 +OS SX/A E50/E60B +Compiler /bin/cc +変更事項 SWITCHES に -DSYSV_SYSTEM_DIR -DNOBSTRING -DNOFTRUNCATE + -DUSG -DEUC -DNEED_INCREMENTAL_INDICATOR を追加 +備考 本当は -DNOFTRUNCATE はE50でのみ必要 +---------------------------------------------------------------- +社名 EPSON/NEC/IBM +マシン PC-386GE/PC-9801NS/IBM PC-AT +OS MINIX 1.5.10 + MIX 386 patch +Compiler MIX版gcc +変更事項 SWITCHES を -DEUC -DNOSTRDUP -D_MINIX -D_POSIX_SOURCE + -DSYSTIME_HAS_NO_TM -DSYSV_SYSTEM_DIR -DNOFTRUNCATE + -DNOBSTRING -DUSG -DNOINDEX -DTZSET に変更 + CC を gcc に変更 + OPTIMIZE から -g を削除 +備考 (1) maketree.cでUINT_MAXの評価がCPPエラーになったら + /usr/local/lib/include/gcc-limits.hを + /usr/local/lib/include/limits.hにmvまたはlnするか、 + その部分の#if #endifをコメントアウトすること + (これは、MIX版gccの問題です。 最新版gccでは解決されています。) + (2) コンパイル後以下のコマンドを実行し、メモリサイズを + 変更すること + chmem =500000 lha +---------------------------------------------------------------- +社名 Silicon Graphics +マシン IRIS200 +OS IRIX 2.2 +Compiler /usr/bin/cc +変更事項 +備考 +--------------------------------------------------------------------- +社名 Silicon Graphics +マシン IRIS 4D/25GT,4D/310GTX +OS IRIX System V Release 3.3.1 +Compiler /usr/bin/cc +変更事項 SWITCHES に -DSYSV_SYSTEM_DIR -DNOBSTRING -DNOINDEX を追加 +---------------------------------------------------------------- +社名 クボタコンピュータ +マシン TITAN3000 +OS OS 3.0.3,OS 4.1 +Compiler /bin/cc +変更事項 SWITCHES に -DNOINDEX -DSYSV_SYSTEM_DIR を追加 +備考 titan +---------------------------------------------------------------- +社名 クボタコンピュータ +マシン TITAN1500 +OS OS 2.5 +Compiler cc +変更事項 SWITCHES に -DNOINDEX -DSYSV_SYSTEM_DIR -DSYSTIME_HAS_NO_TM + を追加 +備考 titan +---------------------------------------------------------------- +社名 クボタコンピュータ +マシン TITAN VISTRA800ex/VISTRA800b +OS 2.0 +Compiler /usr/ucb/cc +変更事項 SWITCHES に -DSYSV_SYSTEM_DIR -DSYSTIME_HAS_NO_TM を追加 +備考 titan +---------------------------------------------------------------- +社名 IBM +マシン RISC System/6000 POWERstation 530 +OS AIX version 3.1 +Compiler /bin/cc +変更事項 SWITCHES に -DSYSV_SYSTEM_DIR -D_BSD_INCLUDES -DAIX を追加 +備考 +---------------------------------------------------------------- +社名 Convex +マシン Mini Super Computer C-201,C-230,C-240 +OS ConvexOS V.8.1, v9.1.6 (BSD 4.2) +Compiler /bin/cc V4.0 +変更事項 SWITCHES に -DSYSV_SYSTEM_DIR を追加, CC に -pcc を追加 +備考 __convexc__ +---------------------------------------------------------------- +社名 電産 +マシン WORKS-3000, idea 2010 +OS DEVOS V3 (4.3 More/bsd/NFS) +Compiler gcc -traditional (gcc 1.40) +変更事項 SWITCHES に -DFTIME -DNOSTRDUP を追加 +備考 +------------------------------------------------------------------------ +社名 SONY +マシン NWS-1860 +OS NEWS-OS 4.2.1C +Compiler cc +変更事項 SWITCHES に -DNOSTRDUP を追加 +備考 sony_news +------------------------------------------------------------------------ +社名 SONY +マシン NWS-3870 +OS NEWS-OS 4.2.1R +Compiler cc +変更事項 SWITCHES に -DNOSTRDUP を追加 +備考 sony_news +------------------------------------------------------------------------ +社名 富士通 +マシン DS/90 7750 (Single CPU type) +OS UNIX_System_V 4.0.0 V10L20 Y92121 +Compiler cc +変更事項 SWITCHES に -DEUC -DUSG -DSYSV_SYSTEM_DIR -DNOBSTRING + -DSYSTIME_HAS_NO_TM -DNOINDEX を追加 +備考 +---------------------------------------------------------------- +社名 DEC +マシン DECstation 5000/25 +OS ULTRIX V4.3 +Compiler cc +変更事項 SWITCHES に -DUSESTRCASECMP -DNOSTRDUP -DNOINDEX + -DNOBSTRING を追加 +備考 ultrix +---------------------------------------------------------------- +社名 DEC +マシン DEC 3000/300 +OS DEC OSF/1 V1.3A +Compiler cc +変更事項 SWITCHES に -DSYSV_SYSTEM_DIR -DNOINDEX -DNOBSTRING を追加 +備考 osf +---------------------------------------------------------------- +社名 Silicon Graphics +マシン INDY, INDIGO, ONYX +OS IRIX Release 5.1 +Compiler cc +変更事項 SWITCHES に -DSYSV_SYSTEM_DIR -DNOBSTRING -DNOINDEX を追加 +---------------------------------------------------------------- +社名 Apple +マシン Quadra 950 +OS A/UX 3.0 +Compiler cc +変更事項 SWITCHES に -DNOSTRDUP -DTZSET を追加 +---------------------------------------------------------------- +マシン 不明(Pentium133MHz) +OS BSDI BSD/OS 2.0 +Compiler cc(gcc) +変更事項 SWITCHES から -DFTIME を削除する。 +---------------------------------------------------------------- +マシン IBM-PC/AT 互換機(Pentium133MHz) +OS FreeBSD 2.1.0 Release +Compiler gcc +変更事項 SWITCHES から -DFTIME を削除し、 + -DHAVE_TM_ZONE を追加する。 +---------------------------------------------------------------- +マシン 不明(Pentium99MHz) +OS Linux 1.2.13(POSIX) +Compiler cc(gcc) +変更事項 特に変更なし。 +---------------------------------------------------------------- +社名 Hewlett Packard +マシン HP9000 s720 +OS HP-UX 9.01 +Compiler c89 +変更事項 SWITCHES に -DUSESTRCASECMP を追加。 + SWITCHES に -D_HPUX_SOURCE を追加。 + Shift-JIS を使用する場合はさらに -DEUCを削除。 + OPTIMIZE には -O だけを指定 +---------------------------------------------------------------- diff -Nru lha-1.14i/olddoc/Makefile.am lha-1.14i-acc20050924p1/olddoc/Makefile.am --- lha-1.14i/olddoc/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/olddoc/Makefile.am 2002-11-14 19:40:54.000000000 +0000 @@ -0,0 +1,6 @@ +## Process this file with automake to produce Makefile.in +EXTRA_DIST = CHANGES.euc MACHINES.euc \ + MACHINES2.euc PROBLEMS.euc README.euc IFNAMES \ + change-114e.txt change-114f.txt change-114g.txt \ + change-114h.txt change-114i.txt \ + config.eng config.jpn.euc diff -Nru lha-1.14i/olddoc/Makefile.in lha-1.14i-acc20050924p1/olddoc/Makefile.in --- lha-1.14i/olddoc/Makefile.in 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/olddoc/Makefile.in 2006-10-16 14:50:09.000000000 +0000 @@ -0,0 +1,296 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +LIBOBJDIR = +subdir = olddoc +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEF_KCODE = @DEF_KCODE@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SUPPORT_LZHUFF_METHOD = @SUPPORT_LZHUFF_METHOD@ +U = @U@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +EXTRA_DIST = CHANGES.euc MACHINES.euc \ + MACHINES2.euc PROBLEMS.euc README.euc IFNAMES \ + change-114e.txt change-114f.txt change-114g.txt \ + change-114h.txt change-114i.txt \ + config.eng config.jpn.euc + +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu olddoc/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu olddoc/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +uninstall-info-am: +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff -Nru lha-1.14i/olddoc/PROBLEMS.euc lha-1.14i-acc20050924p1/olddoc/PROBLEMS.euc --- lha-1.14i/olddoc/PROBLEMS.euc 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/olddoc/PROBLEMS.euc 2002-11-14 19:40:54.000000000 +0000 @@ -0,0 +1,45 @@ + + LHa Version 1.14 に関する問題点 + +1) アーカイブ内の漢字ファイル名に対応していない + + 試作版のころに内田@富士通さんから指摘されてい + たのですがまだ対処していません。(すみません) + また、対処の方法もいくつか選択肢があります。 + アーカイブ内のファイル名はすべて S-JIS として + 扱うべきなのか、UNIX であれば EUC を含めて良い + のか、などなど。 (原本:沖 氏) + + P.S + きちんと圧縮と展開ができるので対応してると思ってました。 + なお、私にはなんのことやらさっぱりわかりませんので未対応です。 + (綿崎) + + +2) マシン別の Makefile の設定がまとまっていない + + config.h をつくってそこにマシン別のマクロ定義を + いれてみたいと思います。現在はまだ Makefile で + 指定して下さい。 (原本:沖 氏) + + P.S + 仕事先にSunしかないのでなんとも‥‥未対応です。 + (綿崎) + +3) 書庫の中のファイルがソートされていない場合、書庫へのファイルの追加、 + 更新がうまくいかない。 + + LHa for Unix は書庫の中のファイルがソートされていると仮定して + ファイルの追加、更新処理を行なっている。MS-DOS の LHarc は書庫 + の中のファイルをソートしていたが、LHA はソートしなくなった為、 + MS-DOS で作られた書庫へのファイルの追加、更新が正常に行なわれ + ない可能性がある。 + 対処方法は一度解凍を行なってから、LHa for Unix で再圧縮すれば + 良い。 + +4) 時間表示がおかしくなる + + DOS で作成した書庫のファイルスタンプが正しく表示されなかったり、 + TZ に値を設定するとタイムスタンプがずれたりします。いろいろある + 時間に関する関数がよく分かっていないので、分かってきたらきちん + と直そうと思います。 diff -Nru lha-1.14i/olddoc/README.euc lha-1.14i-acc20050924p1/olddoc/README.euc --- lha-1.14i/olddoc/README.euc 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/olddoc/README.euc 2002-11-14 19:40:54.000000000 +0000 @@ -0,0 +1,98 @@ + LHa for UNIX version 1.14e Jun. 7 1999 by Tsugio Okamoto + + This file is used EUC code. + + ※取扱についての注意 version 1.14e + + このバージョンは、UNIX 版 LHa の正式発行なものではありません。 + 以前公開された、沖勝氏の UNIX 版 LHa Ver. 1.00、綿崎氏の + Ver. 1.14 を改変したものです。 + + 連絡は、以下の連絡先の方にしてください沖勝氏および綿崎氏の方には、 + 御迷惑がかかりますのでなるべくしないでください。 + + このバージョンのバグの報告などは、私(岡本 継男, + E-MAIL:tsugio@muc.biglobe.ne.jp)まで連絡下さい。 + + + -lh5-, -lh6- 圧縮形式での圧縮/展開が可能なアーカイバ + LHa の UNIX 版の非正式 バージョンアップ版です。 + + UNIX 版 LHarc 1.02 (by Y.Tagawa) を改造し MS-DOS 版 LHx C2.01E + (by 吉崎 栄泰) のアルゴリズムを付加した LHx(arc) V2.00 for OSK + (by Sakura Tomozou) を、沖勝氏が UNIX 上で動作するようにしました。 + それを、綿崎氏が Symbolic Link と 展開時のタイムスタンプ対応しま + した。そして私が -lh6- の圧縮形式に対応しました。 + + MACHINES, config.jpn.euc (config.eng) を参考にして + Makefile を適宜変更し、make してください。 + + コンパイル時および動作に問題が発生した場合は連絡をお願いします。 + 対象プラットフォーム (機種、OS バージョン、コンパイラ) および + 症状を詳しくお知らせ下さい。また、LHa のソース変更によって正し + く動作させることができた時には変更点をお知らせ下さい。 + 可能ならば次回の Version UP に反映したいと思います。 + (非正式発行版なので、未定ですが‥‥。) + + また、新しいプラットフォームでのコンパイルおよび動作確認ができ + ましたら、お知らせ下さい。動作確認プラットフォームの情報を更新 + したいと思います。 + + MACHINES にこれまで報告のあったプラットフォームのコンパイル + オプションについて記述しています。 + (CHANGES.euc には機種依存マクロの場所を SWITCHIES から MACHINE に + 変更したとありますが、MACHINES.euc の内容は SWITCHES のままになってます。 + 置き換えて読んでください。) + MACHINES2 は Ver. 1.14d 以降(Ver.1.14cも多少含む)に報告のあった + プラットフォームのコンパイルオプションについて記述しました。 + + (注意)MACHINE, MACHINE2, SWITCHIESはは上記通りにまだなって + いないところがあります。1999.6.7 + + コンパイルがうまくいかない場合は、Ver. 1.00 の Makefile で + コンパイルできる可能性があります。src/ と man/ の下の + ファイルを入れ替えてコンパイルしてみてください。 + なお、添付の Makefile は FreeBSD 3.1用になっております. + (以前のバージョンから変更されています。以前は SunOS でした。) + + なお、文書は全てEUCで記述されていますので変換が必要な方はお手間で + しょうが各自変換してください。 + + なお、ネットでの配付は自由ですが、ネットにアクセスできない方(雑誌および、 + CD-ROM などによる)への配付は、配付前にこちらに Inter-Net の方にE-Mail + を お願いします。 どこそこに、掲載するという旨があれば結構ですので。 + また、それも出来ない際には、後日 E-Mail を必ずお願いします。 + + + LHa for UNIX Ver. 1.00 との変更点 + + CHANGES, CHANGE2, change-*.txt を参照して下さい。 + + わかっている不具合 + + PROBLEMS, change-*.txt を参照して下さい。 + + 連絡先 + + E-Mail address: tsugio@muc.biglobe.ne.jp + Home page : http://www2m.biglobe.ne.jp/~dolphin/index.htm + (1999年 5月25日現在) + + 謝辞 + + LHarc および LHa の原作者である吉崎栄泰さん、LHarc UNIX + の作者である Y.Tagawa さん、LHx(arc) for OSK を作成された + Sakura Tomozou さん、LHa for UNIX をここまで仕上げてくださった + 沖 勝さん、綿崎修隆さん、さらに開発にかかわった方々や協力して + くれた皆様に感謝致します。 + + 1999 年 6 月 7 日 + 岡本 継男 + + データ形式について + + なお、データファイルは、tar + gzip でアップロードされています。 + よって、gzip -cd lha-114e.tgz | tar xf - 等で展開してください。 + +[eof] + diff -Nru lha-1.14i/PROBLEMS.euc lha-1.14i-acc20050924p1/PROBLEMS.euc --- lha-1.14i/PROBLEMS.euc 2000-12-15 12:13:16.000000000 +0000 +++ lha-1.14i-acc20050924p1/PROBLEMS.euc 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ - - LHa Version 1.14 に関する問題点 - -1) アーカイブ内の漢字ファイル名に対応していない - - 試作版のころに内田@富士通さんから指摘されてい - たのですがまだ対処していません。(すみません) - また、対処の方法もいくつか選択肢があります。 - アーカイブ内のファイル名はすべて S-JIS として - 扱うべきなのか、UNIX であれば EUC を含めて良い - のか、などなど。 (原本:沖 氏) - - P.S - きちんと圧縮と展開ができるので対応してると思ってました。 - なお、私にはなんのことやらさっぱりわかりませんので未対応です。 - (綿崎) - - -2) マシン別の Makefile の設定がまとまっていない - - config.h をつくってそこにマシン別のマクロ定義を - いれてみたいと思います。現在はまだ Makefile で - 指定して下さい。 (原本:沖 氏) - - P.S - 仕事先にSunしかないのでなんとも‥‥未対応です。 - (綿崎) - -3) 書庫の中のファイルがソートされていない場合、書庫へのファイルの追加、 - 更新がうまくいかない。 - - LHa for Unix は書庫の中のファイルがソートされていると仮定して - ファイルの追加、更新処理を行なっている。MS-DOS の LHarc は書庫 - の中のファイルをソートしていたが、LHA はソートしなくなった為、 - MS-DOS で作られた書庫へのファイルの追加、更新が正常に行なわれ - ない可能性がある。 - 対処方法は一度解凍を行なってから、LHa for Unix で再圧縮すれば - 良い。 - -4) 時間表示がおかしくなる - - DOS で作成した書庫のファイルスタンプが正しく表示されなかったり、 - TZ に値を設定するとタイムスタンプがずれたりします。いろいろある - 時間に関する関数がよく分かっていないので、分かってきたらきちん - と直そうと思います。 diff -Nru lha-1.14i/README.euc lha-1.14i-acc20050924p1/README.euc --- lha-1.14i/README.euc 2000-12-15 12:13:16.000000000 +0000 +++ lha-1.14i-acc20050924p1/README.euc 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ - LHa for UNIX version 1.14e Jun. 7 1999 by Tsugio Okamoto - - This file is used EUC code. - - ※取扱についての注意 version 1.14e - - このバージョンは、UNIX 版 LHa の正式発行なものではありません。 - 以前公開された、沖勝氏の UNIX 版 LHa Ver. 1.00、綿崎氏の - Ver. 1.14 を改変したものです。 - - 連絡は、以下の連絡先の方にしてください沖勝氏および綿崎氏の方には、 - 御迷惑がかかりますのでなるべくしないでください。 - - このバージョンのバグの報告などは、私(岡本 継男, - E-MAIL:tsugio@muc.biglobe.ne.jp)まで連絡下さい。 - - - -lh5-, -lh6- 圧縮形式での圧縮/展開が可能なアーカイバ - LHa の UNIX 版の非正式 バージョンアップ版です。 - - UNIX 版 LHarc 1.02 (by Y.Tagawa) を改造し MS-DOS 版 LHx C2.01E - (by 吉崎 栄泰) のアルゴリズムを付加した LHx(arc) V2.00 for OSK - (by Sakura Tomozou) を、沖勝氏が UNIX 上で動作するようにしました。 - それを、綿崎氏が Symbolic Link と 展開時のタイムスタンプ対応しま - した。そして私が -lh6- の圧縮形式に対応しました。 - - MACHINES, config.jpn.euc (config.eng) を参考にして - Makefile を適宜変更し、make してください。 - - コンパイル時および動作に問題が発生した場合は連絡をお願いします。 - 対象プラットフォーム (機種、OS バージョン、コンパイラ) および - 症状を詳しくお知らせ下さい。また、LHa のソース変更によって正し - く動作させることができた時には変更点をお知らせ下さい。 - 可能ならば次回の Version UP に反映したいと思います。 - (非正式発行版なので、未定ですが‥‥。) - - また、新しいプラットフォームでのコンパイルおよび動作確認ができ - ましたら、お知らせ下さい。動作確認プラットフォームの情報を更新 - したいと思います。 - - MACHINES にこれまで報告のあったプラットフォームのコンパイル - オプションについて記述しています。 - (CHANGES.euc には機種依存マクロの場所を SWITCHIES から MACHINE に - 変更したとありますが、MACHINES.euc の内容は SWITCHES のままになってます。 - 置き換えて読んでください。) - MACHINES2 は Ver. 1.14d 以降(Ver.1.14cも多少含む)に報告のあった - プラットフォームのコンパイルオプションについて記述しました。 - - (注意)MACHINE, MACHINE2, SWITCHIESはは上記通りにまだなって - いないところがあります。1999.6.7 - - コンパイルがうまくいかない場合は、Ver. 1.00 の Makefile で - コンパイルできる可能性があります。src/ と man/ の下の - ファイルを入れ替えてコンパイルしてみてください。 - なお、添付の Makefile は FreeBSD 3.1用になっております. - (以前のバージョンから変更されています。以前は SunOS でした。) - - なお、文書は全てEUCで記述されていますので変換が必要な方はお手間で - しょうが各自変換してください。 - - なお、ネットでの配付は自由ですが、ネットにアクセスできない方(雑誌および、 - CD-ROM などによる)への配付は、配付前にこちらに Inter-Net の方にE-Mail - を お願いします。 どこそこに、掲載するという旨があれば結構ですので。 - また、それも出来ない際には、後日 E-Mail を必ずお願いします。 - - - LHa for UNIX Ver. 1.00 との変更点 - - CHANGES, CHANGE2, change-*.txt を参照して下さい。 - - わかっている不具合 - - PROBLEMS, change-*.txt を参照して下さい。 - - 連絡先 - - E-Mail address: tsugio@muc.biglobe.ne.jp - Home page : http://www2m.biglobe.ne.jp/~dolphin/index.htm - (1999年 5月25日現在) - - 謝辞 - - LHarc および LHa の原作者である吉崎栄泰さん、LHarc UNIX - の作者である Y.Tagawa さん、LHx(arc) for OSK を作成された - Sakura Tomozou さん、LHa for UNIX をここまで仕上げてくださった - 沖 勝さん、綿崎修隆さん、さらに開発にかかわった方々や協力して - くれた皆様に感謝致します。 - - 1999 年 6 月 7 日 - 岡本 継男 - - データ形式について - - なお、データファイルは、tar + gzip でアップロードされています。 - よって、gzip -cd lha-114e.tgz | tar xf - 等で展開してください。 - -[eof] - diff -Nru lha-1.14i/src/append.c lha-1.14i-acc20050924p1/src/append.c --- lha-1.14i/src/append.c 2000-10-04 14:57:38.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/append.c 2003-07-21 19:47:28.000000000 +0000 @@ -1,132 +1,52 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* append.c -- append to archive */ -/* */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* LHa for UNIX */ +/* append.c -- append to archive */ +/* */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ /* ------------------------------------------------------------------------ */ #include "lha.h" -/* ------------------------------------------------------------------------ */ int encode_lzhuf(infp, outfp, size, original_size_var, packed_size_var, - name, hdr_method) - FILE *infp; - FILE *outfp; - long size; - long *original_size_var; - long *packed_size_var; - char *name; - char *hdr_method; -{ - static int method = -1; - - if (method < 0) { - method = compress_method; - if (method > 0) - method = encode_alloc(method); - } - - interface.method = method; - - if (interface.method > 0) { - interface.infile = infp; - interface.outfile = outfp; - interface.original = size; - start_indicator(name, size, "Freezing", 1 << dicbit); - encode(&interface); - *packed_size_var = interface.packed; - *original_size_var = interface.original; - } else { - copyfile(infp, outfp, size, 1); - *packed_size_var = *original_size_var = size; - } - bcopy("-lh -", hdr_method, 5); - hdr_method[3] = interface.method + '0'; - - finish_indicator2(name, "Frozen", - (int) ((*packed_size_var * 100L) / *original_size_var)); - return crc; -} -/* ------------------------------------------------------------------------ */ -void -start_indicator(name, size, msg, def_indicator_threshold) - char *name; - long size; - char *msg; - long def_indicator_threshold; -{ -#ifdef NEED_INCREMENTAL_INDICATOR - long i; - int m; -#endif - - if (quiet) - return; - -#ifdef NEED_INCREMENTAL_INDICATOR - switch (quiet_mode) { - case 0: - m = MAX_INDICATOR_COUNT - strlen(name); - if (m < 1) /* Bug Fixed by N.Watazaki */ - m = 3; /* (^_^) */ - printf("\r%s\t- %s : ", name, msg); - indicator_threshold = - ((size + (m * def_indicator_threshold - 1)) / - (m * def_indicator_threshold) * - def_indicator_threshold); - if (indicator_threshold) - i = ((size + (indicator_threshold - 1)) / indicator_threshold); - else - i = 0; - while (i--) - putchar('.'); - indicator_count = 0; - printf("\r%s\t- %s : ", name, msg); - break; - case 1: - printf("\r%s :", name); - break; - } -#else - printf("%s\t- ", name); -#endif - fflush(stdout); - reading_size = 0L; -} -/* ------------------------------------------------------------------------ */ -void -finish_indicator2(name, msg, pcnt) - char *name; - char *msg; - int pcnt; + name, hdr_method) + FILE *infp; + FILE *outfp; + size_t size; + size_t *original_size_var; + size_t *packed_size_var; + char *name; + char *hdr_method; { - if (quiet) - return; - - if (pcnt > 100) - pcnt = 100; /* (^_^) */ -#ifdef NEED_INCREMENTAL_INDICATOR - printf("\r%s\t- %s(%d%%)\n", name, msg, pcnt); -#else - printf("%s\n", msg); -#endif - fflush(stdout); -} -/* ------------------------------------------------------------------------ */ -void -finish_indicator(name, msg) - char *name; - char *msg; -{ - if (quiet) - return; - -#ifdef NEED_INCREMENTAL_INDICATOR - printf("\r%s\t- %s\n", name, msg); -#else - printf("%s\n", msg); -#endif - fflush(stdout); + static int method = -1; + unsigned int crc; + struct interfacing interface; + + if (method < 0) { + method = compress_method; + if (method > 0) + method = encode_alloc(method); + } + + interface.method = method; + + if (interface.method > 0) { + interface.infile = infp; + interface.outfile = outfp; + interface.original = size; + start_indicator(name, size, "Freezing", 1 << dicbit); + crc = encode(&interface); + *packed_size_var = interface.packed; + *original_size_var = interface.original; + } else { + *packed_size_var = *original_size_var = + copyfile(infp, outfp, size, 0, &crc); + } + memcpy(hdr_method, "-lh -", 5); + hdr_method[3] = interface.method + '0'; + + finish_indicator2(name, "Frozen", + (int) ((*packed_size_var * 100L) / *original_size_var)); + return crc; } diff -Nru lha-1.14i/src/bitio.c lha-1.14i-acc20050924p1/src/bitio.c --- lha-1.14i/src/bitio.c 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/bitio.c 2003-07-29 21:01:21.000000000 +0000 @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------------ */ +/* LHa for UNIX */ +/* bitio.c -- bit stream */ +/* */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* Separated from crcio.c 2002.10.26 Koji Arai */ +/* ------------------------------------------------------------------------ */ +#include "lha.h" + +static unsigned char subbitbuf, bitcount; + +void +fillbuf(n) /* Shift bitbuf n bits left, read n bits */ + unsigned char n; +{ + while (n > bitcount) { + n -= bitcount; + bitbuf = (bitbuf << bitcount) + (subbitbuf >> (CHAR_BIT - bitcount)); + if (compsize != 0) { + compsize--; + subbitbuf = (unsigned char) getc(infile); + } + else + subbitbuf = 0; + bitcount = CHAR_BIT; + } + bitcount -= n; + bitbuf = (bitbuf << n) + (subbitbuf >> (CHAR_BIT - n)); + subbitbuf <<= n; +} + +unsigned short +getbits(n) + unsigned char n; +{ + unsigned short x; + + x = bitbuf >> (2 * CHAR_BIT - n); + fillbuf(n); + return x; +} + +void +putcode(n, x) /* Write leftmost n bits of x */ + unsigned char n; + unsigned short x; +{ + while (n >= bitcount) { + n -= bitcount; + subbitbuf += x >> (USHRT_BIT - bitcount); + x <<= bitcount; + if (compsize < origsize) { + if (fwrite(&subbitbuf, 1, 1, outfile) == 0) { + fatal_error("Write error in bitio.c(putcode)"); + } + compsize++; + } + else + unpackable = 1; + subbitbuf = 0; + bitcount = CHAR_BIT; + } + subbitbuf += x >> (USHRT_BIT - bitcount); + bitcount -= n; +} + +void +putbits(n, x) /* Write rightmost n bits of x */ + unsigned char n; + unsigned short x; +{ + x <<= USHRT_BIT - n; + putcode(n, x); +} + +void +init_getbits( /* void */ ) +{ + bitbuf = 0; + subbitbuf = 0; + bitcount = 0; + fillbuf(2 * CHAR_BIT); +} + +void +init_putbits( /* void */ ) +{ + bitcount = CHAR_BIT; + subbitbuf = 0; +} diff -Nru lha-1.14i/src/crcio.c lha-1.14i-acc20050924p1/src/crcio.c --- lha-1.14i/src/crcio.c 2000-10-04 14:57:38.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/crcio.c 2006-10-10 16:27:51.000000000 +0000 @@ -1,16 +1,14 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* crcio.c -- crc input / output */ -/* */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* LHa for UNIX */ +/* crcio.c -- crc input / output */ +/* */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ /* ------------------------------------------------------------------------ */ #include "lha.h" /* ------------------------------------------------------------------------ */ -static unsigned short crctable[UCHAR_MAX + 1]; -static unsigned char subbitbuf, bitcount; #ifdef EUC static int putc_euc_cache; #endif @@ -20,339 +18,206 @@ void make_crctable( /* void */ ) { - unsigned int i, j, r; + unsigned int i, j, r; - for (i = 0; i <= UCHAR_MAX; i++) { - r = i; - for (j = 0; j < CHAR_BIT; j++) - if (r & 1) - r = (r >> 1) ^ CRCPOLY; - else - r >>= 1; - crctable[i] = r; - } + for (i = 0; i <= UCHAR_MAX; i++) { + r = i; + for (j = 0; j < CHAR_BIT; j++) + if (r & 1) + r = (r >> 1) ^ CRCPOLY; + else + r >>= 1; + crctable[i] = r; + } } /* ------------------------------------------------------------------------ */ -#ifdef NEED_INCREMENTAL_INDICATOR -static void -put_indicator(count) - long int count; -{ - if (!quiet && indicator_threshold) { - while (count > indicator_count) { - putchar('o'); - fflush(stdout); - indicator_count += indicator_threshold; - } - } +unsigned int +calccrc(crc, p, n) + unsigned int crc; + unsigned char *p; + unsigned int n; +{ + while (n-- > 0) + crc = UPDATE_CRC(crc, *p++); + return crc; } -#endif /* ------------------------------------------------------------------------ */ -unsigned short -calccrc(p, n) - unsigned char *p; - unsigned int n; -{ - reading_size += n; +int +fread_crc(crcp, p, n, fp) + unsigned int *crcp; + unsigned char *p; + int n; + FILE *fp; +{ + if (text_mode) + n = fread_txt(p, n, fp); + else + n = fread(p, 1, n, fp); + + *crcp = calccrc(*crcp, p, n); #ifdef NEED_INCREMENTAL_INDICATOR - put_indicator(reading_size); + put_indicator(n); #endif - while (n-- > 0) - UPDATE_CRC(*p++); - return crc; -} - -/* ------------------------------------------------------------------------ */ -void -fillbuf(n) /* Shift bitbuf n bits left, read n bits */ - unsigned char n; -{ - while (n > bitcount) { - n -= bitcount; - bitbuf = (bitbuf << bitcount) + (subbitbuf >> (CHAR_BIT - bitcount)); - if (compsize != 0) { - compsize--; - subbitbuf = (unsigned char) getc(infile); - } - else - subbitbuf = 0; - bitcount = CHAR_BIT; - } - bitcount -= n; - bitbuf = (bitbuf << n) + (subbitbuf >> (CHAR_BIT - n)); - subbitbuf <<= n; -} - -/* ------------------------------------------------------------------------ */ -unsigned short -getbits(n) - unsigned char n; -{ - unsigned short x; - - x = bitbuf >> (2 * CHAR_BIT - n); - fillbuf(n); - return x; -} - -/* ------------------------------------------------------------------------ */ -void -putcode(n, x) /* Write rightmost n bits of x */ - unsigned char n; - unsigned short x; -{ - while (n >= bitcount) { - n -= bitcount; - subbitbuf += x >> (USHRT_BIT - bitcount); - x <<= bitcount; - if (compsize < origsize) { - if (fwrite(&subbitbuf, 1, 1, outfile) == 0) { - /* fileerror(WTERR, outfile); */ - fatal_error("Write error in crcio.c(putcode)\n"); - /* exit(errno); */ - } - compsize++; - } - else - unpackable = 1; - subbitbuf = 0; - bitcount = CHAR_BIT; - } - subbitbuf += x >> (USHRT_BIT - bitcount); - bitcount -= n; + return n; } /* ------------------------------------------------------------------------ */ void -putbits(n, x) /* Write rightmost n bits of x */ - unsigned char n; - unsigned short x; +fwrite_crc(crcp, p, n, fp) + unsigned int *crcp; + unsigned char *p; + int n; + FILE *fp; { - x <<= USHRT_BIT - n; - while (n >= bitcount) { - n -= bitcount; - subbitbuf += x >> (USHRT_BIT - bitcount); - x <<= bitcount; - if (compsize < origsize) { - if (fwrite(&subbitbuf, 1, 1, outfile) == 0) { - /* fileerror(WTERR, outfile); */ - fatal_error("Write error in crcio.c(putbits)\n"); - /* exit(errno); */ - } - compsize++; - } - else - unpackable = 1; - subbitbuf = 0; - bitcount = CHAR_BIT; - } - subbitbuf += x >> (USHRT_BIT - bitcount); - bitcount -= n; -} - -/* ------------------------------------------------------------------------ */ -int -fread_crc(p, n, fp) - unsigned char *p; - int n; - FILE *fp; -{ - if (text_mode) - n = fread_txt(p, n, fp); - else - n = fread(p, 1, n, fp); - - calccrc(p, n); - return n; -} + *crcp = calccrc(*crcp, p, n); +#ifdef NEED_INCREMENTAL_INDICATOR + put_indicator(n); +#endif + if (verify_mode) + return; -/* ------------------------------------------------------------------------ */ -void -fwrite_crc(p, n, fp) - unsigned char *p; - int n; - FILE *fp; -{ - calccrc(p, n); - if (verify_mode) - return; - - if (fp) { - if (text_mode) { - if (fwrite_txt(p, n, fp)) - fatal_error("File write error\n"); - } - else { - if (fwrite(p, 1, n, fp) < n) - fatal_error("File write error\n"); - } - } + if (fp) { + if (text_mode) { + if (fwrite_txt(p, n, fp)) + fatal_error("File write error"); + } + else { + if (fwrite(p, 1, n, fp) < n) + fatal_error("File write error"); + } + } } /* ------------------------------------------------------------------------ */ void init_code_cache( /* void */ ) -{ /* called from copyfile() in util.c */ -#ifdef EUC - putc_euc_cache = EOF; -#endif - getc_euc_cache = EOF; -} - -void -init_getbits( /* void */ ) -{ - bitbuf = 0; - subbitbuf = 0; - bitcount = 0; - fillbuf(2 * CHAR_BIT); +{ /* called from copyfile() in util.c */ #ifdef EUC - putc_euc_cache = EOF; + putc_euc_cache = EOF; #endif -} - -/* ------------------------------------------------------------------------ */ -void -init_putbits( /* void */ ) -{ - bitcount = CHAR_BIT; - subbitbuf = 0; - getc_euc_cache = EOF; + getc_euc_cache = EOF; } /* ------------------------------------------------------------------------ */ #ifdef EUC -void +int putc_euc(c, fd) - int c; - FILE *fd; + int c; + FILE *fd; { - int d; + int d; - if (putc_euc_cache == EOF) { - if (!euc_mode || c < 0x81 || c > 0xFC) { - putc(c, fd); - return; - } - if (c >= 0xA0 && c < 0xE0) { - putc(0x8E, fd); /* single shift */ - putc(c, fd); - return; - } - putc_euc_cache = c; /* save first byte */ - return; - } - d = putc_euc_cache; - putc_euc_cache = EOF; - if (d >= 0xA0) - d -= 0xE0 - 0xA0; - if (c > 0x9E) { - c = c - 0x9F + 0x21; - d = (d - 0x81) * 2 + 0x22; - } - else { - if (c > 0x7E) - c--; - c -= 0x1F; - d = (d - 0x81) * 2 + 0x21; - } - putc(0x80 | d, fd); - putc(0x80 | c, fd); + if (putc_euc_cache == EOF) { + if (!euc_mode || c < 0x81 || c > 0xFC) { + return putc(c, fd); + } + if (c >= 0xA0 && c < 0xE0) { + if (putc(0x8E, fd) == EOF) return EOF; /* single shift */ + return putc(c, fd); + } + putc_euc_cache = c; /* save first byte */ + return c; + } + d = putc_euc_cache; + putc_euc_cache = EOF; + if (d >= 0xA0) + d -= 0xE0 - 0xA0; + if (c > 0x9E) { + c = c - 0x9F + 0x21; + d = (d - 0x81) * 2 + 0x22; + } + else { + if (c > 0x7E) + c--; + c -= 0x1F; + d = (d - 0x81) * 2 + 0x21; + } + if (putc(0x80 | d, fd) == EOF) return EOF; + return putc(0x80 | c, fd); } #endif /* ------------------------------------------------------------------------ */ int fwrite_txt(p, n, fp) - unsigned char *p; - int n; - FILE *fp; + unsigned char *p; + int n; + FILE *fp; { - while (--n >= 0) { - if (*p != '\015' && *p != '\032') { + while (--n >= 0) { + if (*p != '\015' && *p != '\032') { #ifdef EUC - putc_euc(*p, fp); + if (putc_euc(*p, fp) == EOF) + break; #else - putc(*p, fp); + if (putc(*p, fp) == EOF) + break; #endif - } - - prev_char = *p++; - } - return (ferror(fp)); + } + p++; + } + return (ferror(fp)); } /* ------------------------------------------------------------------------ */ int fread_txt(p, n, fp) - unsigned char *p; - int n; - FILE *fp; -{ - int c; - int cnt = 0; - - while (cnt < n) { - if (getc_euc_cache != EOF) { - c = getc_euc_cache; - getc_euc_cache = EOF; - } - else { - if ((c = fgetc(fp)) == EOF) - break; - if (c == '\n') { - getc_euc_cache = c; - ++origsize; - c = '\r'; - } -#ifdef EUC - else if (euc_mode && (c == 0x8E || 0xA0 < c && c < 0xFF)) { - int d = fgetc(fp); - if (d == EOF) { - *p++ = c; - cnt++; - break; - } - if (c == 0x8E) { /* single shift (KANA) */ - if ((0x20 < d && d < 0x7F) || (0xA0 < d && d < 0xFF)) - c = d | 0x80; - else - getc_euc_cache = d; - } - else { - if (0xA0 < d && d < 0xFF) { /* if GR */ - c &= 0x7F; /* convert to MS-kanji */ - d &= 0x7F; - if (!(c & 1)) { - c--; - d += 0x7F - 0x21; - } - if ((d += 0x40 - 0x21) > 0x7E) - d++; - if ((c = (c >> 1) + 0x71) >= 0xA0) - c += 0xE0 - 0xA0; - } - getc_euc_cache = d; - } - } -#endif - } - *p++ = c; - cnt++; - } - return cnt; -} - -/* ------------------------------------------------------------------------ */ -unsigned short -calc_header_crc(p, n) /* Thanks T.Okamoto */ - unsigned char *p; - unsigned int n; -{ - crc = 0; - while (n-- > 0) - UPDATE_CRC(*p++); - return crc; + unsigned char *p; + int n; + FILE *fp; +{ + int c; + int cnt = 0; + + while (cnt < n) { + if (getc_euc_cache != EOF) { + c = getc_euc_cache; + getc_euc_cache = EOF; + } + else { + if ((c = fgetc(fp)) == EOF) + break; + if (c == '\n') { + getc_euc_cache = c; + ++origsize; + c = '\r'; + } +#ifdef EUC + else if (euc_mode && (c == 0x8E || (0xA0 < c && c < 0xFF))) { + int d = fgetc(fp); + if (d == EOF) { + *p++ = c; + cnt++; + break; + } + if (c == 0x8E) { /* single shift (KANA) */ + if ((0x20 < d && d < 0x7F) || (0xA0 < d && d < 0xFF)) + c = d | 0x80; + else + getc_euc_cache = d; + } + else { + if (0xA0 < d && d < 0xFF) { /* if GR */ + c &= 0x7F; /* convert to MS-kanji */ + d &= 0x7F; + if (!(c & 1)) { + c--; + d += 0x7F - 0x21; + } + if ((d += 0x40 - 0x21) > 0x7E) + d++; + if ((c = (c >> 1) + 0x71) >= 0xA0) + c += 0xE0 - 0xA0; + } + getc_euc_cache = d; + } + } +#endif + } + *p++ = c; + cnt++; + } + return cnt; } diff -Nru lha-1.14i/src/dhuf.c lha-1.14i-acc20050924p1/src/dhuf.c --- lha-1.14i/src/dhuf.c 2000-10-04 14:57:38.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/dhuf.c 2003-01-18 07:26:47.000000000 +0000 @@ -1,17 +1,17 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* dhuf.c -- Dynamic Hufffman routine */ -/* */ -/* Modified H.Yoshizaki */ -/* */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* LHa for UNIX */ +/* dhuf.c -- Dynamic Hufffman routine */ +/* */ +/* Modified H.Yoshizaki */ +/* */ +/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ /* ------------------------------------------------------------------------ */ #include "lha.h" /* ------------------------------------------------------------------------ */ static short child[TREESIZE], parent[TREESIZE], block[TREESIZE], edge[TREESIZE], stock[TREESIZE], - s_node[TREESIZE / 2]; /* Changed N.Watazaki */ -/* node[..] -> s_node[..] */ + s_node[TREESIZE / 2]; /* Changed N.Watazaki */ +/* node[..] -> s_node[..] */ static unsigned short freq[TREESIZE]; @@ -23,327 +23,330 @@ void start_c_dyn( /* void */ ) { - int i, j, f; + int i, j, f; - n1 = (n_max >= 256 + maxmatch - THRESHOLD + 1) ? 512 : n_max - 1; - for (i = 0; i < TREESIZE_C; i++) { - stock[i] = i; - block[i] = 0; - } - for (i = 0, j = n_max * 2 - 2; i < n_max; i++, j--) { - freq[j] = 1; - child[j] = ~i; - s_node[i] = j; - block[j] = 1; - } - avail = 2; - edge[1] = n_max - 1; - i = n_max * 2 - 2; - while (j >= 0) { - f = freq[j] = freq[i] + freq[i - 1]; - child[j] = i; - parent[i] = parent[i - 1] = j; - if (f == freq[j + 1]) { - edge[block[j] = block[j + 1]] = j; - } - else { - edge[block[j] = stock[avail++]] = j; - } - i -= 2; - j--; - } + n1 = (n_max >= 256 + maxmatch - THRESHOLD + 1) ? 512 : n_max - 1; + for (i = 0; i < TREESIZE_C; i++) { + stock[i] = i; + block[i] = 0; + } + for (i = 0, j = n_max * 2 - 2; i < n_max; i++, j--) { + freq[j] = 1; + child[j] = ~i; + s_node[i] = j; + block[j] = 1; + } + avail = 2; + edge[1] = n_max - 1; + i = n_max * 2 - 2; + while (j >= 0) { + f = freq[j] = freq[i] + freq[i - 1]; + child[j] = i; + parent[i] = parent[i - 1] = j; + if (f == freq[j + 1]) { + edge[block[j] = block[j + 1]] = j; + } + else { + edge[block[j] = stock[avail++]] = j; + } + i -= 2; + j--; + } } /* ------------------------------------------------------------------------ */ static void start_p_dyn( /* void */ ) { - freq[ROOT_P] = 1; - child[ROOT_P] = ~(N_CHAR); - s_node[N_CHAR] = ROOT_P; - edge[block[ROOT_P] = stock[avail++]] = ROOT_P; - most_p = ROOT_P; - total_p = 0; - nn = 1 << dicbit; - nextcount = 64; + freq[ROOT_P] = 1; + child[ROOT_P] = ~(N_CHAR); + s_node[N_CHAR] = ROOT_P; + edge[block[ROOT_P] = stock[avail++]] = ROOT_P; + most_p = ROOT_P; + total_p = 0; + nn = 1 << dicbit; + nextcount = 64; } /* ------------------------------------------------------------------------ */ +/* lh2 */ void decode_start_dyn( /* void */ ) { - n_max = 286; - maxmatch = MAXMATCH; - init_getbits(); - start_c_dyn(); - start_p_dyn(); + n_max = 286; + maxmatch = MAXMATCH; + init_getbits(); + init_code_cache(); + start_c_dyn(); + start_p_dyn(); } /* ------------------------------------------------------------------------ */ static void reconst(start, end) - int start; - int end; + int start; + int end; { - int i, j, k, l, b; - unsigned int f, g; + int i, j, k, l, b; + unsigned int f, g; - for (i = j = start; i < end; i++) { - if ((k = child[i]) < 0) { - freq[j] = (freq[i] + 1) / 2; - child[j] = k; - j++; - } - if (edge[b = block[i]] == i) { - stock[--avail] = b; - } - } - j--; - i = end - 1; - l = end - 2; - while (i >= start) { - while (i >= l) { - freq[i] = freq[j]; - child[i] = child[j]; - i--, j--; - } - f = freq[l] + freq[l + 1]; - for (k = start; f < freq[k]; k++); - while (j >= k) { - freq[i] = freq[j]; - child[i] = child[j]; - i--, j--; - } - freq[i] = f; - child[i] = l + 1; - i--; - l -= 2; - } - f = 0; - for (i = start; i < end; i++) { - if ((j = child[i]) < 0) - s_node[~j] = i; - else - parent[j] = parent[j - 1] = i; - if ((g = freq[i]) == f) { - block[i] = b; - } - else { - edge[b = block[i] = stock[avail++]] = i; - f = g; - } - } + for (i = j = start; i < end; i++) { + if ((k = child[i]) < 0) { + freq[j] = (freq[i] + 1) / 2; + child[j] = k; + j++; + } + if (edge[b = block[i]] == i) { + stock[--avail] = b; + } + } + j--; + i = end - 1; + l = end - 2; + while (i >= start) { + while (i >= l) { + freq[i] = freq[j]; + child[i] = child[j]; + i--, j--; + } + f = freq[l] + freq[l + 1]; + for (k = start; f < freq[k]; k++); + while (j >= k) { + freq[i] = freq[j]; + child[i] = child[j]; + i--, j--; + } + freq[i] = f; + child[i] = l + 1; + i--; + l -= 2; + } + f = 0; + for (i = start; i < end; i++) { + if ((j = child[i]) < 0) + s_node[~j] = i; + else + parent[j] = parent[j - 1] = i; + if ((g = freq[i]) == f) { + block[i] = b; + } + else { + edge[b = block[i] = stock[avail++]] = i; + f = g; + } + } } /* ------------------------------------------------------------------------ */ static int swap_inc(p) - int p; + int p; { - int b, q, r, s; + int b, q, r, s; - b = block[p]; - if ((q = edge[b]) != p) { /* swap for leader */ - r = child[p]; - s = child[q]; - child[p] = s; - child[q] = r; - if (r >= 0) - parent[r] = parent[r - 1] = q; - else - s_node[~r] = q; - if (s >= 0) - parent[s] = parent[s - 1] = p; - else - s_node[~s] = p; - p = q; - goto Adjust; - } - else if (b == block[p + 1]) { + b = block[p]; + if ((q = edge[b]) != p) { /* swap for leader */ + r = child[p]; + s = child[q]; + child[p] = s; + child[q] = r; + if (r >= 0) + parent[r] = parent[r - 1] = q; + else + s_node[~r] = q; + if (s >= 0) + parent[s] = parent[s - 1] = p; + else + s_node[~s] = p; + p = q; + goto Adjust; + } + else if (b == block[p + 1]) { Adjust: - edge[b]++; - if (++freq[p] == freq[p - 1]) { - block[p] = block[p - 1]; - } - else { - edge[block[p] = stock[avail++]] = p; /* create block */ - } - } - else if (++freq[p] == freq[p - 1]) { - stock[--avail] = b; /* delete block */ - block[p] = block[p - 1]; - } - return parent[p]; + edge[b]++; + if (++freq[p] == freq[p - 1]) { + block[p] = block[p - 1]; + } + else { + edge[block[p] = stock[avail++]] = p; /* create block */ + } + } + else if (++freq[p] == freq[p - 1]) { + stock[--avail] = b; /* delete block */ + block[p] = block[p - 1]; + } + return parent[p]; } /* ------------------------------------------------------------------------ */ static void update_c(p) - int p; + int p; { - int q; + int q; - if (freq[ROOT_C] == 0x8000) { - reconst(0, n_max * 2 - 1); - } - freq[ROOT_C]++; - q = s_node[p]; - do { - q = swap_inc(q); - } while (q != ROOT_C); + if (freq[ROOT_C] == 0x8000) { + reconst(0, n_max * 2 - 1); + } + freq[ROOT_C]++; + q = s_node[p]; + do { + q = swap_inc(q); + } while (q != ROOT_C); } /* ------------------------------------------------------------------------ */ static void update_p(p) - int p; + int p; { - int q; + int q; - if (total_p == 0x8000) { - reconst(ROOT_P, most_p + 1); - total_p = freq[ROOT_P]; - freq[ROOT_P] = 0xffff; - } - q = s_node[p + N_CHAR]; - while (q != ROOT_P) { - q = swap_inc(q); - } - total_p++; + if (total_p == 0x8000) { + reconst(ROOT_P, most_p + 1); + total_p = freq[ROOT_P]; + freq[ROOT_P] = 0xffff; + } + q = s_node[p + N_CHAR]; + while (q != ROOT_P) { + q = swap_inc(q); + } + total_p++; } /* ------------------------------------------------------------------------ */ static void make_new_node(p) - int p; + int p; { - int q, r; + int q, r; - r = most_p + 1; - q = r + 1; - s_node[~(child[r] = child[most_p])] = r; - child[q] = ~(p + N_CHAR); - child[most_p] = q; - freq[r] = freq[most_p]; - freq[q] = 0; - block[r] = block[most_p]; - if (most_p == ROOT_P) { - freq[ROOT_P] = 0xffff; - edge[block[ROOT_P]]++; - } - parent[r] = parent[q] = most_p; - edge[block[q] = stock[avail++]] = s_node[p + N_CHAR] = most_p = q; - update_p(p); + r = most_p + 1; + q = r + 1; + s_node[~(child[r] = child[most_p])] = r; + child[q] = ~(p + N_CHAR); + child[most_p] = q; + freq[r] = freq[most_p]; + freq[q] = 0; + block[r] = block[most_p]; + if (most_p == ROOT_P) { + freq[ROOT_P] = 0xffff; + edge[block[ROOT_P]]++; + } + parent[r] = parent[q] = most_p; + edge[block[q] = stock[avail++]] = s_node[p + N_CHAR] = most_p = q; + update_p(p); } /* ------------------------------------------------------------------------ */ static void encode_c_dyn(c) - unsigned int c; + unsigned int c; { - unsigned int bits; - int p, d, cnt; + unsigned int bits; + int p, d, cnt; - d = c - n1; - if (d >= 0) { - c = n1; - } - cnt = bits = 0; - p = s_node[c]; - do { - bits >>= 1; - if (p & 1) { - bits |= 0x8000; - } - if (++cnt == 16) { - putcode(16, bits); - cnt = bits = 0; - } - } while ((p = parent[p]) != ROOT_C); - putcode(cnt, bits); - if (d >= 0) - putbits(8, d); - update_c(c); + d = c - n1; + if (d >= 0) { + c = n1; + } + cnt = bits = 0; + p = s_node[c]; + do { + bits >>= 1; + if (p & 1) { + bits |= 0x80000000L; + } + cnt++; + } while ((p = parent[p]) != ROOT_C); + if (cnt <= 16) { + putcode(cnt, bits >> 16); + } else { + putcode(16, bits >> 16); + putbits(cnt - 16, bits); + } + if (d >= 0) + putbits(8, d); + update_c(c); } /* ------------------------------------------------------------------------ */ +/* lh1, 2 */ unsigned short decode_c_dyn( /* void */ ) { - int c; - short buf, cnt; + int c; + short buf, cnt; - c = child[ROOT_C]; - buf = bitbuf; - cnt = 0; - do { - c = child[c - (buf < 0)]; - buf <<= 1; - if (++cnt == 16) { - fillbuf(16); - buf = bitbuf; - cnt = 0; - } - } while (c > 0); - fillbuf(cnt); - c = ~c; - update_c(c); - if (c == n1) - c += getbits(8); - return c; + c = child[ROOT_C]; + buf = bitbuf; + cnt = 0; + do { + c = child[c - (buf < 0)]; + buf <<= 1; + if (++cnt == 16) { + fillbuf(16); + buf = bitbuf; + cnt = 0; + } + } while (c > 0); + fillbuf(cnt); + c = ~c; + update_c(c); + if (c == n1) + c += getbits(8); + return c; } /* ------------------------------------------------------------------------ */ +/* lh2 */ unsigned short decode_p_dyn( /* void */ ) { - int c; - short buf, cnt; + int c; + short buf, cnt; - while (count > nextcount) { - make_new_node(nextcount / 64); - if ((nextcount += 64) >= nn) - nextcount = 0xffffffff; - } - c = child[ROOT_P]; - buf = bitbuf; - cnt = 0; - while (c > 0) { - c = child[c - (buf < 0)]; - buf <<= 1; - if (++cnt == 16) { - fillbuf(16); - buf = bitbuf; - cnt = 0; - } - } - fillbuf(cnt); - c = (~c) - N_CHAR; - update_p(c); + while (decode_count > nextcount) { + make_new_node(nextcount / 64); + if ((nextcount += 64) >= nn) + nextcount = 0xffffffff; + } + c = child[ROOT_P]; + buf = bitbuf; + cnt = 0; + while (c > 0) { + c = child[c - (buf < 0)]; + buf <<= 1; + if (++cnt == 16) { + fillbuf(16); + buf = bitbuf; + cnt = 0; + } + } + fillbuf(cnt); + c = (~c) - N_CHAR; + update_p(c); - return (c << 6) + getbits(6); + return (c << 6) + getbits(6); } /* ------------------------------------------------------------------------ */ +/* lh1 */ void output_dyn(code, pos) - unsigned int code; - unsigned int pos; + unsigned int code; + unsigned int pos; { - encode_c_dyn(code); - if (code >= 0x100) { - encode_p_st0(pos); - } + encode_c_dyn(code); + if (code >= 0x100) { + encode_p_st0(pos); + } } /* ------------------------------------------------------------------------ */ +/* lh1 */ void encode_end_dyn( /* void */ ) { - putcode(7, 0); + putcode(7, 0); } - -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* End: */ diff -Nru lha-1.14i/src/extract.c lha-1.14i-acc20050924p1/src/extract.c --- lha-1.14i/src/extract.c 2000-10-04 14:57:38.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/extract.c 2003-07-21 19:47:28.000000000 +0000 @@ -1,70 +1,91 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* extract.c -- extrcat from archive */ -/* */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* LHa for UNIX */ +/* extract.c -- extrcat from archive */ +/* */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ /* ------------------------------------------------------------------------ */ #include "lha.h" int -decode_lzhuf(infp, outfp, original_size, packed_size, name, method) - FILE *infp; - FILE *outfp; - long original_size; - long packed_size; - char *name; - int method; +decode_lzhuf(infp, outfp, original_size, packed_size, name, method, read_sizep) + FILE *infp; + FILE *outfp; + size_t original_size; + size_t packed_size; + char *name; + int method; + size_t *read_sizep; { - interface.method = method; - interface.dicbit = 13; /* method + 8; -lh5- */ - interface.infile = infp; - interface.outfile = outfp; - interface.original = original_size; - interface.packed = packed_size; - - switch (method) { - case LZHUFF0_METHOD_NUM: - case LARC4_METHOD_NUM: - start_indicator(name, original_size - ,verify_mode ? "Testing " : "Melting ", 2048); - copyfile(infp, (verify_mode ? NULL : outfp), original_size, 2); - break; - case LARC_METHOD_NUM: /* -lzs- */ - interface.dicbit = 11; - start_indicator(name, original_size - ,verify_mode ? "Testing " : "Melting " - ,1 << interface.dicbit); - decode(&interface); - break; - case LZHUFF1_METHOD_NUM: /* -lh1- */ - case LZHUFF4_METHOD_NUM: /* -lh4- */ - case LARC5_METHOD_NUM: /* -lz5- */ - interface.dicbit = 12; - start_indicator(name, original_size - ,verify_mode ? "Testing " : "Melting " - ,1 << interface.dicbit); - decode(&interface); - break; - case LZHUFF6_METHOD_NUM: /* -lh6- */ /* Added N.Watazaki (^_^) */ -#ifdef SUPPORT_LH7 - case LZHUFF7_METHOD_NUM: /* -lh7- */ -#endif - interface.dicbit = (method - LZHUFF6_METHOD_NUM) + 15; - - default: - start_indicator(name, original_size - ,verify_mode ? "Testing " : "Melting " - ,1 << interface.dicbit); - decode(&interface); - } - finish_indicator(name, verify_mode ? "Tested " : "Melted "); + unsigned int crc; + struct interfacing interface; - return crc; -} + interface.method = method; + interface.infile = infp; + interface.outfile = outfp; + interface.original = original_size; + interface.packed = packed_size; + interface.read_size = 0; + + switch (method) { + case LZHUFF0_METHOD_NUM: /* -lh0- */ + interface.dicbit = LZHUFF0_DICBIT; + break; + case LZHUFF1_METHOD_NUM: /* -lh1- */ + interface.dicbit = LZHUFF1_DICBIT; + break; + case LZHUFF2_METHOD_NUM: /* -lh2- */ + interface.dicbit = LZHUFF2_DICBIT; + break; + case LZHUFF3_METHOD_NUM: /* -lh2- */ + interface.dicbit = LZHUFF3_DICBIT; + break; + case LZHUFF4_METHOD_NUM: /* -lh4- */ + interface.dicbit = LZHUFF4_DICBIT; + break; + case LZHUFF5_METHOD_NUM: /* -lh5- */ + interface.dicbit = LZHUFF5_DICBIT; + break; + case LZHUFF6_METHOD_NUM: /* -lh6- */ + interface.dicbit = LZHUFF6_DICBIT; + break; + case LZHUFF7_METHOD_NUM: /* -lh7- */ + interface.dicbit = LZHUFF7_DICBIT; + break; + case LARC_METHOD_NUM: /* -lzs- */ + interface.dicbit = LARC_DICBIT; + break; + case LARC5_METHOD_NUM: /* -lz5- */ + interface.dicbit = LARC5_DICBIT; + break; + case LARC4_METHOD_NUM: /* -lz4- */ + interface.dicbit = LARC4_DICBIT; + break; + default: + warning("unknown method %d", method); + interface.dicbit = LZHUFF5_DICBIT; /* for backward compatibility */ + break; + } + + if (interface.dicbit == 0) { /* LZHUFF0_DICBIT or LARC4_DICBIT */ + start_indicator(name, + original_size, + verify_mode ? "Testing " : "Melting ", + 2048); + *read_sizep = copyfile(infp, (verify_mode ? NULL : outfp), + original_size, 2, &crc); + } + else { + start_indicator(name, + original_size, + verify_mode ? "Testing " : "Melting ", + 1 << interface.dicbit); + crc = decode(&interface); + *read_sizep = interface.read_size; + } -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* End: */ + finish_indicator(name, verify_mode ? "Tested " : "Melted "); + + return crc; +} diff -Nru lha-1.14i/src/fnmatch.c lha-1.14i-acc20050924p1/src/fnmatch.c --- lha-1.14i/src/fnmatch.c 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/fnmatch.c 2003-02-04 17:12:39.000000000 +0000 @@ -0,0 +1,219 @@ +/* $OpenBSD: fnmatch.c,v 1.9 2002/02/19 19:39:36 millert Exp $ */ + +/* + * Copyright (c) 1989, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Guido van Rossum. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94"; +#else +static char rcsid[] = "$OpenBSD: fnmatch.c,v 1.9 2002/02/19 19:39:36 millert Exp $"; +#endif +#endif /* LIBC_SCCS and not lint */ + +/* + * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6. + * Compares a filename or pathname to a pattern. + */ + +#include +#include +#include +#include + +#define EOS '\0' + +#define RANGE_MATCH 1 +#define RANGE_NOMATCH 0 +#define RANGE_ERROR (-1) + +static int rangematch(const char *, char, int, char **); + +int +fnmatch(pattern, string, flags) + const char *pattern, *string; + int flags; +{ + const char *stringstart; + char *newp; + char c, test; + + for (stringstart = string;;) + switch (c = *pattern++) { + case EOS: + if ((flags & FNM_LEADING_DIR) && *string == '/') + return (0); + return (*string == EOS ? 0 : FNM_NOMATCH); + case '?': + if (*string == EOS) + return (FNM_NOMATCH); + if (*string == '/' && (flags & FNM_PATHNAME)) + return (FNM_NOMATCH); + if (*string == '.' && (flags & FNM_PERIOD) && + (string == stringstart || + ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) + return (FNM_NOMATCH); + ++string; + break; + case '*': + c = *pattern; + /* Collapse multiple stars. */ + while (c == '*') + c = *++pattern; + + if (*string == '.' && (flags & FNM_PERIOD) && + (string == stringstart || + ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) + return (FNM_NOMATCH); + + /* Optimize for pattern with * at end or before /. */ + if (c == EOS) { + if (flags & FNM_PATHNAME) + return ((flags & FNM_LEADING_DIR) || + strchr(string, '/') == NULL ? + 0 : FNM_NOMATCH); + else + return (0); + } else if (c == '/' && (flags & FNM_PATHNAME)) { + if ((string = strchr(string, '/')) == NULL) + return (FNM_NOMATCH); + break; + } + + /* General case, use recursion. */ + while ((test = *string) != EOS) { + if (!fnmatch(pattern, string, flags & ~FNM_PERIOD)) + return (0); + if (test == '/' && (flags & FNM_PATHNAME)) + break; + ++string; + } + return (FNM_NOMATCH); + case '[': + if (*string == EOS) + return (FNM_NOMATCH); + if (*string == '/' && (flags & FNM_PATHNAME)) + return (FNM_NOMATCH); + if (*string == '.' && (flags & FNM_PERIOD) && + (string == stringstart || + ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) + return (FNM_NOMATCH); + + switch (rangematch(pattern, *string, flags, &newp)) { + case RANGE_ERROR: + /* not a good range, treat as normal text */ + goto normal; + case RANGE_MATCH: + pattern = newp; + break; + case RANGE_NOMATCH: + return (FNM_NOMATCH); + } + ++string; + break; + case '\\': + if (!(flags & FNM_NOESCAPE)) { + if ((c = *pattern++) == EOS) { + c = '\\'; + --pattern; + } + } + /* FALLTHROUGH */ + default: + normal: + if (c != *string && !((flags & FNM_CASEFOLD) && + (tolower((unsigned char)c) == + tolower((unsigned char)*string)))) + return (FNM_NOMATCH); + ++string; + break; + } + /* NOTREACHED */ +} + +static int +rangematch(const char *pattern, char test, int flags, char **newp) +{ + int negate, ok; + char c, c2; + + /* + * A bracket expression starting with an unquoted circumflex + * character produces unspecified results (IEEE 1003.2-1992, + * 3.13.2). This implementation treats it like '!', for + * consistency with the regular expression syntax. + * J.T. Conklin (conklin@ngai.kaleida.com) + */ + if ((negate = (*pattern == '!' || *pattern == '^'))) + ++pattern; + + if (flags & FNM_CASEFOLD) + test = tolower((unsigned char)test); + + /* + * A right bracket shall lose its special meaning and represent + * itself in a bracket expression if it occurs first in the list. + * -- POSIX.2 2.8.3.2 + */ + ok = 0; + c = *pattern++; + do { + if (c == '\\' && !(flags & FNM_NOESCAPE)) + c = *pattern++; + if (c == EOS) + return (RANGE_ERROR); + if (c == '/' && (flags & FNM_PATHNAME)) + return (RANGE_NOMATCH); + if ((flags & FNM_CASEFOLD)) + c = tolower((unsigned char)c); + if (*pattern == '-' + && (c2 = *(pattern+1)) != EOS && c2 != ']') { + pattern += 2; + if (c2 == '\\' && !(flags & FNM_NOESCAPE)) + c2 = *pattern++; + if (c2 == EOS) + return (RANGE_ERROR); + if (flags & FNM_CASEFOLD) + c2 = tolower((unsigned char)c2); + if (c <= test && test <= c2) + ok = 1; + } else if (c == test) + ok = 1; + } while ((c = *pattern++) != ']'); + + *newp = (char *)pattern; + return (ok == negate ? RANGE_NOMATCH : RANGE_MATCH); +} diff -Nru lha-1.14i/src/fnmatch.h lha-1.14i-acc20050924p1/src/fnmatch.h --- lha-1.14i/src/fnmatch.h 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/fnmatch.h 2003-02-16 18:07:24.000000000 +0000 @@ -0,0 +1,56 @@ +/* $OpenBSD: fnmatch.h,v 1.6 2002/02/16 21:27:17 millert Exp $ */ +/* $NetBSD: fnmatch.h,v 1.5 1994/10/26 00:55:53 cgd Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _FNMATCH_H_ +#define _FNMATCH_H_ + +#define FNM_NOMATCH 1 /* Match failed. */ +#define FNM_NOSYS 2 /* Function not supported (unused). */ + +#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ +#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ +#define FNM_PERIOD 0x04 /* Period must be matched by period. */ + +#define FNM_LEADING_DIR 0x08 /* Ignore / after Imatch. */ +#define FNM_CASEFOLD 0x10 /* Case insensitive search. */ +#define FNM_IGNORECASE FNM_CASEFOLD +#define FNM_FILE_NAME FNM_PATHNAME + +int fnmatch(const char *, const char *, int); + +#endif /* !_FNMATCH_H_ */ diff -Nru lha-1.14i/src/getopt_long.c lha-1.14i-acc20050924p1/src/getopt_long.c --- lha-1.14i/src/getopt_long.c 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/getopt_long.c 2004-09-28 17:06:39.000000000 +0000 @@ -0,0 +1,2096 @@ +/* + This getopt_long() is compatible with GNU's, however, added original + extention (short 1 byte option). + + + Copyright (c) 2004 Koji Arai + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation files + (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + + + Compilation for Test: + + GNU: + cc -DUSE_GNU -DDEBUG getopt_long.c -o test_getopt_long_gnu + + not GNU: + cc -I. -DDEBUG getopt_long.c -o test_getopt_long + + ./test_getopt_long + ./test_getopt_long_gnu + + BUGS: + * not implemented any features for getopt() and getopt_long(). +*/ + +#include +#include +#include + +#if DEBUG +static int +puts_argv(char **argv) +{ + int i; + + for (i = 0; argv[i]; i++) { + if (i) printf(" "); + + printf("%s", argv[i]); + } + printf("\n"); + + return 0; +} +#endif + +#ifndef USE_GNU +#include +#include + +char *optarg; +int optind; + +int opterr; +int optopt; + +/* + return value 0: no option (include '-') + 1: short option like '-x' + 2: long option like '--xxx' and just '--' +*/ +static int +is_option(char *arg) +{ + if (arg[0] == '-') { + switch (arg[1]) { + case 0: /* just "-" */ + return 0; + case '-': /* long option (include just "--")*/ + return 2; + default: /* short option */ + return 1; + } + } + return 0; +} + +static int +insert_argv(char **argv, int src, int dest) +{ + int i; + char *tmp = argv[src]; + + if (src > dest) { + for (i = src; i > dest; i--) + argv[i] = argv[i-1]; + } + if (src < dest) { + for (i = src; i < dest; i++) + argv[i] = argv[i+1]; + } + + argv[dest] = tmp; + + return 0; +} + +static int +search_longopt(char *arg, struct option *longopts) +{ + int i, found = -1; + int len; + for (len = 0; arg[len] && arg[len] != '='; len++) + ; + + for (i = 0; longopts[i].name; i++) { + if (strncmp(arg, longopts[i].name, len) == 0) { + if (found != -1) + return -1; /* found some candidate */ + found = i; + } + } + return found; +} + +/* + * implemented my extention feature. + * optional 1 byte argument with [...] + * e.g.) shortopts = "a[0123]b" + * accepts "-a0 -a1b" (same as "-a0 -a1 -b") + */ +static int +has_argument_short(char *arg, const char *shortopts) +{ + int i; + int open_bracket = 0; + for (i = 0; shortopts[i]; i++) { + switch (shortopts[i]) { + case '[': + open_bracket++; + continue; + case ']': + if (open_bracket <= 0) { + fprintf(stderr, "getopt_long() -- unbalanced bracket in short options"); + return -1; + } + open_bracket--; + continue; + } + if (open_bracket) continue; + if (*arg != shortopts[i]) continue; + + switch (shortopts[i+1]) { + case ':': + if (shortopts[i+2] != ':') { + if (arg[1]) + return 1; /* following string is argument */ + else + return 2; /* next argv is argument */ + } + else { + /* '::' means optional argument (GNU extention) */ + if (arg[1]) + return 1; + else + return 0; /* no argument */ + } + case '[': + if (arg[1] == '\0') + return 0; /* no argument */ + /* my extention */ + for (i++; shortopts[i] && shortopts[i] != ']'; i++) { + if (arg[1] == shortopts[i]) + return 3; /* has 1 byte argument */ + } + if (!shortopts[i]) { + fprintf(stderr, "getopt_long() -- unbalanced bracket in short options"); + return -1; + } + break; + default: + return 0; /* no argument */ + } + } + /* Invalid option */ + return -1; +} + +static int +has_argument_long(char *arg, struct option *longopts) +{ + int i; + + i = search_longopt(arg, longopts); + if (i == -1) { + /* Invalid option */ + return -1; + } + else { + int len = strlen(arg); + char *p = strchr(arg, '='); + if (p) { + len = p - arg; + } + + switch (longopts[i].has_arg) { + case no_argument: + return 0; + case required_argument: + if (arg[len] == '=') + return 1; + else + return 2; + case optional_argument: + if (arg[len] == '=') + return 1; + else + return 0; + default: + assert(0); + } + } +} + +/* + -1: no option + 0: no argument + 1: has argument in this argv + 2: has argument in next argv + 3: has 1 byte argument in this argv +*/ +static int +has_argument(char *arg, + const char *shortopts, + struct option *longopts) +{ + int i, n; + + switch (is_option(arg)) { + case 0: /* no option */ + return -1; + case 1: + /* short option */ + n = -1; + for (i = 1; arg[i]; i++) { + n = has_argument_short(arg+i, shortopts); + if (n == 0 && arg[i+1]) continue; + if (n == 3 && arg[i+2]) { i++; continue; } + break; + } + return n; + case 2: + /* long option */ + return has_argument_long(arg+2, longopts); + break; + default: + assert(0); + } +} + +int +getopt_long(int argc, char **argv, + const char *shortopts, + struct option *longopts, + int *indexptr) +{ + char *opt; + int i; + static int shortoptind; + static int no_optind = 0; + + if (optind == 0) { /* skip first argument (command name) */ + optind++; + no_optind = 0; + shortoptind = 0; + } + + optarg = 0; + + if (no_optind && !shortoptind) { + while (!is_option(argv[no_optind])) + insert_argv(argv, no_optind, optind-1); + + if (has_argument(argv[no_optind], shortopts, longopts) == 2) + no_optind += 2; + else + no_optind++; + + if (argv[optind] && strcmp(argv[optind], "--") == 0) { + while (!is_option(argv[no_optind])) + insert_argv(argv, no_optind, optind); + optind = no_optind; + no_optind = 0; + } + } + + if (optind >= argc) + goto end_of_option; + + retry: + /* + puts_argv(&argv[optind]); + */ + opt = argv[optind]; + + if (shortoptind == 0 && is_option(opt) == 1) { + shortoptind++; + } + + if (shortoptind) { + /* short option */ + char *p = &opt[shortoptind]; + + if (*p == '\0') + assert(0); + + switch (has_argument_short(p, shortopts)) { + case 0: + /* no argument */ + optarg = 0; + + shortoptind++; + if (opt[shortoptind] == '\0') + optind++, shortoptind = 0; + return *p; + case 1: + /* following character is argument */ + optind++, shortoptind = 0; + optarg = &p[1]; + return *p; + case 2: + /* next argv is argument */ + optind++, shortoptind = 0; + optarg = argv[optind++]; + return *p; + case 3: + /* has 1 byte argument */ + optarg = &p[1]; + if (p[2] == 0) + optind++, shortoptind = 0; + else + shortoptind += 2; + return *p; + default: + /* Invalid option */ + if (opterr) + fprintf(stderr, + "%s: invalid option -- %c\n", + argv[0], + *p); + + optind++, shortoptind = 0; + optopt = *p; + return '?'; + } + } + else if (opt[0] == '-' && opt[1] == '-') { + /* long option */ + + if (opt[2] == '\0') { + /* end of command line switch */ + optind++; + return -1; + } + + opt += 2; + + i = search_longopt(opt, longopts); + if (i == -1) { + optind++; + optopt = 0; + return '?'; + } + else { + int len = strlen(opt); + char *p = strchr(opt, '='); + if (p) { + len = p - opt; + } + + switch (longopts[i].has_arg) { + case no_argument: + break; + case required_argument: + if (opt[len] == '=') + optarg = opt + len + 1; + else { + optind++; + optarg = argv[optind]; + if (optarg == 0) { + if (opterr) + fprintf(stderr, + "%s: option `--%s' requires an argument\n", + argv[0], + opt); + + optopt = 0; + return '?'; /* no argument */ + } + } + break; + case optional_argument: + if (opt[len] == '=') + optarg = opt + len + 1; + else { + optarg = 0; + } + break; + default: + break; + } + + *indexptr = i; + optind++; + if (longopts[i].flag) { + *longopts[i].flag = longopts[i].val; + return 0; + } + else { + return longopts[i].val; + } + } + + optind++; + optopt = 0; + return '?'; + } + + /* not option */ + if (no_optind == 0) + no_optind = optind; + + for (i = optind; argv[i]; i++) { + if (is_option(argv[i])) { + optind = i; + goto retry; + } + } + + end_of_option: + if (no_optind) { + optind = no_optind; + no_optind = 0; + } + + return -1; +} +#endif /* USE_GNU */ + +#if DEBUG + +#include +#include +#include + +#if USE_GNU +#include /* use GNU getopt_long() */ +#endif + +static int verbose_flag; +static int option_index; +int argc; +char *argv[50]; +char **p; +int c; +static struct option long_options[] = { + {"verbose", no_argument, &verbose_flag, 1}, + {"brief", no_argument, &verbose_flag, 0}, + {"add", required_argument, 0, 'a'}, + {"append", no_argument, 0, 0}, + {"delete", required_argument, 0, 0}, + {"create", optional_argument, 0, 0}, + {"change", optional_argument, 0, 0}, + {0, 0, 0, 0} +}; + +int +call_getopt_long(int argc, char **argv, + const char *shortopts, + struct option *longopts, + int *indexptr) +{ + int c; + c = getopt_long(argc, argv, shortopts, longopts, indexptr); + puts_argv(argv); + printf("ret=%d(%c) option_index=%d ", c, c, option_index); + printf("optind=%d optarg=[%s] opterr=%d optopt=%d(%c)\n", + optind, optarg, opterr, optopt, optopt); + if (c == 0) { + struct option *opt; + opt = &longopts[*indexptr]; + printf("long option: --%s has_arg=%d\n", opt->name, opt->has_arg); + if (opt->flag) + printf(" flag=[%8p] val=%d\n", opt->flag, *opt->flag); + } + + return c; +} + +void +test1() +{ + optind = 0; + argc = 0; + p = argv; + + argc++; *p++ = "command_name"; + argc++; *p++ = "-a"; + argc++; *p++ = "-bcd"; + argc++; *p++ = "-d"; + argc++; *p++ = "-e"; + argc++; *p++ = "-f"; + argc++; *p++ = "-g"; + *p = 0; + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + assert(c == 'a'); + assert(option_index == 0); + assert(optind == 2); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + assert(c == 'b'); + assert(option_index == 0); + assert(optind == 2); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + assert(c == 'c'); + assert(option_index == 0); + assert(optind == 3); + assert(optarg == &argv[2][3]); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + assert(c == 'd'); + assert(option_index == 0); + assert(optind == 5); + assert(optarg == argv[4]); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + assert(c == '?'); + assert(option_index == 0); + assert(optind == 6); + assert(optarg == 0); + assert(optopt == 'f'); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + assert(c == '?'); + assert(option_index == 0); + assert(optind == 7); + assert(optarg == 0); + assert(optopt == 'g'); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + assert(c == -1); + assert(option_index == 0); + assert(optind == 7); + assert(optarg == 0); + assert(optopt == 'g'); /* no changed */ +} + +void +test2() +{ + optind = 0; + argc = 0; + p = argv; + + argc++; *p++ = "command_name"; + argc++; *p++ = "--verbose"; + argc++; *p++ = "--brief"; + argc++; *p++ = "--add"; + argc++; *p++ = "add_argument"; + argc++; *p++ = "--add=add_argument"; + argc++; *p++ = "--append"; + argc++; *p++ = "--delete=del_argument"; + argc++; *p++ = "--create=cre_argument"; + argc++; *p++ = "--create"; + argc++; *p++ = "files..."; + *p = 0; + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + assert(c == 0); + assert(option_index == 0); + assert(optind == 2); + assert(optarg == 0); + assert(optopt == 'g'); /* no changed */ + assert(strcmp(long_options[option_index].name, "verbose") == 0); + assert(*long_options[option_index].flag == 1); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + assert(c == 0); + assert(option_index == 1); + assert(optind == 3); + assert(optarg == 0); + assert(optopt == 'g'); /* no changed */ + assert(strcmp(long_options[option_index].name, "brief") == 0); + assert(*long_options[option_index].flag == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + assert(c == 'a'); + assert(option_index == 2); + assert(optind == 5); + assert(optarg == argv[4]); + assert(optopt == 'g'); /* no changed */ + assert(strcmp(long_options[option_index].name, "add") == 0); + assert(long_options[option_index].flag == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + assert(c == 'a'); + assert(option_index == 2); + assert(optind == 6); + assert(optarg == argv[5]+6); + assert(optopt == 'g'); /* no changed */ + assert(strcmp(long_options[option_index].name, "add") == 0); + assert(long_options[option_index].flag == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + assert(c == 0); + assert(option_index == 3); + assert(optind == 7); + assert(optarg == 0); + assert(optopt == 'g'); /* no changed */ + assert(strcmp(long_options[option_index].name, "append") == 0); + assert(long_options[option_index].flag == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + assert(c == 0); + assert(option_index == 4); + assert(optind == 8); + assert(optarg == argv[7]+9); + assert(optopt == 'g'); /* no changed */ + assert(strcmp(long_options[option_index].name, "delete") == 0); + assert(long_options[option_index].flag == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + assert(c == 0); + assert(option_index == 5); + assert(optind == 9); + assert(optarg == argv[8]+9); + assert(optopt == 'g'); /* no changed */ + assert(strcmp(long_options[option_index].name, "create") == 0); + assert(long_options[option_index].flag == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + assert(c == 0); + assert(option_index == 5); + assert(optind == 10); + assert(optarg == 0); + assert(optopt == 'g'); /* no changed */ + assert(strcmp(long_options[option_index].name, "create") == 0); + assert(long_options[option_index].flag == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + assert(c == -1); + assert(option_index == 5); /* no changed */ + assert(optind == 10); + assert(optarg == 0); + assert(optopt == 'g'); /* no changed */ + assert(strcmp(argv[optind], "files...") == 0); + +} + +void +test3() +{ + optind = 0; + argc = 0; + p = argv; + + argc++; *p++ = "command_name"; + argc++; *p++ = "--delete"; /* required argument has no argument */ + *p = 0; + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + assert(c == '?'); + assert(option_index == 5); /* no changed */ + assert(optind == 2); /* changed */ + assert(optarg == 0); + assert(optopt == 0); /* changed */ + assert(argv[optind] == 0); + + /* */ + optind = 0; + argc = 0; + p = argv; + + argc++; *p++ = "command_name"; + argc++; *p++ = "--file"; /* not option */ + *p = 0; + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + assert(c == '?'); + assert(option_index == 5); /* no changed */ + assert(optind == 2); + assert(optarg == 0); + assert(optopt == 0); + assert(argv[optind] == 0); +} + +void +test4() +{ + optind = 0; + argc = 0; + p = argv; + + argc++; *p++ = "command_name"; + argc++; *p++ = "-a"; + argc++; *p++ = "a1"; + argc++; *p++ = "a2"; + argc++; *p++ = "-b"; + argc++; *p++ = "b"; + argc++; *p++ = "-efg"; /* some options in a argument */ + argc++; *p++ = "g"; + argc++; *p++ = "-c"; + argc++; *p++ = "c"; + argc++; *p++ = "d"; + *p = 0; + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:efg:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "a1") == 0); + assert(strcmp(*p++, "a2") == 0); + assert(strcmp(*p++, "-b") == 0); + assert(strcmp(*p++, "b") == 0); + assert(strcmp(*p++, "-efg") == 0); + assert(strcmp(*p++, "g") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "c") == 0); + assert(strcmp(*p++, "d") == 0); + assert(*p == 0); + + assert(c == 'a'); + assert(option_index == 5); /* no changed */ + assert(optind == 2); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:efg:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "a1") == 0); + assert(strcmp(*p++, "a2") == 0); + assert(strcmp(*p++, "-b") == 0); + assert(strcmp(*p++, "b") == 0); + assert(strcmp(*p++, "-efg") == 0); + assert(strcmp(*p++, "g") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "c") == 0); + assert(strcmp(*p++, "d") == 0); + assert(*p == 0); + + assert(c == 'b'); + assert(option_index == 5); /* no changed */ + assert(optind == 5); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:efg:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-b") == 0); + assert(strcmp(*p++, "a1") == 0); + assert(strcmp(*p++, "a2") == 0); + assert(strcmp(*p++, "b") == 0); + assert(strcmp(*p++, "-efg") == 0); + assert(strcmp(*p++, "g") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "c") == 0); + assert(strcmp(*p++, "d") == 0); + assert(*p == 0); + + assert(c == 'e'); + assert(option_index == 5); /* no changed */ + assert(optind == 6); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:efg:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-b") == 0); + assert(strcmp(*p++, "a1") == 0); + assert(strcmp(*p++, "a2") == 0); + assert(strcmp(*p++, "b") == 0); + assert(strcmp(*p++, "-efg") == 0); + assert(strcmp(*p++, "g") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "c") == 0); + assert(strcmp(*p++, "d") == 0); + assert(*p == 0); + + assert(c == 'f'); + assert(option_index == 5); /* no changed */ + assert(optind == 6); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:efg:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-b") == 0); + assert(strcmp(*p++, "a1") == 0); + assert(strcmp(*p++, "a2") == 0); + assert(strcmp(*p++, "b") == 0); + assert(strcmp(*p++, "-efg") == 0); + assert(strcmp(*p++, "g") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "c") == 0); + assert(strcmp(*p++, "d") == 0); + assert(*p == 0); + + assert(c == 'g'); + assert(option_index == 5); /* no changed */ + assert(optind == 8); + assert(optarg == argv[7]); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:efg:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-b") == 0); + assert(strcmp(*p++, "-efg") == 0); + assert(strcmp(*p++, "g") == 0); + assert(strcmp(*p++, "a1") == 0); + assert(strcmp(*p++, "a2") == 0); + assert(strcmp(*p++, "b") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "c") == 0); + assert(strcmp(*p++, "d") == 0); + assert(*p == 0); + + assert(c == 'c'); + assert(option_index == 5); /* no changed */ + assert(optind == 10); + assert(optarg == argv[9]); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:efg:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-b") == 0); + assert(strcmp(*p++, "-efg") == 0); + assert(strcmp(*p++, "g") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "c") == 0); + assert(strcmp(*p++, "a1") == 0); + assert(strcmp(*p++, "a2") == 0); + assert(strcmp(*p++, "b") == 0); + assert(strcmp(*p++, "d") == 0); + assert(*p == 0); + + assert(c == -1); + assert(option_index == 5); /* no changed */ + assert(optind == 7); + assert(optarg == 0); + assert(optopt == 0); + +} + +void +test5() +{ + optind = 0; + argc = 0; + p = argv; + + argc++; *p++ = "command_name"; + argc++; *p++ = "-a"; + argc++; *p++ = "-"; + argc++; *p++ = "-b"; + *p = 0; + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-") == 0); + assert(strcmp(*p++, "-b") == 0); + assert(*p == 0); + + assert(c == 'a'); + assert(option_index == 5); /* no changed */ + assert(optind == 2); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-") == 0); + assert(strcmp(*p++, "-b") == 0); + assert(*p == 0); + + assert(c == 'b'); + assert(option_index == 5); /* no changed */ + assert(optind == 4); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-b") == 0); + assert(strcmp(*p++, "-") == 0); + assert(*p == 0); + + assert(c == -1); + assert(option_index == 5); /* no changed */ + assert(optind == 3); + assert(optarg == 0); + assert(optopt == 0); +} + +void +test6() +{ + optind = 0; + argc = 0; + p = argv; + + argc++; *p++ = "command_name"; + argc++; *p++ = "-a"; + argc++; *p++ = "-"; + argc++; *p++ = "-"; + argc++; *p++ = "-b"; + *p = 0; + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-") == 0); + assert(strcmp(*p++, "-") == 0); + assert(strcmp(*p++, "-b") == 0); + assert(*p == 0); + + assert(c == 'a'); + assert(option_index == 5); /* no changed */ + assert(optind == 2); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-") == 0); + assert(strcmp(*p++, "-") == 0); + assert(strcmp(*p++, "-b") == 0); + assert(*p == 0); + + assert(c == 'b'); + assert(option_index == 5); /* no changed */ + assert(optind == 5); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-b") == 0); + assert(strcmp(*p++, "-") == 0); + assert(strcmp(*p++, "-") == 0); + assert(*p == 0); + + assert(c == -1); + assert(option_index == 5); /* no changed */ + assert(optind == 3); + assert(optarg == 0); + assert(optopt == 0); +} + +void +test7() +{ + optind = 0; + argc = 0; + p = argv; + + argc++; *p++ = "command_name"; + argc++; *p++ = "-a"; + argc++; *p++ = "-"; + argc++; *p++ = "-"; + argc++; *p++ = "-c"; + argc++; *p++ = "c"; + *p = 0; + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-") == 0); + assert(strcmp(*p++, "-") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "c") == 0); + assert(*p == 0); + + assert(c == 'a'); + assert(option_index == 5); /* no changed */ + assert(optind == 2); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-") == 0); + assert(strcmp(*p++, "-") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "c") == 0); + assert(*p == 0); + + assert(c == 'c'); + assert(option_index == 5); /* no changed */ + assert(optind == 6); + assert(optarg == argv[5]); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "c") == 0); + assert(strcmp(*p++, "-") == 0); + assert(strcmp(*p++, "-") == 0); + assert(*p == 0); + + assert(c == -1); + assert(option_index == 5); /* no changed */ + assert(optind == 4); + assert(optarg == 0); + assert(optopt == 0); +} + +void +test8() +{ + optind = 0; + argc = 0; + p = argv; + + argc++; *p++ = "command_name"; + argc++; *p++ = "-a"; + argc++; *p++ = "-c"; + argc++; *p++ = "c"; + argc++; *p++ = "--"; + argc++; *p++ = "-d"; + argc++; *p++ = "d"; + *p = 0; + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "c") == 0); + assert(strcmp(*p++, "--") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(*p == 0); + + assert(c == 'a'); + assert(option_index == 5); /* no changed */ + assert(optind == 2); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "c") == 0); + assert(strcmp(*p++, "--") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(*p == 0); + + assert(c == 'c'); + assert(option_index == 5); /* no changed */ + assert(optind == 4); + assert(optarg == argv[3]); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "c") == 0); + assert(strcmp(*p++, "--") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(*p == 0); + + assert(c == -1); + assert(option_index == 5); /* no changed */ + assert(optind == 5); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "c") == 0); + assert(strcmp(*p++, "--") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(*p == 0); + + assert(c == 'd'); + assert(option_index == 5); /* no changed */ + assert(optind == 7); + assert(optarg == argv[6]); + assert(optopt == 0); +} + +void +test9() +{ + optind = 0; + argc = 0; + p = argv; + + argc++; *p++ = "command_name"; + argc++; *p++ = "-a"; + argc++; *p++ = "-"; + argc++; *p++ = "-"; + argc++; *p++ = "-c"; + argc++; *p++ = "c"; + argc++; *p++ = "--"; + argc++; *p++ = "-d"; + argc++; *p++ = "d"; + *p = 0; + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-") == 0); + assert(strcmp(*p++, "-") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "c") == 0); + assert(strcmp(*p++, "--") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(*p == 0); + + assert(c == 'a'); + assert(option_index == 5); /* no changed */ + assert(optind == 2); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-") == 0); + assert(strcmp(*p++, "-") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "c") == 0); + assert(strcmp(*p++, "--") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(*p == 0); + + assert(c == 'c'); + assert(option_index == 5); /* no changed */ + assert(optind == 6); + assert(optarg == argv[5]); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "c") == 0); + assert(strcmp(*p++, "--") == 0); + assert(strcmp(*p++, "-") == 0); + assert(strcmp(*p++, "-") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(*p == 0); + + assert(c == -1); + assert(option_index == 5); /* no changed */ + assert(optind == 5); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "c") == 0); + assert(strcmp(*p++, "--") == 0); + assert(strcmp(*p++, "-") == 0); + assert(strcmp(*p++, "-") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(*p == 0); + + assert(c == 'd'); + assert(option_index == 5); /* no changed */ + assert(optind == 9); + assert(optarg == argv[8]); + assert(optopt == 0); +} + +void +test10() +{ + optind = 0; + argc = 0; + p = argv; + + argc++; *p++ = "command_name"; + argc++; *p++ = "-a"; + argc++; *p++ = "-cc"; + argc++; *p++ = "-d"; + argc++; *p++ = "d"; + argc++; *p++ = "-c"; /* no argument */ + argc++; *p++ = "-d"; /* at last */ + *p = 0; + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-cc") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(*p == 0); + + assert(c == 'a'); + assert(option_index == 5); /* no changed */ + assert(optind == 2); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-cc") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(*p == 0); + + assert(c == 'c'); + assert(option_index == 5); /* no changed */ + assert(optind == 3); + assert(optarg == argv[2]+2); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-cc") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(*p == 0); + + assert(c == 'd'); + assert(option_index == 5); /* no changed */ + assert(optind == 4); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-cc") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(*p == 0); + + assert(c == 'c'); + assert(option_index == 5); /* no changed */ + assert(optind == 6); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-cc") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(*p == 0); + + assert(c == 'd'); + assert(option_index == 5); /* no changed */ + assert(optind == 7); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-cc") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "-c") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(*p == 0); + + assert(c == -1); + assert(option_index == 5); /* no changed */ + assert(optind == 6); + assert(optarg == 0); + assert(optopt == 0); +} + +void +test11() +{ + optind = 0; + argc = 0; + p = argv; + + argc++; *p++ = "command_name"; + argc++; *p++ = "--verbose"; + argc++; *p++ = "--create=c"; + argc++; *p++ = "--change"; + argc++; *p++ = "d"; + argc++; *p++ = "--create"; /* no argument */ + argc++; *p++ = "--change"; /* at last */ + *p = 0; + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "--verbose") == 0); + assert(strcmp(*p++, "--create=c") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "--create") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(*p == 0); + + assert(c == 0); + assert(option_index == 0); + assert(optind == 2); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "--verbose") == 0); + assert(strcmp(*p++, "--create=c") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "--create") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(*p == 0); + + assert(c == 0); + assert(option_index == 5); + assert(optind == 3); + assert(optarg == argv[2]+9); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "--verbose") == 0); + assert(strcmp(*p++, "--create=c") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "--create") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(*p == 0); + + assert(c == 0); + assert(option_index == 6); + assert(optind == 4); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "--verbose") == 0); + assert(strcmp(*p++, "--create=c") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "--create") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(*p == 0); + + assert(c == 0); + assert(option_index == 5); + assert(optind == 6); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "--verbose") == 0); + assert(strcmp(*p++, "--create=c") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(strcmp(*p++, "--create") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(*p == 0); + + assert(c == 0); + assert(option_index == 6); + assert(optind == 7); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "--verbose") == 0); + assert(strcmp(*p++, "--create=c") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(strcmp(*p++, "--create") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(strcmp(*p++, "d") == 0); + assert(*p == 0); + + assert(c == -1); + assert(option_index == 6); + assert(optind == 6); + assert(optarg == 0); + assert(optopt == 0); +} + +void +test12() +{ + optind = 0; + argc = 0; + p = argv; + + argc++; *p++ = "command_name"; + argc++; *p++ = "--verbose"; + argc++; *p++ = "--create=c"; + argc++; *p++ = "files..."; + argc++; *p++ = "--delete"; /* required argument */ + argc++; *p++ = "d"; + argc++; *p++ = "--create"; /* no argument */ + argc++; *p++ = "--change"; /* at last */ + *p = 0; + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "--verbose") == 0); + assert(strcmp(*p++, "--create=c") == 0); + assert(strcmp(*p++, "files...") == 0); + assert(strcmp(*p++, "--delete") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "--create") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(*p == 0); + + assert(c == 0); + assert(option_index == 0); + assert(optind == 2); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "--verbose") == 0); + assert(strcmp(*p++, "--create=c") == 0); + assert(strcmp(*p++, "files...") == 0); + assert(strcmp(*p++, "--delete") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "--create") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(*p == 0); + + assert(c == 0); + assert(option_index == 5); + assert(optind == 3); + assert(optarg == argv[2]+9); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "--verbose") == 0); + assert(strcmp(*p++, "--create=c") == 0); + assert(strcmp(*p++, "files...") == 0); + assert(strcmp(*p++, "--delete") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "--create") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(*p == 0); + + assert(c == 0); + assert(option_index == 4); + assert(optind == 6); + assert(optarg == argv[5]); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "--verbose") == 0); + assert(strcmp(*p++, "--create=c") == 0); + assert(strcmp(*p++, "--delete") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "files...") == 0); + assert(strcmp(*p++, "--create") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(*p == 0); + + assert(c == 0); + assert(option_index == 5); + assert(optind == 7); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "--verbose") == 0); + assert(strcmp(*p++, "--create=c") == 0); + assert(strcmp(*p++, "--delete") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "--create") == 0); + assert(strcmp(*p++, "files...") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(*p == 0); + + assert(c == 0); + assert(option_index == 6); + assert(optind == 8); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "--verbose") == 0); + assert(strcmp(*p++, "--create=c") == 0); + assert(strcmp(*p++, "--delete") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "--create") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(strcmp(*p++, "files...") == 0); + assert(*p == 0); + + assert(c == -1); + assert(option_index == 6); + assert(optind == 7); + assert(optarg == 0); + assert(optopt == 0); +} + +void +test13() +{ + optind = 0; + argc = 0; + p = argv; + + argc++; *p++ = "command_name"; + argc++; *p++ = "--verbose"; + argc++; *p++ = "--create=c"; + argc++; *p++ = "files..."; + argc++; *p++ = "--delete"; + argc++; *p++ = "d"; + argc++; *p++ = "--"; /* option terminator */ + argc++; *p++ = "--change"; + *p = 0; + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "--verbose") == 0); + assert(strcmp(*p++, "--create=c") == 0); + assert(strcmp(*p++, "files...") == 0); + assert(strcmp(*p++, "--delete") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "--") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(*p == 0); + + assert(c == 0); + assert(option_index == 0); + assert(optind == 2); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "--verbose") == 0); + assert(strcmp(*p++, "--create=c") == 0); + assert(strcmp(*p++, "files...") == 0); + assert(strcmp(*p++, "--delete") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "--") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(*p == 0); + + assert(c == 0); + assert(option_index == 5); + assert(optind == 3); + assert(optarg == argv[2]+9); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "--verbose") == 0); + assert(strcmp(*p++, "--create=c") == 0); + assert(strcmp(*p++, "files...") == 0); + assert(strcmp(*p++, "--delete") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "--") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(*p == 0); + + assert(c == 0); + assert(option_index == 4); + assert(optind == 6); + assert(optarg == argv[5]); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "--verbose") == 0); + assert(strcmp(*p++, "--create=c") == 0); + assert(strcmp(*p++, "--delete") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "--") == 0); + assert(strcmp(*p++, "files...") == 0); + assert(strcmp(*p++, "--change") == 0); + assert(*p == 0); + + assert(c == -1); + assert(option_index == 4); + assert(optind == 6); + assert(optarg == 0); + assert(optopt == 0); + +} + +void +test14() +{ + optind = 0; + argc = 0; + p = argv; + + argc++; *p++ = "command_name"; + argc++; *p++ = "-o5"; + argc++; *p++ = "files..."; + *p = 0; + + /*************************/ + c = call_getopt_long(argc, argv, "o[567]", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-o5") == 0); + assert(strcmp(*p++, "files...") == 0); + assert(*p == 0); + + assert(c == 'o'); + assert(option_index == 4); /* no changed */ + assert(optind == 2); + assert(optarg == argv[1]+2); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc[cde]d[fgh]", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-o5") == 0); + assert(strcmp(*p++, "files...") == 0); + assert(*p == 0); + + assert(c == -1); + assert(option_index == 4); /* no changed */ + assert(optind == 2); + assert(optarg == 0); + assert(optopt == 0); + +} + +void +test15() +{ + optind = 0; + argc = 0; + p = argv; + + argc++; *p++ = "command_name"; + argc++; *p++ = "-a"; + argc++; *p++ = "-ccd"; + argc++; *p++ = "-ce"; + argc++; *p++ = "-d"; + argc++; *p++ = "d"; + argc++; *p++ = "-cdd"; + argc++; *p++ = "-d"; + *p = 0; + + /*************************/ + c = call_getopt_long(argc, argv, "abc[cde]d[fgh]", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-ccd") == 0); + assert(strcmp(*p++, "-ce") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "-cdd") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(*p == 0); + + assert(c == 'a'); + assert(option_index == 4); /* no changed */ + assert(optind == 2); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc[cde]d[fgh]", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-ccd") == 0); + assert(strcmp(*p++, "-ce") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "-cdd") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(*p == 0); + + assert(c == 'c'); + assert(option_index == 4); /* no changed */ + assert(optind == 2); + assert(optarg == argv[2]+2); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc[cde]d[fgh]", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-ccd") == 0); + assert(strcmp(*p++, "-ce") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "-cdd") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(*p == 0); + + assert(c == 'd'); + assert(option_index == 4); /* no changed */ + assert(optind == 3); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc[cde]d[fgh]", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-ccd") == 0); + assert(strcmp(*p++, "-ce") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "-cdd") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(*p == 0); + + assert(c == 'c'); + assert(option_index == 4); /* no changed */ + assert(optind == 4); + assert(optarg == argv[3]+2); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc[cde]d[fgh]", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-ccd") == 0); + assert(strcmp(*p++, "-ce") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "-cdd") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(*p == 0); + + assert(c == 'd'); + assert(option_index == 4); /* no changed */ + assert(optind == 5); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc[cde]d[fgh]", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-ccd") == 0); + assert(strcmp(*p++, "-ce") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "-cdd") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(*p == 0); + + assert(c == 'c'); + assert(option_index == 4); /* no changed */ + assert(optind == 6); + assert(optarg == argv[6]+2); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc[cde]d[fgh]", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-ccd") == 0); + assert(strcmp(*p++, "-ce") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "-cdd") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(*p == 0); + + assert(c == 'd'); + assert(option_index == 4); /* no changed */ + assert(optind == 7); + assert(optarg == 0); + assert(optopt == 0); + + /*************************/ + c = call_getopt_long(argc, argv, "abc[cde]d[fgh]", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-ccd") == 0); + assert(strcmp(*p++, "-ce") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "-cdd") == 0); + assert(strcmp(*p++, "d") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(*p == 0); + + assert(c == 'd'); + assert(option_index == 4); /* no changed */ + assert(optind == 8); + assert(optarg == 0); + assert(optopt == 0); + + + /*************************/ + c = call_getopt_long(argc, argv, "abc[cde]d[fgh]", long_options, &option_index); + + p = argv; + assert(strcmp(*p++, "command_name") == 0); + assert(strcmp(*p++, "-a") == 0); + assert(strcmp(*p++, "-ccd") == 0); + assert(strcmp(*p++, "-ce") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "-cdd") == 0); + assert(strcmp(*p++, "-d") == 0); + assert(strcmp(*p++, "d") == 0); + assert(*p == 0); + + assert(c == -1); + assert(option_index == 4); /* no changed */ + assert(optind == 7); + assert(optarg == 0); + assert(optopt == 0); + + +} + +int +main() +{ + opterr = 0; + optopt = 0; + + test1(); + test2(); + test3(); + test4(); + test5(); + test6(); + test7(); + test8(); + test9(); + test10(); + test11(); + test12(); + test13(); +#ifndef USE_GNU + test14(); + test15(); +#endif + + return 0; +} +#endif diff -Nru lha-1.14i/src/getopt_long.h lha-1.14i-acc20050924p1/src/getopt_long.h --- lha-1.14i/src/getopt_long.h 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/getopt_long.h 2004-09-28 17:06:39.000000000 +0000 @@ -0,0 +1,48 @@ +/* + This getopt_long() is compatible with GNU's, however, added original + extention (short 1 byte option). + + + Copyright (c) 2004 Koji Arai + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation files + (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +struct option { + const char *name; + int has_arg; + + /* values of has_arg */ +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + + int *flag; + int val; +}; + +extern char *optarg; +extern int optind; + +int getopt_long(int argc, char **argv, + const char *shortopts, + struct option *longopts, + int *indexptr); diff -Nru lha-1.14i/src/header.c lha-1.14i-acc20050924p1/src/header.c --- lha-1.14i/src/header.c 2000-10-05 17:36:03.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/header.c 2006-10-10 16:27:51.000000000 +0000 @@ -1,875 +1,1957 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* header.c -- header manipulate functions */ -/* */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Original Y.Tagawa */ -/* modified 1991.12.16 M.Oki */ -/* Ver. 1.10 Symbolic Link added 1993.10.01 N.Watazaki */ -/* 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 */ +/* LHa for UNIX */ +/* header.c -- header manipulate functions */ +/* */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Original Y.Tagawa */ +/* modified 1991.12.16 M.Oki */ +/* Ver. 1.10 Symbolic Link added 1993.10.01 N.Watazaki */ +/* 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" -/* ------------------------------------------------------------------------ */ +#define DUMP_HEADER 1 /* for debugging */ + +#if !STRCHR_8BIT_CLEAN +/* should use 8 bit clean version */ +#undef strchr +#undef strrchr +#define strchr xstrchr +#define strrchr xstrrchr +#endif + static char *get_ptr; -/* ------------------------------------------------------------------------ */ +#define GET_BYTE() (*get_ptr++ & 0xff) + +#if DUMP_HEADER +static char *start_ptr; +#define setup_get(PTR) (start_ptr = get_ptr = (PTR)) +#define get_byte() dump_get_byte() +#define skip_bytes(len) dump_skip_bytes(len) +#else +#define setup_get(PTR) (get_ptr = (PTR)) +#define get_byte() GET_BYTE() +#define skip_bytes(len) (get_ptr += (len)) +#endif +#define put_ptr get_ptr +#define setup_put(PTR) (put_ptr = (PTR)) +#define put_byte(c) (*put_ptr++ = (char)(c)) + +int optional_archive_kanji_code = NONE; +int optional_system_kanji_code = NONE; +char *optional_archive_delim = NULL; +char *optional_system_delim = NULL; +int optional_filename_case = NONE; + +#ifdef MULTIBYTE_FILENAME +int default_system_kanji_code = MULTIBYTE_FILENAME; +#else +int default_system_kanji_code = NONE; +#endif + int calc_sum(p, len) - register char *p; - register int len; + char *p; + int len; { - register int sum; + int sum = 0; - for (sum = 0; len; len--) - sum += *p++; + while (len--) sum += *p++; - return sum & 0xff; + return sum & 0xff; } -/* ------------------------------------------------------------------------ */ -static unsigned short +#if DUMP_HEADER +static int +dump_get_byte() +{ + int c; + + if (verbose_listing && verbose > 1) + printf("%02d %2d: ", get_ptr - start_ptr, 1); + c = GET_BYTE(); + if (verbose_listing && verbose > 1) { + if (isprint(c)) + printf("%d(0x%02x) '%c'\n", c, c, c); + else + printf("%d(0x%02x)\n", c, c); + } + return c; +} + +static void +dump_skip_bytes(len) + int len; +{ + if (len == 0) return; + if (verbose_listing && verbose > 1) { + printf("%02d %2d: ", get_ptr - start_ptr, len); + while (len--) + printf("0x%02x ", GET_BYTE()); + printf("... ignored\n"); + } + else + get_ptr += len; +} +#endif + +static int get_word() { - int b0, b1; + int b0, b1; + int w; - b0 = get_byte(); - b1 = get_byte(); - return (b1 << 8) + b0; +#if DUMP_HEADER + if (verbose_listing && verbose > 1) + printf("%02d %2d: ", get_ptr - start_ptr, 2); +#endif + b0 = GET_BYTE(); + b1 = GET_BYTE(); + w = (b1 << 8) + b0; +#if DUMP_HEADER + if (verbose_listing && verbose > 1) + printf("%d(0x%04x)\n", w, w); +#endif + return w; } -/* ------------------------------------------------------------------------ */ static void put_word(v) - unsigned int v; + unsigned int v; { - put_byte(v); - put_byte(v >> 8); + put_byte(v); + put_byte(v >> 8); } -/* ------------------------------------------------------------------------ */ static long get_longword() { - long b0, b1, b2, b3; + long b0, b1, b2, b3; + long l; - b0 = get_byte(); - b1 = get_byte(); - b2 = get_byte(); - b3 = get_byte(); - return (b3 << 24) + (b2 << 16) + (b1 << 8) + b0; +#if DUMP_HEADER + if (verbose_listing && verbose > 1) + printf("%02d %2d: ", get_ptr - start_ptr, 4); +#endif + b0 = GET_BYTE(); + b1 = GET_BYTE(); + b2 = GET_BYTE(); + b3 = GET_BYTE(); + l = (b3 << 24) + (b2 << 16) + (b1 << 8) + b0; +#if DUMP_HEADER + if (verbose_listing && verbose > 1) + printf("%ld(0x%08lx)\n", l, l); +#endif + return l; } -/* ------------------------------------------------------------------------ */ static void put_longword(v) - long v; + long v; { - put_byte(v); - put_byte(v >> 8); - put_byte(v >> 16); - put_byte(v >> 24); + put_byte(v); + put_byte(v >> 8); + put_byte(v >> 16); + put_byte(v >> 24); } -/* ------------------------------------------------------------------------ */ -static void -msdos_to_unix_filename(name, len) - register char *name; - register int len; -{ - register int i; - -#ifdef MULTIBYTE_CHAR - for (i = 0; i < len; i++) { - if (MULTIBYTE_FIRST_P(name[i]) && - MULTIBYTE_SECOND_P(name[i + 1])) - i++; - else if (name[i] == '\\') - name[i] = '/'; - else if (!noconvertcase && isupper(name[i])) - name[i] = tolower(name[i]); - } +static int +get_bytes(buf, len, size) + char *buf; + int len, size; +{ + int i; + +#if DUMP_HEADER + if (verbose_listing && verbose > 1) + printf("%02d %2d: \"", get_ptr - start_ptr, len); + + for (i = 0; i < len; i++) { + if (i < size) buf[i] = get_ptr[i]; + + if (verbose_listing && verbose > 1) { + if (isprint(buf[i])) + printf("%c", buf[i]); + else + printf("\\x%02x", (unsigned char)buf[i]); + } + } + + if (verbose_listing && verbose > 1) + printf("\"\n"); #else - for (i = 0; i < len; i++) { - if (name[i] == '\\') - name[i] = '/'; - else if (!noconvertcase && isupper(name[i])) - name[i] = tolower(name[i]); - } + for (i = 0; i < len && i < size; i++) + buf[i] = get_ptr[i]; #endif + + get_ptr += len; + return i; } -/* ------------------------------------------------------------------------ */ static void -generic_to_unix_filename(name, len) - register char *name; - register int len; -{ - register int i; - boolean lower_case_used = FALSE; - -#ifdef MULTIBYTE_CHAR - for (i = 0; i < len; i++) { - if (MULTIBYTE_FIRST_P(name[i]) && - MULTIBYTE_SECOND_P(name[i + 1])) - i++; - else if (islower(name[i])) { - lower_case_used = TRUE; - break; - } - } - for (i = 0; i < len; i++) { - if (MULTIBYTE_FIRST_P(name[i]) && - MULTIBYTE_SECOND_P(name[i + 1])) - i++; - else if (name[i] == '\\') - name[i] = '/'; - else if (!noconvertcase && !lower_case_used && isupper(name[i])) - name[i] = tolower(name[i]); - } +put_bytes(buf, len) + char *buf; + int len; +{ + int i; + for (i = 0; i < len; i++) + put_byte(buf[i]); +} + +/* added by Koji Arai */ +void +convert_filename(name, len, size, + from_code, to_code, + from_delim, to_delim, + case_to) + char *name; + int len; /* length of name */ + int size; /* size of name buffer */ + int from_code, to_code, case_to; + char *from_delim, *to_delim; + +{ + int i; +#ifdef MULTIBYTE_FILENAME + char tmp[FILENAME_LENGTH]; + int to_code_save = NONE; + + if (from_code == CODE_CAP) { + len = cap_to_sjis(tmp, name, sizeof(tmp)); + strncpy(name, tmp, size); + name[size-1] = 0; + len = strlen(name); + from_code = CODE_SJIS; + } + + if (to_code == CODE_CAP) { + to_code_save = CODE_CAP; + to_code = CODE_SJIS; + } + + if (from_code == CODE_SJIS && to_code == CODE_UTF8) { + for (i = 0; i < len; i++) + /* FIXME: provisionally fix for the Mac OS CoreFoundation */ + if ((unsigned char)name[i] == LHA_PATHSEP) name[i] = '/'; + sjis_to_utf8(tmp, name, sizeof(tmp)); + strncpy(name, tmp, size); + name[size-1] = 0; + len = strlen(name); + for (i = 0; i < len; i++) + if (name[i] == '/') name[i] = LHA_PATHSEP; + from_code = CODE_UTF8; + } + else if (from_code == CODE_UTF8 && to_code == CODE_SJIS) { + for (i = 0; i < len; i++) + /* FIXME: provisionally fix for the Mac OS CoreFoundation */ + if ((unsigned char)name[i] == LHA_PATHSEP) name[i] = '/'; + utf8_to_sjis(tmp, name, sizeof(tmp)); + strncpy(name, tmp, size); + name[size-1] = 0; + len = strlen(name); + for (i = 0; i < len; i++) + if (name[i] == '/') name[i] = LHA_PATHSEP; + from_code = CODE_SJIS; + } +#endif + + /* special case: if `name' has small lettter, not convert case. */ + if (from_code == CODE_SJIS && case_to == TO_LOWER) { + for (i = 0; i < len; i++) { +#ifdef MULTIBYTE_FILENAME + if (SJIS_FIRST_P(name[i]) && SJIS_SECOND_P(name[i+1])) + i++; + else +#endif + if (islower(name[i])) { + case_to = NONE; + break; + } + } + } + + for (i = 0; i < len; i ++) { +#ifdef MULTIBYTE_FILENAME + if (from_code == CODE_EUC && + (unsigned char)name[i] == 0x8e) { + if (to_code != CODE_SJIS) { + i++; + continue; + } + + /* X0201 KANA */ + memmove(name + i, name + i + 1, len - i); + len--; + continue; + } + if (from_code == CODE_SJIS && X0201_KANA_P(name[i])) { + if (to_code != CODE_EUC) { + continue; + } + + if (len == size - 1) /* check overflow */ + len--; + memmove(name+i+1, name+i, len-i); + name[i] = 0x8e; + i++; + len++; + continue; + } + if (from_code == CODE_EUC && (name[i] & 0x80) && (name[i+1] & 0x80)) { + int c1, c2; + if (to_code != CODE_SJIS) { + i++; + continue; + } + + c1 = (unsigned char)name[i]; + c2 = (unsigned char)name[i+1]; + euc2sjis(&c1, &c2); + name[i] = c1; + name[i+1] = c2; + i++; + continue; + } + if (from_code == CODE_SJIS && + SJIS_FIRST_P(name[i]) && + SJIS_SECOND_P(name[i+1])) { + int c1, c2; + + if (to_code != CODE_EUC) { + i++; + continue; + } + + c1 = (unsigned char)name[i]; + c2 = (unsigned char)name[i+1]; + sjis2euc(&c1, &c2); + name[i] = c1; + name[i+1] = c2; + i++; + continue; + } +#endif /* MULTIBYTE_FILENAME */ + { + char *ptr; + + /* transpose from_delim to to_delim */ + + if ((ptr = strchr(from_delim, name[i])) != NULL) { + name[i] = to_delim[ptr - from_delim]; + continue; + } + } + + if (case_to == TO_UPPER && islower(name[i])) { + name[i] = toupper(name[i]); + continue; + } + if (case_to == TO_LOWER && isupper(name[i])) { + name[i] = tolower(name[i]); + continue; + } + } + +#ifdef MULTIBYTE_FILENAME + if (to_code_save == CODE_CAP) { + len = sjis_to_cap(tmp, name, sizeof(tmp)); + strncpy(name, tmp, size); + name[size-1] = 0; + len = strlen(name); + } +#endif /* MULTIBYTE_FILENAME */ +} + +/* + * 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-1980 --->|<- month ->|<--- day ---->| + * + * 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 + * |<--- hour --->|<---- minute --->|<- second/2 ->| + * + */ + +static time_t +generic_to_unix_stamp(t) + long t; +{ + struct tm tm; + +#define subbits(n, off, len) (((n) >> (off)) & ((1 << (len))-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(&tm); #else - for (i = 0; i < len; i++) - if (islower(name[i])) { - lower_case_used = TRUE; - break; - } - for (i = 0; i < len; i++) { - if (name[i] == '\\') - name[i] = '/'; - else if (!noconvertcase && !lower_case_used && isupper(name[i])) - name[i] = tolower(name[i]); - } + return timelocal(&tm); #endif } -/* ------------------------------------------------------------------------ */ -static void -macos_to_unix_filename(name, len) - register char *name; - register int len; -{ - register int i; - - for (i = 0; i < len; i++) { - if (name[i] == ':') - name[i] = '/'; - else if (name[i] == '/') - name[i] = ':'; - } +static long +unix_to_generic_stamp(t) + time_t t; +{ + struct tm *tm = localtime(&t); + + tm->tm_year -= 80; + tm->tm_mon += 1; + + return ((long)(tm->tm_year << 25) + + (tm->tm_mon << 21) + + (tm->tm_mday << 16) + + (tm->tm_hour << 11) + + (tm->tm_min << 5) + + (tm->tm_sec / 2)); } -/* ------------------------------------------------------------------------ */ -static void -unix_to_generic_filename(name, len) - register char *name; - register int len; -{ - register int i; - - for (i = 0; i < len; i++) { - if (name[i] == '/') - name[i] = '\\'; - else if (islower(name[i])) - name[i] = toupper(name[i]); - } +static unsigned long +wintime_to_unix_stamp() +{ +#if HAVE_UINT64_T + uint64_t t; + uint64_t epoch = ((uint64_t)0x019db1de << 32) + 0xd53e8000; + /* 0x019db1ded53e8000ULL: 1970-01-01 00:00:00 (UTC) */ + + t = (unsigned long)get_longword(); + t |= (uint64_t)(unsigned long)get_longword() << 32; + t = (t - epoch) / 10000000; + return t; +#else + int i, borrow; + unsigned long t, q, x; + unsigned long wintime[8]; + unsigned long epoch[8] = {0x01,0x9d,0xb1,0xde, 0xd5,0x3e,0x80,0x00}; + /* 1970-01-01 00:00:00 (UTC) */ + /* wintime -= epoch */ + borrow = 0; + for (i = 7; i >= 0; i--) { + wintime[i] = (unsigned)get_byte() - epoch[i] - borrow; + borrow = (wintime[i] > 0xff) ? 1 : 0; + wintime[i] &= 0xff; + } + + /* q = wintime / 10000000 */ + t = q = 0; + x = 10000000; /* x: 24bit */ + for (i = 0; i < 8; i++) { + t = (t << 8) + wintime[i]; /* 24bit + 8bit. t must be 32bit variable */ + q <<= 8; /* q must be 32bit (time_t) */ + q += t / x; + t %= x; /* 24bit */ + } + return q; +#endif } -/* ------------------------------------------------------------------------ */ -/* */ -/* Generic stamp format: */ -/* */ -/* 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 */ -/* |<-------- year ------->|<- month ->|<-- day -->| */ -/* */ -/* 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 */ -/* |<--- hour --->|<---- minute --->|<- second*2 ->| */ -/* */ -/* ------------------------------------------------------------------------ */ +/* + * extended header + * + * size field name + * -------------------------------- + * base header: : + * 2 or 4 next-header size [*1] + * -------------------------------------- + * ext header: 1 ext-type ^ + * ? contents | [*1] next-header size + * 2 or 4 next-header size v + * -------------------------------------- + * + * on level 1, 2 header: + * size field is 2 bytes + * on level 3 header: + * size field is 4 bytes + */ + +static ssize_t +get_extended_header(fp, hdr, header_size, hcrc) + FILE *fp; + LzHeader *hdr; + size_t header_size; + unsigned int *hcrc; +{ + char data[LZHEADER_STORAGE]; + int name_length; + char dirname[FILENAME_LENGTH]; + int dir_length = 0; + int i; + ssize_t whole_size = header_size; + int ext_type; + int n = 1 + hdr->size_field_length; /* `ext-type' + `next-header size' */ + + if (hdr->header_level == 0) + return 0; + + name_length = strlen(hdr->name); + + while (header_size) { + setup_get(data); + if (sizeof(data) < header_size) { + error("header size (%ld) too large.", header_size); + exit(1); + } + + if (fread(data, header_size, 1, fp) == 0) { + error("Invalid header (LHa file ?)"); + return -1; + } + + ext_type = get_byte(); + switch (ext_type) { + case 0: + /* header crc (CRC-16) */ + hdr->header_crc = get_word(); + /* clear buffer for CRC calculation. */ + data[1] = data[2] = 0; + skip_bytes(header_size - n - 2); + break; + case 1: + /* filename */ + name_length = + get_bytes(hdr->name, header_size-n, sizeof(hdr->name)-1); + hdr->name[name_length] = 0; + break; + case 2: + /* directory */ + dir_length = get_bytes(dirname, header_size-n, sizeof(dirname)-1); + dirname[dir_length] = 0; + break; + case 0x40: + /* MS-DOS attribute */ + hdr->attribute = get_word(); + break; + case 0x41: + /* Windows time stamp (FILETIME structure) */ + /* it is time in 100 nano seconds since 1601-01-01 00:00:00 */ + + skip_bytes(8); /* create time is ignored */ + + /* set last modified time */ + if (hdr->header_level >= 2) + skip_bytes(8); /* time_t has been already set */ + else + hdr->unix_last_modified_stamp = wintime_to_unix_stamp(); + + skip_bytes(8); /* last access time is ignored */ + + break; + case 0x50: + /* UNIX permission */ + hdr->unix_mode = get_word(); + break; + case 0x51: + /* UNIX gid and uid */ + hdr->unix_gid = get_word(); + hdr->unix_uid = get_word(); + break; + case 0x52: + /* UNIX group name */ + i = get_bytes(hdr->group, header_size-n, sizeof(hdr->group)-1); + hdr->group[i] = '\0'; + break; + case 0x53: + /* UNIX user name */ + i = get_bytes(hdr->user, header_size-n, sizeof(hdr->user)-1); + hdr->user[i] = '\0'; + break; + case 0x54: + /* UNIX last modified time */ + hdr->unix_last_modified_stamp = (time_t) get_longword(); + break; + default: + /* other headers */ + /* 0x39: multi-disk header + 0x3f: uncompressed comment + 0x42: 64bit large file size + 0x48-0x4f(?): reserved for authenticity verification + 0x7d: encapsulation + 0x7e: extended attribute - platform information + 0x7f: extended attribute - permission, owner-id and timestamp + (level 3 on OS/2) + 0xc4: compressed comment (dict size: 4096) + 0xc5: compressed comment (dict size: 8192) + 0xc6: compressed comment (dict size: 16384) + 0xc7: compressed comment (dict size: 32768) + 0xc8: compressed comment (dict size: 65536) + 0xd0-0xdf(?): operating systemm specific information + 0xfc: encapsulation (another opinion) + 0xfe: extended attribute - platform information(another opinion) + 0xff: extended attribute - permission, owner-id and timestamp + (level 3 on UNLHA32) */ + if (verbose) + warning("unknown extended header 0x%02x", ext_type); + skip_bytes(header_size - n); + break; + } + + if (hcrc) + *hcrc = calccrc(*hcrc, data, header_size); + + if (hdr->size_field_length == 2) + whole_size += header_size = get_word(); + else + whole_size += header_size = get_longword(); + } + + /* concatenate dirname and filename */ + if (dir_length) { + if (name_length + dir_length >= sizeof(hdr->name)) { + warning("the length of pathname \"%s%s\" is too long.", + dirname, hdr->name); + name_length = sizeof(hdr->name) - dir_length - 1; + hdr->name[name_length] = 0; + } + strcat(dirname, hdr->name); /* ok */ + strcpy(hdr->name, dirname); /* ok */ + name_length += dir_length; + } + + return whole_size; +} + +#define I_HEADER_SIZE 0 /* level 0,1,2 */ +#define I_HEADER_CHECKSUM 1 /* level 0,1 */ +#define I_METHOD 2 /* level 0,1,2,3 */ +#define I_PACKED_SIZE 7 /* level 0,1,2,3 */ +#define I_ATTRIBUTE 19 /* level 0,1,2,3 */ +#define I_HEADER_LEVEL 20 /* level 0,1,2,3 */ + +#define COMMON_HEADER_SIZE 21 /* size of common part */ + +#define I_GENERIC_HEADER_SIZE 24 /* + name_length */ +#define I_LEVEL0_HEADER_SIZE 36 /* + name_length (unix extended) */ +#define I_LEVEL1_HEADER_SIZE 27 /* + name_length */ +#define I_LEVEL2_HEADER_SIZE 26 /* + padding */ +#define I_LEVEL3_HEADER_SIZE 32 /* - * NOTE : If you don't have `gettimeofday(2)', or your gettimeofday(2) - * returns bogus timezone information, try FTIME, MKTIME, TIMELOCAL or TZSET. + * level 0 header + * + * + * offset size field name + * ---------------------------------- + * 0 1 header size [*1] + * 1 1 header sum + * --------------------------------------- + * 2 5 method ID ^ + * 7 4 packed size [*2] | + * 11 4 original size | + * 15 2 time | + * 17 2 date | + * 19 1 attribute | [*1] header size (X+Y+22) + * 20 1 level (0x00 fixed) | + * 21 1 name length | + * 22 X pathname | + * X +22 2 file crc (CRC-16) | + * X +24 Y ext-header(old style) v + * ------------------------------------------------- + * X+Y+24 data ^ + * : | [*2] packed size + * : v + * ------------------------------------------------- + * + * ext-header(old style) + * 0 1 ext-type ('U') + * 1 1 minor version + * 2 4 UNIX time + * 6 2 mode + * 8 2 uid + * 10 2 gid + * + * attribute (MS-DOS) + * bit1 read only + * bit2 hidden + * bit3 system + * bit4 volume label + * bit5 directory + * bit6 archive bit (need to backup) + * */ +static int +get_header_level0(fp, hdr, data) + FILE *fp; + LzHeader *hdr; + char *data; +{ + size_t header_size; + ssize_t extend_size; + int checksum; + int name_length; + int i; + + hdr->size_field_length = 2; /* in bytes */ + hdr->header_size = header_size = get_byte(); + checksum = get_byte(); + + if (fread(data + COMMON_HEADER_SIZE, + header_size + 2 - COMMON_HEADER_SIZE, 1, fp) == 0) { + error("Invalid header (LHarc file ?)"); + return FALSE; /* finish */ + } + + if (calc_sum(data + I_METHOD, header_size) != checksum) { + error("Checksum error (LHarc file?)"); + return FALSE; + } + + get_bytes(hdr->method, 5, sizeof(hdr->method)); + hdr->packed_size = get_longword(); + hdr->original_size = get_longword(); + hdr->unix_last_modified_stamp = generic_to_unix_stamp(get_longword()); + hdr->attribute = get_byte(); /* MS-DOS attribute */ + hdr->header_level = get_byte(); + name_length = get_byte(); + i = get_bytes(hdr->name, name_length, sizeof(hdr->name)-1); + hdr->name[i] = '\0'; + + /* defaults for other type */ + hdr->unix_mode = UNIX_FILE_REGULAR | UNIX_RW_RW_RW; + hdr->unix_gid = 0; + hdr->unix_uid = 0; + + extend_size = header_size+2 - name_length - 24; + + if (extend_size < 0) { + if (extend_size == -2) { + /* CRC field is not given */ + hdr->extend_type = EXTEND_GENERIC; + hdr->has_crc = FALSE; + + return TRUE; + } + + error("Unkonwn header (lha file?)"); + exit(1); + } + + hdr->has_crc = TRUE; + hdr->crc = get_word(); + + if (extend_size == 0) + return TRUE; + + hdr->extend_type = get_byte(); + extend_size--; + + if (hdr->extend_type == EXTEND_UNIX) { + if (extend_size >= 11) { + hdr->minor_version = get_byte(); + hdr->unix_last_modified_stamp = (time_t) get_longword(); + hdr->unix_mode = get_word(); + hdr->unix_uid = get_word(); + hdr->unix_gid = get_word(); + extend_size -= 11; + } else { + hdr->extend_type = EXTEND_GENERIC; + } + } + if (extend_size > 0) + skip_bytes(extend_size); -/* choose one */ -#if defined(MKTIME) -#ifdef TIMELOCAL -#undef TIMELOCAL -#endif -#endif /* defined(MKTIME) */ + hdr->header_size += 2; + return TRUE; +} -#if defined(MKTIME) || defined(TIMELOCAL) -#ifdef TZSET -#undef TZSET -#endif -#endif /* defined(MKTIME) || defined(TIMELOCAL) */ +/* + * level 1 header + * + * + * offset size field name + * ----------------------------------- + * 0 1 header size [*1] + * 1 1 header sum + * ------------------------------------- + * 2 5 method ID ^ + * 7 4 skip size [*2] | + * 11 4 original size | + * 15 2 time | + * 17 2 date | + * 19 1 attribute (0x20 fixed) | [*1] header size (X+Y+25) + * 20 1 level (0x01 fixed) | + * 21 1 name length | + * 22 X filename | + * X+ 22 2 file crc (CRC-16) | + * X+ 24 1 OS ID | + * X +25 Y ??? | + * X+Y+25 2 next-header size v + * ------------------------------------------------- + * X+Y+27 Z ext-header ^ + * : | + * ----------------------------------- | [*2] skip size + * X+Y+Z+27 data | + * : v + * ------------------------------------------------- + * + */ +static int +get_header_level1(fp, hdr, data) + FILE *fp; + LzHeader *hdr; + char *data; +{ + size_t header_size; + ssize_t extend_size; + int checksum; + int name_length; + int i, dummy; + + hdr->size_field_length = 2; /* in bytes */ + hdr->header_size = header_size = get_byte(); + checksum = get_byte(); + + if (fread(data + COMMON_HEADER_SIZE, + header_size + 2 - COMMON_HEADER_SIZE, 1, fp) == 0) { + error("Invalid header (LHarc file ?)"); + return FALSE; /* finish */ + } + + if (calc_sum(data + I_METHOD, header_size) != checksum) { + error("Checksum error (LHarc file?)"); + return FALSE; + } + + get_bytes(hdr->method, 5, sizeof(hdr->method)); + hdr->packed_size = get_longword(); /* skip size */ + hdr->original_size = get_longword(); + hdr->unix_last_modified_stamp = generic_to_unix_stamp(get_longword()); + hdr->attribute = get_byte(); /* 0x20 fixed */ + hdr->header_level = get_byte(); + + name_length = get_byte(); + i = get_bytes(hdr->name, name_length, sizeof(hdr->name)-1); + hdr->name[i] = '\0'; + + /* defaults for other type */ + hdr->unix_mode = UNIX_FILE_REGULAR | UNIX_RW_RW_RW; + hdr->unix_gid = 0; + hdr->unix_uid = 0; + + hdr->has_crc = TRUE; + hdr->crc = get_word(); + hdr->extend_type = get_byte(); + + dummy = header_size+2 - name_length - I_LEVEL1_HEADER_SIZE; + if (dummy > 0) + skip_bytes(dummy); /* skip old style extend header */ + + extend_size = get_word(); + extend_size = get_extended_header(fp, hdr, extend_size, 0); + if (extend_size == -1) + return FALSE; + + /* On level 1 header, size fields should be adjusted. */ + /* the `packed_size' field contains the extended header size. */ + /* the `header_size' field does not. */ + hdr->packed_size -= extend_size; + hdr->header_size += extend_size + 2; -#if defined(MKTIME) || defined(TIMELOCAL) || defined(TZSET) -#ifdef FTIME -#undef FTIME -#endif -#endif + return TRUE; +} -#if defined(MKTIME) || defined(TIMELOCAL) || defined(TZSET) || defined(FTIME) -#ifdef GETTIMEOFDAY -#undef GETTIMEOFDAY -#endif -#else -#ifndef GETTIMEOFDAY -#define GETTIMEOFDAY /* use gettimeofday() */ -#endif -#endif +/* + * level 2 header + * + * + * offset size field name + * -------------------------------------------------- + * 0 2 total header size [*1] ^ + * ----------------------- | + * 2 5 method ID | + * 7 4 packed size [*2] | + * 11 4 original size | + * 15 4 time | + * 19 1 RESERVED (0x20 fixed) | [*1] total header size + * 20 1 level (0x02 fixed) | (X+26+(1)) + * 21 2 file crc (CRC-16) | + * 23 1 OS ID | + * 24 2 next-header size | + * ----------------------------------- | + * 26 X ext-header | + * : | + * ----------------------------------- | + * X +26 (1) padding v + * ------------------------------------------------- + * X +26+(1) data ^ + * : | [*2] packed size + * : v + * ------------------------------------------------- + * + */ +static int +get_header_level2(fp, hdr, data) + FILE *fp; + LzHeader *hdr; + char *data; +{ + size_t header_size; + ssize_t extend_size; + int padding; + unsigned int hcrc; + + hdr->size_field_length = 2; /* in bytes */ + hdr->header_size = header_size = get_word(); + + if (fread(data + COMMON_HEADER_SIZE, + I_LEVEL2_HEADER_SIZE - COMMON_HEADER_SIZE, 1, fp) == 0) { + error("Invalid header (LHarc file ?)"); + return FALSE; /* finish */ + } + + get_bytes(hdr->method, 5, sizeof(hdr->method)); + hdr->packed_size = get_longword(); + hdr->original_size = get_longword(); + hdr->unix_last_modified_stamp = get_longword(); + hdr->attribute = get_byte(); /* reserved */ + hdr->header_level = get_byte(); + + /* defaults for other type */ + hdr->unix_mode = UNIX_FILE_REGULAR | UNIX_RW_RW_RW; + hdr->unix_gid = 0; + hdr->unix_uid = 0; + + hdr->has_crc = TRUE; + hdr->crc = get_word(); + hdr->extend_type = get_byte(); + extend_size = get_word(); + + INITIALIZE_CRC(hcrc); + hcrc = calccrc(hcrc, data, get_ptr - data); + + extend_size = get_extended_header(fp, hdr, extend_size, &hcrc); + if (extend_size == -1) + return FALSE; + + padding = header_size - I_LEVEL2_HEADER_SIZE - extend_size; + while (padding--) /* padding should be 0 or 1 */ + hcrc = UPDATE_CRC(hcrc, fgetc(fp)); -#ifdef FTIME -#include -#endif + if (hdr->header_crc != hcrc) + error("header CRC error"); + + return TRUE; +} /* - * You may define as : #define TIMEZONE_HOOK \ extern long - * timezone ; \ extern void tzset(); + * level 3 header + * + * + * offset size field name + * -------------------------------------------------- + * 0 2 size field length (4 fixed) ^ + * 2 5 method ID | + * 7 4 packed size [*2] | + * 11 4 original size | + * 15 4 time | + * 19 1 RESERVED (0x20 fixed) | [*1] total header size + * 20 1 level (0x03 fixed) | (X+32) + * 21 2 file crc (CRC-16) | + * 23 1 OS ID | + * 24 4 total header size [*1] | + * 28 4 next-header size | + * ----------------------------------- | + * 32 X ext-header | + * : v + * ------------------------------------------------- + * X +32 data ^ + * : | [*2] packed size + * : v + * ------------------------------------------------- + * */ -#ifdef TIMEZONE_HOOK -TIMEZONE_HOOK -/* Which do you like better, `TIMEZONE_HOOK' or `TIMEZONE_HOOK;' ? */ +static int +get_header_level3(fp, hdr, data) + FILE *fp; + LzHeader *hdr; + char *data; +{ + size_t header_size; + ssize_t extend_size; + int padding; + unsigned int hcrc; + + hdr->size_field_length = get_word(); + + if (fread(data + COMMON_HEADER_SIZE, + I_LEVEL3_HEADER_SIZE - COMMON_HEADER_SIZE, 1, fp) == 0) { + error("Invalid header (LHarc file ?)"); + return FALSE; /* finish */ + } + + get_bytes(hdr->method, 5, sizeof(hdr->method)); + hdr->packed_size = get_longword(); + hdr->original_size = get_longword(); + hdr->unix_last_modified_stamp = get_longword(); + hdr->attribute = get_byte(); /* reserved */ + hdr->header_level = get_byte(); + + /* defaults for other type */ + hdr->unix_mode = UNIX_FILE_REGULAR | UNIX_RW_RW_RW; + hdr->unix_gid = 0; + hdr->unix_uid = 0; + + hdr->has_crc = TRUE; + hdr->crc = get_word(); + hdr->extend_type = get_byte(); + hdr->header_size = header_size = get_longword(); + extend_size = get_longword(); + + INITIALIZE_CRC(hcrc); + hcrc = calccrc(hcrc, data, get_ptr - data); + + extend_size = get_extended_header(fp, hdr, extend_size, &hcrc); + if (extend_size == -1) + return FALSE; + + padding = header_size - I_LEVEL3_HEADER_SIZE - extend_size; + while (padding--) /* padding should be 0 */ + hcrc = UPDATE_CRC(hcrc, fgetc(fp)); + + if (hdr->header_crc != hcrc) + error("header CRC error"); + + return TRUE; +} + +boolean +get_header(fp, hdr) + FILE *fp; + LzHeader *hdr; +{ + char data[LZHEADER_STORAGE]; + + int archive_kanji_code = CODE_SJIS; + int system_kanji_code = default_system_kanji_code; + char *archive_delim = "\377\\"; /* `\' is for level 0 header and + broken archive. */ + char *system_delim = "//"; + int filename_case = NONE; + int end_mark; + + memset(hdr, 0, sizeof(LzHeader)); + + setup_get(data); + + if ((end_mark = getc(fp)) == EOF || end_mark == 0) { + return FALSE; /* finish */ + } + data[0] = end_mark; + + if (fread(data + 1, COMMON_HEADER_SIZE - 1, 1, fp) == 0) { + error("Invalid header (LHarc file ?)"); + return FALSE; /* finish */ + } + + switch (data[I_HEADER_LEVEL]) { + case 0: + if (get_header_level0(fp, hdr, data) == FALSE) + return FALSE; + break; + case 1: + if (get_header_level1(fp, hdr, data) == FALSE) + return FALSE; + break; + case 2: + if (get_header_level2(fp, hdr, data) == FALSE) + return FALSE; + break; + case 3: + if (get_header_level3(fp, hdr, data) == FALSE) + return FALSE; + break; + default: + error("Unknown level header (level %d)", data[I_HEADER_LEVEL]); + return FALSE; + } + + /* filename conversion */ + switch (hdr->extend_type) { + case EXTEND_MSDOS: + filename_case = noconvertcase ? NONE : TO_LOWER; + break; + case EXTEND_HUMAN: + case EXTEND_OS68K: + case EXTEND_XOSK: + case EXTEND_UNIX: + case EXTEND_JAVA: + filename_case = NONE; + break; + + case EXTEND_MACOS: + archive_delim = "\377/:\\"; + /* `\' is for level 0 header and broken archive. */ + system_delim = "/://"; + filename_case = NONE; + break; + + default: + filename_case = noconvertcase ? NONE : TO_LOWER; + break; + } + + if (optional_archive_kanji_code) + archive_kanji_code = optional_archive_kanji_code; + if (optional_system_kanji_code) + system_kanji_code = optional_system_kanji_code; + if (optional_archive_delim) + archive_delim = optional_archive_delim; + if (optional_system_delim) + system_delim = optional_system_delim; + if (optional_filename_case) + filename_case = optional_filename_case; + + /* kanji code and delimiter conversion */ + convert_filename(hdr->name, strlen(hdr->name), sizeof(hdr->name), + archive_kanji_code, + system_kanji_code, + archive_delim, system_delim, filename_case); + + if ((hdr->unix_mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK) { + char *p; + /* split symbolic link */ + p = strchr(hdr->name, '|'); + if (p) { + /* hdr->name is symbolic link name */ + /* hdr->realname is real name */ + *p = 0; + strcpy(hdr->realname, p+1); /* ok */ + } + else + error("unknown symlink name \"%s\"", hdr->name); + } + + return TRUE; +} + +/* skip SFX header */ +int +seek_lha_header(fp) + FILE *fp; +{ + unsigned char buffer[64 * 1024]; /* max seek size */ + unsigned char *p; + int n; + + n = fread(buffer, 1, sizeof(buffer), fp); + + for (p = buffer; p < buffer + n; p++) { + if (! (p[I_METHOD]=='-' && p[I_METHOD+1]=='l' && p[I_METHOD+4]=='-')) + continue; + /* found "-l??-" keyword (as METHOD type string) */ + + /* level 0 or 1 header */ + if ((p[I_HEADER_LEVEL] == 0 || p[I_HEADER_LEVEL] == 1) + && p[I_HEADER_SIZE] > 20 + && p[I_HEADER_CHECKSUM] == calc_sum(p+2, p[I_HEADER_SIZE])) { + if (fseeko(fp, (p - buffer) - n, SEEK_CUR) == -1) + fatal_error("cannot seek header"); + return 0; + } + + /* level 2 header */ + if (p[I_HEADER_LEVEL] == 2 + && p[I_HEADER_SIZE] >= 24 + && p[I_ATTRIBUTE] == 0x20) { + if (fseeko(fp, (p - buffer) - n, SEEK_CUR) == -1) + fatal_error("cannot seek header"); + return 0; + } + } + + if (fseeko(fp, -n, SEEK_CUR) == -1) + fatal_error("cannot seek header"); + return -1; +} + + +/* remove leading `xxxx/..' */ +static char * +remove_leading_dots(char *path) +{ + char *first = path; + char *ptr = 0; + + if (strcmp(first, "..") == 0) { + warning("Removing leading `..' from member name."); + return first+1; /* change to "." */ + } + + if (strstr(first, "..") == 0) + return first; + + while (path && *path) { + + if (strcmp(path, "..") == 0) + ptr = path = path+2; + else if (strncmp(path, "../", 3) == 0) + ptr = path = path+3; + else + path = strchr(path, '/'); + + if (path && *path == '/') { + path++; + } + } + + if (ptr) { + warning("Removing leading `%.*s' from member name.", ptr-first, first); + return ptr; + } + + return first; +} + +void +init_header(name, v_stat, hdr) + char *name; + struct stat *v_stat; + LzHeader *hdr; +{ + int len; + + memset(hdr, 0, sizeof(LzHeader)); + + /* the `method' member is rewrote by the encoding function. + but need set for empty files */ + memcpy(hdr->method, LZHUFF0_METHOD, METHOD_TYPE_STORAGE); + + hdr->packed_size = 0; + hdr->original_size = v_stat->st_size; + hdr->attribute = GENERIC_ATTRIBUTE; + hdr->header_level = header_level; + len = str_safe_copy(hdr->name, + remove_leading_dots(name), + sizeof(hdr->name)); + hdr->crc = 0x0000; + hdr->extend_type = EXTEND_UNIX; + hdr->unix_last_modified_stamp = v_stat->st_mtime; + /* since 00:00:00 JAN.1.1970 */ +#ifdef NOT_COMPATIBLE_MODE + /* Please need your modification in this space. */ +#else + hdr->unix_mode = v_stat->st_mode; #endif -#if defined(TZSET) && defined(_MINIX) -extern long timezone; /* not defined in time.h */ + hdr->unix_uid = v_stat->st_uid; + hdr->unix_gid = v_stat->st_gid; + +#if INCLUDE_OWNER_NAME_IN_HEADER +#if HAVE_GETPWUID + { + struct passwd *ent = getpwuid(hdr->unix_uid); + + if (ent) { + strncpy(hdr->user, ent->pw_name, sizeof(hdr->user)); + if (hdr->user[sizeof(hdr->user)-1]) + hdr->user[sizeof(hdr->user)-1] = 0; + } + } +#endif +#if HAVE_GETGRGID + { + struct group *ent = getgrgid(hdr->unix_gid); + + if (ent) { + strncpy(hdr->group, ent->gr_name, sizeof(hdr->group)); + if (hdr->group[sizeof(hdr->group)-1]) + hdr->group[sizeof(hdr->group)-1] = 0; + } + } +#endif +#endif /* INCLUDE_OWNER_NAME_IN_HEADER */ + if (is_directory(v_stat)) { + memcpy(hdr->method, LZHDIRS_METHOD, METHOD_TYPE_STORAGE); + hdr->attribute = GENERIC_DIRECTORY_ATTRIBUTE; + hdr->original_size = 0; + if (len > 0 && hdr->name[len - 1] != '/') { + if (len < sizeof(hdr->name)-1) + strcpy(&hdr->name[len++], "/"); /* ok */ + else + warning("the length of dirname \"%s\" is too long.", + hdr->name); + } + } + +#ifdef S_IFLNK + if (is_symlink(v_stat)) { + memcpy(hdr->method, LZHDIRS_METHOD, METHOD_TYPE_STORAGE); + hdr->attribute = GENERIC_DIRECTORY_ATTRIBUTE; + hdr->original_size = 0; + readlink(name, hdr->realname, sizeof(hdr->realname)); + } #endif +} -/* ------------------------------------------------------------------------ */ -#if defined(FTIME) || defined(GETTIMEOFDAY) || defined(TZSET) -static long -gettz() -#ifdef TZSET +static void +write_unix_info(hdr) + LzHeader *hdr; { - tzset(); - return timezone; + /* UNIX specific informations */ + + put_word(5); /* size */ + put_byte(0x50); /* permission */ + put_word(hdr->unix_mode); + + put_word(7); /* size */ + put_byte(0x51); /* gid and uid */ + put_word(hdr->unix_gid); + put_word(hdr->unix_uid); + + if (hdr->group[0]) { + int len = strlen(hdr->group); + put_word(len + 3); /* size */ + put_byte(0x52); /* group name */ + put_bytes(hdr->group, len); + } + + if (hdr->user[0]) { + int len = strlen(hdr->user); + put_word(len + 3); /* size */ + put_byte(0x53); /* user name */ + put_bytes(hdr->user, len); + } + + if (hdr->header_level == 1) { + put_word(7); /* size */ + put_byte(0x54); /* time stamp */ + put_longword(hdr->unix_last_modified_stamp); + } } -#endif -/* ------------------------------------------------------------------------ */ -#if !defined(TZSET) && defined(FTIME) +static size_t +write_header_level0(data, hdr, pathname) + LzHeader *hdr; + char *data, *pathname; { - struct timeb buf; + int limit; + int name_length; + size_t header_size; + + setup_put(data); + memset(data, 0, LZHEADER_STORAGE); + + put_byte(0x00); /* header size */ + put_byte(0x00); /* check sum */ + put_bytes(hdr->method, 5); + put_longword(hdr->packed_size); + put_longword(hdr->original_size); + put_longword(unix_to_generic_stamp(hdr->unix_last_modified_stamp)); + put_byte(hdr->attribute); + put_byte(hdr->header_level); /* level 0 */ + + /* write pathname (level 0 header contains the directory part) */ + name_length = strlen(pathname); + if (generic_format) + limit = 255 - I_GENERIC_HEADER_SIZE + 2; + else + limit = 255 - I_LEVEL0_HEADER_SIZE + 2; + + if (name_length > limit) { + warning("the length of pathname \"%s\" is too long.", pathname); + name_length = limit; + } + put_byte(name_length); + put_bytes(pathname, name_length); + put_word(hdr->crc); + + if (generic_format) { + header_size = I_GENERIC_HEADER_SIZE + name_length - 2; + data[I_HEADER_SIZE] = header_size; + data[I_HEADER_CHECKSUM] = calc_sum(data + I_METHOD, header_size); + } else { + /* write old-style extend header */ + put_byte(EXTEND_UNIX); + put_byte(CURRENT_UNIX_MINOR_VERSION); + put_longword(hdr->unix_last_modified_stamp); + put_word(hdr->unix_mode); + put_word(hdr->unix_uid); + put_word(hdr->unix_gid); + + /* size of extended header is 12 */ + header_size = I_LEVEL0_HEADER_SIZE + name_length - 2; + data[I_HEADER_SIZE] = header_size; + data[I_HEADER_CHECKSUM] = calc_sum(data + I_METHOD, header_size); + } - ftime(&buf); - return buf.timezone * 60L; + return header_size + 2; } -#endif -/* ------------------------------------------------------------------------ */ -#if !defined(TZSET) && !defined(FTIME) /* maybe defined(GETTIMEOFDAY) */ +static size_t +write_header_level1(data, hdr, pathname) + LzHeader *hdr; + char *data, *pathname; { -#ifdef HAVE_TM_ZONE - time_t tt; + int name_length, dir_length, limit; + char *basename, *dirname; + size_t header_size; + char *extend_header_top; + size_t extend_header_size; + + basename = strrchr(pathname, LHA_PATHSEP); + if (basename) { + basename++; + name_length = strlen(basename); + dirname = pathname; + dir_length = basename - dirname; + } + else { + basename = pathname; + name_length = strlen(basename); + dirname = ""; + dir_length = 0; + } + + setup_put(data); + memset(data, 0, LZHEADER_STORAGE); + + put_byte(0x00); /* header size */ + put_byte(0x00); /* check sum */ + put_bytes(hdr->method, 5); + put_longword(hdr->packed_size); + put_longword(hdr->original_size); + put_longword(unix_to_generic_stamp(hdr->unix_last_modified_stamp)); + put_byte(0x20); + put_byte(hdr->header_level); /* level 1 */ + + /* level 1 header: write filename (basename only) */ + limit = 255 - I_LEVEL1_HEADER_SIZE + 2; + if (name_length > limit) { + put_byte(0); /* name length */ + } + else { + put_byte(name_length); + put_bytes(basename, name_length); + } + + put_word(hdr->crc); + + if (generic_format) + put_byte(0x00); + else + put_byte(EXTEND_UNIX); + + /* write extend header from here. */ + + extend_header_top = put_ptr+2; /* +2 for the field `next header size' */ + header_size = extend_header_top - data - 2; + + /* write filename and dirname */ + + if (name_length > limit) { + put_word(name_length + 3); /* size */ + put_byte(0x01); /* filename */ + put_bytes(basename, name_length); + } + + if (dir_length > 0) { + put_word(dir_length + 3); /* size */ + put_byte(0x02); /* dirname */ + put_bytes(dirname, dir_length); + } + + if (!generic_format) + write_unix_info(hdr); + + put_word(0x0000); /* next header size */ + + extend_header_size = put_ptr - extend_header_top; + /* On level 1 header, the packed size field is contains the ext-header */ + hdr->packed_size += put_ptr - extend_header_top; + + /* put `skip size' */ + setup_put(data + I_PACKED_SIZE); + put_longword(hdr->packed_size); + + data[I_HEADER_SIZE] = header_size; + data[I_HEADER_CHECKSUM] = calc_sum(data + I_METHOD, header_size); - time(&tt); - return -localtime(&tt)->tm_gmtoff; -#else /* HAVE_TM_ZONE */ - struct timeval tp; - struct timezone tzp; - gettimeofday(&tp, &tzp);/* specific to 4.3BSD */ - /* - * return (tzp.tz_minuteswest * 60L + (tzp.tz_dsttime != 0 ? 60L * - * 60L : 0)); - */ - return (tzp.tz_minuteswest * 60L); -#endif /* HAVE_TM_ZONE */ + return header_size + extend_header_size + 2; } -#endif -#endif /* defined(FTIME) || defined(GETTIMEOFDAY) || - * defined(TZSET) */ -/* ------------------------------------------------------------------------ */ -#ifdef NOT_USED -static struct tm * -msdos_to_unix_stamp_tm(a) - long a; -{ - static struct tm t; - - t.tm_sec = (a & 0x1f) * 2; - t.tm_min = (a >> 5) & 0x3f; - t.tm_hour = (a >> 11) & 0x1f; - t.tm_mday = (a >> 16) & 0x1f; - t.tm_mon = ((a >> 16 + 5) & 0x0f) - 1; - t.tm_year = ((a >> 16 + 9) & 0x7f) + 80; - return &t; +static size_t +write_header_level2(data, hdr, pathname) + LzHeader *hdr; + char *data, *pathname; +{ + int name_length, dir_length; + char *basename, *dirname; + size_t header_size; + char *extend_header_top; + char *headercrc_ptr; + unsigned int hcrc; + + basename = strrchr(pathname, LHA_PATHSEP); + if (basename) { + basename++; + name_length = strlen(basename); + dirname = pathname; + dir_length = basename - dirname; + } + else { + basename = pathname; + name_length = strlen(basename); + dirname = ""; + dir_length = 0; + } + + setup_put(data); + memset(data, 0, LZHEADER_STORAGE); + + put_word(0x0000); /* header size */ + put_bytes(hdr->method, 5); + put_longword(hdr->packed_size); + put_longword(hdr->original_size); + put_longword(hdr->unix_last_modified_stamp); + put_byte(0x20); + put_byte(hdr->header_level); /* level 2 */ + + put_word(hdr->crc); + + if (generic_format) + put_byte(0x00); + else + put_byte(EXTEND_UNIX); + + /* write extend header from here. */ + + extend_header_top = put_ptr+2; /* +2 for the field `next header size' */ + + /* write common header */ + put_word(5); + put_byte(0x00); + headercrc_ptr = put_ptr; + put_word(0x0000); /* header CRC */ + + /* write filename and dirname */ + /* must have this header, even if the name_length is 0. */ + put_word(name_length + 3); /* size */ + put_byte(0x01); /* filename */ + put_bytes(basename, name_length); + + if (dir_length > 0) { + put_word(dir_length + 3); /* size */ + put_byte(0x02); /* dirname */ + put_bytes(dirname, dir_length); + } + + if (!generic_format) + write_unix_info(hdr); + + put_word(0x0000); /* next header size */ + + header_size = put_ptr - data; + if ((header_size & 0xff) == 0) { + /* cannot put zero at the first byte on level 2 header. */ + /* adjust header size. */ + put_byte(0); /* padding */ + header_size++; + } + + /* put header size */ + setup_put(data + I_HEADER_SIZE); + put_word(header_size); + + /* put header CRC in extended header */ + INITIALIZE_CRC(hcrc); + hcrc = calccrc(hcrc, data, (unsigned int) header_size); + setup_put(headercrc_ptr); + put_word(hcrc); + + return header_size; } -#endif -/* ------------------------------------------------------------------------ */ -static time_t -generic_to_unix_stamp(t) - long t; -#if defined(MKTIME) || defined(TIMELOCAL) +void +write_header(fp, hdr) + FILE *fp; + LzHeader *hdr; { - struct tm dostm; + size_t header_size; + char data[LZHEADER_STORAGE]; - /* - * special case: if MSDOS format date and time were zero, then we - * set time to be zero here too. - */ - if (t == 0) - return (time_t) 0; - - 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; -#if 0 - dostm.tm_isdst = 0; /* correct? */ -#endif - dostm.tm_isdst = -1; /* correct? */ -#ifdef MKTIME - return (time_t) mktime(&dostm); -#else /* maybe defined(TIMELOCAL) */ - return (time_t) timelocal(&dostm); -#endif -} - -#else /* defined(MKTIME) || defined(TIMELOCAL) */ -{ - int year, month, day, hour, min, sec; - long longtime; - static unsigned int dsboy[12] = {0, 31, 59, 90, 120, 151, - 181, 212, 243, 273, 304, 334}; - unsigned int days; - - /* - * special case: if MSDOS format date and time were zero, then we - * set time to be zero here too. - */ - if (t == 0) - return (time_t) 0; - - year = ((int) (t >> 16 + 9) & 0x7f) + 1980; - month = (int) (t >> 16 + 5) & 0x0f; /* 1..12 means Jan..Dec */ - day = (int) (t >> 16) & 0x1f; /* 1..31 means 1st,...31st */ - - hour = ((int) t >> 11) & 0x1f; - min = ((int) t >> 5) & 0x3f; - sec = ((int) t & 0x1f) * 2; - - /* Calculate days since 1970.01.01 */ - days = (365 * (year - 1970) + /* days due to whole years */ - (year - 1970 + 1) / 4 + /* days due to leap years */ - dsboy[month - 1] + /* days since beginning of this year */ - day - 1); /* days since beginning of month */ - - if ((year % 4 == 0) && - (year % 100 != 0 || year % 400 == 0) && /* 1999.5.24 t.oka */ - (month >= 3)) /* if this is a leap year and month */ - days++; /* is March or later, add a day */ - - /* Knowing the days, we can find seconds */ - longtime = (((days * 24) + hour) * 60 + min) * 60 + sec; - longtime += gettz(); /* adjust for timezone */ + int archive_kanji_code = CODE_SJIS; + int system_kanji_code = default_system_kanji_code; + char *archive_delim = "\377"; + char *system_delim = "/"; + int filename_case = NONE; + char pathname[FILENAME_LENGTH]; + + if (optional_archive_kanji_code) + archive_kanji_code = optional_archive_kanji_code; + if (optional_system_kanji_code) + system_kanji_code = optional_system_kanji_code; + + if (generic_format) + filename_case = TO_UPPER; + + if (hdr->header_level == 0) { + archive_delim = "\\"; + } + + if ((hdr->unix_mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK) { + char *p; + p = strchr(hdr->name, '|'); + if (p) { + error("symlink name \"%s\" contains '|' char. change it into '_'", + hdr->name); + *p = '_'; + } + if (xsnprintf(pathname, sizeof(pathname), + "%s|%s", hdr->name, hdr->realname) == -1) + error("file name is too long (%s -> %s)", hdr->name, hdr->realname); + } + else { + strncpy(pathname, hdr->name, sizeof(pathname)); + pathname[sizeof(pathname)-1] = 0; + } + + convert_filename(pathname, strlen(pathname), sizeof(pathname), + system_kanji_code, + archive_kanji_code, + system_delim, archive_delim, filename_case); + + switch (hdr->header_level) { + case 0: + header_size = write_header_level0(data, hdr, pathname); + break; + case 1: + header_size = write_header_level1(data, hdr, pathname); + break; + case 2: + header_size = write_header_level2(data, hdr, pathname); + break; + default: + error("Unknown level header (level %d)", hdr->header_level); + exit(1); + } - /* LONGTIME is now the time in seconds, since 1970/01/01 00:00:00. */ - return (time_t) longtime; + if (fwrite(data, header_size, 1, fp) == 0) + fatal_error("Cannot write to temporary file"); } -#endif /* defined(MKTIME) || defined(TIMELOCAL) */ -/* ------------------------------------------------------------------------ */ -static long -unix_to_generic_stamp(t) - time_t t; +#if MULTIBYTE_FILENAME + +#if defined(__APPLE__) /* Added by Hiroto Sakai */ + +#include +#include + +/* this is not need for Mac OS X v 10.2 later */ +enum { + kCFStringEncodingAllowLossyConversion = 1, + kCFStringEncodingBasicDirectionLeftToRight = (1 << 1), + kCFStringEncodingBasicDirectionRightToLeft = (1 << 2), + kCFStringEncodingSubstituteCombinings = (1 << 3), + kCFStringEncodingComposeCombinings = (1 << 4), + kCFStringEncodingIgnoreCombinings = (1 << 5), + kCFStringEncodingUseCanonical = (1 << 6), + kCFStringEncodingUseHFSPlusCanonical = (1 << 7), + kCFStringEncodingPrependBOM = (1 << 8), + kCFStringEncodingDisableCorporateArea = (1 << 9), + kCFStringEncodingASCIICompatibleConversion = (1 << 10), +}; + +static int +ConvertEncodingToUTF8(const char* inCStr, + char* outUTF8Buffer, + int outUTF8BufferLength, + unsigned long scriptEncoding, + unsigned long flags) { - struct tm *tm = localtime(&t); + unsigned long unicodeChars; + unsigned long srcCharsUsed; + unsigned long usedByteLen = 0; + UniChar uniStr[512]; + unsigned long cfResult; + + cfResult = CFStringEncodingBytesToUnicode(scriptEncoding, + flags, + (char *)inCStr, + strlen(inCStr), + &srcCharsUsed, + uniStr, + 512, + &unicodeChars); + if (cfResult == 0) { + cfResult = CFStringEncodingUnicodeToBytes(kCFStringEncodingUTF8, + flags, + uniStr, + unicodeChars, + &srcCharsUsed, + (char*)outUTF8Buffer, + outUTF8BufferLength - 1, + &usedByteLen); + outUTF8Buffer[usedByteLen] = '\0'; + } - return ((((long) (tm->tm_year - 80)) << 25) + - (((long) (tm->tm_mon + 1)) << 21) + - (((long) tm->tm_mday) << 16) + - (long) ((tm->tm_hour << 11) + - (tm->tm_min << 5) + - (tm->tm_sec / 2))); + return cfResult; } -/* ------------------------------------------------------------------------ */ -/* build header functions */ -/* ------------------------------------------------------------------------ */ -boolean -get_header(fp, hdr) - FILE *fp; - register LzHeader *hdr; +static int +ConvertUTF8ToEncoding(const char* inUTF8Buf, + int inUTF8BufLength, + char* outCStrBuffer, + int outCStrBufferLength, + unsigned long scriptEncoding, + unsigned long flags) { - int header_size; - int name_length; - char data[LZHEADER_STRAGE]; - char dirname[FILENAME_LENGTH]; - int dir_length = 0; - int checksum; - int i; - char *ptr; - int extend_size; - int dmy; - - bzero(hdr, sizeof(LzHeader)); - - if (((header_size = getc(fp)) == EOF) || (header_size == 0)) { - return FALSE; /* finish */ - } - - if (fread(data + I_HEADER_CHECKSUM, - sizeof(char), header_size - 1, fp) < header_size - 1) { - fatal_error("Invalid header (LHarc file ?)"); - return FALSE; /* finish */ - } - setup_get(data + I_HEADER_LEVEL); - hdr->header_level = get_byte(); - if (hdr->header_level != 2 && - fread(data + header_size, sizeof(char), 2, fp) < 2) { - fatal_error("Invalid header (LHarc file ?)"); - return FALSE; /* finish */ - } - - if (hdr->header_level >= 3) { - fatal_error("Unknown level header"); - return FALSE; - } - - setup_get(data + I_HEADER_CHECKSUM); - checksum = get_byte(); - - if (hdr->header_level == 2) { - hdr->header_size = header_size + checksum*256; - } else { - hdr->header_size = header_size; - } - bcopy(data + I_METHOD, hdr->method, METHOD_TYPE_STRAGE); - setup_get(data + I_PACKED_SIZE); - hdr->packed_size = get_longword(); - hdr->original_size = get_longword(); - hdr->last_modified_stamp = get_longword(); - hdr->attribute = get_byte(); - - if ((hdr->header_level = get_byte()) != 2) { - if (calc_sum(data + I_METHOD, header_size) != checksum) - warning("Checksum error (LHarc file?)", ""); - name_length = get_byte(); - for (i = 0; i < name_length; i++) - hdr->name[i] = (char) get_byte(); - hdr->name[name_length] = '\0'; - } - else { - hdr->unix_last_modified_stamp = hdr->last_modified_stamp; - name_length = 0; - } - - /* defaults for other type */ - hdr->unix_mode = UNIX_FILE_REGULAR | UNIX_RW_RW_RW; - hdr->unix_gid = 0; - hdr->unix_uid = 0; - - if (hdr->header_level == 0) { - extend_size = header_size - name_length -22; - if (extend_size < 0) { - if (extend_size == -2) { - hdr->extend_type = EXTEND_GENERIC; - hdr->has_crc = FALSE; - } else { - fatal_error("Unkonwn header (lha file?)"); - return FALSE; - } - } else { - hdr->has_crc = TRUE; - hdr->crc = get_word(); - } - - if (extend_size >= 1) { - hdr->extend_type = get_byte(); - extend_size--; - } - if (hdr->extend_type == EXTEND_UNIX) { - if (extend_size >= 11) { - hdr->minor_version = get_byte(); - hdr->unix_last_modified_stamp = (time_t) get_longword(); - hdr->unix_mode = get_word(); - hdr->unix_uid = get_word(); - hdr->unix_gid = get_word(); - extend_size -= 11; - } else { - hdr->extend_type = EXTEND_GENERIC; - } - } - while (extend_size-- > 0) - dmy = get_byte(); - if (hdr->extend_type == EXTEND_UNIX) - return TRUE; - } else if (hdr->header_level == 1) { - hdr->has_crc = TRUE; - extend_size = header_size - name_length-25; - hdr->crc = get_word(); - hdr->extend_type = get_byte(); - while (extend_size-- > 0) - dmy = get_byte(); - } else { /* level 2 */ - hdr->has_crc = TRUE; - hdr->crc = get_word(); - hdr->extend_type = get_byte(); - } - - if (hdr->header_level > 0) { - /* Extend Header */ - if (hdr->header_level != 2) - setup_get(data + hdr->header_size); - ptr = get_ptr; - while ((header_size = get_word()) != 0) { - if (hdr->header_level != 2 && - ((data + LZHEADER_STRAGE - get_ptr < header_size) || - fread(get_ptr, sizeof(char), header_size, fp) < header_size)) { - fatal_error("Invalid header (LHa file ?)"); - return FALSE; - } - switch (get_byte()) { - case 0: - /* - * header crc - */ - setup_get(get_ptr + header_size - 3); - break; - case 1: - /* - * filename - */ - for (i = 0; i < header_size - 3; i++) - hdr->name[i] = (char) get_byte(); - hdr->name[header_size - 3] = '\0'; - name_length = header_size - 3; - break; - case 2: - /* - * directory - */ - for (i = 0; i < header_size - 3; i++) - dirname[i] = (char) get_byte(); - dirname[header_size - 3] = '\0'; - convdelim(dirname, DELIM); - dir_length = header_size - 3; - break; - case 0x40: - /* - * MS-DOS attribute - */ - if (hdr->extend_type == EXTEND_MSDOS || - hdr->extend_type == EXTEND_HUMAN || - hdr->extend_type == EXTEND_GENERIC) - hdr->attribute = get_word(); - break; - case 0x50: - /* - * UNIX permission - */ - if (hdr->extend_type == EXTEND_UNIX) - hdr->unix_mode = get_word(); - break; - case 0x51: - /* - * UNIX gid and uid - */ - if (hdr->extend_type == EXTEND_UNIX) { - hdr->unix_gid = get_word(); - hdr->unix_uid = get_word(); - } - break; - case 0x52: - /* - * UNIX group name - */ - setup_get(get_ptr + header_size - 3); - break; - case 0x53: - /* - * UNIX user name - */ - setup_get(get_ptr + header_size - 3); - break; - case 0x54: - /* - * UNIX last modified time - */ - if (hdr->extend_type == EXTEND_UNIX) - hdr->unix_last_modified_stamp = (time_t) get_longword(); - break; - default: - /* - * other headers - */ - setup_get(get_ptr + header_size - 3); - break; - } - } - if (hdr->header_level != 2 && get_ptr - ptr != 2) { - hdr->packed_size -= get_ptr - ptr - 2; - hdr->header_size += get_ptr - ptr - 2; - } - } - - switch (hdr->extend_type) { - case EXTEND_MSDOS: - msdos_to_unix_filename(hdr->name, name_length); - msdos_to_unix_filename(dirname, dir_length); - case EXTEND_HUMAN: - if (hdr->header_level == 2) - hdr->unix_last_modified_stamp = hdr->last_modified_stamp; - else - hdr->unix_last_modified_stamp = - generic_to_unix_stamp(hdr->last_modified_stamp); - break; - -#ifdef OSK - case EXTEND_OS68K: - case EXTEND_XOSK: -#endif - case EXTEND_UNIX: - break; - - case EXTEND_MACOS: - macos_to_unix_filename(hdr->name, name_length); - /* macos_to_unix_filename(dirname, dir_length); */ - hdr->unix_last_modified_stamp = - generic_to_unix_stamp(hdr->last_modified_stamp); - break; - - default: - generic_to_unix_filename(hdr->name, name_length); - generic_to_unix_filename(dirname, dir_length); - if (hdr->header_level == 2) - hdr->unix_last_modified_stamp = hdr->last_modified_stamp; - else - hdr->unix_last_modified_stamp = - generic_to_unix_stamp(hdr->last_modified_stamp); - } - - if (dir_length) { - strcat(dirname, hdr->name); - strcpy(hdr->name, dirname); - name_length += dir_length; - } + unsigned long unicodeChars; + unsigned long srcCharsUsed; + unsigned long usedByteLen = 0; + UniChar uniStr[256]; + unsigned long cfResult; + + cfResult = CFStringEncodingBytesToUnicode(kCFStringEncodingUTF8, + flags, + (char*)inUTF8Buf, + inUTF8BufLength, + &srcCharsUsed, + uniStr, + 255, + &unicodeChars); + if (cfResult == 0) { + cfResult = CFStringEncodingUnicodeToBytes(scriptEncoding, + flags, + uniStr, + unicodeChars, + &srcCharsUsed, + (char*)outCStrBuffer, + outCStrBufferLength - 1, + &usedByteLen); + outCStrBuffer[usedByteLen] = '\0'; + } - return TRUE; + return cfResult; } -/* ------------------------------------------------------------------------ */ -void -init_header(name, v_stat, hdr) - char *name; - struct stat *v_stat; - LzHeader *hdr; -{ - int len; - - if (compress_method == LZHUFF5_METHOD_NUM) /* Changed N.Watazaki */ - bcopy(LZHUFF5_METHOD, hdr->method, METHOD_TYPE_STRAGE); - else if (compress_method) - bcopy(LZHUFF1_METHOD, hdr->method, METHOD_TYPE_STRAGE); - else - bcopy(LZHUFF0_METHOD, hdr->method, METHOD_TYPE_STRAGE); - - hdr->packed_size = 0; - hdr->original_size = v_stat->st_size; - hdr->last_modified_stamp = unix_to_generic_stamp(v_stat->st_mtime); - hdr->attribute = GENERIC_ATTRIBUTE; - hdr->header_level = header_level; - strcpy(hdr->name, name); - len = strlen(name); - hdr->crc = 0x0000; - hdr->extend_type = EXTEND_UNIX; - hdr->unix_last_modified_stamp = v_stat->st_mtime; - /* since 00:00:00 JAN.1.1970 */ -#ifdef NOT_COMPATIBLE_MODE - /* Please need your modification in this space. */ +#elif HAVE_ICONV +#include + +static int +ConvertEncodingByIconv(const char *src, char *dst, int dstsize, + const char *srcEnc, const char *dstEnc) +{ + iconv_t ic; + static char szTmpBuf[2048]; + char *src_p; + char *dst_p; + size_t sLen; + size_t iLen; + + dst_p = &szTmpBuf[0]; + iLen = (size_t)sizeof(szTmpBuf)-1; + src_p = (char *)src; + sLen = (size_t)strlen(src); + memset(szTmpBuf, 0, sizeof(szTmpBuf)); + memset(dst, 0, dstsize); + + ic = iconv_open(dstEnc, srcEnc); + if (ic == (iconv_t)-1) { + error("iconv_open() failure: %s", strerror(errno)); + return -1; + } + + if (iconv(ic, &src_p, &sLen, &dst_p, &iLen) == (size_t)-1) { + error("iconv() failure: %s", strerror(errno)); + iconv_close(ic); + return -1; + } + + strncpy(dst, szTmpBuf, dstsize); + + iconv_close(ic); + + return 0; +} +#endif /* defined(__APPLE__) */ + +char * +sjis_to_utf8(char *dst, const char *src, size_t dstsize) +{ +#if defined(__APPLE__) + dst[0] = '\0'; + if (ConvertEncodingToUTF8(src, dst, dstsize, + kCFStringEncodingDOSJapanese, + kCFStringEncodingUseHFSPlusCanonical) == 0) + return dst; +#elif HAVE_ICONV + if (ConvertEncodingByIconv(src, dst, dstsize, "SJIS", "UTF-8") != -1) + return dst; #else - hdr->unix_mode = v_stat->st_mode; + error("not support utf-8 conversion"); #endif - hdr->unix_uid = v_stat->st_uid; - hdr->unix_gid = v_stat->st_gid; + if (dstsize < 1) return dst; + dst[dstsize-1] = 0; + return strncpy(dst, src, dstsize-1); +} + +char * +utf8_to_sjis(char *dst, const char *src, size_t dstsize) +{ +#if defined(__APPLE__) + int srclen; - if (is_directory(v_stat)) { - bcopy(LZHDIRS_METHOD, hdr->method, METHOD_TYPE_STRAGE); - hdr->attribute = GENERIC_DIRECTORY_ATTRIBUTE; - hdr->original_size = 0; - if (len > 0 && hdr->name[len - 1] != '/') - strcpy(&hdr->name[len++], "/"); - } - -#ifdef S_IFLNK - if (is_symlink(v_stat)) { - char lkname[257]; - int len; - bcopy(LZHDIRS_METHOD, hdr->method, METHOD_TYPE_STRAGE); - hdr->attribute = GENERIC_DIRECTORY_ATTRIBUTE; - hdr->original_size = 0; - len = readlink(name, lkname, 256); - lkname[len] = (char)'\0'; - sprintf(hdr->name, "%s|%s", hdr->name, lkname); - } + dst[0] = '\0'; + srclen = strlen(src); + if (ConvertUTF8ToEncoding(src, srclen, dst, dstsize, + kCFStringEncodingDOSJapanese, + kCFStringEncodingUseHFSPlusCanonical) == 0) + return dst; +#elif HAVE_ICONV + if (ConvertEncodingByIconv(src, dst, dstsize, "UTF-8", "SJIS") != -1) + return dst; +#else + error("not support utf-8 conversion"); #endif - if (generic_format) - unix_to_generic_filename(hdr->name, len); + + if (dstsize < 1) return dst; + dst[dstsize-1] = 0; + return strncpy(dst, src, dstsize-1); +} + +/* + * SJIS <-> EUC 変換関数 + * 「日本語情報処理」 ソフトバンク(株) + * より抜粋(by Koji Arai) + */ +void +euc2sjis(int *p1, int *p2) +{ + unsigned char c1 = *p1 & 0x7f; + unsigned char c2 = *p2 & 0x7f; + int rowoff = c1 < 0x5f ? 0x70 : 0xb0; + int celoff = c1 % 2 ? (c2 > 0x5f ? 0x20 : 0x1f) : 0x7e; + *p1 = ((c1 + 1) >> 1) + rowoff; + *p2 += celoff - 0x80; } -/* ------------------------------------------------------------------------ */ -/* Write unix extended header or generic header. */ void -write_header(nafp, hdr) - FILE *nafp; - LzHeader *hdr; -{ - int header_size; - int name_length; - char data[LZHEADER_STRAGE]; - char *p; - char *headercrc_ptr; - - bzero(data, LZHEADER_STRAGE); - bcopy(hdr->method, data + I_METHOD, METHOD_TYPE_STRAGE); - setup_put(data + I_PACKED_SIZE); - put_longword(hdr->packed_size); - put_longword(hdr->original_size); - - if (hdr->header_level == HEADER_LEVEL2) - put_longword((long) hdr->unix_last_modified_stamp); - else - put_longword(hdr->last_modified_stamp); - - switch (hdr->header_level) { - case HEADER_LEVEL0: - put_byte(hdr->attribute); - break; - case HEADER_LEVEL1: - case HEADER_LEVEL2: - put_byte(0x20); - break; - } - - put_byte(hdr->header_level); - - convdelim(hdr->name, DELIM2); - if (hdr->header_level != HEADER_LEVEL2) { - if (p = (char *) rindex(hdr->name, DELIM2)) - name_length = strlen(++p); - else - name_length = strlen(hdr->name); - put_byte(name_length); - bcopy(p ? p : hdr->name, data + I_NAME, name_length); - setup_put(data + I_NAME + name_length); - } - - put_word(hdr->crc); - if (header_level == HEADER_LEVEL0) { - if (generic_format) { - header_size = I_GENERIC_HEADER_BOTTOM - 2 + name_length; - data[I_HEADER_SIZE] = header_size; - data[I_HEADER_CHECKSUM] = calc_sum(data + I_METHOD, header_size); - } else { - /* write old-style extend header */ - put_byte(EXTEND_UNIX); - put_byte(CURRENT_UNIX_MINOR_VERSION); - put_longword((long) hdr->unix_last_modified_stamp); - put_word(hdr->unix_mode); - put_word(hdr->unix_uid); - put_word(hdr->unix_gid); - header_size = I_UNIX_EXTEND_BOTTOM - 2 + name_length; - data[I_HEADER_SIZE] = header_size; - data[I_HEADER_CHECKSUM] = calc_sum(data + I_METHOD, header_size); - } - } else { - /* write extend header. */ - char *ptr; - - if (generic_format) - put_byte(0x00); - else - put_byte(EXTEND_UNIX); - - ptr = put_ptr; - if (hdr->header_level == HEADER_LEVEL2) { - /* write common header */ - put_word(5); - put_byte(0x00); - headercrc_ptr = put_ptr; - put_word(0x0000); - } - - if (generic_format) { - header_size = put_ptr - data; /* +2 for last 0x0000 */ - } else { - put_word(5); - if (hdr->header_level == HEADER_LEVEL1) - header_size = put_ptr - data - 2; - put_byte(0x50); /* permission */ - put_word(hdr->unix_mode); - put_word(7); - put_byte(0x51); /* gid and uid */ - put_word(hdr->unix_gid); - put_word(hdr->unix_uid); - - if (p = (char *) rindex(hdr->name, DELIM2)) { - int i; - - name_length = p - hdr->name + 1; - put_word(name_length + 3); - put_byte(2); /* dirname */ - for (i = 0; i < name_length; i++) - put_byte(hdr->name[i]); - } - } /* if generic .. */ - - if (header_level != HEADER_LEVEL2) { - if (!generic_format) { - put_word(7); - put_byte(0x54); /* time stamp */ - put_longword(hdr->unix_last_modified_stamp); - } - hdr->packed_size += put_ptr - ptr; - ptr = put_ptr; - setup_put(data + I_PACKED_SIZE); - put_longword(hdr->packed_size); - put_ptr = ptr; - data[I_HEADER_SIZE] = header_size; - data[I_HEADER_CHECKSUM] = calc_sum(data + I_METHOD, header_size); - } else { /* header level 2 */ - int i; - if (p = (char *) rindex(hdr->name, DELIM2)) - name_length = strlen(++p); - else { - p = hdr->name; - name_length = strlen(hdr->name); - } - put_word(name_length + 3); - put_byte(1); /* filename */ - for (i = 0; i < name_length; i++) - put_byte(*p++); - } /* if he.. != HEAD_LV2 */ - header_size = put_ptr - data; - } - - if (header_level == HEADER_LEVEL2) { - unsigned short hcrc; - setup_put(data + I_HEADER_SIZE); - put_word(header_size + 2); - /* common header */ - hcrc = calc_header_crc(data, (unsigned int) header_size + 2); - setup_put(headercrc_ptr); - put_word(hcrc); - } - - if (fwrite(data, sizeof(char), header_size + 2, nafp) == 0) - fatal_error("Cannot write to temporary file"); - - convdelim(hdr->name, DELIM); -} - -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* compile-command:"gcc -c header.c" */ -/* End: */ +sjis2euc(int *p1, int *p2) +{ + unsigned char c1 = *p1; + unsigned char c2 = *p2; + int adjust = c2 < 0x9f; + int rowoff = c1 < 0xa0 ? 0x70 : 0xb0; + int celoff = adjust ? (c2 > 0x7f ? 0x20 : 0x1f) : 0x7e; + *p1 = ((c1 - rowoff) << 1) - adjust; + *p2 -= celoff; + + *p1 |= 0x80; + *p2 |= 0x80; +} + +static int +hex2int(int c) +{ + switch (c) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + return c - '0'; + + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + return c - 'a' + 10; + + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + return c - 'A' + 10; + default: + return -1; + } +} + +static int +int2hex(int c) +{ + switch (c) { + case 0: case 1: case 2: case 3: case 4: + case 5: case 6: case 7: case 8: case 9: + return c + '0'; + + case 10: case 11: case 12: case 13: case 14: case 15: + return c + 'a' - 10; + + default: + return -1; + } +} + +int +cap_to_sjis(char *dst, const char *src, size_t dstsize) +{ + int i, j; + size_t len = strlen(src); + int a, b; + + for (i = j = 0; i < len && i < dstsize; i++) { + if (src[i] != ':') { + dst[j++] = src[i]; + continue; + } + + i++; + a = hex2int((unsigned char)src[i]); + b = hex2int((unsigned char)src[i+1]); + + if (a == -1 || b == -1) { + /* leave as it */ + dst[j++] = ':'; + strncpy(dst+j, src+i, dstsize-j); + dst[dstsize-1] = 0; + return strlen(dst); + } + + i++; + + dst[j++] = a * 16 + b; + } + dst[j] = 0; + return j; +} + +int +sjis_to_cap(char *dst, const char *src, size_t dstsize) +{ + int i, j; + size_t len = strlen(src); + int a, b; + + for (i = j = 0; i < len && i < dstsize; i++) { + if (src[i] == ':') { + strncpy(dst+j, ":3a", dstsize-j); + dst[dstsize-1] = 0; + j = strlen(dst); + continue; + } + if (isprint(src[i])) { + dst[j++] = src[i]; + continue; + } + + if (j + 3 >= dstsize) { + dst[j] = 0; + return j; + } + + a = int2hex((unsigned char)src[i] / 16); + b = int2hex((unsigned char)src[i] % 16); + + dst[j++] = ':'; + dst[j++] = a; + dst[j++] = b; + } + dst[j] = 0; + return j; +} +#endif /* MULTIBYTE_FILENAME */ diff -Nru lha-1.14i/src/huf.c lha-1.14i-acc20050924p1/src/huf.c --- lha-1.14i/src/huf.c 2000-10-05 17:35:49.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/huf.c 2006-10-10 16:39:06.000000000 +0000 @@ -1,494 +1,490 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* huf.c -- new static Huffman */ -/* */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ -/* Ver. 1.14i Support LH7 & Bug Fixed 2000.10. 6 t.okamoto */ +/* LHa for UNIX */ +/* huf.c -- new static Huffman */ +/* */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* Ver. 1.14i Support LH7 & Bug Fixed 2000.10. 6 t.okamoto */ /* ------------------------------------------------------------------------ */ #include "lha.h" -#ifdef sony_news +#if HAVE_SYS_PARAM_H #include #endif -#if defined(__STDC__) || defined(NEWSOS) +#if STDC_HEADERS #include +#else +extern char *malloc (); #endif /* ------------------------------------------------------------------------ */ -unsigned short left[2 * NC - 1], right[2 * NC - 1]; -unsigned char c_len[NC], pt_len[NPT]; -unsigned short c_freq[2 * NC - 1], c_table[4096], c_code[NC], p_freq[2 * NP - 1], - pt_table[256], pt_code[NPT], t_freq[2 * NT - 1]; - -static unsigned char *buf; -static unsigned int bufsiz; -static unsigned short blocksize; -static unsigned short output_pos, output_mask; -static int pbit; -static int np; +unsigned short left[2 * NC - 1], right[2 * NC - 1]; + +unsigned short c_code[NC]; /* encode */ +unsigned short pt_code[NPT]; /* encode */ + +unsigned short c_table[4096]; /* decode */ +unsigned short pt_table[256]; /* decode */ + +unsigned short c_freq[2 * NC - 1]; /* encode */ +unsigned short p_freq[2 * NP - 1]; /* encode */ +unsigned short t_freq[2 * NT - 1]; /* encode */ + +unsigned char c_len[NC]; +unsigned char pt_len[NPT]; + +static unsigned char *buf; /* encode */ +static unsigned int bufsiz; /* encode */ +static unsigned short blocksize; /* decode */ +static unsigned short output_pos, output_mask; /* encode */ + +static int pbit; +static int np; /* ------------------------------------------------------------------------ */ -/* Encording */ +/* Encording */ /* ------------------------------------------------------------------------ */ static void count_t_freq(/*void*/) { - short i, k, n, count; + short i, k, n, count; - for (i = 0; i < NT; i++) - t_freq[i] = 0; - n = NC; - while (n > 0 && c_len[n - 1] == 0) - n--; - i = 0; - while (i < n) { - k = c_len[i++]; - if (k == 0) { - count = 1; - while (i < n && c_len[i] == 0) { - i++; - count++; - } - if (count <= 2) - t_freq[0] += count; - else if (count <= 18) - t_freq[1]++; - else if (count == 19) { - t_freq[0]++; - t_freq[1]++; - } - else - t_freq[2]++; - } else - t_freq[k + 2]++; - } + for (i = 0; i < NT; i++) + t_freq[i] = 0; + n = NC; + while (n > 0 && c_len[n - 1] == 0) + n--; + i = 0; + while (i < n) { + k = c_len[i++]; + if (k == 0) { + count = 1; + while (i < n && c_len[i] == 0) { + i++; + count++; + } + if (count <= 2) + t_freq[0] += count; + else if (count <= 18) + t_freq[1]++; + else if (count == 19) { + t_freq[0]++; + t_freq[1]++; + } + else + t_freq[2]++; + } else + t_freq[k + 2]++; + } } /* ------------------------------------------------------------------------ */ static void write_pt_len(n, nbit, i_special) - short n; - short nbit; - short i_special; -{ - short i, k; - - while (n > 0 && pt_len[n - 1] == 0) - n--; - putbits(nbit, n); - i = 0; - while (i < n) { - k = pt_len[i++]; - if (k <= 6) - putbits(3, k); - else - putbits(k - 3, USHRT_MAX << 1); - if (i == i_special) { - while (i < 6 && pt_len[i] == 0) - i++; - putbits(2, i - 3); - } - } + short n; + short nbit; + short i_special; +{ + short i, k; + + while (n > 0 && pt_len[n - 1] == 0) + n--; + putbits(nbit, n); + i = 0; + while (i < n) { + k = pt_len[i++]; + if (k <= 6) + putbits(3, k); + else + /* k=7 -> 1110 k=8 -> 11110 k=9 -> 111110 ... */ + putbits(k - 3, USHRT_MAX << 1); + if (i == i_special) { + while (i < 6 && pt_len[i] == 0) + i++; + putbits(2, i - 3); + } + } } /* ------------------------------------------------------------------------ */ static void write_c_len(/*void*/) { - short i, k, n, count; + short i, k, n, count; - n = NC; - while (n > 0 && c_len[n - 1] == 0) - n--; - putbits(CBIT, n); - i = 0; - while (i < n) { - k = c_len[i++]; - if (k == 0) { - count = 1; - while (i < n && c_len[i] == 0) { - i++; - count++; - } - if (count <= 2) { - for (k = 0; k < count; k++) - putcode(pt_len[0], pt_code[0]); - } - else if (count <= 18) { - putcode(pt_len[1], pt_code[1]); - putbits(4, count - 3); - } - else if (count == 19) { - putcode(pt_len[0], pt_code[0]); - putcode(pt_len[1], pt_code[1]); - putbits(4, 15); - } - else { - putcode(pt_len[2], pt_code[2]); - putbits(CBIT, count - 20); - } - } - else - putcode(pt_len[k + 2], pt_code[k + 2]); - } + n = NC; + while (n > 0 && c_len[n - 1] == 0) + n--; + putbits(CBIT, n); + i = 0; + while (i < n) { + k = c_len[i++]; + if (k == 0) { + count = 1; + while (i < n && c_len[i] == 0) { + i++; + count++; + } + if (count <= 2) { + for (k = 0; k < count; k++) + putcode(pt_len[0], pt_code[0]); + } + else if (count <= 18) { + putcode(pt_len[1], pt_code[1]); + putbits(4, count - 3); + } + else if (count == 19) { + putcode(pt_len[0], pt_code[0]); + putcode(pt_len[1], pt_code[1]); + putbits(4, 15); + } + else { + putcode(pt_len[2], pt_code[2]); + putbits(CBIT, count - 20); + } + } + else + putcode(pt_len[k + 2], pt_code[k + 2]); + } } /* ------------------------------------------------------------------------ */ static void encode_c(c) - short c; + short c; { - putcode(c_len[c], c_code[c]); + putcode(c_len[c], c_code[c]); } /* ------------------------------------------------------------------------ */ static void encode_p(p) - unsigned short p; + unsigned short p; { - unsigned short c, q; + unsigned short c, q; - c = 0; - q = p; - while (q) { - q >>= 1; - c++; - } - putcode(pt_len[c], pt_code[c]); - if (c > 1) - putbits(c - 1, p); + c = 0; + q = p; + while (q) { + q >>= 1; + c++; + } + putcode(pt_len[c], pt_code[c]); + if (c > 1) + putbits(c - 1, p); } /* ------------------------------------------------------------------------ */ static void send_block( /* void */ ) { - unsigned char flags; - unsigned short i, k, root, pos, size; + unsigned char flags; + unsigned short i, k, root, pos, size; - root = make_tree(NC, c_freq, c_len, c_code); - size = c_freq[root]; - putbits(16, size); - if (root >= NC) { - count_t_freq(); - root = make_tree(NT, t_freq, pt_len, pt_code); - if (root >= NT) { - write_pt_len(NT, TBIT, 3); - } else { - putbits(TBIT, 0); - putbits(TBIT, root); - } - write_c_len(); - } else { - putbits(TBIT, 0); - putbits(TBIT, 0); - putbits(CBIT, 0); - putbits(CBIT, root); - } - root = make_tree(np, p_freq, pt_len, pt_code); - if (root >= np) { - write_pt_len(np, pbit, -1); - } - else { - putbits(pbit, 0); - putbits(pbit, root); - } - pos = 0; - for (i = 0; i < size; i++) { - if (i % CHAR_BIT == 0) - flags = buf[pos++]; - else - flags <<= 1; - if (flags & (1 << (CHAR_BIT - 1))) { - encode_c(buf[pos++] + (1 << CHAR_BIT)); - k = buf[pos++] << CHAR_BIT; - k += buf[pos++]; - encode_p(k); - } else - encode_c(buf[pos++]); - if (unpackable) - return; - } - for (i = 0; i < NC; i++) - c_freq[i] = 0; - for (i = 0; i < np; i++) - p_freq[i] = 0; + root = make_tree(NC, c_freq, c_len, c_code); + size = c_freq[root]; + putbits(16, size); + if (root >= NC) { + count_t_freq(); + root = make_tree(NT, t_freq, pt_len, pt_code); + if (root >= NT) { + write_pt_len(NT, TBIT, 3); + } else { + putbits(TBIT, 0); + putbits(TBIT, root); + } + write_c_len(); + } else { + putbits(TBIT, 0); + putbits(TBIT, 0); + putbits(CBIT, 0); + putbits(CBIT, root); + } + root = make_tree(np, p_freq, pt_len, pt_code); + if (root >= np) { + write_pt_len(np, pbit, -1); + } + else { + putbits(pbit, 0); + putbits(pbit, root); + } + pos = 0; + for (i = 0; i < size; i++) { + if (i % CHAR_BIT == 0) + flags = buf[pos++]; + else + flags <<= 1; + if (flags & (1 << (CHAR_BIT - 1))) { + encode_c(buf[pos++] + (1 << CHAR_BIT)); + k = buf[pos++] << CHAR_BIT; + k += buf[pos++]; + encode_p(k); + } else + encode_c(buf[pos++]); + if (unpackable) + return; + } + for (i = 0; i < NC; i++) + c_freq[i] = 0; + for (i = 0; i < np; i++) + p_freq[i] = 0; } /* ------------------------------------------------------------------------ */ +/* lh4, 5, 6, 7 */ void output_st1(c, p) - unsigned short c; - unsigned short p; + unsigned short c; + unsigned short p; { - static unsigned short cpos; + static unsigned short cpos; - output_mask >>= 1; - if (output_mask == 0) { - output_mask = 1 << (CHAR_BIT - 1); - if (output_pos >= bufsiz - 3 * CHAR_BIT) { - send_block(); - if (unpackable) - return; - output_pos = 0; - } - cpos = output_pos++; - buf[cpos] = 0; - } - buf[output_pos++] = (unsigned char) c; - c_freq[c]++; - if (c >= (1 << CHAR_BIT)) { - buf[cpos] |= output_mask; - buf[output_pos++] = (unsigned char) (p >> CHAR_BIT); - buf[output_pos++] = (unsigned char) p; - c = 0; - while (p) { - p >>= 1; - c++; - } - p_freq[c]++; - } + output_mask >>= 1; + if (output_mask == 0) { + output_mask = 1 << (CHAR_BIT - 1); + if (output_pos >= bufsiz - 3 * CHAR_BIT) { + send_block(); + if (unpackable) + return; + output_pos = 0; + } + cpos = output_pos++; + buf[cpos] = 0; + } + buf[output_pos++] = (unsigned char) c; + c_freq[c]++; + if (c >= (1 << CHAR_BIT)) { + buf[cpos] |= output_mask; + buf[output_pos++] = (unsigned char) (p >> CHAR_BIT); + buf[output_pos++] = (unsigned char) p; + c = 0; + while (p) { + p >>= 1; + c++; + } + p_freq[c]++; + } } /* ------------------------------------------------------------------------ */ unsigned char * alloc_buf( /* void */ ) { - bufsiz = 16 * 1024 *2; /* 65408U; */ /* t.okamoto */ - while ((buf = (unsigned char *) malloc(bufsiz)) == NULL) { - bufsiz = (bufsiz / 10) * 9; - if (bufsiz < 4 * 1024) - break; - } - return buf; + bufsiz = 16 * 1024 *2; /* 65408U; */ /* t.okamoto */ + while ((buf = (unsigned char *) malloc(bufsiz)) == NULL) { + bufsiz = (bufsiz / 10) * 9; + if (bufsiz < 4 * 1024) + fatal_error("Not enough memory"); + } + return buf; } /* ------------------------------------------------------------------------ */ +/* lh4, 5, 6, 7 */ void encode_start_st1( /* void */ ) { - int i; - -#if 0 - if (dicbit <= (MAX_DICBIT - 2)) { - pbit = 4; /* lh4,5 etc. */ - np = 14; - } else { - pbit = 5; /* lh6 */ - np = 16; - } -#endif + int i; - if (dicbit <= 13) { - pbit = 4; /* lh4,5 etc. */ - np = 14; - } else { - pbit = 5; /* lh6,7 */ - if (dicbit == 16) - np = 17; - else - np = 16; - } - - for (i = 0; i < NC; i++) - c_freq[i] = 0; - for (i = 0; i < np; i++) - p_freq[i] = 0; - output_pos = output_mask = 0; - init_putbits(); - buf[0] = 0; + switch (dicbit) { + case LZHUFF4_DICBIT: + case LZHUFF5_DICBIT: pbit = 4; np = LZHUFF5_DICBIT + 1; break; + case LZHUFF6_DICBIT: pbit = 5; np = LZHUFF6_DICBIT + 1; break; + case LZHUFF7_DICBIT: pbit = 5; np = LZHUFF7_DICBIT + 1; break; + default: + fatal_error("Cannot use %d bytes dictionary", 1 << dicbit); + } + + for (i = 0; i < NC; i++) + c_freq[i] = 0; + for (i = 0; i < np; i++) + p_freq[i] = 0; + output_pos = output_mask = 0; + init_putbits(); + init_code_cache(); + buf[0] = 0; } /* ------------------------------------------------------------------------ */ +/* lh4, 5, 6, 7 */ void encode_end_st1( /* void */ ) { - if (!unpackable) { - send_block(); - putbits(CHAR_BIT - 1, 0); /* flush remaining bits */ - } + if (!unpackable) { + send_block(); + putbits(CHAR_BIT - 1, 0); /* flush remaining bits */ + } } /* ------------------------------------------------------------------------ */ -/* decoding */ +/* decoding */ /* ------------------------------------------------------------------------ */ static void read_pt_len(nn, nbit, i_special) - short nn; - short nbit; - short i_special; -{ - int i, c, n; - - n = getbits(nbit); - if (n == 0) { - c = getbits(nbit); - for (i = 0; i < nn; i++) - pt_len[i] = 0; - for (i = 0; i < 256; i++) - pt_table[i] = c; - } - else { - i = 0; - while (i < n) { - c = bitbuf >> (16 - 3); - if (c == 7) { - unsigned short mask = 1 << (16 - 4); - while (mask & bitbuf) { - mask >>= 1; - c++; - } - } - fillbuf((c < 7) ? 3 : c - 3); - pt_len[i++] = c; - if (i == i_special) { - c = getbits(2); - while (--c >= 0) - pt_len[i++] = 0; - } - } - while (i < nn) - pt_len[i++] = 0; - make_table(nn, pt_len, 8, pt_table); - } + short nn; + short nbit; + short i_special; +{ + int i, c, n; + + n = getbits(nbit); + if (n == 0) { + c = getbits(nbit); + for (i = 0; i < nn; i++) + pt_len[i] = 0; + for (i = 0; i < 256; i++) + pt_table[i] = c; + } + else { + i = 0; + while (i < MIN(n, NPT)) { + c = peekbits(3); + if (c != 7) + fillbuf(3); + else { + unsigned short mask = 1 << (16 - 4); + while (mask & bitbuf) { + mask >>= 1; + c++; + } + fillbuf(c - 3); + } + + pt_len[i++] = c; + if (i == i_special) { + c = getbits(2); + while (--c >= 0 && i < NPT) + pt_len[i++] = 0; + } + } + while (i < nn) + pt_len[i++] = 0; + make_table(nn, pt_len, 8, pt_table); + } } /* ------------------------------------------------------------------------ */ static void read_c_len( /* void */ ) { - short i, c, n; + short i, c, n; - n = getbits(CBIT); - if (n == 0) { - c = getbits(CBIT); - for (i = 0; i < NC; i++) - c_len[i] = 0; - for (i = 0; i < 4096; i++) - c_table[i] = c; - } else { - i = 0; - while (i < n) { - c = pt_table[bitbuf >> (16 - 8)]; - if (c >= NT) { - unsigned short mask = 1 << (16 - 9); - do { - if (bitbuf & mask) - c = right[c]; - else - c = left[c]; - mask >>= 1; - } while (c >= NT); - } - fillbuf(pt_len[c]); - if (c <= 2) { - if (c == 0) - c = 1; - else if (c == 1) - c = getbits(4) + 3; - else - c = getbits(CBIT) + 20; - while (--c >= 0) - c_len[i++] = 0; - } - else - c_len[i++] = c - 2; - } - while (i < NC) - c_len[i++] = 0; - make_table(NC, c_len, 12, c_table); - } + n = getbits(CBIT); + if (n == 0) { + c = getbits(CBIT); + for (i = 0; i < NC; i++) + c_len[i] = 0; + for (i = 0; i < 4096; i++) + c_table[i] = c; + } else { + i = 0; + while (i < MIN(n,NC)) { + c = pt_table[peekbits(8)]; + if (c >= NT) { + unsigned short mask = 1 << (16 - 9); + do { + if (bitbuf & mask) + c = right[c]; + else + c = left[c]; + mask >>= 1; + } while (c >= NT && (mask || c != left[c])); /* CVE-2006-4338 */ + } + fillbuf(pt_len[c]); + if (c <= 2) { + if (c == 0) + c = 1; + else if (c == 1) + c = getbits(4) + 3; + else + c = getbits(CBIT) + 20; + while (--c >= 0) + c_len[i++] = 0; + } + else + c_len[i++] = c - 2; + } + while (i < NC) + c_len[i++] = 0; + make_table(NC, c_len, 12, c_table); + } } /* ------------------------------------------------------------------------ */ +/* lh4, 5, 6, 7 */ unsigned short decode_c_st1( /*void*/ ) { - unsigned short j, mask; + unsigned short j, mask; - if (blocksize == 0) { - blocksize = getbits(16); - read_pt_len(NT, TBIT, 3); - read_c_len(); - read_pt_len(np, pbit, -1); - } - blocksize--; - j = c_table[bitbuf >> 4]; - if (j < NC) - fillbuf(c_len[j]); - else { - fillbuf(12); - mask = 1 << (16 - 1); - do { - if (bitbuf & mask) - j = right[j]; - else - j = left[j]; - mask >>= 1; - } while (j >= NC); - fillbuf(c_len[j] - 12); - } - return j; + if (blocksize == 0) { + blocksize = getbits(16); + read_pt_len(NT, TBIT, 3); + read_c_len(); + read_pt_len(np, pbit, -1); + } + blocksize--; + j = c_table[peekbits(12)]; + if (j < NC) + fillbuf(c_len[j]); + else { + fillbuf(12); + mask = 1 << (16 - 1); + do { + if (bitbuf & mask) + j = right[j]; + else + j = left[j]; + mask >>= 1; + } while (j >= NC && (mask || j != left[j])); /* CVE-2006-4338 */ + fillbuf(c_len[j] - 12); + } + return j; } /* ------------------------------------------------------------------------ */ +/* lh4, 5, 6, 7 */ unsigned short decode_p_st1( /* void */ ) { - unsigned short j, mask; + unsigned short j, mask; - j = pt_table[bitbuf >> (16 - 8)]; - if (j < np) - fillbuf(pt_len[j]); - else { - fillbuf(8); - mask = 1 << (16 - 1); - do { - if (bitbuf & mask) - j = right[j]; - else - j = left[j]; - mask >>= 1; - } while (j >= np); - fillbuf(pt_len[j] - 8); - } - if (j != 0) - j = (1 << (j - 1)) + getbits(j - 1); - return j; + j = pt_table[peekbits(8)]; + if (j < np) + fillbuf(pt_len[j]); + else { + fillbuf(8); + mask = 1 << (16 - 1); + do { + if (bitbuf & mask) + j = right[j]; + else + j = left[j]; + mask >>= 1; + } while (j >= np && (mask || j != left[j])); /* CVE-2006-4338 */ + fillbuf(pt_len[j] - 8); + } + if (j != 0) + j = (1 << (j - 1)) + getbits(j - 1); + return j; } /* ------------------------------------------------------------------------ */ +/* lh4, 5, 6, 7 */ void decode_start_st1( /* void */ ) { - if (dicbit <= 13) { - np = 14; - pbit = 4; - } else { - if (dicbit == 16) { - np = 17; /* for -lh7- */ - } else { - np = 16; - } - pbit = 5; - } - -#if 0 - if (dicbit <= 13) { /* 13 ... Changed N.Watazaki */ - np = 14; - pbit = 4; - } else { - np = 16; - pbit = 5; - } -#endif - init_getbits(); - blocksize = 0; + switch (dicbit) { + case LZHUFF4_DICBIT: + case LZHUFF5_DICBIT: pbit = 4; np = LZHUFF5_DICBIT + 1; break; + case LZHUFF6_DICBIT: pbit = 5; np = LZHUFF6_DICBIT + 1; break; + case LZHUFF7_DICBIT: pbit = 5; np = LZHUFF7_DICBIT + 1; break; + default: + fatal_error("Cannot use %d bytes dictionary", 1 << dicbit); + } + + init_getbits(); + init_code_cache(); + blocksize = 0; } - -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* End: */ diff -Nru lha-1.14i/src/indicator.c lha-1.14i-acc20050924p1/src/indicator.c --- lha-1.14i/src/indicator.c 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/indicator.c 2003-07-27 08:31:28.000000000 +0000 @@ -0,0 +1,141 @@ +/* ------------------------------------------------------------------------ */ +/* LHa for UNIX */ +/* indicator.c -- put indicator */ +/* */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* Separated from append.c 2003.07.21 Koji Arai */ +/* ------------------------------------------------------------------------ */ +#include "lha.h" + +#define MAX_INDICATOR_COUNT 58 + +static size_t reading_size; + +#ifdef NEED_INCREMENTAL_INDICATOR +static size_t indicator_count; +static long indicator_threshold; +#endif + +#define ALIGN(size, threshold) (((size) + ((threshold)-1))/(threshold)) + +static void +carriage_return() +{ + static int tty = -1; + if (tty == -1) { + if (isatty(1)) /* stdout */ + tty = 1; + else + tty = 0; + } + + if (tty) + fputs("\r", stdout); + else + fputs("\n", stdout); +} + +void +start_indicator(name, size, msg, def_indicator_threshold) + char *name; + size_t size; + char *msg; + long def_indicator_threshold; +{ +#ifdef NEED_INCREMENTAL_INDICATOR + long i; + int m; +#endif + + if (quiet) + return; + +#ifdef NEED_INCREMENTAL_INDICATOR + switch (quiet_mode) { + case 0: + m = MAX_INDICATOR_COUNT - strlen(name); + if (m < 1) /* Bug Fixed by N.Watazaki */ + m = 3; /* (^_^) */ + carriage_return(); + printf("%s\t- %s : ", name, msg); + + indicator_threshold = + ALIGN(size, m*def_indicator_threshold) * def_indicator_threshold; + + if (indicator_threshold) + i = ALIGN(size, indicator_threshold); + else + i = 0; + + while (i--) + putchar('.'); + indicator_count = 0; + carriage_return(); + printf("%s\t- %s : ", name, msg); + break; + case 1: + carriage_return(); + printf("%s :", name); + break; + } +#else + printf("%s\t- ", name); +#endif + fflush(stdout); + reading_size = 0L; +} + +#ifdef NEED_INCREMENTAL_INDICATOR +void +put_indicator(count) + long int count; +{ + reading_size += count; + if (!quiet && indicator_threshold) { + while (reading_size > indicator_count) { + putchar('o'); + fflush(stdout); + indicator_count += indicator_threshold; + } + } +} +#endif + +void +finish_indicator2(name, msg, pcnt) + char *name; + char *msg; + int pcnt; +{ + if (quiet) + return; + + if (pcnt > 100) + pcnt = 100; /* (^_^) */ +#ifdef NEED_INCREMENTAL_INDICATOR + carriage_return(); + printf("%s\t- %s(%d%%)\n", name, msg, pcnt); +#else + printf("%s\n", msg); +#endif + fflush(stdout); +} + +void +finish_indicator(name, msg) + char *name; + char *msg; +{ + if (quiet) + return; + +#ifdef NEED_INCREMENTAL_INDICATOR + carriage_return(); + printf("%s\t- %s\n", name, msg); +#else + printf("%s\n", msg); +#endif + fflush(stdout); +} diff -Nru lha-1.14i/src/larc.c lha-1.14i-acc20050924p1/src/larc.c --- lha-1.14i/src/larc.c 2000-10-04 14:57:38.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/larc.c 2002-11-16 19:03:23.000000000 +0000 @@ -1,85 +1,92 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* larc.c -- extra *.lzs */ -/* */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* LHa for UNIX */ +/* larc.c -- extra *.lzs */ +/* */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ /* ------------------------------------------------------------------------ */ #include "lha.h" /* ------------------------------------------------------------------------ */ static int flag, flagcnt, matchpos; /* ------------------------------------------------------------------------ */ +/* lzs */ unsigned short decode_c_lzs( /*void*/ ) { - if (getbits(1)) { - return getbits(8); - } - else { - matchpos = getbits(11); - return getbits(4) + 0x100; - } + if (getbits(1)) { + return getbits(8); + } + else { + matchpos = getbits(11); + return getbits(4) + 0x100; + } } /* ------------------------------------------------------------------------ */ +/* lzs */ unsigned short decode_p_lzs( /*void*/ ) { - return (loc - matchpos - MAGIC0) & 0x7ff; + return (loc - matchpos - MAGIC0) & 0x7ff; } /* ------------------------------------------------------------------------ */ +/* lzs */ void decode_start_lzs( /*void*/ ) { - init_getbits(); + init_getbits(); + init_code_cache(); } /* ------------------------------------------------------------------------ */ +/* lz5 */ unsigned short decode_c_lz5( /*void*/ ) { - int c; + int c; - if (flagcnt == 0) { - flagcnt = 8; - flag = getc(infile); - } - flagcnt--; - c = getc(infile); - if ((flag & 1) == 0) { - matchpos = c; - c = getc(infile); - matchpos += (c & 0xf0) << 4; - c &= 0x0f; - c += 0x100; - } - flag >>= 1; - return c; + if (flagcnt == 0) { + flagcnt = 8; + flag = getc(infile); + } + flagcnt--; + c = getc(infile); + if ((flag & 1) == 0) { + matchpos = c; + c = getc(infile); + matchpos += (c & 0xf0) << 4; + c &= 0x0f; + c += 0x100; + } + flag >>= 1; + return c; } /* ------------------------------------------------------------------------ */ +/* lz5 */ unsigned short decode_p_lz5( /*void*/ ) { - return (loc - matchpos - MAGIC5) & 0xfff; + return (loc - matchpos - MAGIC5) & 0xfff; } /* ------------------------------------------------------------------------ */ +/* lz5 */ void decode_start_lz5( /*void*/ ) { - int i; + int i; - flagcnt = 0; - for (i = 0; i < 256; i++) - memset(&text[i * 13 + 18], i, 13); - for (i = 0; i < 256; i++) - text[256 * 13 + 18 + i] = i; - for (i = 0; i < 256; i++) - text[256 * 13 + 256 + 18 + i] = 255 - i; - memset(&text[256 * 13 + 512 + 18], 0, 128); - memset(&text[256 * 13 + 512 + 128 + 18], ' ', 128 - 18); + flagcnt = 0; + for (i = 0; i < 256; i++) + memset(&text[i * 13 + 18], i, 13); + for (i = 0; i < 256; i++) + text[256 * 13 + 18 + i] = i; + for (i = 0; i < 256; i++) + text[256 * 13 + 256 + 18 + i] = 255 - i; + memset(&text[256 * 13 + 512 + 18], 0, 128); + memset(&text[256 * 13 + 512 + 128 + 18], ' ', 128 - 18); } diff -Nru lha-1.14i/src/lhadd.c lha-1.14i-acc20050924p1/src/lhadd.c --- lha-1.14i/src/lhadd.c 2000-10-04 14:57:38.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/lhadd.c 2006-10-10 16:27:51.000000000 +0000 @@ -1,11 +1,11 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* lhadd.c -- LHarc Add Command */ -/* */ -/* Copyright (C) MCMLXXXIX Yooichi.Tagawa */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* LHa for UNIX */ +/* lhadd.c -- LHarc Add Command */ +/* */ +/* Copyright (C) MCMLXXXIX Yooichi.Tagawa */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ /* ------------------------------------------------------------------------ */ #include "lha.h" /* ------------------------------------------------------------------------ */ @@ -16,272 +16,257 @@ /* ------------------------------------------------------------------------ */ static void add_one(fp, nafp, hdr) - FILE *fp, *nafp; - LzHeader *hdr; + FILE *fp, *nafp; + LzHeader *hdr; { - long header_pos, next_pos, org_pos, data_pos; - long v_original_size, v_packed_size; - int mode; - - reading_filename = hdr->name; - writting_filename = temporary_name; - - if (!fp && generic_format) /* [generic] doesn't need directory - * info. */ - return; - header_pos = ftell(nafp); - write_header(nafp, hdr);/* DUMMY */ - - if ((hdr->unix_mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK) { - char buf[256], *b1, *b2; - if (!quiet) { - strcpy(buf, hdr->name); - b1 = strtok(buf, "|"); - b2 = strtok(NULL, "|"); - printf("%s -> %s\t- Symbolic Link\n", b1, b2); - } /* if quiet .. */ - } - - if (hdr->original_size == 0) /* empty file or directory */ - return; /* previous write_header is not DUMMY. (^_^) */ - - org_pos = ftell(fp); - data_pos = ftell(nafp); - - hdr->crc = encode_lzhuf(fp, nafp, hdr->original_size, - &v_original_size, &v_packed_size, hdr->name, hdr->method); - - if (v_packed_size < v_original_size) { - next_pos = ftell(nafp); - } - else { /* retry by stored method */ - fseek(fp, org_pos, SEEK_SET); - fseek(nafp, data_pos, SEEK_SET); - hdr->crc = encode_stored_crc(fp, nafp, hdr->original_size, - &v_original_size, &v_packed_size); - fflush(nafp); - next_pos = ftell(nafp); -#ifndef NOFTRUNCATE - ftruncate(fileno(nafp), next_pos); + off_t header_pos, next_pos, org_pos, data_pos; + size_t v_original_size, v_packed_size; + + reading_filename = hdr->name; + writing_filename = temporary_name; + + if (!fp && generic_format) /* [generic] doesn't need directory info. */ + return; + header_pos = ftello(nafp); + write_header(nafp, hdr);/* DUMMY */ + + if ((hdr->unix_mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK) { + if (!quiet) + printf("%s -> %s\t- Symbolic Link\n", hdr->name, hdr->realname); + } + + if (hdr->original_size == 0) { /* empty file, symlink or directory */ + finish_indicator2(hdr->name, "Frozen", 0); + return; /* previous write_header is not DUMMY. (^_^) */ + } + org_pos = ftello(fp); + data_pos = ftello(nafp); + + hdr->crc = encode_lzhuf(fp, nafp, hdr->original_size, + &v_original_size, &v_packed_size, hdr->name, hdr->method); + + if (v_packed_size < v_original_size) { + next_pos = ftello(nafp); + } + else { /* retry by stored method */ + fseeko(fp, org_pos, SEEK_SET); + fseeko(nafp, data_pos, SEEK_SET); + hdr->crc = encode_stored_crc(fp, nafp, hdr->original_size, + &v_original_size, &v_packed_size); + fflush(nafp); + next_pos = ftello(nafp); +#if HAVE_FTRUNCATE + if (ftruncate(fileno(nafp), next_pos) == -1) + error("cannot truncate archive"); +#elif HAVE_CHSIZE + if (chsize(fileno(nafp), next_pos) == -1) + error("cannot truncate archive"); +#else + CAUSE COMPILE ERROR #endif - bcopy(LZHUFF0_METHOD, hdr->method, METHOD_TYPE_STRAGE); - } - hdr->original_size = v_original_size; - hdr->packed_size = v_packed_size; - fseek(nafp, header_pos, SEEK_SET); - write_header(nafp, hdr); - fseek(nafp, next_pos, SEEK_SET); + memcpy(hdr->method, LZHUFF0_METHOD, METHOD_TYPE_STORAGE); + } + hdr->original_size = v_original_size; + hdr->packed_size = v_packed_size; + fseeko(nafp, header_pos, SEEK_SET); + write_header(nafp, hdr); + fseeko(nafp, next_pos, SEEK_SET); } - -/* ------------------------------------------------------------------------ */ FILE * append_it(name, oafp, nafp) - char *name; - FILE *oafp, *nafp; + char *name; + FILE *oafp, *nafp; { - LzHeader ahdr, hdr; - FILE *fp; - long old_header; - int cmp; - int filec; - char **filev; - int i; - struct stat stbuf /*, lstbuf*/; - - boolean directory, symlink; - - if (GETSTAT(name, &stbuf) < 0) { - error("Cannot access", name); /* See cleaning_files, Why? */ - return oafp; - } - - directory = is_directory(&stbuf); + LzHeader ahdr, hdr; + FILE *fp; + long old_header; + int cmp; + int filec; + char **filev; + int i; + struct stat stbuf; + + boolean directory, symlink; + + if (GETSTAT(name, &stbuf) < 0) { + error("Cannot access file \"%s\"", name); /* See cleaning_files, Why? */ + return oafp; + } + + directory = is_directory(&stbuf); #ifdef S_IFLNK - symlink = is_symlink(&stbuf); + symlink = is_symlink(&stbuf); #else - symlink = 0; + symlink = 0; #endif - init_header(name, &stbuf, &hdr); - if (!directory && !noexec) - if (symlink) - fp = NULL; - else - fp = xfopen(name, READ_BINARY); - else { - fp = NULL; - } - - while (oafp) { - old_header = ftell(oafp); - if (!get_header(oafp, &ahdr)) { - fclose(oafp); - oafp = NULL; - break; - } else { -#if 0 - cmp = STRING_COMPARE(ahdr.name, hdr.name); -#endif - /* for symbolic link. t.okamoto */ - cmp = strcmp_filename(ahdr.name, hdr.name); - if (cmp < 0) { /* SKIP */ - /* copy old to new */ - if (!noexec) { - fseek(oafp, old_header, SEEK_SET); - copy_old_one(oafp, nafp, &ahdr); - } - else - fseek(oafp, ahdr.packed_size, SEEK_CUR); - } else if (cmp == 0) { /* REPLACE */ - /* drop old archive's */ - fseek(oafp, ahdr.packed_size, SEEK_CUR); - break; - } else { /* cmp > 0, INSERT */ - fseek(oafp, old_header, SEEK_SET); - break; - } - } - } - - if (update_if_newer) { - if (!oafp || /* not in archive */ - cmp > 0 || /* // */ - ahdr.unix_last_modified_stamp < /* newer than archive's */ - hdr.unix_last_modified_stamp) { - if (noexec) - printf("ADD %s\n", name); - else - add_one(fp, nafp, &hdr); - } else { /* cmp == 0 *//* copy old to new */ - if (!noexec) { - fseek(oafp, old_header, SEEK_SET); - copy_old_one(oafp, nafp, &ahdr); - } - } - } else { - if (!oafp || cmp > 0) { /* not in archive or dropped */ - if (noexec) - printf("ADD %s\n", name); - else - add_one(fp, nafp, &hdr); - } - else { /* cmp == 0 */ - /* replace */ - if (noexec) - printf("REPLACE\n"); - else - add_one(fp, nafp, &hdr); - } - } - - if (!directory) { - if (!noexec) - if (!symlink) - fclose(fp); - } - else { /* recurcive call */ - if (find_files(name, &filec, &filev)) { - for (i = 0; i < filec; i++) - oafp = append_it(filev[i], oafp, nafp); - free_files(filec, filev); - } - } - return oafp; + fp = NULL; + if (!directory && !symlink && !noexec) { + fp = fopen(name, READ_BINARY); + if (!fp) { + error("Cannot open file \"%s\": %s", name, strerror(errno)); + return oafp; + } + } + + init_header(name, &stbuf, &hdr); + + cmp = 0; /* avoid compiler warnings `uninitialized' */ + while (oafp) { + old_header = ftello(oafp); + if (!get_header(oafp, &ahdr)) { + /* end of archive or error occurred */ + fclose(oafp); + oafp = NULL; + break; + } + + cmp = strcmp(ahdr.name, hdr.name); + if (cmp < 0) { /* SKIP */ + /* copy old to new */ + if (!noexec) { + fseeko(oafp, old_header, SEEK_SET); + copy_old_one(oafp, nafp, &ahdr); + } + else + fseeko(oafp, ahdr.packed_size, SEEK_CUR); + } else if (cmp == 0) { /* REPLACE */ + /* drop old archive's */ + fseeko(oafp, ahdr.packed_size, SEEK_CUR); + break; + } else { /* cmp > 0, INSERT */ + fseeko(oafp, old_header, SEEK_SET); + break; + } + } + + if (!oafp || cmp > 0) { /* not in archive */ + if (noexec) + printf("ADD %s\n", name); + else + add_one(fp, nafp, &hdr); + } + else { /* cmp == 0 */ + if (!update_if_newer || + ahdr.unix_last_modified_stamp < hdr.unix_last_modified_stamp) { + /* newer than archive's */ + if (noexec) + printf("REPLACE %s\n", name); + else + add_one(fp, nafp, &hdr); + } + else { /* copy old to new */ + if (!noexec) { + fseeko(oafp, old_header, SEEK_SET); + copy_old_one(oafp, nafp, &ahdr); + } + } + } + + if (fp) fclose(fp); + + if (directory) { /* recursive call */ + if (find_files(name, &filec, &filev)) { + for (i = 0; i < filec; i++) + oafp = append_it(filev[i], oafp, nafp); + free_files(filec, filev); + } + } + return oafp; } /* ------------------------------------------------------------------------ */ static void find_update_files(oafp) - FILE *oafp; /* old archive */ + FILE *oafp; /* old archive */ { - char name[FILENAME_LENGTH]; - struct string_pool sp; - LzHeader hdr; - long pos; - struct stat stbuf; - int len; - - pos = ftell(oafp); - - init_sp(&sp); - while (get_header(oafp, &hdr)) { - 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 ((hdr.unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_DIRECTORY) { - strcpy(name, hdr.name); - len = strlen(name); - if (len > 0 && name[len - 1] == '/') - name[--len] = '\0'; /* strip tail '/' */ - if (stat(name, &stbuf) >= 0) /* exist ? */ - add_sp(&sp, name, len + 1); - } - fseek(oafp, hdr.packed_size, SEEK_CUR); - } + char name[FILENAME_LENGTH]; + struct string_pool sp; + LzHeader hdr; + off_t pos; + struct stat stbuf; + int len; + + pos = ftello(oafp); + + init_sp(&sp); + while (get_header(oafp, &hdr)) { + 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 ((hdr.unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_DIRECTORY) { + strcpy(name, hdr.name); /* ok */ + len = strlen(name); + if (len > 0 && name[len - 1] == '/') + name[--len] = '\0'; /* strip tail '/' */ + if (stat(name, &stbuf) >= 0) /* exist ? */ + add_sp(&sp, name, len + 1); + } + fseeko(oafp, hdr.packed_size, SEEK_CUR); + } - fseek(oafp, pos, SEEK_SET); + fseeko(oafp, pos, SEEK_SET); - finish_sp(&sp, &cmd_filec, &cmd_filev); + finish_sp(&sp, &cmd_filec, &cmd_filev); } /* ------------------------------------------------------------------------ */ static void delete(oafp, nafp) - FILE *oafp, *nafp; + FILE *oafp, *nafp; { - LzHeader ahdr; - long old_header_pos; - char lpath[256], *b1, *b2; - - old_header_pos = ftell(oafp); - while (get_header(oafp, &ahdr)) { - strcpy(lpath, ahdr.name); - b1 = strtok(lpath, "|"); - b2 = strtok(NULL, "|"); - if (need_file(b1)) { /* skip */ - fseek(oafp, ahdr.packed_size, SEEK_CUR); - if (noexec || !quiet) - if (b2 != NULL) - printf("delete %s -> %s\n", b1, b2); - else - printf("delete %s\n", b1); - } - else { /* copy */ - if (noexec) { - fseek(oafp, ahdr.packed_size, SEEK_CUR); - } - else { - fseek(oafp, old_header_pos, SEEK_SET); - copy_old_one(oafp, nafp, &ahdr); - } - } - old_header_pos = ftell(oafp); - } - return; + LzHeader ahdr; + off_t old_header_pos; + + old_header_pos = ftello(oafp); + while (get_header(oafp, &ahdr)) { + if (need_file(ahdr.name)) { /* skip */ + fseeko(oafp, ahdr.packed_size, SEEK_CUR); + if (noexec || !quiet) { + if ((ahdr.unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK) + message("delete %s -> %s", ahdr.name, ahdr.realname); + else + message("delete %s", ahdr.name); + } + } + else { /* copy */ + if (noexec) { + fseeko(oafp, ahdr.packed_size, SEEK_CUR); + } + else { + fseeko(oafp, old_header_pos, SEEK_SET); + copy_old_one(oafp, nafp, &ahdr); + } + } + old_header_pos = ftello(oafp); + } + return; } /* ------------------------------------------------------------------------ */ -/* */ +/* */ /* ------------------------------------------------------------------------ */ static FILE * build_temporary_file() { - int old_umask; - FILE *afp; + FILE *afp; + + signal(SIGINT, interrupt); +#ifdef SIGHUP + signal(SIGHUP, interrupt); +#endif - build_temporary_name(); - signal(SIGINT, interrupt); - signal(SIGHUP, interrupt); - - old_umask = umask(077); - afp = xfopen(temporary_name, WRITE_BINARY); - remove_temporary_at_error = TRUE; - temporary_fp = afp; - umask(old_umask); + temporary_fd = build_temporary_name(); + if (temporary_fd == -1) + fatal_error("Cannot open temporary file \"%s\"", temporary_name); + + afp = fdopen(temporary_fd, WRITE_BINARY); + if (afp == NULL) + fatal_error("Cannot open temporary file \"%s\"", temporary_name); - return afp; + return afp; } /* ------------------------------------------------------------------------ */ @@ -289,346 +274,383 @@ build_backup_file() { - build_backup_name(backup_archive_name, archive_name); - if (!noexec) { - signal(SIGINT, SIG_IGN); - signal(SIGHUP, SIG_IGN); - if (rename(archive_name, backup_archive_name) < 0) - fatal_error(archive_name); - recover_archive_when_interrupt = TRUE; - signal(SIGINT, interrupt); - signal(SIGHUP, interrupt); - } + build_backup_name(backup_archive_name, archive_name, + sizeof(backup_archive_name)); + if (!noexec) { + signal(SIGINT, SIG_IGN); +#ifdef SIGHUP + signal(SIGHUP, SIG_IGN); +#endif + if (rename(archive_name, backup_archive_name) < 0) { +#if __MINGW32__ + /* On MinGW, cannot rename when + newfile (backup_archive_name) already exists */ + if (unlink(backup_archive_name) < 0 || + rename(archive_name, backup_archive_name) < 0) +#endif + fatal_error("Cannot make backup file \"%s\"", archive_name); + } + recover_archive_when_interrupt = TRUE; + signal(SIGINT, interrupt); +#ifdef SIGHUP + signal(SIGHUP, interrupt); +#endif + } } /* ------------------------------------------------------------------------ */ static void report_archive_name_if_different() { - if (!quiet && new_archive_name == new_archive_name_buffer) { - /* warning at old archive is SFX */ - printf("New archive file is \"%s\"\n", new_archive_name); - } + if (!quiet && new_archive_name == new_archive_name_buffer) { + /* warning at old archive is SFX */ + message("New archive file is \"%s\"", new_archive_name); + } } /* ------------------------------------------------------------------------ */ -#ifdef TMP_FILENAME_TEMPLATE void temporary_to_new_archive_file(new_archive_size) - long new_archive_size; + size_t new_archive_size; { - FILE *oafp, *nafp; - - oafp = xfopen(temporary_name, READ_BINARY); - if (!strcmp(new_archive_name, "-")) { - nafp = stdout; - writting_filename = "starndard output"; - } - else { - nafp = xfopen(new_archive_name, WRITE_BINARY); - writting_filename = archive_name; - } - reading_filename = temporary_name; - copyfile(oafp, nafp, new_archive_size, 0); - if (nafp != stdout) - fclose(nafp); - fclose(oafp); + FILE *oafp, *nafp; - recover_archive_when_interrupt = FALSE; - unlink(temporary_name); + if (!strcmp(new_archive_name, "-")) { + nafp = stdout; + writing_filename = "starndard output"; +#if __MINGW32__ + setmode(fileno(stdout), O_BINARY); +#endif + } + else { + unlink(new_archive_name); + if (rename(temporary_name, new_archive_name) == 0) + return; + nafp = xfopen(new_archive_name, WRITE_BINARY); + writing_filename = archive_name; + } + + oafp = xfopen(temporary_name, READ_BINARY); + reading_filename = temporary_name; + copyfile(oafp, nafp, new_archive_size, 0, 0); + if (nafp != stdout) + fclose(nafp); + fclose(oafp); - remove_temporary_at_error = FALSE; + recover_archive_when_interrupt = FALSE; + unlink(temporary_name); } -#else -temporary_to_new_archive_file(new_archive_size) - long new_archive_size; -{ - char *p; - p = (char *) rindex(new_archive_name, '/'); - p = p ? p + 1 : new_archive_name; - unlink(new_archive_name); - if (rename(temporary_name, p) < 0) { - fprintf(stderr, "Can't rename temporary_name '%s'\n", new_archive_name); - exit(1); - } -} -#endif /* ------------------------------------------------------------------------ */ static void set_archive_file_mode() { - int umask_value; - struct stat stbuf; + int umask_value; + struct stat stbuf; - if (archive_file_gid < 0) { - umask(umask_value = umask(0)); - archive_file_mode = (~umask_value) & 0666; /* rw-rw-rw- */ - if (stat(".", &stbuf) >= 0) - archive_file_gid = stbuf.st_gid; - } - if (archive_file_gid >= 0) - chown(new_archive_name, getuid(), archive_file_gid); + if (archive_file_gid < 0) { + umask(umask_value = umask(0)); + archive_file_mode = (~umask_value) & 0666; /* rw-rw-rw- */ + if (stat(".", &stbuf) >= 0) + archive_file_gid = stbuf.st_gid; + } + if (archive_file_gid >= 0) + chown(new_archive_name, getuid(), archive_file_gid); - chmod(new_archive_name, archive_file_mode); + chmod(new_archive_name, archive_file_mode); } /* ------------------------------------------------------------------------ */ -/* REMOVE FILE/DIRECTORY */ +/* REMOVE FILE/DIRECTORY */ /* ------------------------------------------------------------------------ */ static void remove_one(name) - char *name; + char *name; { - struct stat stbuf; - int filec; - char **filev; - - if (GETSTAT(name, &stbuf) < 0) { - warning("Cannot access", name); - } - else if (is_directory(&stbuf)) { - if (find_files(name, &filec, &filev)) { - remove_files(filec, filev); - free_files(filec, filev); - } - else - warning("Cannot open directory", name); - - if (noexec) - printf("REMOVE DIRECTORY %s\n", name); - else if (rmdir(name) < 0) - warning("Cannot remove directory", name); - else if (verbose) - printf("Removed %s.\n", name); - } - else if (is_regularfile(&stbuf)) { - if (noexec) - printf("REMOVE FILE %s.\n", name); - else if (unlink(name) < 0) - warning("Cannot remove", name); - else if (verbose) - printf("Removed %s.\n", name); - } + struct stat stbuf; + int filec; + char **filev; + + if (GETSTAT(name, &stbuf) < 0) { + warning("Cannot access \"%s\": %s", name, strerror(errno)); + } + else if (is_directory(&stbuf)) { + if (find_files(name, &filec, &filev)) { + remove_files(filec, filev); + free_files(filec, filev); + } + else + warning("Cannot open directory \"%s\"", name); + + if (noexec) + message("REMOVE DIRECTORY %s", name); + else if (rmdir(name) < 0) + warning("Cannot remove directory \"%s\"", name); + else if (verbose) + message("Removed %s.", name); + } + else if (is_regularfile(&stbuf)) { + if (noexec) + message("REMOVE FILE %s.", name); + else if (unlink(name) < 0) + warning("Cannot remove \"%s\"", name); + else if (verbose) + message("Removed %s.", name); + } #ifdef S_IFLNK - else if (is_symlink(&stbuf)) { - if (noexec) - printf("REMOVE SYMBOLIC LINK %s.\n", name); - else if (unlink(name) < 0) - warning("Cannot remove", name); - else if (verbose) - printf("Removed %s.\n", name); - } + else if (is_symlink(&stbuf)) { + if (noexec) + printf("REMOVE SYMBOLIC LINK %s.\n", name); + else if (unlink(name) < 0) + warning("Cannot remove", name); + else if (verbose) + message("Removed %s.", name); + } #endif - else { - error("Cannot remove (not a file or directory)", name); - } + else { + error("Cannot remove file \"%s\" (not a file or directory)", name); + } } static void remove_files(filec, filev) - int filec; - char **filev; + int filec; + char **filev; { - int i; + int i; - for (i = 0; i < filec; i++) - remove_one(filev[i]); + for (i = 0; i < filec; i++) + remove_one(filev[i]); } /* ------------------------------------------------------------------------ */ -/* */ +/* */ /* ------------------------------------------------------------------------ */ void cmd_add() { - LzHeader ahdr; - FILE *oafp, *nafp; - int i; - long old_header; - boolean old_archive_exist; - long new_archive_size; - - /* exit if no operation */ - if (!update_if_newer && cmd_filec == 0) { - error("No files given in argument, do nothing.", ""); - return; - } - - /* open old archive if exist */ - if ((oafp = open_old_archive()) == NULL) - old_archive_exist = FALSE; - else - old_archive_exist = TRUE; - - if (update_if_newer && cmd_filec == 0 && !oafp) - fatal_error(archive_name); /* exit if cannot execute - * automatic update */ - errno = 0; - - if (new_archive && old_archive_exist) { - fclose(oafp); - oafp = NULL; - } - - if (oafp && archive_is_msdos_sfx1(archive_name)) { - skip_msdos_sfx1_code(oafp); - build_standard_archive_name(new_archive_name_buffer, archive_name); - new_archive_name = new_archive_name_buffer; - } - else { - new_archive_name = archive_name; - } - - /* build temporary file */ - if (!noexec) - nafp = build_temporary_file(); - - /* find needed files when automatic update */ - if (update_if_newer && cmd_filec == 0) - find_update_files(oafp); - - /* build new archive file */ - /* cleaning arguments */ - cleaning_files(&cmd_filec, &cmd_filev); - if (cmd_filec == 0) { - if (oafp) - fclose(oafp); - if (!noexec) - fclose(nafp); - return; - } - - for (i = 0; i < cmd_filec; i++) - oafp = append_it(cmd_filev[i], oafp, nafp); - if (oafp) { - old_header = ftell(oafp); - while (get_header(oafp, &ahdr)) { - if (noexec) - fseek(oafp, ahdr.packed_size, SEEK_CUR); - else { - fseek(oafp, old_header, SEEK_SET); - copy_old_one(oafp, nafp, &ahdr); - } - old_header = ftell(oafp); - } - fclose(oafp); - } - if (!noexec) { - write_archive_tail(nafp); - new_archive_size = ftell(nafp); - fclose(nafp); - } - - /* build backup archive file */ - if (old_archive_exist) - build_backup_file(); - - report_archive_name_if_different(); - - /* copy temporary file to new archive file */ - if (!noexec && (!strcmp(new_archive_name, "-") || - rename(temporary_name, new_archive_name) < 0)) - temporary_to_new_archive_file(new_archive_size); - - /* set new archive file mode/group */ - set_archive_file_mode(); - - /* remove archived files */ - if (delete_after_append) - remove_files(cmd_filec, cmd_filev); + LzHeader ahdr; + FILE *oafp, *nafp; + int i; + long old_header; + boolean old_archive_exist; + size_t new_archive_size; + + /* exit if no operation */ + if (!update_if_newer && cmd_filec == 0) { + error("No files given in argument, do nothing."); + exit(1); + } + + /* open old archive if exist */ + if ((oafp = open_old_archive()) == NULL) + old_archive_exist = FALSE; + else + old_archive_exist = TRUE; + + if (update_if_newer && cmd_filec == 0) { + warning("No files given in argument"); + if (!oafp) { + error("archive file \"%s\" does not exists.", + archive_name); + exit(1); + } + } + + if (new_archive && old_archive_exist) { + fclose(oafp); + oafp = NULL; + } + + if (oafp && archive_is_msdos_sfx1(archive_name)) { + seek_lha_header(oafp); + build_standard_archive_name(new_archive_name_buffer, + archive_name, + sizeof(new_archive_name_buffer)); + new_archive_name = new_archive_name_buffer; + } + else { + new_archive_name = archive_name; + } + + /* build temporary file */ + nafp = NULL; /* avoid compiler warnings `uninitialized' */ + if (!noexec) + nafp = build_temporary_file(); + + /* find needed files when automatic update */ + if (update_if_newer && cmd_filec == 0) + find_update_files(oafp); + + /* build new archive file */ + /* cleaning arguments */ + cleaning_files(&cmd_filec, &cmd_filev); + if (cmd_filec == 0) { + if (oafp) + fclose(oafp); + if (!noexec) + fclose(nafp); + return; + } + + for (i = 0; i < cmd_filec; i++) { + int j; + + if (strcmp(cmd_filev[i], archive_name) == 0) { + /* exclude target archive */ + warning("specified file \"%s\" is the generating archive. skip", + cmd_filev[i]); + for (j = i; j < cmd_filec-1; j++) + cmd_filev[j] = cmd_filev[j+1]; + cmd_filec--; + i--; + continue; + } + + /* exclude files specified by -x option */ + for (j = 0; exclude_files && exclude_files[j]; j++) { + if (fnmatch(exclude_files[j], basename(cmd_filev[i]), + FNM_PATHNAME|FNM_NOESCAPE|FNM_PERIOD) == 0) + goto next; + } + + oafp = append_it(cmd_filev[i], oafp, nafp); + next: + ; + } + + if (oafp) { + old_header = ftello(oafp); + while (get_header(oafp, &ahdr)) { + if (noexec) + fseeko(oafp, ahdr.packed_size, SEEK_CUR); + else { + fseeko(oafp, old_header, SEEK_SET); + copy_old_one(oafp, nafp, &ahdr); + } + old_header = ftello(oafp); + } + fclose(oafp); + } + + new_archive_size = 0; /* avoid compiler warnings `uninitialized' */ + if (!noexec) { + off_t tmp; + + write_archive_tail(nafp); + tmp = ftello(nafp); + if (tmp == -1) { + warning("ftello(): %s", strerror(errno)); + new_archive_size = 0; + } + else + new_archive_size = tmp; + + fclose(nafp); + } + + /* build backup archive file */ + if (old_archive_exist && backup_old_archive) + build_backup_file(); + + report_archive_name_if_different(); + + /* copy temporary file to new archive file */ + if (!noexec) { + if (strcmp(new_archive_name, "-") == 0 || + rename(temporary_name, new_archive_name) < 0) { + + temporary_to_new_archive_file(new_archive_size); + } + } + + /* set new archive file mode/group */ + set_archive_file_mode(); + + /* remove archived files */ + if (delete_after_append) + remove_files(cmd_filec, cmd_filev); - return; + return; } /* ------------------------------------------------------------------------ */ void cmd_delete() { - FILE *oafp, *nafp; - long new_archive_size; + FILE *oafp, *nafp; + size_t new_archive_size; + + /* open old archive if exist */ + if ((oafp = open_old_archive()) == NULL) + fatal_error("Cannot open archive file \"%s\"", archive_name); + + /* exit if no operation */ + if (cmd_filec == 0) { + fclose(oafp); + warning("No files given in argument, do nothing."); + return; + } + + if (archive_is_msdos_sfx1(archive_name)) { + seek_lha_header(oafp); + build_standard_archive_name(new_archive_name_buffer, + archive_name, + sizeof(new_archive_name_buffer)); + new_archive_name = new_archive_name_buffer; + } + else { + new_archive_name = archive_name; + } + + /* build temporary file */ + nafp = NULL; /* avoid compiler warnings `uninitialized' */ + if (!noexec) + nafp = build_temporary_file(); + + /* build new archive file */ + delete(oafp, nafp); + fclose(oafp); + + new_archive_size = 0; /* avoid compiler warnings `uninitialized' */ + if (!noexec) { + off_t tmp; + + write_archive_tail(nafp); + tmp = ftello(nafp); + if (tmp == -1) { + warning("ftello(): %s", strerror(errno)); + new_archive_size = 0; + } + else + new_archive_size = tmp; + + fclose(nafp); + } + + /* build backup archive file */ + if (backup_old_archive) + build_backup_file(); + + /* 1999.5.24 t.oka */ + if(!noexec && new_archive_size <= 1){ + unlink(temporary_name); + if (!backup_old_archive) + unlink(archive_name); + warning("The archive file \"%s\" was removed because it would be empty.", new_archive_name); + return; + } + + report_archive_name_if_different(); + + /* copy temporary file to new archive file */ + if (!noexec) { + if (rename(temporary_name, new_archive_name) < 0) + temporary_to_new_archive_file(new_archive_size); + } - /* open old archive if exist */ - if ((oafp = open_old_archive()) == NULL) - fatal_error(archive_name); - errno = 0; - - /* exit if no operation */ - if (cmd_filec == 0) { - fclose(oafp); - warning("No files given in argument, do nothing.", ""); - return; - } - - if (archive_is_msdos_sfx1(archive_name)) { - skip_msdos_sfx1_code(oafp); - build_standard_archive_name(new_archive_name_buffer, archive_name); - new_archive_name = new_archive_name_buffer; - } - else { - new_archive_name = archive_name; - } - - /* build temporary file */ - if (!noexec) - nafp = build_temporary_file(); - - /* build new archive file */ - delete(oafp, nafp); - fclose(oafp); - - if (!noexec) { - write_archive_tail(nafp); - new_archive_size = ftell(nafp); - fclose(nafp); - } - - /* build backup archive file */ - build_backup_file(); - - /* 1999.5.24 t.oka */ - if(!noexec && new_archive_size <= 1){ - unlink(temporary_name); - printf("New archive file \"%s\" is not created because it would be empty.\n", new_archive_name); - return; - } - - report_archive_name_if_different(); - - /* copy temporary file to new archive file */ - if (!noexec && rename(temporary_name, new_archive_name) < 0) - temporary_to_new_archive_file(new_archive_size); - - /* set new archive file mode/group */ - set_archive_file_mode(); - - return; -} - -/* for symbolic link name. t.okamoto 96/2/20 */ -int strcmp_filename( str1, str2 ) -char *str1; -char *str2; -{ - char *p, *q; - - p = str1; q = str2; - while (*p != 0 && *q != 0) { - if (*p == '|') { - if (*q == 0) return 0; - else if (*q != '|') return -1; - } else if (*q == '|') { - if (*p == 0) return 0; - else if (*q != '|') return 1; - } else if (*p != *q) break; - p++; q++; - } - return (int)*p-(int)*q; -} - - -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* compile-command:"gcc -c lhadd.c" */ -/* End: */ + /* set new archive file mode/group */ + set_archive_file_mode(); + + return; +} diff -Nru lha-1.14i/src/lha.h lha-1.14i-acc20050924p1/src/lha.h --- lha-1.14i/src/lha.h 2000-10-05 17:35:38.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/lha.h 2006-10-10 16:27:51.000000000 +0000 @@ -1,105 +1,301 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX Archiver Driver */ -/* */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 1.14 Soruce All chagned 1995.01.14 N.Watazaki */ -/* Ver. 1.14i Modified and bug fixed 2000.10.06 t.okamoto */ +/* LHa for UNIX Archiver Driver */ +/* */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Ver. 1.14 Soruce All chagned 1995.01.14 N.Watazaki */ +/* Ver. 1.14i Modified and bug fixed 2000.10.06 t.okamoto */ /* ------------------------------------------------------------------------ */ /* - Included... - lharc.h interface.h slidehuf.h + Included... + lharc.h interface.h slidehuf.h */ + +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include #include #include #include #include - #include +#if HAVE_INTTYPES_H +# include +#else +# if HAVE_STDINT_H +# include +# endif +#endif + +#if STDC_HEADERS +# include +#else +# if !HAVE_STRCHR +# define strchr index +# define strrchr rindex +# endif +char *strchr (), *strrchr (); +# if !HAVE_MEMCPY +# define memcmp(s1, s2, n) bcmp ((s1), (s2), (n)) +# define memcpy(d, s, n) bcopy ((s), (d), (n)) +# define memmove(d, s, n) bcopy ((s), (d), (n)) +# endif +#endif + +#if STDC_HEADERS +# include +# include +#else +# if HAVE_STDLIB_H +# include +# endif +#endif + +#ifndef NULL +#define NULL ((char *)0) +#endif + +#if HAVE_UNISTD_H +#include +#endif + +#if STDC_HEADERS +# include +# define va_init(a,b) va_start(a,b) +#else +# include +# define va_init(a,b) va_start(a) +#endif + +#if HAVE_PWD_H +# include +#endif +#if HAVE_GRP_H +# include +#endif + +#if !HAVE_UID_T +typedef int uid_t; +#endif +#if !HAVE_GID_T +typedef int gid_t; +#endif + +#if !HAVE_UINT64_T +# define HAVE_UINT64_T 1 +# if SIZEOF_LONG == 8 + typedef unsigned long uint64_t; +# elif HAVE_LONG_LONG + typedef unsigned long long uint64_t; +# else +# undef HAVE_UINT64_T +# endif +#endif + +#if !HAVE_SSIZE_T +typedef long ssize_t; +#endif + +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + +#if HAVE_UTIME_H +#include +#else +struct utimbuf { + time_t actime; + time_t modtime; +}; +int utime(const char *, struct utimbuf *); +#endif + +#if HAVE_DIRENT_H +# include +# define NAMLEN(dirent) strlen((dirent)->d_name) +#else +# define dirent direct +# define NAMLEN(dirent) (dirent)->d_namlen +# if HAVE_SYS_NDIR_H +# include +# endif +# if HAVE_SYS_DIR_H +# include +# endif +# if HAVE_NDIR_H +# include +# endif +# ifdef NONSYSTEM_DIR_LIBRARY /* no use ?? */ +# include "lhdir.h" +# endif +#endif + +#if HAVE_FNMATCH_H +# include +#else +int fnmatch(const char *pattern, const char *string, int flags); +# define FNM_PATHNAME 1 +# define FNM_NOESCAPE 2 +# define FNM_PERIOD 4 +#endif + +#ifndef SEEK_SET +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif /* SEEK_SET */ + +#if HAVE_LIMITS_H +#include +#else + +#ifndef CHAR_BIT +#define CHAR_BIT 8 +#endif + +#ifndef UCHAR_MAX +#define UCHAR_MAX ((1<<(sizeof(unsigned char)*8))-1) +#endif + +#ifndef USHRT_MAX +#define USHRT_MAX ((1<<(sizeof(unsigned short)*8))-1) +#endif + +#ifndef SHRT_MAX +#define SHRT_MAX ((1<<(sizeof(short)*8-1))-1) +#endif + +#ifndef SHRT_MIN +#define SHRT_MIN (SHRT_MAX-USHRT_MAX) +#endif + +#ifndef ULONG_MAX +#define ULONG_MAX ((1<<(sizeof(unsigned long)*8))-1) +#endif + +#ifndef LONG_MAX +#define LONG_MAX ((1<<(sizeof(long)*8-1))-1) +#endif + +#ifndef LONG_MIN +#define LONG_MIN (LONG_MAX-ULONG_MAX) +#endif + +#endif /* HAVE_LIMITS_H */ + +#if !HAVE_FSEEKO +# define fseeko fseek +#endif +#if !HAVE_FTELLO +# define ftello ftell +#endif + #include "lha_macro.h" +#define exit(n) lha_exit(n) + struct encode_option { #if defined(__STDC__) || defined(AIX) - void (*output) (); - void (*encode_start) (); - void (*encode_end) (); -#else - int (*output) (); - int (*encode_start) (); - int (*encode_end) (); + void (*output) (); + void (*encode_start) (); + void (*encode_end) (); +#else + int (*output) (); + int (*encode_start) (); + int (*encode_end) (); #endif }; struct decode_option { - unsigned short (*decode_c) (); - unsigned short (*decode_p) (); + unsigned short (*decode_c) (); + unsigned short (*decode_p) (); #if defined(__STDC__) || defined(AIX) - void (*decode_start) (); + void (*decode_start) (); #else - int (*decode_start) (); + int (*decode_start) (); #endif }; /* ------------------------------------------------------------------------ */ -/* LHa File Type Definition */ +/* LHa File Type Definition */ /* ------------------------------------------------------------------------ */ +typedef int boolean; /* TRUE or FALSE */ + struct string_pool { - int used; - int size; - int n; - char *buffer; + int used; + int size; + int n; + char *buffer; }; typedef struct LzHeader { - unsigned char header_size; - char method[METHOD_TYPE_STRAGE]; - long packed_size; - long original_size; - long last_modified_stamp; - unsigned char attribute; - unsigned char header_level; - char name[256]; - unsigned short crc; - boolean has_crc; - unsigned char extend_type; - unsigned char minor_version; - - /* extend_type == EXTEND_UNIX and convert from other type. */ - time_t unix_last_modified_stamp; - unsigned short unix_mode; - unsigned short unix_uid; - unsigned short unix_gid; + size_t header_size; + int size_field_length; + char method[METHOD_TYPE_STORAGE]; + size_t packed_size; + size_t original_size; + unsigned char attribute; + unsigned char header_level; + char name[FILENAME_LENGTH]; + char realname[FILENAME_LENGTH];/* real name for symbolic link */ + unsigned int crc; /* file CRC */ + boolean has_crc; /* file CRC */ + unsigned int header_crc; /* header CRC */ + unsigned char extend_type; + unsigned char minor_version; + + /* extend_type == EXTEND_UNIX and convert from other type. */ + time_t unix_last_modified_stamp; + unsigned short unix_mode; + unsigned short unix_uid; + unsigned short unix_gid; + char user[256]; + char group[256]; } LzHeader; struct interfacing { - FILE *infile; - FILE *outfile; - unsigned long original; - unsigned long packed; - int dicbit; - int method; + FILE *infile; + FILE *outfile; + size_t original; + size_t packed; + size_t read_size; + int dicbit; + int method; }; /* ------------------------------------------------------------------------ */ -/* Option switch variable */ +/* Option switch variable */ /* ------------------------------------------------------------------------ */ +#ifdef LHA_MAIN_SRC +#define EXTERN +#else +#define EXTERN extern +#endif + /* command line options (common options) */ EXTERN boolean quiet; EXTERN boolean text_mode; EXTERN boolean verbose; -EXTERN boolean noexec; /* debugging option */ +EXTERN boolean noexec; /* debugging option */ EXTERN boolean force; -EXTERN boolean prof; EXTERN boolean delete_after_append; -EXTERN int compress_method; -EXTERN int header_level; -/* EXTERN int quiet_mode; */ /* 1996.8.13 t.okamoto */ +EXTERN int compress_method; +EXTERN int header_level; +/* EXTERN int quiet_mode; */ /* 1996.8.13 t.okamoto */ #ifdef EUC -EXTERN boolean euc_mode; +EXTERN boolean euc_mode; #endif /* list command flags */ @@ -113,54 +309,46 @@ EXTERN boolean update_if_newer; EXTERN boolean generic_format; -EXTERN boolean remove_temporary_at_error; -EXTERN boolean recover_archive_when_interrupt; -EXTERN boolean remove_extracting_file_when_interrupt; -EXTERN boolean get_filename_from_stdin; -EXTERN boolean ignore_directory; -EXTERN boolean verify_mode; +EXTERN boolean remove_temporary_at_error; +EXTERN boolean recover_archive_when_interrupt; +EXTERN boolean remove_extracting_file_when_interrupt; +EXTERN boolean get_filename_from_stdin; +EXTERN boolean ignore_directory; +EXTERN char **exclude_files; +EXTERN boolean verify_mode; /* Indicator flag */ -EXTERN int quiet_mode; +EXTERN int quiet_mode; + +EXTERN boolean backup_old_archive; +EXTERN boolean extract_broken_archive; /* ------------------------------------------------------------------------ */ -/* Globale Variable */ +/* Globale Variable */ /* ------------------------------------------------------------------------ */ -EXTERN char **cmd_filev; +EXTERN char **cmd_filev; EXTERN int cmd_filec; -EXTERN char *archive_name; -EXTERN char expanded_archive_name[FILENAME_LENGTH]; +EXTERN char *archive_name; EXTERN char temporary_name[FILENAME_LENGTH]; EXTERN char backup_archive_name[FILENAME_LENGTH]; -EXTERN char *reading_filename, *writting_filename; - -/* 1996.8.13 t.okamoto */ -#if 0 -EXTERN boolean remove_temporary_at_error; -EXTERN boolean recover_archive_when_interrupt; -EXTERN boolean remove_extracting_file_when_interrupt; -#endif +EXTERN char *extract_directory; +EXTERN char *reading_filename, *writing_filename; EXTERN int archive_file_mode; EXTERN int archive_file_gid; -EXTERN struct interfacing interface; -EXTERN node *next; -/* EXTERN unsigned short crc; */ /* 1996.8.13 t.okamoto */ - EXTERN int noconvertcase; /* 2000.10.6 */ /* slide.c */ EXTERN int unpackable; -EXTERN unsigned long origsize, compsize; +EXTERN size_t origsize, compsize; EXTERN unsigned short dicbit; EXTERN unsigned short maxmatch; -EXTERN unsigned long count; -EXTERN unsigned long loc; /* short -> long .. Changed N.Watazaki */ +EXTERN size_t decode_count; +EXTERN unsigned long loc; /* short -> long .. Changed N.Watazaki */ EXTERN unsigned char *text; -EXTERN int prev_char; /* huf.c */ #ifndef LHA_MAIN_SRC /* t.okamoto 96/2/20 */ @@ -170,153 +358,21 @@ EXTERN unsigned short p_freq[], pt_table[], pt_code[], t_freq[]; #endif -/* append.c */ -#ifdef NEED_INCREMENTAL_INDICATOR -EXTERN long indicator_count; -EXTERN long indicator_threshold; -#endif +/* bitio.c */ +EXTERN FILE *infile, *outfile; +EXTERN unsigned short bitbuf; /* crcio.c */ -EXTERN FILE *infile, *outfile; -EXTERN unsigned short crc, bitbuf; +EXTERN unsigned int crctable[UCHAR_MAX + 1]; EXTERN int dispflg; -EXTERN long reading_size; /* from dhuf.c */ EXTERN unsigned int n_max; /* lhadd.c */ -EXTERN FILE *temporary_fp; +EXTERN int temporary_fd; /* ------------------------------------------------------------------------ */ -/* Functions */ +/* Functions */ /* ------------------------------------------------------------------------ */ -/* from lharc.c */ -extern int patmatch(); - -extern void interrupt(); - -extern void message(); -extern void warning(); -extern void error(); -extern void fatal_error(); - -extern boolean need_file(); -extern int inquire(); -extern FILE *xfopen(); - -extern boolean find_files(); -extern void free_files(); - -extern void init_sp(); -extern void add_sp(); -extern void finish_sp(); -extern void free_sp(); -extern void cleaning_files(); - -extern void build_temporary_name(); -extern void build_backup_file_name(); -extern void build_standard_archive_name(); - -extern FILE *open_old_archive(); -extern void init_header(); -extern boolean get_header(); -extern boolean archive_is_msdos_sfx1(); -extern boolean skip_msdos_sfx1_code(); -extern void write_header(); -extern void write_archive_tail(); -extern void copy_old_one(); -extern unsigned char *convdelim(); -extern long copyfile(); - -extern void cmd_list(), cmd_extract(), cmd_add(), cmd_delete(); - -extern boolean ignore_directory; -extern boolean compress_method; -extern boolean verify_mode; - -extern char *extract_directory; - -/* from slide.c */ - -extern int encode_alloc(); -extern void encode(); -extern void decode(); - -/* from append.c */ -extern void start_indicator(); -extern void finish_indicator(); -extern void finish_indicator2(); - -/* slide.c */ -extern void output_st1(); -extern unsigned char *alloc_buf(); -extern void encode_start_st1(); -extern void encode_end_st1(); -extern unsigned short decode_c_st1(); -extern unsigned short decode_p_st1(); -extern void decode_start_st1(); - -/* from shuf.c */ -extern void decode_start_st0(); -extern void encode_p_st0( /* unsigned short j */ ); -extern void encode_start_fix(); -extern void decode_start_fix(); -extern unsigned short decode_c_st0(); -extern unsigned short decode_p_st0(); - -/* from dhuf.c */ -extern void start_c_dyn(); -extern void decode_start_dyn(); -extern unsigned short decode_c_dyn(); -extern unsigned short decode_p_dyn(); -extern void output_dyn( /* int code, unsigned int pos */ ); -extern void encode_end_dyn(); - -extern int decode_lzhuf(); - -/* from larc.c */ - -extern unsigned short decode_c_lzs(); -extern unsigned short decode_p_lzs(); -extern unsigned short decode_c_lz5(); -extern unsigned short decode_p_lz5(); -extern void decode_start_lzs(); -extern void decode_start_lz5(); - -extern void make_table( /* int nchar, uchar bitlen[], int tablebits, - ushort table[] */ ); - -/* from maketree.c */ -/* - * void make_code(short n, uchar len[], ushort code[]); short make_tree(short - * nparm, ushort freqparm[], uchar lenparm[], ushort codeparam[]); - */ -extern void make_code( /* int n, uchar len[], ushort code[] */ ); -extern short make_tree( /* int nparm, ushort freqparm[], uchar lenparm[], - ushort codeparam[] */ ); - -/* from crcio.c */ -extern void make_crctable(); -extern unsigned short calccrc( /* uchar *p, uint n */ ); -extern void fillbuf( /* uchar n */ ); -extern unsigned short getbits( /* uchar n */ ); -extern void putcode( /* uchar n, ushort x */ ); -extern void putbits( /* uchar n, ushort x */ ); -extern int fread_crc( /* uchar *p, int n, FILE *f */ ); -extern void fwrite_crc( /* uchar *p, int n, FILE *f */ ); -extern void init_getbits(); -extern void init_putbits(); -extern void make_crctable(); -extern unsigned short calccrc(); - -/* from lhadd.c */ -extern int encode_lzhuf(); -extern int encode_stored_crc(); - -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* End: */ - - +#include "prototypes.h" diff -Nru lha-1.14i/src/lha_macro.h lha-1.14i-acc20050924p1/src/lha_macro.h --- lha-1.14i/src/lha_macro.h 2012-04-22 16:48:31.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/lha_macro.h 2006-10-10 16:39:06.000000000 +0000 @@ -1,115 +1,55 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX Archiver Driver macro define */ -/* */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 1.14 Soruce All chagned 1995.01.14 N.Watazaki */ -/* Ver. 1.14g modified 2000.05.06 T.OKAMOTO */ +/* LHa for UNIX Archiver Driver macro define */ +/* */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Ver. 1.14 Soruce All chagned 1995.01.14 N.Watazaki */ +/* Ver. 1.14g modified 2000.05.06 T.OKAMOTO */ /* ------------------------------------------------------------------------ */ -#define LHA_VERSION "lha for unix version 1.14i" +#define FALSE 0 +#define TRUE 1 -/* Most of System V, define SYSTIME_HAS_NO_TM */ -#ifdef SYSTIME_HAS_NO_TM -#include -#else -#include -#endif /* SYSTIME_HAS_NO_TM */ - -/* ------------------------------------------------------------------------ */ -/* Directory Access Stuff */ -/* ------------------------------------------------------------------------ */ -#ifndef NODIRECTORY -#ifdef SYSV_SYSTEM_DIR - -#include - -#define DIRENTRY struct dirent -#define NAMLEN(p) strlen (p->d_name) - -#else /* not SYSV_SYSTEM_DIR */ - -#ifdef NONSYSTEM_DIR_LIBRARY -#include "lhdir.h" -#else -#include -#endif /* not NONSYSTEM_DIR_LIBRARY */ +#define FILENAME_LENGTH 1024 -#define DIRENTRY struct direct -#define NAMLEN(p) p->d_namlen - -#endif /* not SYSV_SYSTEM_DIR */ -#endif /* NODIRECTORY */ - -/* ------------------------------------------------------------------------ */ -/* Other Define */ -/* ------------------------------------------------------------------------ */ -/* Not support 'void' */ -#ifdef NOVOID -#define void -#endif - -#ifndef SEEK_SET -#define SEEK_SET 0 -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif /* SEEK_SET - - -/* non-integral functions */ -extern struct tm *localtime(); -extern char *getenv(); - -#ifndef _MINIX -#ifndef __STDC__ -extern char *malloc(); -extern char *realloc(); -#endif +#if defined __MINGW32__ +# define getuid() 0 +# define chown(file, uid, gid) 0 +# define kill(pid, sig) 0 #endif -/* external variables */ -extern int errno; - -#define FALSE 0 -#define TRUE 1 -typedef int boolean; - -/* used by qsort() for alphabetic-sort */ -#define STRING_COMPARE(a,b) strcmp((a),(b)) - -#define FILENAME_LENGTH 1024 - /* ------------------------------------------------------------------------ */ -/* YOUR CUSTOMIZIES */ +/* YOUR CUSTOMIZIES */ /* ------------------------------------------------------------------------ */ #ifndef ARCHIVENAME_EXTENTION -#define ARCHIVENAME_EXTENTION ".lzh" +#define ARCHIVENAME_EXTENTION ".lzh" #endif #ifndef BACKUPNAME_EXTENTION -#define BACKUPNAME_EXTENTION ".bak" -#endif -#ifndef TMP_FILENAME_TEMPLATE -#define TMP_FILENAME_TEMPLATE "/tmp/lhXXXXXX" +#define BACKUPNAME_EXTENTION ".bak" #endif -#define SJC_FIRST_P(c) \ - (((unsigned char)(c) >= 0x80) && \ - (((unsigned char)(c) < 0xa0) || \ - ((unsigned char)(c) >= 0xe0) && \ - ((unsigned char)(c) < 0xfd))) -#define SJC_SECOND_P(c) \ - (((unsigned char)(c) >= 0x40) && \ - ((unsigned char)(c) < 0xfd) && \ - ((unsigned char)(c) != 0x7f)) - -#ifdef MULTIBYTE_CHAR -#define MULTIBYTE_FIRST_P SJC_FIRST_P -#define MULTIBYTE_SECOND_P SJC_SECOND_P -#endif /* MULTIBYTE_CHAR */ +#define SJIS_FIRST_P(c) \ + (((unsigned char)(c) >= 0x80 && (unsigned char)(c) < 0xa0) || \ + ((unsigned char)(c) >= 0xe0 && (unsigned char)(c) < 0xfd)) +#define SJIS_SECOND_P(c) \ + (((unsigned char)(c) >= 0x40 && (unsigned char)(c) < 0xfd) && \ + (unsigned char)(c) != 0x7f) + +#define X0201_KANA_P(c)\ + (0xa0 < (unsigned char)(c) && (unsigned char)(c) < 0xe0) + +/* for filename conversion */ +#define NONE 0 +#define CODE_EUC 1 +#define CODE_SJIS 2 +#define CODE_UTF8 3 +#define CODE_CAP 4 /* Columbia AppleTalk Program */ +#define TO_LOWER 1 +#define TO_UPPER 2 /* ------------------------------------------------------------------------ */ -/* LHa File Definitions */ +/* LHa File Definitions */ /* ------------------------------------------------------------------------ */ #ifdef S_IFLNK #define GETSTAT lstat @@ -117,216 +57,149 @@ #define GETSTAT stat #endif -#ifdef LHA_MAIN_SRC -#define EXTERN -#else -#define EXTERN extern -#endif /* LHA_MAIN_SRC */ - -#define LZHUFF0_METHOD "-lh0-" -#define LZHUFF1_METHOD "-lh1-" -#define LZHUFF2_METHOD "-lh2-" -#define LZHUFF3_METHOD "-lh3-" -#define LZHUFF4_METHOD "-lh4-" -#define LZHUFF5_METHOD "-lh5-" -#define LZHUFF6_METHOD "-lh6-" -#define LZHUFF7_METHOD "-lh7-" -#define LARC_METHOD "-lzs-" -#define LARC5_METHOD "-lz5-" -#define LARC4_METHOD "-lz4-" -#define LZHDIRS_METHOD "-lhd-" +#define LZHUFF0_METHOD "-lh0-" +#define LZHUFF1_METHOD "-lh1-" +#define LZHUFF2_METHOD "-lh2-" +#define LZHUFF3_METHOD "-lh3-" +#define LZHUFF4_METHOD "-lh4-" +#define LZHUFF5_METHOD "-lh5-" +#define LZHUFF6_METHOD "-lh6-" +#define LZHUFF7_METHOD "-lh7-" +#define LARC_METHOD "-lzs-" +#define LARC5_METHOD "-lz5-" +#define LARC4_METHOD "-lz4-" +#define LZHDIRS_METHOD "-lhd-" -#define METHOD_TYPE_STRAGE 5 +#define METHOD_TYPE_STORAGE 5 /* Added N.Watazaki ..V */ -#define LZHUFF0_METHOD_NUM 0 -#define LZHUFF1_METHOD_NUM 1 -#define LZHUFF2_METHOD_NUM 2 -#define LZHUFF3_METHOD_NUM 3 -#define LZHUFF4_METHOD_NUM 4 -#define LZHUFF5_METHOD_NUM 5 -#define LZHUFF6_METHOD_NUM 6 -#define LZHUFF7_METHOD_NUM 7 -#define LARC_METHOD_NUM 8 -#define LARC5_METHOD_NUM 9 -#define LARC4_METHOD_NUM 10 -#define LZHDIRS_METHOD_NUM 11 +#define LZHUFF0_METHOD_NUM 0 +#define LZHUFF1_METHOD_NUM 1 +#define LZHUFF2_METHOD_NUM 2 +#define LZHUFF3_METHOD_NUM 3 +#define LZHUFF4_METHOD_NUM 4 +#define LZHUFF5_METHOD_NUM 5 +#define LZHUFF6_METHOD_NUM 6 +#define LZHUFF7_METHOD_NUM 7 +#define LARC_METHOD_NUM 8 +#define LARC5_METHOD_NUM 9 +#define LARC4_METHOD_NUM 10 +#define LZHDIRS_METHOD_NUM 11 /* Added N.Watazaki ..^ */ -#define I_HEADER_SIZE 0 -#define I_HEADER_CHECKSUM 1 -#define I_METHOD 2 -#define I_PACKED_SIZE 7 -#define I_ORIGINAL_SIZE 11 -#define I_LAST_MODIFIED_STAMP 15 -#define I_ATTRIBUTE 19 -#define I_HEADER_LEVEL 20 -#define I_NAME_LENGTH 21 -#define I_NAME 22 - -#define I_CRC 22 /* + name_length */ -#define I_EXTEND_TYPE 24 /* + name_length */ -#define I_MINOR_VERSION 25 /* + name_length */ -#define I_UNIX_LAST_MODIFIED_STAMP 26 /* + name_length */ -#define I_UNIX_MODE 30 /* + name_length */ -#define I_UNIX_UID 32 /* + name_length */ -#define I_UNIX_GID 34 /* + name_length */ -#define I_UNIX_EXTEND_BOTTOM 36 /* + name_length */ - -#define I_GENERIC_HEADER_BOTTOM I_EXTEND_TYPE - -#define EXTEND_GENERIC 0 -#define EXTEND_UNIX 'U' -#define EXTEND_MSDOS 'M' -#define EXTEND_MACOS 'm' -#define EXTEND_OS9 '9' -#define EXTEND_OS2 '2' -#define EXTEND_OS68K 'K' -#define EXTEND_OS386 '3' /* OS-9000??? */ -#define EXTEND_HUMAN 'H' -#define EXTEND_CPM 'C' -#define EXTEND_FLEX 'F' -#define EXTEND_RUNSER 'R' - -/* this OS type is not official */ +#define LZHUFF0_DICBIT 0 /* no compress */ +#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 */ -#define EXTEND_TOWNSOS 'T' -#define EXTEND_XOSK 'X' - -/*---------------------------------------------------------------------------*/ - -#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 - -#define DELIM ('/') -#define DELIM2 (0xff) -#define DELIMSTR "/" - -#define OSK_RW_RW_RW 0000033 -#define OSK_FILE_REGULAR 0000000 -#define OSK_DIRECTORY_PERM 0000200 -#define OSK_SHARED_PERM 0000100 -#define OSK_OTHER_EXEC_PERM 0000040 -#define OSK_OTHER_WRITE_PERM 0000020 -#define OSK_OTHER_READ_PERM 0000010 -#define OSK_OWNER_EXEC_PERM 0000004 -#define OSK_OWNER_WRITE_PERM 0000002 -#define OSK_OWNER_READ_PERM 0000001 - -#define UNIX_FILE_TYPEMASK 0170000 -#define UNIX_FILE_REGULAR 0100000 -#define UNIX_FILE_DIRECTORY 0040000 -#define UNIX_FILE_SYMLINK 0120000 -#define UNIX_SETUID 0004000 -#define UNIX_SETGID 0002000 -#define UNIX_STYCKYBIT 0001000 -#define UNIX_OWNER_READ_PERM 0000400 -#define UNIX_OWNER_WRITE_PERM 0000200 -#define UNIX_OWNER_EXEC_PERM 0000100 -#define UNIX_GROUP_READ_PERM 0000040 -#define UNIX_GROUP_WRITE_PERM 0000020 -#define UNIX_GROUP_EXEC_PERM 0000010 -#define UNIX_OTHER_READ_PERM 0000004 -#define UNIX_OTHER_WRITE_PERM 0000002 -#define UNIX_OTHER_EXEC_PERM 0000001 -#define UNIX_RW_RW_RW 0000666 - -#define LZHEADER_STRAGE 4096 - -#define MAX_INDICATOR_COUNT 64 - -typedef short node; - -/* ------------------------------------------------------------------------ */ -/* Slide relation */ -/* ------------------------------------------------------------------------ */ -#if defined(__STDC__) || defined(AIX) - -#include - -#else - -#ifndef CHAR_BIT -#define CHAR_BIT 8 +#ifdef SUPPORT_LH7 +#define MAX_DICBIT LZHUFF7_DICBIT /* lh7 use 16bits */ #endif - -#ifndef UCHAR_MAX -#define UCHAR_MAX ((1<<(sizeof(unsigned char)*8))-1) +#ifndef SUPPORT_LH7 +#define MAX_DICBIT LZHUFF6_DICBIT /* lh6 use 15bits */ #endif -#ifndef USHRT_MAX -#define USHRT_MAX ((1<<(sizeof(unsigned short)*8))-1) -#endif +#define MAX_DICSIZ (1L << MAX_DICBIT) -#ifndef SHRT_MAX -#define SHRT_MAX ((1<<(sizeof(short)*8-1))-1) -#endif +#define EXTEND_GENERIC 0 +#define EXTEND_UNIX 'U' +#define EXTEND_MSDOS 'M' +#define EXTEND_MACOS 'm' +#define EXTEND_OS9 '9' +#define EXTEND_OS2 '2' +#define EXTEND_OS68K 'K' +#define EXTEND_OS386 '3' /* OS-9000??? */ +#define EXTEND_HUMAN 'H' +#define EXTEND_CPM 'C' +#define EXTEND_FLEX 'F' +#define EXTEND_RUNSER 'R' -#ifndef SHRT_MIN -#define SHRT_MIN (SHRT_MAX-USHRT_MAX) -#endif +/* this OS type is not official */ -#ifndef ULONG_MAX -#define ULONG_MAX ((1<<(sizeof(unsigned long)*8))-1) -#endif +#define EXTEND_TOWNSOS 'T' +#define EXTEND_XOSK 'X' /* OS-9 for X68000 (?) */ +#define EXTEND_JAVA 'J' -#ifndef LONG_MAX -#define LONG_MAX ((1<<(sizeof(long)*8-1))-1) -#endif +/*---------------------------------------------------------------------------*/ -#ifndef LONG_MIN -#define LONG_MIN (LONG_MAX-ULONG_MAX) -#endif +#define GENERIC_ATTRIBUTE 0x20 +#define GENERIC_DIRECTORY_ATTRIBUTE 0x10 -#endif /* not __STDC__ */ +#define CURRENT_UNIX_MINOR_VERSION 0x00 -/* ------------------------------------------------------------------------ */ -/* FILE Attribute */ -/* ------------------------------------------------------------------------ */ -#define is_directory(statp) (((statp)->st_mode & S_IFMT) == S_IFDIR) -#define is_symlink(statp) (((statp)->st_mode & S_IFMT) == S_IFLNK) -#define is_regularfile(statp) (((statp)->st_mode & S_IFMT) == S_IFREG) - -#ifdef MSDOS -#define WRITE_BINARY "wb" -#define READ_BINARY "rb" +#define LHA_PATHSEP 0xff /* path separator of the + filename in lha header. + it should compare with + `unsigned char' or `int', + that is not '\xff', but 0xff. */ + +#define OSK_RW_RW_RW 0000033 +#define OSK_FILE_REGULAR 0000000 +#define OSK_DIRECTORY_PERM 0000200 +#define OSK_SHARED_PERM 0000100 +#define OSK_OTHER_EXEC_PERM 0000040 +#define OSK_OTHER_WRITE_PERM 0000020 +#define OSK_OTHER_READ_PERM 0000010 +#define OSK_OWNER_EXEC_PERM 0000004 +#define OSK_OWNER_WRITE_PERM 0000002 +#define OSK_OWNER_READ_PERM 0000001 + +#define UNIX_FILE_TYPEMASK 0170000 +#define UNIX_FILE_REGULAR 0100000 +#define UNIX_FILE_DIRECTORY 0040000 +#define UNIX_FILE_SYMLINK 0120000 +#define UNIX_SETUID 0004000 +#define UNIX_SETGID 0002000 +#define UNIX_STICKYBIT 0001000 +#define UNIX_OWNER_READ_PERM 0000400 +#define UNIX_OWNER_WRITE_PERM 0000200 +#define UNIX_OWNER_EXEC_PERM 0000100 +#define UNIX_GROUP_READ_PERM 0000040 +#define UNIX_GROUP_WRITE_PERM 0000020 +#define UNIX_GROUP_EXEC_PERM 0000010 +#define UNIX_OTHER_READ_PERM 0000004 +#define UNIX_OTHER_WRITE_PERM 0000002 +#define UNIX_OTHER_EXEC_PERM 0000001 +#define UNIX_RW_RW_RW 0000666 + +#define LZHEADER_STORAGE 4096 + +/* ------------------------------------------------------------------------ */ +/* FILE Attribute */ +/* ------------------------------------------------------------------------ */ +#define is_directory(statp) (((statp)->st_mode & S_IFMT) == S_IFDIR) +#define is_symlink(statp) (((statp)->st_mode & S_IFMT) == S_IFLNK) +#define is_regularfile(statp) (((statp)->st_mode & S_IFMT) == S_IFREG) + +#if 1 /* assume that fopen() will accepts "b" as binary mode on all systems. */ +#define WRITE_BINARY "wb" +#define READ_BINARY "rb" #else -#define WRITE_BINARY "w" -#define READ_BINARY "r" +#define WRITE_BINARY "w" +#define READ_BINARY "r" #endif /* ------------------------------------------------------------------------ */ -/* Memory and String function */ +/* Individual macro define */ /* ------------------------------------------------------------------------ */ -#include - -#ifdef NOINDEX -#define index strchr -#define rindex strrchr -#endif /* NOINDEX */ - -#ifdef NOBSTRING -#define bcmp(a,b,n) memcmp ((a),(b),(n)) -#define bzero(d,n) memset((d),0,(n)) -#define bcopy(s,d,n) memmove((d),(s),(n)) -#endif /* NOBSTRING */ -#ifdef USESTRCASECMP -#define strucmp(p,q) strcasecmp((p),(q)) -#endif +#define MIN(a,b) ((a) <= (b) ? (a) : (b)) -/* ------------------------------------------------------------------------ */ -/* Individual macro define */ -/* ------------------------------------------------------------------------ */ +/* bitio.c */ +#define peekbits(n) (bitbuf >> (sizeof(bitbuf)*8 - (n))) -/* from crcio.c */ -#define CRCPOLY 0xA001 /* CRC-16 */ -#define UPDATE_CRC(c) crc = crctable[(crc ^ (c)) & 0xFF] ^ (crc >> CHAR_BIT) +/* 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) \ + (crctable[((crc) ^ (c)) & 0xFF] ^ ((crc) >> CHAR_BIT)) /* dhuf.c */ #define N_CHAR (256 + 60 - THRESHOLD + 1) @@ -336,56 +209,41 @@ #define ROOT_C 0 #define ROOT_P TREESIZE_C -/* header.c */ -#define setup_get(PTR) (get_ptr = (PTR)) -#define get_byte() (*get_ptr++ & 0xff) -#define put_ptr get_ptr -#define setup_put(PTR) (put_ptr = (PTR)) -#define put_byte(c) (*put_ptr++ = (char)(c)) - /* huf.c */ -#define NP (MAX_DICBIT + 1) -#define NT (USHRT_BIT + 3) -#if 0 -#define PBIT 4 /* smallest integer such that (1 << PBIT) > * NP */ -#define TBIT 5 /* smallest integer such that (1 << TBIT) > * NT */ -#endif - -#define PBIT 5 /* smallest integer such that (1 << PBIT) > * NP */ -#define TBIT 5 /* smallest integer such that (1 << TBIT) > * NT */ - -#define NC (UCHAR_MAX + MAXMATCH + 2 - THRESHOLD) +#define USHRT_BIT 16 /* (CHAR_BIT * sizeof(ushort)) */ +#define NP (MAX_DICBIT + 1) +#define NT (USHRT_BIT + 3) +#define NC (UCHAR_MAX + MAXMATCH + 2 - THRESHOLD) + +#define PBIT 5 /* smallest integer such that (1 << PBIT) > * NP */ +#define TBIT 5 /* smallest integer such that (1 << TBIT) > * NT */ +#define CBIT 9 /* smallest integer such that (1 << CBIT) > * NC */ -/* #if NT > NP #define NPT NT #else #define NPT NP #endif */ -#define NPT 0x80 +/* #if NT > NP #define NPT NT #else #define NPT NP #endif */ +#define NPT 0x80 /* larc.c */ -#define MAGIC0 18 -#define MAGIC5 19 +#define MAGIC0 18 +#define MAGIC5 19 /* lharc.c */ -#define CMD_UNKNOWN 0 -#define CMD_EXTRACT 1 -#define CMD_ADD 2 -#define CMD_LIST 3 -#define CMD_DELETE 4 +#define CMD_UNKNOWN 0 +#define CMD_EXTRACT 1 +#define CMD_ADD 2 +#define CMD_LIST 3 +#define CMD_DELETE 4 -#define STREQU(a,b) (((a)[0] == (b)[0]) ? (strcmp ((a),(b)) == 0) : FALSE) +#define STREQU(a,b) (((a)[0] == (b)[0]) ? (strcmp ((a),(b)) == 0) : FALSE) /* shuf.c */ -#define N1 286 /* alphabet size */ -#define N2 (2 * N1 - 1) /* # of nodes in Huffman tree */ -#define EXTRABITS 8 /* >= log2(F-THRESHOLD+258-N1) */ -#define BUFBITS 16 /* >= log2(MAXBUF) */ -#define LENFIELD 4 /* bit size of length field for tree output */ +#define N1 286 /* alphabet size */ +#define N2 (2 * N1 - 1) /* # of nodes in Huffman tree */ +#define EXTRABITS 8 /* >= log2(F-THRESHOLD+258-N1) */ +#define BUFBITS 16 /* >= log2(MAXBUF) */ +#define LENFIELD 4 /* bit size of length field for tree output */ /* util.c */ -#define BUFFERSIZE 2048 -#define MAXSFXCODE 1024*64 - -#ifndef NULL -#define NULL (char *)0 -#endif +#define BUFFERSIZE 2048 /* slide.c */ /* @@ -395,26 +253,5 @@ */ /* slide.c */ -#ifdef SUPPORT_LH7 -#define MAX_DICBIT 16 /* lh7 use 16bits */ -#endif - -#ifndef SUPPORT_LH7 -#define MAX_DICBIT 15 /* lh6 use 15bits */ -#endif - -#define MAX_DICSIZ (1 << MAX_DICBIT) -#define MATCHBIT 8 /* bits for MAXMATCH - THRESHOLD */ -#define MAXMATCH 256 /* formerly F (not more than UCHAR_MAX + 1) */ -#define THRESHOLD 3 /* choose optimal value */ - -/* from huf.c */ - -/* alphabet = {0, 1, 2, ..., NC - 1} */ -#define CBIT 9 /* $\lfloor \log_2 NC \rfloor + 1$ */ -#define USHRT_BIT 16 /* (CHAR_BIT * sizeof(ushort)) */ - -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* End: */ +#define MAXMATCH 256 /* formerly F (not more than UCHAR_MAX + 1) */ +#define THRESHOLD 3 /* choose optimal value */ diff -Nru lha-1.14i/src/lharc.c lha-1.14i-acc20050924p1/src/lharc.c --- lha-1.14i/src/lharc.c 2000-10-05 17:33:34.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/lharc.c 2006-10-10 16:27:51.000000000 +0000 @@ -1,41 +1,41 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* lharc.c -- append to archive */ -/* */ -/* Copyright (C) MCMLXXXIX Yooichi.Tagawa */ -/* Modified Nobutaka Watazaki */ -/* Thanks to H.Yoshizaki. (MS-DOS LHarc) */ -/* */ -/* Ver. 0.00 Original 1988.05.23 Y.Tagawa */ -/* Ver. 0.01 Alpha Version (for 4.2BSD) 1989.05.28 Y.Tagawa */ -/* Ver. 0.02 Alpha Version Rel.2 1989.05.29 Y.Tagawa */ -/* Ver. 0.03 Release #3 Beta Version 1989.07.02 Y.Tagawa */ -/* Ver. 0.03a Debug 1989.07.03 Y.Tagawa */ -/* Ver. 0.03b Modified 1989.07.13 Y.Tagawa */ -/* Ver. 0.03c Debug (Thanks to void@rena.dit.junet) */ -/* 1989.08.09 Y.Tagawa */ -/* Ver. 0.03d Modified (quiet and verbose) 1989.09.14 Y.Tagawa */ -/* V1.00 Fixed 1989.09.22 Y.Tagawa */ -/* V1.01 Bug Fixed 1989.12.25 Y.Tagawa */ -/* */ -/* DOS-Version Original LHx V C2.01 (C) H.Yohizaki */ -/* */ -/* V2.00 UNIX Lharc + DOS LHx -> OSK LHx 1990.11.01 Momozou */ -/* V2.01 Minor Modified 1990.11.24 Momozou */ -/* */ -/* Ver. 0.02 LHx for UNIX 1991.11.18 M.Oki */ -/* Ver. 0.03 LHa for UNIX 1991.12.17 M.Oki */ -/* Ver. 0.04 LHa for UNIX beta version 1992.01.20 M.Oki */ -/* Ver. 1.00 LHa for UNIX Fixed 1992.03.19 M.Oki */ -/* */ -/* Ver. 1.10 for Symblic Link 1993.06.25 N.Watazaki */ -/* Ver. 1.11 for Symblic Link Bug Fixed 1993.08.18 N.Watazaki */ -/* Ver. 1.12 for File Date Check 1993.10.28 N.Watazaki */ -/* Ver. 1.13 Bug Fixed (Idicator calcurate) 1994.02.21 N.Watazaki */ -/* Ver. 1.13a Bug Fixed (Sym. Link delete) 1994.03.11 N.Watazaki */ -/* Ver. 1.13b Bug Fixed (Sym. Link delete) 1994.07.29 N.Watazaki */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ -/* Ver. 1.14b,c Bug Fixed 1996.03.07 t.okamoto */ +/* LHa for UNIX */ +/* lharc.c -- append to archive */ +/* */ +/* Copyright (C) MCMLXXXIX Yooichi.Tagawa */ +/* Modified Nobutaka Watazaki */ +/* Thanks to H.Yoshizaki. (MS-DOS LHarc) */ +/* */ +/* Ver. 0.00 Original 1988.05.23 Y.Tagawa */ +/* Ver. 0.01 Alpha Version (for 4.2BSD) 1989.05.28 Y.Tagawa */ +/* Ver. 0.02 Alpha Version Rel.2 1989.05.29 Y.Tagawa */ +/* Ver. 0.03 Release #3 Beta Version 1989.07.02 Y.Tagawa */ +/* Ver. 0.03a Debug 1989.07.03 Y.Tagawa */ +/* Ver. 0.03b Modified 1989.07.13 Y.Tagawa */ +/* Ver. 0.03c Debug (Thanks to void@rena.dit.junet) */ +/* 1989.08.09 Y.Tagawa */ +/* Ver. 0.03d Modified (quiet and verbose) 1989.09.14 Y.Tagawa */ +/* V1.00 Fixed 1989.09.22 Y.Tagawa */ +/* V1.01 Bug Fixed 1989.12.25 Y.Tagawa */ +/* */ +/* DOS-Version Original LHx V C2.01 (C) H.Yohizaki */ +/* */ +/* V2.00 UNIX Lharc + DOS LHx -> OSK LHx 1990.11.01 Momozou */ +/* V2.01 Minor Modified 1990.11.24 Momozou */ +/* */ +/* Ver. 0.02 LHx for UNIX 1991.11.18 M.Oki */ +/* Ver. 0.03 LHa for UNIX 1991.12.17 M.Oki */ +/* Ver. 0.04 LHa for UNIX beta version 1992.01.20 M.Oki */ +/* Ver. 1.00 LHa for UNIX Fixed 1992.03.19 M.Oki */ +/* */ +/* Ver. 1.10 for Symbolic Link 1993.06.25 N.Watazaki */ +/* Ver. 1.11 for Symbolic Link Bug Fixed 1993.08.18 N.Watazaki */ +/* Ver. 1.12 for File Date Check 1993.10.28 N.Watazaki */ +/* Ver. 1.13 Bug Fixed (Idicator calcurate) 1994.02.21 N.Watazaki */ +/* Ver. 1.13a Bug Fixed (Sym. Link delete) 1994.03.11 N.Watazaki */ +/* Ver. 1.13b Bug Fixed (Sym. Link delete) 1994.07.29 N.Watazaki */ +/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* Ver. 1.14b,c Bug Fixed 1996.03.07 t.okamoto */ /* Ver. 1.14d Version up 1997.01.12 t.okamoto */ /* Ver. 1.14g Bug Fixed 2000.05.06 t.okamoto */ /* Ver. 1.14i Modified 2000.10.06 t.okamoto */ @@ -44,109 +44,107 @@ #include "lha.h" -/* ------------------------------------------------------------------------ */ -/* PROGRAM */ -/* ------------------------------------------------------------------------ */ static int cmd = CMD_UNKNOWN; - -/* 1996.8.13 t.okamoto */ -#if 0 -char **cmd_filev; -int cmd_filec; - -char *archive_name; -char expanded_archive_name[FILENAME_LENGTH]; -char temporary_name[FILENAME_LENGTH]; -char backup_archive_name[FILENAME_LENGTH]; -#endif +static int error_occurred; /* static functions */ static void sort_files(); -static void print_version(); +static void print_version(); -char *extract_directory = NULL; -char **xfilev; -int xfilec = 257; - -/* 1996.8.13 t.okamoto */ -#if 0 -char *writting_filename; -char *reading_filename; +extern int optional_archive_kanji_code; +extern int optional_system_kanji_code; -int archive_file_mode; -int archive_file_gid; -#endif /* ------------------------------------------------------------------------ */ static void -init_variable() /* Added N.Watazaki */ +init_variable() /* Added N.Watazaki */ { /* options */ - quiet = FALSE; - text_mode = FALSE; - verbose = FALSE; - noexec = FALSE; /* debugging option */ - force = FALSE; - prof = FALSE; -#ifndef SUPPORT_LH7 - compress_method = LZHUFF5_METHOD_NUM; -#endif -#ifdef SUPPORT_LH7 - compress_method = LZHUFF7_METHOD_NUM; -#endif + quiet = FALSE; + text_mode = FALSE; + verbose = 0; + noexec = FALSE; /* debugging option */ + force = FALSE; + + compress_method = DEFAULT_LZHUFF_METHOD; /* defined in config.h */ - header_level = HEADER_LEVEL1; - quiet_mode = 0; + header_level = 2; /* level 2 */ + quiet_mode = 0; #ifdef EUC - euc_mode = FALSE; + euc_mode = FALSE; #endif /* view command flags */ - verbose_listing = FALSE; + verbose_listing = FALSE; /* extract command flags */ - output_to_stdout = FALSE; + output_to_stdout = FALSE; /* append command flags */ - new_archive = FALSE; - update_if_newer = FALSE; - delete_after_append = FALSE; - generic_format = FALSE; - - remove_temporary_at_error = FALSE; - recover_archive_when_interrupt = FALSE; - remove_extracting_file_when_interrupt = FALSE; - get_filename_from_stdin = FALSE; - ignore_directory = FALSE; - verify_mode = FALSE; - - noconvertcase = FALSE; - - extract_directory = NULL; - xfilec = 257; + new_archive = FALSE; + update_if_newer = FALSE; + delete_after_append = FALSE; + generic_format = FALSE; + + recover_archive_when_interrupt = FALSE; + remove_extracting_file_when_interrupt = FALSE; + get_filename_from_stdin = FALSE; + ignore_directory = FALSE; + exclude_files = NULL; + verify_mode = FALSE; + + noconvertcase = FALSE; + + extract_directory = NULL; + temporary_fd = -1; + +#if BACKUP_OLD_ARCHIVE + backup_old_archive = TRUE; +#else + backup_old_archive = FALSE; +#endif + + extract_broken_archive = FALSE; } /* ------------------------------------------------------------------------ */ -/* NOTES : Text File Format */ -/* GENERATOR NewLine */ -/* [generic] 0D 0A */ -/* [MS-DOS] 0D 0A */ -/* [OS9][MacOS] 0D */ -/* [UNIX] 0A */ +/* NOTES : Text File Format */ +/* GENERATOR NewLine */ +/* [generic] 0D 0A */ +/* [MS-DOS] 0D 0A */ +/* [OS9][MacOS] 0D */ +/* [UNIX] 0A */ /* ------------------------------------------------------------------------ */ static void -print_tiny_usage_and_exit() +print_tiny_usage() +{ + fprintf(stderr, "\ +usage: lha [-][] [- ...] archive_file [file...]\n\ + commands: [axelvudmcpt]\n\ + options: [q[012]vnfto[567]dizg012e[w=|x=]]\n\ + long options: --system-kanji-code={euc,sjis,utf8,cap}\n\ + --archive-kanji-code={euc,sjis,utf8,cap}\n\ + --extract-broken-archive\n\ + --help\n\ + --version\n"); +} + +static void +print_usage() { - fprintf(stderr, "\ + fprintf(stderr, "\ LHarc for UNIX V 1.02 Copyright(C) 1989 Y.Tagawa\n\ LHx for MSDOS V C2.01 Copyright(C) 1990 H.Yoshizaki\n\ LHx(arc) for OSK V 2.01 Modified 1990 Momozou\n\ LHa for UNIX V 1.00 Copyright(C) 1992 Masaru Oki\n\ LHa for UNIX V 1.14 Modified 1995 Nobutaka Watazaki\n\ LHa for UNIX V 1.14i Modified 2000 Tsugio Okamoto\n\ + Autoconfiscated 2001-2005 Koji Arai\n\ "); - fprintf(stderr, "\ -usage: lha [-]{axelvudmcp[q[num]][vnfodizg012]}[w=] archive_file [file...]\n\ + + print_tiny_usage(); + + fprintf(stderr, "\ commands: options:\n\ a Add(or replace) to archive q{num} quiet (num:quiet mode)\n\ x,e EXtract from archive v verbose\n\ @@ -154,982 +152,1245 @@ u Update newer files to archive f force (over write at extract)\n\ d Delete from archive t FILES are TEXT file\n"); #ifdef SUPPORT_LH7 - fprintf(stderr, "\ - m Move to archive (means 'ad') o[567] compression method (a/u)\n\ + fprintf(stderr, "\ + m Move to archive (means 'ad') o[567] compression method (a/u/c)\n\ "); #endif #ifndef SUPPORT_LH7 - fprintf(stderr, "\ - m Move to archive (means 'ad') o use LHarc compatible method (a/u)\n\ + fprintf(stderr, "\ + m Move to archive (means 'ad') o use LHarc compatible method (a/u/c)\n\ "); #endif - fprintf(stderr, "\ - c re-Construct new archive w= specify extract directory (a/u/m/x/e)\n\ - p Print to STDOUT from archive d delete FILES after (a/u/c)\n\ - t Test file CRC in archive i ignore directory path (x/e)\n\ - z files not compress (a/u)\n\ + fprintf(stderr, "\ + c re-Construct new archive d delete FILES after (a/u/c)\n\ + p Print to STDOUT from archive i ignore directory path (x/e)\n\ + t Test file CRC in archive z files not compress (a/u/c)\n\ g Generic format (for compatibility)\n\ or not convert case when extracting\n\ - 0/1/2 header level (a/u)\n\ + 0/1/2 header level (a/u/c)\n\ "); #ifdef EUC - fprintf(stderr, "\ + fprintf(stderr, "\ e TEXT code convert from/to EUC\n\ "); #endif - exit(1); + fprintf(stderr, "\ + w= specify extract directory (x/e)\n\ + x= eXclude files (a/u/c)\n\ +"); +#if IGNORE_DOT_FILES /* experimental feature */ + fprintf(stderr, "\ + X ignore dot files (a/u/c)\n\ +"); +#endif } -/* ------------------------------------------------------------------------ */ -int -main(argc, argv) - int argc; - char *argv[]; -{ - char *p, inpbuf[256]; +#include "getopt_long.h" - int i; - int ac; - char **av, *m; - - init_variable(); /* Added N.Watazaki */ - - ac = argc; - av = (char **)malloc( sizeof(char*)*argc ); - if (av == NULL) fatal_error("not enough memory\n"); - for (i=0; i= xfilec) { - xfilec += 256; - cmd_filev = (char **) realloc(xfilev, - sizeof(char *) * xfilec); - if (cmd_filev == NULL) - fatal_error("Virtual memory exhausted\n"); - xfilev = cmd_filev; - } - if (strlen(inpbuf) < 1) - continue; - if ((xfilev[cmd_filec++] = (char *) strdup(inpbuf)) == NULL) - fatal_error("Virtual memory exhausted\n"); - } - xfilev[cmd_filec] = NULL; - cmd_filev = xfilev; - } else { - cmd_filec = ac - 3; - cmd_filev = av + 3; - } - sort_files(); - - /* make crc table */ - make_crctable(); - - switch (cmd) { - case CMD_EXTRACT: - cmd_extract(); - break; - case CMD_ADD: - cmd_add(); - break; - case CMD_LIST: - cmd_list(); - break; - case CMD_DELETE: - cmd_delete(); - break; - } - -#ifdef USE_PROF - if (!prof) - exit(0); + case '6': + compress_method = LZHUFF6_METHOD_NUM; + break; + case '7': + compress_method = LZHUFF7_METHOD_NUM; + break; #endif + default: + error("invalid compression method 'o%c'", *optarg); + return -1; + } + break; + case 'z': + compress_method = LZHUFF0_METHOD_NUM; /* Changed N.Watazaki */ + break; + case 'i': + ignore_directory = TRUE; + break; + case 'x': + if (!optarg) { + error("exclude files does not specified for `-x'"); + exit(2); + } + + for (i = 0; exclude_files && exclude_files[i]; i++) + ; + exclude_files = (char**)xrealloc(exclude_files, + sizeof(char*) * (i+2)); + + if (*optarg == '=') + optarg++; + exclude_files[i] = optarg; + exclude_files[i+1] = 0; + + break; +#if IGNORE_DOT_FILES /* experimental feature */ + case 'X': + for (i = 0; exclude_files && exclude_files[i]; i++) + ; + exclude_files = (char**)xrealloc(exclude_files, + sizeof(char*) * (i+2)); + + exclude_files[i] = xstrdup(".*"); + exclude_files[i+1] = 0; + break; +#endif + case 'w': + if (!optarg) { + error("working directory does not specified for `-w'"); + exit(2); + } + if (*optarg == '=') + optarg++; + + extract_directory = optarg; + break; + case '0': + header_level = 0; + break; + case '1': + header_level = 1; + break; + case '2': + header_level = 2; + break; + case SYSTEM_KANJI_CODE_OPTION: + if (!optarg) { + error("kanji code not specified for --%s", + long_options[option_index].name); + return -1; + } + if (strcmp(optarg, "euc") == 0) { + optional_system_kanji_code = CODE_EUC; + } + else if (strcmp(optarg, "sjis") == 0) { + optional_system_kanji_code = CODE_SJIS; + } + else if (strcmp(optarg, "utf8") == 0) { + optional_system_kanji_code = CODE_UTF8; + } + else if (strcmp(optarg, "cap") == 0) { + optional_system_kanji_code = CODE_CAP; + } + else { + error("unknown kanji code \"%s\"", optarg); + return -1; + } + break; + + case ARCHIVE_KANJI_CODE_OPTION: + if (!optarg) { + error("kanji code not specified for --%s", + long_options[option_index].name); + return -1; + } + if (strcmp(optarg, "euc") == 0) { + optional_archive_kanji_code = CODE_EUC; + } + else if (strcmp(optarg, "sjis") == 0) { + optional_archive_kanji_code = CODE_SJIS; + } + else if (strcmp(optarg, "utf8") == 0) { + optional_archive_kanji_code = CODE_UTF8; + } + else if (strcmp(optarg, "cap") == 0) { + optional_archive_kanji_code = CODE_CAP; + } + else { + error("unknown kanji code \"%s\"", optarg); + return -1; + } + break; + + default: + error("unknown option `-%c'.", c); + return -1; + } + } + + argc -= optind; + argv += optind; + + if (!archive_name) { + archive_name = *argv++; + argc--; + } + + cmd_filec = argc; + cmd_filev = argv; - return 0; + return 0; } +/* + Parse LHA command and options. +*/ +static int +parse_option(int argc, char **argv) +{ + char *cmd_char; -/* ------------------------------------------------------------------------ */ -/* */ -/* ------------------------------------------------------------------------ */ + if (argv[1] == NULL || strcmp(argv[1], "--help") == 0) { + print_usage(); + exit(0); + } + + if (strcmp(argv[1], "--version") == 0) { + print_version(); + exit(0); + } + + if (argc == 2 && *argv[1] != '-') { + archive_name = argv[1]; + cmd = CMD_LIST; + cmd_filec = 0; + cmd_filev = 0; + return 0; + } + + cmd_char = argv[1]; + + if (cmd_char[0] == '-') + cmd_char++; + + /* parse commands */ + switch (*cmd_char) { + case 'x': + case 'e': + cmd = CMD_EXTRACT; + break; + + case 'p': + output_to_stdout = TRUE; + cmd = CMD_EXTRACT; + break; + + case 'c': + new_archive = TRUE; + cmd = CMD_ADD; + break; + + case 'a': + cmd = CMD_ADD; + break; + + case 'd': + cmd = CMD_DELETE; + break; + + case 'u': + update_if_newer = TRUE; + cmd = CMD_ADD; + break; + + case 'm': + delete_after_append = TRUE; + cmd = CMD_ADD; + break; + + case 'v': + verbose_listing = TRUE; + cmd = CMD_LIST; + break; + + case 'l': + cmd = CMD_LIST; + break; + + case 't': + cmd = CMD_EXTRACT; + verify_mode = TRUE; + break; + + default: + error("unknown command `-%c'", *cmd_char); + return -1; + } + + if (cmd_char[1] == '\0') { + /* argv[1] is command name */ + argv[1] = argv[0]; + argv++; + argc--; + } + else { + /* Eliminate command character + e.g.) lha cv foo.lzh -> lha -v foo.lzh + lha -cv foo.lzh -> lha -v foo.lzh + */ + cmd_char[0] = '-'; + argv[1] = cmd_char; + } -/* ------------------------------------------------------------------------ */ -static void -print_version() -{ - fprintf(stderr, "%s\n", LHA_VERSION); + return parse_suboption(argc, argv); } /* ------------------------------------------------------------------------ */ -static void -message_1(title, subject, name) - char *title, *subject, *name; +int +main(argc, argv) + int argc; + char *argv[]; { - fprintf(stderr, "LHa: %s%s ", title, subject); - fflush(stderr); + char *p; + + int i; + + init_variable(); /* Added N.Watazaki */ + + if (parse_option(argc, argv) == -1) { + fputs("\n", stderr); + print_tiny_usage(); + exit(2); + } + + if (!archive_name) { + error("archive file does not specified"); + fputs("\n", stderr); + print_tiny_usage(); + exit(2); + } + + if (!strcmp(archive_name, "-")) { + if (!isatty(1) && cmd == CMD_ADD) + quiet = TRUE; + } +#if 0 /* Comment out; IMHO, this feature is useless. by Koji Arai */ + else { + if (argc == 3 && !isatty(0)) { /* 1999.7.18 */ + /* Bug(?) on MinGW, isatty() return 0 on Cygwin console. + mingw-runtime-1.3-2 and Cygwin 1.3.10(0.51/3/2) on Win2000 */ + get_filename_from_stdin = TRUE; + } + } +#endif - if (errno == 0) - fprintf(stderr, "%s\n", name); - else - perror(name); + /* target file name */ + if (get_filename_from_stdin) { + char inpbuf[4096]; + char **xfilev; + int xfilec = 257; + + cmd_filec = 0; + xfilev = (char **)xmalloc(sizeof(char *) * xfilec); + while (fgets(inpbuf, sizeof(inpbuf), stdin)) { + /* delete \n if it exist */ + i=0; p=inpbuf; + while (i < sizeof(inpbuf) && p != 0) { + if (*p == '\n') { + *p = 0; + break; + } + p++; i++; + } + + if (cmd_filec >= xfilec) { + xfilec += 256; + xfilev = (char **) xrealloc(xfilev, + sizeof(char *) * xfilec); + } + if (strlen(inpbuf) < 1) + continue; + xfilev[cmd_filec++] = xstrdup(inpbuf); + } + xfilev[cmd_filec] = NULL; + cmd_filev = xfilev; + } + + sort_files(); + + /* make crc table */ + make_crctable(); + + switch (cmd) { + case CMD_EXTRACT: + cmd_extract(); + break; + case CMD_ADD: + cmd_add(); + break; + case CMD_LIST: + cmd_list(); + break; + case CMD_DELETE: + cmd_delete(); + break; + } + + if (error_occurred) + return 1; + return 0; } + /* ------------------------------------------------------------------------ */ -void -message(subject, name) - char *subject, *name; +static void +print_version() { - message_1("", subject, name); + /* macro PACKAGE_NAME, PACKAGE_VERSION and PLATFORM are + defined in config.h by configure script */ + fprintf(stderr, "%s version %s (%s)\n", + PACKAGE_NAME, PACKAGE_VERSION, PLATFORM); } -/* ------------------------------------------------------------------------ */ void -warning(subject, name) - char *subject, *name; +#if STDC_HEADERS +message(char *fmt, ...) +#else +message(fmt, va_alist) + char *fmt; + va_dcl +#endif { - message_1("Warning: ", subject, name); + int errno_sv = errno; + va_list v; + + fprintf(stderr, "LHa: "); + + va_init(v, fmt); + vfprintf(stderr, fmt, v); + va_end(v); + + fputs("\n", stderr); + + errno = errno_sv; } /* ------------------------------------------------------------------------ */ void -error(subject, msg) - char *subject, *msg; +#if STDC_HEADERS +warning(char *fmt, ...) +#else +warning(fmt, va_alist) + char *fmt; + va_dcl +#endif { - message_1("Error: ", subject, msg); + int errno_sv = errno; + va_list v; + + fprintf(stderr, "LHa: Warning: "); + + va_init(v, fmt); + vfprintf(stderr, fmt, v); + va_end(v); + + fputs("\n", stderr); + + errno = errno_sv; } /* ------------------------------------------------------------------------ */ void -fatal_error(msg) - char *msg; +#if STDC_HEADERS +error(char *fmt, ...) +#else +error(fmt, va_alist) + char *fmt; + va_dcl +#endif { - message_1("Fatal error:", "", msg); + int errno_sv = errno; + va_list v; + + fprintf(stderr, "LHa: Error: "); + + va_init(v, fmt); + vfprintf(stderr, fmt, v); + va_end(v); - if (remove_temporary_at_error) - unlink(temporary_name); + fputs("\n", stderr); - exit(1); + error_occurred = 1; + + errno = errno_sv; } -/* ------------------------------------------------------------------------ */ void -write_error() +#if STDC_HEADERS +fatal_error(char *fmt, ...) +#else +fatal_error(fmt, va_alist) + char *fmt; + va_dcl +#endif { - fatal_error(writting_filename); + int errno_sv = errno; + va_list v; + + fprintf(stderr, "LHa: Fatal error: "); + + va_init(v, fmt); + vfprintf(stderr, fmt, v); + va_end(v); + + if (errno) + fprintf(stderr, ": %s\n", strerror(errno_sv)); + else + fputs("\n", stderr); + + exit(1); } -/* ------------------------------------------------------------------------ */ void -read_error() +cleanup() { - fatal_error(reading_filename); + if (temporary_fd != -1) { + close(temporary_fd); + temporary_fd = -1; + unlink(temporary_name); + } + + if (recover_archive_when_interrupt) { + rename(backup_archive_name, archive_name); + recover_archive_when_interrupt = FALSE; + } + if (remove_extracting_file_when_interrupt) { + message("Removing: %s", writing_filename); + unlink(writing_filename); + remove_extracting_file_when_interrupt = FALSE; + } } -/* ------------------------------------------------------------------------ */ -void +RETSIGTYPE interrupt(signo) - int signo; + int signo; { - errno = 0; - message("Interrupted\n", ""); + message("Interrupted"); + + cleanup(); - if (temporary_fp) - fclose(temporary_fp); - unlink(temporary_name); - if (recover_archive_when_interrupt) - rename(backup_archive_name, archive_name); - if (remove_extracting_file_when_interrupt) { - errno = 0; - message("Removing", writting_filename); - unlink(writting_filename); - } - signal(SIGINT, SIG_DFL); - signal(SIGHUP, SIG_DFL); - kill(getpid(), signo); + signal(SIGINT, SIG_DFL); +#ifdef SIGHUP + signal(SIGHUP, SIG_DFL); +#endif + kill(getpid(), signo); } /* ------------------------------------------------------------------------ */ -/* */ +/* */ /* ------------------------------------------------------------------------ */ static int sort_by_ascii(a, b) - char **a, **b; + char **a, **b; { - register char *p, *q; - register int c1, c2; + register char *p, *q; + register int c1, c2; - p = *a, q = *b; - if (generic_format) { - do { - c1 = *(unsigned char *) p++; - c2 = *(unsigned char *) q++; - if (!c1 || !c2) - break; - if (islower(c1)) - c1 = toupper(c1); - if (islower(c2)) - c2 = toupper(c2); - } - while (c1 == c2); - return c1 - c2; - } - else { - while (*p == *q && *p != '\0') - p++, q++; - return *(unsigned char *) p - *(unsigned char *) q; - } + p = *a, q = *b; + if (generic_format) { + do { + c1 = *(unsigned char *) p++; + c2 = *(unsigned char *) q++; + if (!c1 || !c2) + break; + if (islower(c1)) + c1 = toupper(c1); + if (islower(c2)) + c2 = toupper(c2); + } + while (c1 == c2); + return c1 - c2; + } + else { + while (*p == *q && *p != '\0') + p++, q++; + return *(unsigned char *) p - *(unsigned char *) q; + } } /* ------------------------------------------------------------------------ */ static void sort_files() { - if (cmd_filec > 1) - qsort(cmd_filev, cmd_filec, sizeof(char *), sort_by_ascii); + if (cmd_filec > 1) + qsort(cmd_filev, cmd_filec, sizeof(char *), sort_by_ascii); } /* ------------------------------------------------------------------------ */ -char * +void * xmalloc(size) - int size; + size_t size; { - char *p = (char *) malloc(size); - if (!p) - fatal_error("Not enough memory"); - return p; + void *p = malloc(size); + if (!p) + fatal_error("Not enough memory"); + return p; } /* ------------------------------------------------------------------------ */ -char * +void * xrealloc(old, size) - char *old; - int size; + void *old; + size_t size; { - char *p = (char *) realloc(old, size); - if (!p) - fatal_error("Not enough memory"); - return p; + void *p = (char *) realloc(old, size); + if (!p) + fatal_error("Not enough memory"); + return p; +} + +char * +xstrdup(str) + char *str; +{ + int len = strlen(str); + char *p = (char *)xmalloc(len + 1); + strcpy(p, str); /* ok */ + return p; } /* ------------------------------------------------------------------------ */ -/* STRING POOL */ +/* STRING POOL */ /* ------------------------------------------------------------------------ */ /* string pool : - +-------------+-------------+------+-------------+----------+ - | N A M E 1 \0| N A M E 2 \0| .... | N A M E n \0| | - +-------------+-------------+------+-------------+----------+ - ^ ^ ^ buffer+0 buffer+used buffer+size + +-------------+-------------+------+-------------+----------+ + | N A M E 1 \0| N A M E 2 \0| .... | N A M E n \0| | + +-------------+-------------+------+-------------+----------+ + ^ ^ ^ buffer+0 buffer+used buffer+size vector : - +---------------+---------------+------------- -----------------+ - | pointer to | pointer to | pointer to ... pointer to | - | stringpool | N A M E 1 | N A M E 2 ... N A M E n | - +---------------+---------------+------------- -------------+ - ^ malloc base returned + +---------------+---------------+------------- -----------------+ + | pointer to | pointer to | pointer to ... pointer to | + | stringpool | N A M E 1 | N A M E 2 ... N A M E n | + +---------------+---------------+------------- -------------+ + ^ malloc base returned */ /* ------------------------------------------------------------------------ */ void init_sp(sp) - struct string_pool *sp; + struct string_pool *sp; { - sp->size = 1024 - 8; /* any ( >=0 ) */ - sp->used = 0; - sp->n = 0; - sp->buffer = (char *) xmalloc(sp->size * sizeof(char)); + sp->size = 1024 - 8; /* any ( >=0 ) */ + sp->used = 0; + sp->n = 0; + sp->buffer = (char *) xmalloc(sp->size * sizeof(char)); } /* ------------------------------------------------------------------------ */ void add_sp(sp, name, len) - struct string_pool *sp; - char *name; /* stored '\0' at tail */ - int len; /* include '\0' */ -{ - while (sp->used + len > sp->size) { - sp->size *= 2; - sp->buffer = (char *) xrealloc(sp->buffer, sp->size * sizeof(char)); - } - bcopy(name, sp->buffer + sp->used, len); - sp->used += len; - sp->n++; + struct string_pool *sp; + char *name; /* stored '\0' at tail */ + int len; /* include '\0' */ +{ + while (sp->used + len > sp->size) { + sp->size *= 2; + sp->buffer = (char *) xrealloc(sp->buffer, sp->size * sizeof(char)); + } + memmove(sp->buffer + sp->used, name, len); + sp->used += len; + sp->n++; } /* ------------------------------------------------------------------------ */ void finish_sp(sp, v_count, v_vector) - register struct string_pool *sp; - int *v_count; - char ***v_vector; -{ - int i; - register char *p; - char **v; - - v = (char **) xmalloc((sp->n + 1) * sizeof(char *)); - *v++ = sp->buffer; - *v_vector = v; - *v_count = sp->n; - p = sp->buffer; - for (i = sp->n; i; i--) { - *v++ = p; - if (i - 1) - p += strlen(p) + 1; - } + register struct string_pool *sp; + int *v_count; + char ***v_vector; +{ + int i; + register char *p; + char **v; + + v = (char **) xmalloc((sp->n + 1) * sizeof(char *)); + *v++ = sp->buffer; + *v_vector = v; + *v_count = sp->n; + p = sp->buffer; + for (i = sp->n; i; i--) { + *v++ = p; + if (i - 1) + p += strlen(p) + 1; + } } /* ------------------------------------------------------------------------ */ void free_sp(vector) - char **vector; + char **vector; { - vector--; - free(*vector); /* free string pool */ - free(vector); + vector--; + free(*vector); /* free string pool */ + free(vector); } /* ------------------------------------------------------------------------ */ -/* READ DIRECTORY FILES */ +/* READ DIRECTORY FILES */ /* ------------------------------------------------------------------------ */ static boolean include_path_p(path, name) - char *path, *name; + char *path, *name; { - char *n = name; - while (*path) - if (*path++ != *n++) - return (path[-1] == '/' && *n == '\0'); - return (*n == '/' || (n != name && path[-1] == '/' && n[-1] == '/')); + char *n = name; + while (*path) + if (*path++ != *n++) + return (path[-1] == '/' && *n == '\0'); + return (*n == '/' || (n != name && path[-1] == '/' && n[-1] == '/')); } /* ------------------------------------------------------------------------ */ void cleaning_files(v_filec, v_filev) - int *v_filec; - char ***v_filev; + int *v_filec; + char ***v_filev; { - char *flags; - struct stat stbuf; + char *flags; + struct stat stbuf; - register char **filev = *v_filev; - register int filec = *v_filec; - register char *p; - register int i, j; - - if (filec == 0) - return; - - flags = xmalloc(filec * sizeof(char)); - - /* flags & 0x01 : 1: ignore */ - /* flags & 0x02 : 1: directory, 0 : regular file */ - /* flags & 0x04 : 1: need delete */ - - - for (i = 0; i < filec; i++) - if (GETSTAT(filev[i], &stbuf) < 0) { - flags[i] = 0x04; - fprintf(stderr, - "LHa: Cannot access \"%s\", ignored.\n", filev[i]); - } - else { - if (is_regularfile(&stbuf)) - flags[i] = 0x00; - else if (is_directory(&stbuf)) - flags[i] = 0x02; + register char **filev = *v_filev; + register int filec = *v_filec; + register char *p; + register int i, j; + + if (filec == 0) + return; + + flags = xmalloc(filec * sizeof(char)); + + /* flags & 0x01 : 1: ignore */ + /* flags & 0x02 : 1: directory, 0 : regular file */ + /* flags & 0x04 : 1: need delete */ + + for (i = 0; i < filec; i++) + if (GETSTAT(filev[i], &stbuf) < 0) { + flags[i] = 0x04; + warning("Cannot access \"%s\" : %s; ignored.", filev[i], + strerror(errno)); + } + else { + if (is_regularfile(&stbuf)) + flags[i] = 0x00; + else if (is_directory(&stbuf)) + flags[i] = 0x02; #ifdef S_IFLNK - else if (is_symlink(&stbuf)) /* t.okamoto */ - flags[i] = 0x00; -#endif - else { - flags[i] = 0x04; - fprintf(stderr, - "LHa: Cannot archive \"%s\", ignored.\n", filev[i]); - } - } - errno = 0; - - for (i = 0; i < filec; i++) { - p = filev[i]; - if ((flags[i] & 0x07) == 0x00) { /* regular file, not - * deleted/ignored */ - for (j = i + 1; j < filec; j++) { - if ((flags[j] & 0x07) == 0x00) { /* regular file, not - * deleted/ignored */ - if (STREQU(p, filev[j])) - flags[j] = 0x04; /* delete */ - } - } - } - else if ((flags[i] & 0x07) == 0x02) { /* directory, not - * deleted/ignored */ - for (j = i + 1; j < filec; j++) { - if ((flags[j] & 0x07) == 0x00) { /* regular file, not - * deleted/ignored */ - if (include_path_p(p, filev[j])) - flags[j] = 0x04; /* delete */ - } - else if ((flags[j] & 0x07) == 0x02) { /* directory, not - * deleted/ignored */ - if (include_path_p(p, filev[j])) - flags[j] = 0x04; /* delete */ - } - } - } - } - - for (i = j = 0; i < filec; i++) { - if ((flags[i] & 0x04) == 0) { - if (i != j) - filev[j] = filev[i]; - j++; - } - } - *v_filec = j; + else if (is_symlink(&stbuf)) /* t.okamoto */ + flags[i] = 0x00; +#endif + else { + flags[i] = 0x04; + warning("Cannot archive \"%s\", ignored.", filev[i]); + } + } + + for (i = 0; i < filec; i++) { + p = filev[i]; + if ((flags[i] & 0x07) == 0x00) { /* regular file, not + * deleted/ignored */ + for (j = i + 1; j < filec; j++) { + if ((flags[j] & 0x07) == 0x00) { /* regular file, not + * deleted/ignored */ + if (STREQU(p, filev[j])) + flags[j] = 0x04; /* delete */ + } + } + } + else if ((flags[i] & 0x07) == 0x02) { /* directory, not + * deleted/ignored */ + for (j = i + 1; j < filec; j++) { + if ((flags[j] & 0x07) == 0x00) { /* regular file, not + * deleted/ignored */ + if (include_path_p(p, filev[j])) + flags[j] = 0x04; /* delete */ + } + else if ((flags[j] & 0x07) == 0x02) { /* directory, not + * deleted/ignored */ + if (include_path_p(p, filev[j])) + flags[j] = 0x04; /* delete */ + } + } + } + } + + for (i = j = 0; i < filec; i++) { + if ((flags[i] & 0x04) == 0) { + if (i != j) + filev[j] = filev[i]; + j++; + } + } + *v_filec = j; - free(flags); + free(flags); } /* ------------------------------------------------------------------------ */ -#ifdef NODIRECTORY -/* please need your imprementation */ boolean find_files(name, v_filec, v_filev) - char *name; - int *v_filec; - char ***v_filev; -{ - return FALSE; /* DUMMY */ -} - -/* ------------------------------------------------------------------------ */ -void -free_files(filec, filev) - int filec; - char **filev; -{ - /* do nothing */ -} -/* ------------------------------------------------------------------------ */ -#else -boolean -find_files(name, v_filec, v_filev) - char *name; - int *v_filec; - char ***v_filev; -{ - struct string_pool sp; - char newname[FILENAME_LENGTH]; - int len, n; - DIR *dirp; - DIRENTRY *dp; - struct stat tmp_stbuf, arc_stbuf, fil_stbuf; - - strcpy(newname, name); - len = strlen(name); - if (len > 0 && newname[len - 1] != '/') - newname[len++] = '/'; - - dirp = opendir(name); - if (!dirp) - return FALSE; - - init_sp(&sp); - - GETSTAT(temporary_name, &tmp_stbuf); - GETSTAT(archive_name, &arc_stbuf); - - for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) { - n = NAMLEN(dp); - strncpy(newname + len, dp->d_name, n); - newname[len + n] = '\0'; - if (GETSTAT(newname, &fil_stbuf) < 0) - continue; -#ifdef NO_INODE - if ( dp->d_name[0] != '.' || - (n != 1 && - (dp->d_name[1] != '.' || - n != 2)) ) { - add_sp(&sp, newname, len+n+1); - } -#else - if ((dp->d_ino != 0) && - /* exclude '.' and '..' */ - ((dp->d_name[0] != '.') || - ((n != 1) && - ((dp->d_name[1] != '.') || - (n != 2)))) && - ((tmp_stbuf.st_dev != fil_stbuf.st_dev || - tmp_stbuf.st_ino != fil_stbuf.st_ino) && - (arc_stbuf.st_dev != fil_stbuf.st_dev || - arc_stbuf.st_ino != fil_stbuf.st_ino))) { - add_sp(&sp, newname, len + n + 1); - } -#endif - } - closedir(dirp); - finish_sp(&sp, v_filec, v_filev); - if (*v_filec > 1) - qsort(*v_filev, *v_filec, sizeof(char *), sort_by_ascii); - cleaning_files(v_filec, v_filev); + char *name; + int *v_filec; + char ***v_filev; +{ + struct string_pool sp; + char newname[FILENAME_LENGTH]; + int len, n, i; + DIR *dirp; + struct dirent *dp; + struct stat tmp_stbuf, arc_stbuf, fil_stbuf; + int exist_tmp = 1, exist_arc = 1; + + len = str_safe_copy(newname, name, sizeof(newname)); + if (len > 0 && newname[len - 1] != '/') { + if (len < sizeof(newname)-1) + strcpy(&newname[len++], "/"); /* ok */ + else + warning("the length of pathname \"%s\" is too long.", name); + } + + dirp = opendir(name); + if (!dirp) + return FALSE; + + init_sp(&sp); + + if (GETSTAT(temporary_name, &tmp_stbuf) == -1) + exist_tmp = 0; + if (GETSTAT(archive_name, &arc_stbuf) == -1) + exist_arc = 0; + + while ((dp = readdir(dirp)) != NULL) { + n = NAMLEN(dp); + + /* exclude '.' and '..' */ + if (strncmp(dp->d_name, ".", n) == 0 + || strncmp(dp->d_name, "..", n) == 0) + continue; + + /* exclude exclude_files supplied by user */ + for (i = 0; exclude_files && exclude_files[i]; i++) { + if (fnmatch(exclude_files[i], dp->d_name, + FNM_PATHNAME|FNM_NOESCAPE|FNM_PERIOD) == 0) + goto next; + } + + if (len + n >= sizeof(newname)) { + warning("filename is too long"); + continue; + } + + strncpy(newname + len, dp->d_name, n); + newname[len + n] = '\0'; + if (GETSTAT(newname, &fil_stbuf) < 0) + continue; + +#if defined(HAVE_STRUCT_STAT_ST_INO) && !__MINGW32__ + /* MinGW has meaningless st_ino */ + + /* exclude temporary file, archive file and these links */ + if (exist_tmp && + tmp_stbuf.st_dev == fil_stbuf.st_dev && + tmp_stbuf.st_ino == fil_stbuf.st_ino) + continue; + + if (exist_arc && + arc_stbuf.st_dev == fil_stbuf.st_dev && + arc_stbuf.st_ino == fil_stbuf.st_ino) + continue; +#endif + add_sp(&sp, newname, len+n+1); + next: + ; + } + closedir(dirp); + finish_sp(&sp, v_filec, v_filev); + if (*v_filec > 1) + qsort(*v_filev, *v_filec, sizeof(char *), sort_by_ascii); + cleaning_files(v_filec, v_filev); - return TRUE; + return TRUE; } /* ------------------------------------------------------------------------ */ void free_files(filec, filev) - int filec; - char **filev; + int filec; + char **filev; { - free_sp(filev); + free_sp(filev); } -#endif + /* ------------------------------------------------------------------------ */ -/* */ +/* */ /* ------------------------------------------------------------------------ */ /* Build temporary file name and store to TEMPORARY_NAME */ -void +int build_temporary_name() { #ifdef TMP_FILENAME_TEMPLATE - /* "/tmp/lhXXXXXX" etc. */ - if (extract_directory == NULL) { - strcpy(temporary_name, TMP_FILENAME_TEMPLATE); - } - else { - sprintf(temporary_name, "%s/lhXXXXXX", extract_directory); - } -#ifdef MKSTEMP - mkstemp(temporary_name); + /* "/tmp/lhXXXXXX" etc. */ + if (extract_directory == NULL) { + str_safe_copy(temporary_name, TMP_FILENAME_TEMPLATE, + sizeof(temporary_name)); + } + else { + xsnprintf(temporary_name, sizeof(temporary_name), + "%s/lhXXXXXX", extract_directory); + } #else - mktemp(temporary_name); + char *s; + + str_safe_copy(temporary_name, archive_name, sizeof(temporary_name)); + s = strrchr(temporary_name, '/'); + if (s) { + int len; + len = s - temporary_name; + if (len + strlen("lhXXXXXX") < sizeof(temporary_name)) + /* use directory at archive file */ + strcpy(s, "lhXXXXXX"); /* ok */ + else + /* use current directory */ + str_safe_copy(temporary_name, "lhXXXXXX", sizeof(temporary_name)); + } + else + /* use current directory */ + str_safe_copy(temporary_name, "lhXXXXXX", sizeof(temporary_name)); #endif +#ifdef HAVE_MKSTEMP + { + int old_umask, fd; + + old_umask = umask(077); + fd = mkstemp(temporary_name); + umask(old_umask); + return fd; + } #else - char *p, *s; + { + int flags; - strcpy(temporary_name, archive_name); - for (p = temporary_name, s = (char *) 0; *p; p++) - if (*p == '/') - s = p; - strcpy((s ? s + 1 : temporary_name), "lhXXXXXX"); -#ifdef MKSTEMP - mkstemp(temporary_name); -#else - mktemp(temporary_name); + mktemp(temporary_name); + flags = O_CREAT|O_EXCL|O_RDWR; +#ifdef O_BINARY + flags |= O_BINARY; #endif + return open(temporary_name, flags, 0600); + } #endif } /* ------------------------------------------------------------------------ */ static void -modify_filename_extention(buffer, ext) - char *buffer; - char *ext; -{ - register char *p, *dot; - - for (p = buffer, dot = (char *) 0; *p; p++) { - if (*p == '.') - dot = p; - else if (*p == '/') - dot = (char *) 0; - } +modify_filename_extention(buffer, ext, size) + char *buffer; + char *ext; + size_t size; +{ + register char *p, *dot; + + for (p = buffer, dot = (char *) 0; *p; p++) { + if (*p == '.') + dot = p; + else if (*p == '/') + dot = (char *) 0; + } - if (dot) - p = dot; + if (dot) + p = dot; - strcpy(p, ext); + str_safe_copy(p, ext, size - (p - buffer)); } /* ------------------------------------------------------------------------ */ /* build backup file name */ void -build_backup_name(buffer, original) - char *buffer; - char *original; +build_backup_name(buffer, original, size) + char *buffer; + char *original; + size_t size; { - strcpy(buffer, original); - modify_filename_extention(buffer, BACKUPNAME_EXTENTION); /* ".bak" */ + str_safe_copy(buffer, original, size); + modify_filename_extention(buffer, BACKUPNAME_EXTENTION, size); /* ".bak" */ } /* ------------------------------------------------------------------------ */ void -build_standard_archive_name(buffer, orginal) - char *buffer; - char *orginal; +build_standard_archive_name(buffer, original, size) + char *buffer; + char *original; + size_t size; { - strcpy(buffer, orginal); - modify_filename_extention(buffer, ARCHIVENAME_EXTENTION); /* ".lzh" */ + str_safe_copy(buffer, original, size); + modify_filename_extention(buffer, ARCHIVENAME_EXTENTION, size); /* ".lzh" */ } /* ------------------------------------------------------------------------ */ -/* */ +/* */ /* ------------------------------------------------------------------------ */ boolean need_file(name) - char *name; + char *name; { - int i; + int i; - if (cmd_filec == 0) - return TRUE; + if (cmd_filec == 0) + return TRUE; - for (i = 0; i < cmd_filec; i++) { - if (patmatch(cmd_filev[i], name, 0)) - return TRUE; - } + for (i = 0; i < cmd_filec; i++) { + if (patmatch(cmd_filev[i], name, 0)) + return TRUE; + } - return FALSE; + return FALSE; } FILE * xfopen(name, mode) - char *name, *mode; + char *name, *mode; { - FILE *fp; + FILE *fp; - if ((fp = fopen(name, mode)) == NULL) - fatal_error(name); + if ((fp = fopen(name, mode)) == NULL) + fatal_error("Cannot open file \"%s\"", name); - return fp; + return fp; } /* ------------------------------------------------------------------------ */ -/* */ +/* */ /* ------------------------------------------------------------------------ */ static boolean open_old_archive_1(name, v_fp) - char *name; - FILE **v_fp; + char *name; + FILE **v_fp; { - FILE *fp; - struct stat stbuf; + FILE *fp; + struct stat stbuf; - if (stat(name, &stbuf) >= 0 && - is_regularfile(&stbuf) && - (fp = fopen(name, READ_BINARY)) != NULL) { - *v_fp = fp; - archive_file_gid = stbuf.st_gid; - archive_file_mode = stbuf.st_mode; - return TRUE; - } - - *v_fp = NULL; - archive_file_gid = -1; - return FALSE; + if (stat(name, &stbuf) >= 0 && + is_regularfile(&stbuf) && + (fp = fopen(name, READ_BINARY)) != NULL) { + *v_fp = fp; + archive_file_gid = stbuf.st_gid; + archive_file_mode = stbuf.st_mode; + return TRUE; + } + + *v_fp = NULL; + archive_file_gid = -1; + return FALSE; } /* ------------------------------------------------------------------------ */ FILE * open_old_archive() { - FILE *fp; - char *p; - - if (!strcmp(archive_name, "-")) { - if (cmd == CMD_EXTRACT || cmd == CMD_LIST) - return stdin; - else - return NULL; - } - if (p = (char *) rindex(archive_name, '.')) { - if (strucmp(".LZH", p) == 0 - || strucmp(".LZS", p) == 0 - || strucmp(".COM", p) == 0 /* DOS SFX */ - || strucmp(".EXE", p) == 0 - || strucmp(".X", p) == 0 /* HUMAN SFX */ - || strucmp(".BAK", p) == 0) { /* for BackUp */ - open_old_archive_1(archive_name, &fp); - return fp; - } - } - - if (open_old_archive_1(archive_name, &fp)) - return fp; - sprintf(expanded_archive_name, "%s.lzh", archive_name); - if (open_old_archive_1(expanded_archive_name, &fp)) { - archive_name = expanded_archive_name; - return fp; - } - /* - * if ( (errno&0xffff)!=E_PNNF ) { archive_name = - * expanded_archive_name; return NULL; } - */ - sprintf(expanded_archive_name, "%s.lzs", archive_name); - if (open_old_archive_1(expanded_archive_name, &fp)) { - archive_name = expanded_archive_name; - return fp; - } - /* - * if ( (errno&0xffff)!=E_PNNF ) { archive_name = - * expanded_archive_name; return NULL; } - */ - /* - * sprintf( expanded_archive_name , "%s.lzh",archive_name); - * archive_name = expanded_archive_name; - */ - return NULL; + FILE *fp; + char *p; + static char expanded_archive_name[FILENAME_LENGTH]; + + if (!strcmp(archive_name, "-")) { + if (cmd == CMD_EXTRACT || cmd == CMD_LIST) { +#if __MINGW32__ + setmode(fileno(stdin), O_BINARY); +#endif + return stdin; + } + else + return NULL; + } + p = strrchr(archive_name, '.'); + if (p) { + if (strcasecmp(".LZH", p) == 0 + || strcasecmp(".LZS", p) == 0 + || strcasecmp(".COM", p) == 0 /* DOS SFX */ + || strcasecmp(".EXE", p) == 0 + || strcasecmp(".X", p) == 0 /* HUMAN SFX */ + || strcasecmp(".BAK", p) == 0) { /* for BackUp */ + open_old_archive_1(archive_name, &fp); + return fp; + } + } + + if (open_old_archive_1(archive_name, &fp)) + return fp; + xsnprintf(expanded_archive_name, sizeof(expanded_archive_name), + "%s.lzh", archive_name); + if (open_old_archive_1(expanded_archive_name, &fp)) { + archive_name = expanded_archive_name; + return fp; + } + /* + * if ( (errno&0xffff)!=E_PNNF ) { archive_name = + * expanded_archive_name; return NULL; } + */ + xsnprintf(expanded_archive_name, sizeof(expanded_archive_name), + "%s.lzs", archive_name); + if (open_old_archive_1(expanded_archive_name, &fp)) { + archive_name = expanded_archive_name; + return fp; + } + /* + * if ( (errno&0xffff)!=E_PNNF ) { archive_name = + * expanded_archive_name; return NULL; } + */ + /* + * sprintf( expanded_archive_name , "%s.lzh",archive_name); + * archive_name = expanded_archive_name; + */ + return NULL; } /* ------------------------------------------------------------------------ */ int inquire(msg, name, selective) - char *msg, *name, *selective; + char *msg, *name, *selective; { - char buffer[1024]; - char *p; + char buffer[1024]; + char *p; - for (;;) { - fprintf(stderr, "%s %s ", name, msg); - fflush(stderr); - - fgets(buffer, 1024, stdin); - - for (p = selective; *p; p++) - if (buffer[0] == *p) - return p - selective; - } - /* NOTREACHED */ + for (;;) { + fprintf(stderr, "%s %s ", name, msg); + fflush(stderr); + + fgets(buffer, 1024, stdin); + + for (p = selective; *p; p++) + if (buffer[0] == *p) + return p - selective; + } + /* NOTREACHED */ } /* ------------------------------------------------------------------------ */ void write_archive_tail(nafp) - FILE *nafp; + FILE *nafp; { - putc(0x00, nafp); + putc(0x00, nafp); } /* ------------------------------------------------------------------------ */ void copy_old_one(oafp, nafp, hdr) - FILE *oafp, *nafp; - LzHeader *hdr; + FILE *oafp, *nafp; + LzHeader *hdr; { - if (noexec) { - fseek(oafp, (long) (hdr->header_size + 2) + hdr->packed_size, SEEK_CUR); - } - else { - reading_filename = archive_name; - writting_filename = temporary_name; - if (hdr->header_level != 2) { - copyfile(oafp, nafp, - (long) (hdr->header_size + 2) + hdr->packed_size, 0); - } else { - copyfile(oafp, nafp, - (long) (hdr->header_size) + hdr->packed_size, 0); - } - } -} - -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* compile-command:"gcc -c lharc.c" */ -/* End: */ + if (noexec) { + fseeko(oafp, hdr->header_size + hdr->packed_size, SEEK_CUR); + } + else { + reading_filename = archive_name; + writing_filename = temporary_name; + copyfile(oafp, nafp, hdr->header_size + hdr->packed_size, 0, 0); + } +} + +#undef exit + +void +lha_exit(status) + int status; +{ + cleanup(); + exit(status); +} diff -Nru lha-1.14i/src/lhdir.c lha-1.14i-acc20050924p1/src/lhdir.c --- lha-1.14i/src/lhdir.c 2000-10-04 14:57:38.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/lhdir.c 2002-11-16 19:03:23.000000000 +0000 @@ -1,16 +1,16 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* lhdir.c -- Directory access routine */ -/* */ -/* Copyright (C) MCMLXXXIX Yooichi.Tagawa */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Emulate opendir(),readdir(),closedir() function for LHarc */ -/* */ -/* Ver. 0.00 Original 1988.05.31 Y.Tagawa */ -/* Ver. 0.03 Release #3 for LHarc UNIX 1988.07.02 Y.Tagawa */ -/* Ver. 1.00 Fixed 1989.09.22 Y.Tagawa */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* LHa for UNIX */ +/* lhdir.c -- Directory access routine */ +/* */ +/* Copyright (C) MCMLXXXIX Yooichi.Tagawa */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Emulate opendir(),readdir(),closedir() function for LHarc */ +/* */ +/* Ver. 0.00 Original 1988.05.31 Y.Tagawa */ +/* Ver. 0.03 Release #3 for LHarc UNIX 1988.07.02 Y.Tagawa */ +/* Ver. 1.00 Fixed 1989.09.22 Y.Tagawa */ +/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ /* ------------------------------------------------------------------------ */ #include "lha.h" @@ -29,7 +29,7 @@ #ifndef DIRSIZ /* Warning : Are you sure? (normally defined in */ -#define DIRSIZ 14 +#define DIRSIZ 14 #endif #include "lhdir.h" @@ -37,62 +37,62 @@ /* ------------------------------------------------------------------------ */ DIR * opendir(name) - char *name; + char *name; { - register DIR *dirp; - register int fd; + register DIR *dirp; + register int fd; - if ((fd = open(name, O_RDONLY)) >= 0) { - if ((dirp = (DIR *) malloc(sizeof(DIR))) != (DIR *) 0) { - dirp->dd_fd = fd; - dirp->dd_loc = 0; - dirp->dd_size = 0; - return dirp; - } + if ((fd = open(name, O_RDONLY)) >= 0) { + if ((dirp = (DIR *) malloc(sizeof(DIR))) != (DIR *) 0) { + dirp->dd_fd = fd; + dirp->dd_loc = 0; + dirp->dd_size = 0; + return dirp; + } - close(fd); - } + close(fd); + } - return (DIR *) 0; + return (DIR *) 0; } /* ------------------------------------------------------------------------ */ struct direct * readdir(dirp) - register DIR *dirp; + register DIR *dirp; { - static struct direct lhdir; - register struct old_direct *dp; + static struct direct lhdir; + register struct old_direct *dp; - do { - if (dirp->dd_loc >= dirp->dd_size) { - dirp->dd_loc = 0; - if ((dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0) - return (struct direct *) 0; - } + do { + if (dirp->dd_loc >= dirp->dd_size) { + dirp->dd_loc = 0; + if ((dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0) + return (struct direct *) 0; + } - dp = (struct old_direct *) (dirp->dd_buf + dirp->dd_loc); + dp = (struct old_direct *) (dirp->dd_buf + dirp->dd_loc); - if (dirp->dd_loc + sizeof(struct old_direct) > dirp->dd_size) - return (struct direct *) 0; + if (dirp->dd_loc + sizeof(struct old_direct) > dirp->dd_size) + return (struct direct *) 0; - dirp->dd_loc += sizeof(struct old_direct); + dirp->dd_loc += sizeof(struct old_direct); - } while (dp->d_ino == 0); + } while (dp->d_ino == 0); - /* construct new format */ - lhdir.d_ino = dp->d_ino; - strncpy(lhdir.d_name, dp->d_name, DIRSIZ); - lhdir.d_name[DIRSIZ] = '\0'; - lhdir.d_namlen = strlen(lhdir.d_name); + /* construct new format */ + lhdir.d_ino = dp->d_ino; + strncpy(lhdir.d_name, dp->d_name, DIRSIZ); + lhdir.d_name[DIRSIZ] = '\0'; + lhdir.d_namlen = strlen(lhdir.d_name); - return &lhdir; + return &lhdir; } /* ------------------------------------------------------------------------ */ closedir(dirp) - DIR *dirp; + DIR *dirp; { - close(dirp->dd_fd); - free(dirp); + close(dirp->dd_fd); + free(dirp); } diff -Nru lha-1.14i/src/lhdir.h lha-1.14i-acc20050924p1/src/lhdir.h --- lha-1.14i/src/lhdir.h 2000-10-04 14:57:38.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/lhdir.h 2002-11-16 19:03:23.000000000 +0000 @@ -1,35 +1,35 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX Directory access routine */ -/* */ -/* Modified Nobutaka Watazaki */ -/* Emulate opendir(), readdir(), closedir() function for LHa */ -/* */ -/* Ver. 1.14 Soruce All chagned 1995.01.14 N.Watazaki */ +/* LHa for UNIX Directory access routine */ +/* */ +/* Modified Nobutaka Watazaki */ +/* Emulate opendir(), readdir(), closedir() function for LHa */ +/* */ +/* Ver. 1.14 Soruce All chagned 1995.01.14 N.Watazaki */ /* ------------------------------------------------------------------------ */ #ifndef DIRBLKSIZ -#define DIRBLKSIZ 512 +#define DIRBLKSIZ 512 #endif /* ------------------------------------------------------------------------ */ -/* Type Definition */ +/* Type Definition */ /* ------------------------------------------------------------------------ */ struct direct { - int d_ino; - int d_namlen; - char d_name[256]; + int d_ino; + int d_namlen; + char d_name[256]; }; typedef struct { - int dd_fd; - int dd_loc; - int dd_size; - char dd_buf[DIRBLKSIZ]; + int dd_fd; + int dd_loc; + int dd_size; + char dd_buf[DIRBLKSIZ]; } DIR; /* ------------------------------------------------------------------------ */ -/* Functions */ +/* Functions */ /* ------------------------------------------------------------------------ */ -extern DIR *opendir(); +extern DIR *opendir(); extern struct direct *readdir(); -extern int closedir(); +extern int closedir(); diff -Nru lha-1.14i/src/lhext.c lha-1.14i-acc20050924p1/src/lhext.c --- lha-1.14i/src/lhext.c 2000-10-04 14:57:38.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/lhext.c 2006-10-10 16:27:51.000000000 +0000 @@ -1,425 +1,559 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* lhext.c -- LHarc extract */ -/* */ -/* Copyright (C) MCMLXXXIX Yooichi.Tagawa */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 0.00 Original 1988.05.23 Y.Tagawa */ -/* Ver. 1.00 Fixed 1989.09.22 Y.Tagawa */ -/* Ver. 0.03 LHa for UNIX 1991.12.17 M.Oki */ -/* Ver. 1.12 LHa for UNIX 1993.10.01 N.Watazaki */ -/* Ver. 1.13b Symbolic Link Update Bug Fix 1994.06.21 N.Watazaki */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* LHa for UNIX */ +/* lhext.c -- LHarc extract */ +/* */ +/* Copyright (C) MCMLXXXIX Yooichi.Tagawa */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Ver. 0.00 Original 1988.05.23 Y.Tagawa */ +/* Ver. 1.00 Fixed 1989.09.22 Y.Tagawa */ +/* Ver. 0.03 LHa for UNIX 1991.12.17 M.Oki */ +/* Ver. 1.12 LHa for UNIX 1993.10.01 N.Watazaki */ +/* Ver. 1.13b Symbolic Link Update Bug Fix 1994.06.21 N.Watazaki */ +/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ /* Ver. 1.14e bugfix 1999.04.30 T.Okamoto */ /* ------------------------------------------------------------------------ */ #include "lha.h" /* ------------------------------------------------------------------------ */ -static int skip_flg = FALSE; /* FALSE..No Skip , TRUE..Skip */ -static char *methods[] = +static int skip_flg = FALSE; /* FALSE..No Skip , TRUE..Skip */ +static char *methods[] = { - LZHUFF0_METHOD, LZHUFF1_METHOD, LZHUFF2_METHOD, LZHUFF3_METHOD, - LZHUFF4_METHOD, LZHUFF5_METHOD, LZHUFF6_METHOD, LZHUFF7_METHOD, - LARC_METHOD, LARC5_METHOD, LARC4_METHOD, - LZHDIRS_METHOD, - NULL + LZHUFF0_METHOD, LZHUFF1_METHOD, LZHUFF2_METHOD, LZHUFF3_METHOD, + LZHUFF4_METHOD, LZHUFF5_METHOD, LZHUFF6_METHOD, LZHUFF7_METHOD, + LARC_METHOD, LARC5_METHOD, LARC4_METHOD, + LZHDIRS_METHOD, + NULL }; +static void add_dirinfo(char* name, LzHeader* hdr); +static void adjust_dirinfo(); + /* ------------------------------------------------------------------------ */ static boolean inquire_extract(name) - char *name; + char *name; { - struct stat stbuf; + struct stat stbuf; + + skip_flg = FALSE; + if (stat(name, &stbuf) >= 0) { + if (!is_regularfile(&stbuf)) { + error("\"%s\" already exists (not a file)", name); + return FALSE; + } + + if (noexec) { + printf("EXTRACT %s but file is exist.\n", name); + return FALSE; + } + else if (!force) { + if (!isatty(0)) { + warning("skip to extract %s.", name); + return FALSE; + } + + switch (inquire("OverWrite ?(Yes/[No]/All/Skip)", name, "YyNnAaSs\n")) { + case 0: + case 1:/* Y/y */ + break; + case 2: + case 3:/* N/n */ + case 8:/* Return */ + return FALSE; + case 4: + case 5:/* A/a */ + force = TRUE; + break; + case 6: + case 7:/* S/s */ + skip_flg = TRUE; + break; + } + } + } - skip_flg = FALSE; - if (stat(name, &stbuf) >= 0) { - if (!is_regularfile(&stbuf)) { - error("Already exist (not a file)", name); - return FALSE; - } - - if (noexec) { - printf("EXTRACT %s but file is exist.\n", name); - return FALSE; - } - else if (!force) { - if (!isatty(0)) - return FALSE; - - switch (inquire("OverWrite ?(Yes/[No]/All/Skip)", name, "YyNnAaSs\n")) { - case 0: - case 1:/* Y/y */ - break; - case 2: - case 3:/* N/n */ - case 8:/* Return */ - return FALSE; - case 4: - case 5:/* A/a */ - force = TRUE; - break; - case 6: - case 7:/* S/s */ - skip_flg = TRUE; - break; - } - } - } - if (noexec) - printf("EXTRACT %s\n", name); + if (noexec) + printf("EXTRACT %s\n", name); - return TRUE; + return TRUE; } /* ------------------------------------------------------------------------ */ static boolean make_parent_path(name) - char *name; + char *name; { - char path[FILENAME_LENGTH]; - struct stat stbuf; - register char *p; - - /* make parent directory name into PATH for recursive call */ - strcpy(path, name); - for (p = path + strlen(path); p > path; p--) - if (p[-1] == '/') { - *--p = '\0'; - break; - } - - if (p == path) { - message("Why?", "ROOT"); - return FALSE; /* no more parent. */ - } - - if (GETSTAT(path, &stbuf) >= 0) { - if (is_directory(&stbuf)) - return TRUE; - error("Not a directory", path); - return FALSE; - } - errno = 0; - - if (verbose) - printf("Making directory \"%s\".\n", path); - - if (mkdir(path, 0777) >= 0) /* try */ - return TRUE; /* successful done. */ - errno = 0; - - if (!make_parent_path(path)) - return FALSE; - - if (mkdir(path, 0777) < 0) { /* try again */ - message("Cannot make directory", path); - return FALSE; - } + char path[FILENAME_LENGTH]; + struct stat stbuf; + register char *p; + + /* make parent directory name into PATH for recursive call */ + str_safe_copy(path, name, sizeof(path)); + for (p = path + strlen(path); p > path; p--) + if (p[-1] == '/') { + *--p = '\0'; + break; + } + + if (p == path) { + message("invalid path name \"%s\"", name); + return FALSE; /* no more parent. */ + } + + if (GETSTAT(path, &stbuf) >= 0) { + if (is_directory(&stbuf)) + return TRUE; + } + + if (verbose) + message("Making directory \"%s\".", path); + +#if defined __MINGW32__ + if (mkdir(path) >= 0) + return TRUE; +#else + if (mkdir(path, 0777) >= 0) /* try */ + return TRUE; /* successful done. */ +#endif + + if (!make_parent_path(path)) + return FALSE; - return TRUE; +#if defined __MINGW32__ + if (mkdir(path) < 0) { /* try again */ + error("Cannot make directory \"%s\"", path); + return FALSE; + } +#else + if (mkdir(path, 0777) < 0) { /* try again */ + error("Cannot make directory \"%s\"", path); + return FALSE; + } +#endif + + return TRUE; } /* ------------------------------------------------------------------------ */ static FILE * open_with_make_path(name) - char *name; + char *name; { - FILE *fp; + FILE *fp; - if ((fp = fopen(name, WRITE_BINARY)) == NULL) { - errno = 0; - if (!make_parent_path(name) || - (fp = fopen(name, WRITE_BINARY)) == NULL) - error("Cannot extract", name); - errno = 0; - } - return fp; + if ((fp = fopen(name, WRITE_BINARY)) == NULL) { + if (!make_parent_path(name) || + (fp = fopen(name, WRITE_BINARY)) == NULL) + error("Cannot extract a file \"%s\"", name); + } + return fp; } /* ------------------------------------------------------------------------ */ static void adjust_info(name, hdr) - char *name; - LzHeader *hdr; + char *name; + LzHeader *hdr; { - time_t utimebuf[2]; + struct utimbuf utimebuf; - /* adjust file stamp */ - utimebuf[0] = utimebuf[1] = hdr->unix_last_modified_stamp; + /* adjust file stamp */ + utimebuf.actime = utimebuf.modtime = hdr->unix_last_modified_stamp; - if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) != UNIX_FILE_SYMLINK) - utime(name, utimebuf); + 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) { + 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. #else - if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) != UNIX_FILE_SYMLINK) - chmod(name, hdr->unix_mode); + if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) != UNIX_FILE_SYMLINK) + chmod(name, hdr->unix_mode); +#endif + if (!getuid()){ + uid_t uid = hdr->unix_uid; + gid_t gid = hdr->unix_gid; + +#if HAVE_GETPWNAM && HAVE_GETGRNAM + if (hdr->user[0]) { + struct passwd *ent = getpwnam(hdr->user); + if (ent) uid = ent->pw_uid; + } + if (hdr->group[0]) { + struct group *ent = getgrnam(hdr->group); + if (ent) gid = ent->gr_gid; + } +#endif + +#if HAVE_LCHOWN + if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK) + lchown(name, uid, gid); + else +#endif /* HAVE_LCHWON */ + chown(name, uid, gid); + } + } +#if __CYGWIN__ + else { + /* On Cygwin, execute permission should be set for .exe or .dll. */ + mode_t m; + + umask(m = umask(0)); /* get current umask */ + chmod(name, 0777 & ~m); + } #endif - if (!getuid()) { -#ifndef HAVE_NO_LCHOWN - if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK) - lchown(name, hdr->unix_uid, hdr->unix_gid); - else -#endif /* HAVE_NO_LCHWON */ - chown(name, hdr->unix_uid, hdr->unix_gid); - } - errno = 0; - } } /* ------------------------------------------------------------------------ */ -static void +static size_t extract_one(afp, hdr) - FILE *afp; /* archive file */ - LzHeader *hdr; + FILE *afp; /* archive file */ + LzHeader *hdr; { - FILE *fp; /* output file */ - struct stat stbuf; - char name[257]; - int crc; - int method; - boolean save_quiet, save_verbose, up_flag; - char *q = hdr->name, c; - - if (ignore_directory && rindex(hdr->name, '/')) { - q = (char *) rindex(hdr->name, '/') + 1; - } - else { - if (*q == '/') { - q++; - /* - * if OSK then strip device name - */ - if (hdr->extend_type == EXTEND_OS68K - || hdr->extend_type == EXTEND_XOSK) { - do - c = (*q++); - while (c && c != '/'); - if (!c || !*q) - q = "."; /* if device name only */ - } - } - } - - if (extract_directory) - sprintf(name, "%s/%s", extract_directory, q); - else - strcpy(name, q); - - - /* LZHDIRS_METHODを持つヘッダをチェックする */ - /* 1999.4.30 t.okamoto */ - for (method = 0;; method++) { - if (methods[method] == NULL) { - error("Unknown method skiped ...", name); - return; - } - if (bcmp(hdr->method, methods[method], 5) == 0) - break; - } - - if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_REGULAR - && method != LZHDIRS_METHOD_NUM) { + FILE *fp; /* output file */ + struct stat stbuf; + char name[FILENAME_LENGTH]; + unsigned int crc; + int method; + boolean save_quiet, save_verbose, up_flag; + char *q = hdr->name, c; + size_t read_size = 0; + + if (ignore_directory && strrchr(hdr->name, '/')) { + q = (char *) strrchr(hdr->name, '/') + 1; + } + else { + if (is_directory_traversal(q)) { + fprintf(stderr, "Possible directory traversal hack attempt in %s\n", q); + exit(111); + } + + if (*q == '/') { + while (*q == '/') { q++; } + + /* + * if OSK then strip device name + */ + if (hdr->extend_type == EXTEND_OS68K + || hdr->extend_type == EXTEND_XOSK) { + do + c = (*q++); + while (c && c != '/'); + if (!c || !*q) + q = "."; /* if device name only */ + } + } + } + + if (extract_directory) + xsnprintf(name, sizeof(name), "%s/%s", extract_directory, q); + else + str_safe_copy(name, q, sizeof(name)); + + /* LZHDIRS_METHODを持つヘッダをチェックする */ + /* 1999.4.30 t.okamoto */ + for (method = 0;; method++) { + if (methods[method] == NULL) { + error("Unknown method \"%.*s\"; \"%s\" will be skiped ...", + 5, hdr->method, name); + return read_size; + } + if (memcmp(hdr->method, methods[method], 5) == 0) + break; + } + + if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_REGULAR + && method != LZHDIRS_METHOD_NUM) { + extract_regular: #if 0 - for (method = 0;; method++) { - if (methods[method] == NULL) { - error("Unknown method skiped ...", name); - return; - } - if (bcmp(hdr->method, methods[method], 5) == 0) - break; - } -#endif - - reading_filename = archive_name; - writting_filename = name; - if (output_to_stdout || verify_mode) { - if (noexec) { - printf("%s %s\n", verify_mode ? "VERIFY" : "EXTRACT", name); - if (afp == stdin) { - int i = hdr->packed_size; - while (i--) - fgetc(afp); - } - return; - } - - save_quiet = quiet; - save_verbose = verbose; - if (!quiet && output_to_stdout) { - printf("::::::::\n%s\n::::::::\n", name); - quiet = TRUE; - verbose = FALSE; - } - else if (verify_mode) { - quiet = FALSE; - verbose = TRUE; - } - - crc = decode_lzhuf - (afp, stdout, hdr->original_size, hdr->packed_size, name, method); - quiet = save_quiet; - verbose = save_verbose; - } - else { - if (skip_flg == FALSE) { - up_flag = inquire_extract(name); - if (up_flag == FALSE && force == FALSE) { - return; - } - } - - if (skip_flg == TRUE) { /* if skip_flg */ - if (stat(name, &stbuf) == 0 && force != TRUE) { - if (stbuf.st_mtime >= hdr->unix_last_modified_stamp) { - if (quiet != TRUE) - printf("%s : Skipped...\n", name); - return; - } - } - } - if (noexec) { - if (afp == stdin) { - int i = hdr->packed_size; - while (i--) - fgetc(afp); - } - return; - } - - signal(SIGINT, interrupt); - signal(SIGHUP, interrupt); - - unlink(name); - errno = 0; - remove_extracting_file_when_interrupt = TRUE; - - if ((fp = open_with_make_path(name)) != NULL) { - crc = decode_lzhuf - (afp, fp, hdr->original_size, hdr->packed_size, name, method); - fclose(fp); - } - remove_extracting_file_when_interrupt = FALSE; - signal(SIGINT, SIG_DFL); - signal(SIGHUP, SIG_DFL); - - if (!fp) - return; - } - - errno = 0; - if (hdr->has_crc && crc != hdr->crc) - error("CRC error", name); - } - else if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_DIRECTORY - || (hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK - || method == LZHDIRS_METHOD_NUM) { - /* ↑これで、Symblic Link は、大丈夫か? */ - if (!ignore_directory && !verify_mode) { - if (noexec) { - if (quiet != TRUE) - printf("EXTRACT %s (directory)\n", name); - return; - } - /* NAME has trailing SLASH '/', (^_^) */ - if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK) { - char buf[256], *bb1, *bb2; - int l_code; - strcpy(buf, name); - bb1 = strtok(buf, "|"); - bb2 = strtok(NULL, "|"); + for (method = 0;; method++) { + if (methods[method] == NULL) { + error("Unknown method \"%.*s\"; \"%s\" will be skiped ...", + 5, hdr->method, name); + return read_size; + } + if (memcmp(hdr->method, methods[method], 5) == 0) + break; + } +#endif + + reading_filename = archive_name; + writing_filename = name; + if (output_to_stdout || verify_mode) { + if (noexec) { + printf("%s %s\n", verify_mode ? "VERIFY" : "EXTRACT", name); + return read_size; + } + + save_quiet = quiet; + save_verbose = verbose; + if (!quiet && output_to_stdout) { + printf("::::::::\n%s\n::::::::\n", name); + quiet = TRUE; + verbose = FALSE; + } + else if (verify_mode) { + quiet = FALSE; + verbose = TRUE; + } + +#if __MINGW32__ + { + int old_mode; + fflush(stdout); + old_mode = setmode(fileno(stdout), O_BINARY); +#endif + + crc = decode_lzhuf(afp, stdout, + hdr->original_size, hdr->packed_size, + name, method, &read_size); +#if __MINGW32__ + fflush(stdout); + setmode(fileno(stdout), old_mode); + } +#endif + quiet = save_quiet; + verbose = save_verbose; + } + else { + if (skip_flg == FALSE) { + up_flag = inquire_extract(name); + if (up_flag == FALSE && force == FALSE) { + return read_size; + } + } + + if (skip_flg == TRUE) { /* if skip_flg */ + if (stat(name, &stbuf) == 0 && force != TRUE) { + if (stbuf.st_mtime >= hdr->unix_last_modified_stamp) { + if (quiet != TRUE) + printf("%s : Skipped...\n", name); + return read_size; + } + } + } + if (noexec) { + return read_size; + } + + signal(SIGINT, interrupt); +#ifdef SIGHUP + signal(SIGHUP, interrupt); +#endif + + unlink(name); + remove_extracting_file_when_interrupt = TRUE; + + if ((fp = open_with_make_path(name)) != NULL) { + crc = decode_lzhuf(afp, fp, + hdr->original_size, hdr->packed_size, + name, method, &read_size); + fclose(fp); + } + remove_extracting_file_when_interrupt = FALSE; + signal(SIGINT, SIG_DFL); +#ifdef SIGHUP + signal(SIGHUP, SIG_DFL); +#endif + if (!fp) + return read_size; + } + + if (hdr->has_crc && crc != hdr->crc) + error("CRC error: \"%s\"", name); + } + 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) { + if (noexec) { + if (quiet != TRUE) + printf("EXTRACT %s (directory)\n", name); + return read_size; + } + /* NAME has trailing SLASH '/', (^_^) */ + if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK) { + int l_code; #ifdef S_IFLNK - if (skip_flg == FALSE) { - up_flag = inquire_extract(name); - if (up_flag == FALSE && force == FALSE) { - return; - } - } else { - if (GETSTAT(bb1, &stbuf) == 0 && force != TRUE) { - if (stbuf.st_mtime >= hdr->unix_last_modified_stamp) { - if (quiet != TRUE) - printf("%s : Skipped...\n", bb1); - return; - } - } - } - - unlink(bb1); - l_code = symlink(bb2, bb1); - if (l_code < 0) { - if (quiet != TRUE) - warning("Can't make Symbolic Link : "); - } - if (quiet != TRUE) { - printf("Symbolic Link %s -> %s\n", bb1, bb2); - } - strcpy(name, bb1); /* Symbolic's name set */ + if (skip_flg == FALSE) { + up_flag = inquire_extract(name); + if (up_flag == FALSE && force == FALSE) { + return read_size; + } + } else { + if (GETSTAT(name, &stbuf) == 0 && force != TRUE) { + if (stbuf.st_mtime >= hdr->unix_last_modified_stamp) { + if (quiet != TRUE) + printf("%s : Skipped...\n", name); + return read_size; + } + } + } + + unlink(name); + make_parent_path(name); + l_code = symlink(hdr->realname, name); + if (l_code < 0) { + if (quiet != TRUE) + warning("Can't make Symbolic Link \"%s\" -> \"%s\"", + name, hdr->realname); + } + if (quiet != TRUE) { + message("Symbolic Link %s -> %s", + name, hdr->realname); + } #else - sprintf(buf, "%s -> %s", bb1, bb2); - warning("Can't make Symbolic Link", buf); - return; -#endif - } else { /* make directory */ - if (!output_to_stdout && !make_parent_path(name)) - return; - } - } - } - else { - error("Unknown information", name); - } + warning("Can't make Symbolic Link %s -> %s", + name, hdr->realname); + return read_size; +#endif + } else { /* make directory */ + if (!output_to_stdout && !make_parent_path(name)) + return read_size; + /* save directory information */ + add_dirinfo(name, hdr); + } + } + } + else { + if (force) /* force extract */ + goto extract_regular; + else + error("Unknown file type: \"%s\". use `f' option to force extract.", name); + } + + if (!output_to_stdout) + adjust_info(name, hdr); - if (!output_to_stdout) - adjust_info(name, hdr); + return read_size; } /* ------------------------------------------------------------------------ */ -/* EXTRACT COMMAND MAIN */ +/* EXTRACT COMMAND MAIN */ /* ------------------------------------------------------------------------ */ void cmd_extract() { - LzHeader hdr; - long pos; - FILE *afp; - - /* open archive file */ - if ((afp = open_old_archive()) == NULL) - fatal_error(archive_name); - - if (archive_is_msdos_sfx1(archive_name)) - skip_msdos_sfx1_code(afp); - - /* extract each files */ - while (get_header(afp, &hdr)) { - if (need_file(hdr.name)) { - pos = ftell(afp); - extract_one(afp, &hdr); - fseek(afp, pos + hdr.packed_size, SEEK_SET); - } else { - if (afp != stdin) - fseek(afp, hdr.packed_size, SEEK_CUR); - else { - int i = hdr.packed_size; - while (i--) - fgetc(afp); - } - } - } + LzHeader hdr; + off_t pos; + FILE *afp; + size_t read_size; + + /* open archive file */ + if ((afp = open_old_archive()) == NULL) + fatal_error("Cannot open archive file \"%s\"", archive_name); + + if (archive_is_msdos_sfx1(archive_name)) + seek_lha_header(afp); + + /* extract each files */ + while (get_header(afp, &hdr)) { + if (need_file(hdr.name)) { + pos = ftello(afp); + read_size = extract_one(afp, &hdr); + if (read_size != hdr.packed_size) { + /* when error occurred in extract_one(), should adjust + point of file stream */ + if (pos != -1 && afp != stdin) + fseeko(afp, pos + hdr.packed_size - read_size, SEEK_SET); + else { + size_t i = hdr.packed_size - read_size; + while (i--) fgetc(afp); + } + } + } else { + if (afp != stdin) + fseeko(afp, hdr.packed_size, SEEK_CUR); + else { + size_t i = hdr.packed_size; + while (i--) fgetc(afp); + } + } + } + + /* close archive file */ + fclose(afp); + + /* adjust directory information */ + adjust_dirinfo(); + + return; +} + +int +is_directory_traversal(char *path) +{ + int state = 0; + + for (; *path; path++) { + switch (state) { + case 0: + if (*path == '.') state = 1; + else state = 3; + break; + case 1: + if (*path == '.') state = 2; + else if (*path == '/') state = 0; + else state = 3; + break; + case 2: + if (*path == '/') return 1; + else state = 3; + break; + case 3: + if (*path == '/') state = 0; + break; + } + } + + return state == 2; +} + +/* + * restore directory information (time stamp). + * added by A.Iriyama 2003.12.12 + */ + +typedef struct lhdDirectoryInfo_t { + struct lhdDirectoryInfo_t *next; + LzHeader hdr; +} LzHeaderList; + +static LzHeaderList *dirinfo; + +static void add_dirinfo(char *name, LzHeader *hdr) +{ + LzHeaderList *p; + + if (memcmp(hdr->method, LZHDIRS_METHOD, 5) != 0) + return; - /* close archive file */ - fclose(afp); + p = xmalloc(sizeof(LzHeaderList)); - return; + memcpy(&p->hdr, hdr, sizeof(LzHeader)); + strncpy(p->hdr.name, name, sizeof(p->hdr.name)); + p->hdr.name[sizeof(p->hdr.name)-1] = 0; + + { + LzHeaderList *tmp = dirinfo; + dirinfo = p; + dirinfo->next = tmp; + } } -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* End: */ +static void adjust_dirinfo() +{ + while (dirinfo) { + adjust_info(dirinfo->hdr.name, &dirinfo->hdr); + + { + LzHeaderList *tmp = dirinfo; + dirinfo = dirinfo->next; + free(tmp); + } + } +} diff -Nru lha-1.14i/src/lhlist.c lha-1.14i-acc20050924p1/src/lhlist.c --- lha-1.14i/src/lhlist.c 2000-10-04 14:57:38.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/lhlist.c 2006-10-10 16:27:51.000000000 +0000 @@ -1,348 +1,357 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* lhlist.c -- LHarc list */ -/* */ -/* Copyright (C) MCMLXXXIX Yooichi.Tagawa */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 0.00 Original 1988.05.23 Y.Tagawa */ -/* Ver. 1.00 Fixed 1989.09.22 Y.Tagawa */ -/* Ver. 1.01 Bug Fix for month name 1989.12.25 Y.Tagawa */ -/* Ver. 1.10 Changed list format 1993.10.01 N.Watazaki */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ -/* Ver. 1.14e Bug Fix for many problems 1999.05.25 T.Okamoto */ +/* LHa for UNIX */ +/* lhlist.c -- LHarc list */ +/* */ +/* Copyright (C) MCMLXXXIX Yooichi.Tagawa */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Ver. 0.00 Original 1988.05.23 Y.Tagawa */ +/* Ver. 1.00 Fixed 1989.09.22 Y.Tagawa */ +/* Ver. 1.01 Bug Fix for month name 1989.12.25 Y.Tagawa */ +/* Ver. 1.10 Changed list format 1993.10.01 N.Watazaki */ +/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* Ver. 1.14e Bug Fix for many problems 1999.05.25 T.Okamoto */ /* ------------------------------------------------------------------------ */ #include "lha.h" /* ------------------------------------------------------------------------ */ -static long packed_size_total; -static long original_size_total; -static int list_files; - -/* ------------------------------------------------------------------------ */ -/* Print Stuff */ +/* Print Stuff */ /* ------------------------------------------------------------------------ */ /* need 14 or 22 (when verbose_listing is TRUE) column spaces */ static void print_size(packed_size, original_size) - long packed_size, original_size; + long packed_size, original_size; { - if (verbose_listing) - printf("%7d ", packed_size); + if (verbose_listing) + printf("%7lu ", packed_size); - printf("%7d ", original_size); + printf("%7lu ", original_size); - if (original_size == 0L) - printf("******"); - else /* Changed N.Watazaki */ - printf("%5.1f%%", packed_size * 100.0 / original_size); + if (original_size == 0L) + printf("******"); + else /* Changed N.Watazaki */ + printf("%5.1f%%", packed_size * 100.0 / original_size); } /* ------------------------------------------------------------------------ */ /* need 12 or 17 (when verbose_listing is TRUE) column spaces */ static void print_stamp(t) - time_t t; + time_t t; { - static boolean got_now = FALSE; - static time_t now; - static unsigned int threshold; - static char t_month[12 * 3 + 1] = "JanFebMarAprMayJunJulAugSepOctNovDec"; - struct tm *p; - - if (t == 0) { - printf(" "); /* 12 spaces */ - return; - } - - if (!got_now) { - now = time((time_t *) 0); - p = localtime(&now); - threshold = p->tm_year * 12 + p->tm_mon - 6; - got_now = TRUE; - } - - p = localtime(&t); - - if (p->tm_year * 12 + p->tm_mon > threshold) - printf("%.3s %2d %02d:%02d", - &t_month[p->tm_mon * 3], p->tm_mday, p->tm_hour, p->tm_min); - else - printf("%.3s %2d %04d", - &t_month[p->tm_mon * 3], p->tm_mday, p->tm_year + 1900); + static unsigned int threshold; + static char t_month[12 * 3 + 1] = "JanFebMarAprMayJunJulAugSepOctNovDec"; + struct tm *p; + + if (t == 0) { + if (verbose_listing && verbose) + printf(" "); /* 19 spaces */ + else + printf(" "); /* 12 spaces */ + return; + } + + if (!threshold) { + time_t now = time(0); + p = localtime(&now); + threshold = p->tm_year * 12 + p->tm_mon - 6; + } + + p = localtime(&t); + + if (verbose_listing && verbose) + printf("%04d-%02d-%02d %02d:%02d:%02d", + p->tm_year+1900, p->tm_mon+1, p->tm_mday, + p->tm_hour, p->tm_min, p->tm_sec); + else if (p->tm_year * 12 + p->tm_mon > threshold) + printf("%.3s %2d %02d:%02d", + &t_month[p->tm_mon * 3], p->tm_mday, p->tm_hour, p->tm_min); + else + printf("%.3s %2d %04d", + &t_month[p->tm_mon * 3], p->tm_mday, p->tm_year + 1900); } /* ------------------------------------------------------------------------ */ static void print_bar() { - char *p, *q; - /* 17+1+(0 or 7+1)+7+1+6+1+(0 or 1+4)+(12 or 17)+1+20 */ - /* 12345678901234567_ 1234567_123456 _123456789012 1234 */ - - if (verbose_listing) { - p = "- ------ ---------- "; - q = " -------------"; - } - else { - p = " "; - q = " --------------------"; - } - - if (verbose) - q = ""; - - printf("---------- ----------- ------- ------%s------------%s\n", p, q); + if (verbose_listing) { + if (verbose) + /* PERMISSION UID GID PACKED SIZE RATIO METHOD CRC STAMP LV */ + printf("---------- ----------- ------- ------- ------ ---------- ------------------- ---\n"); + else + /* PERMISSION UID GID PACKED SIZE RATIO METHOD CRC STAMP NAME */ + printf("---------- ----------- ------- ------- ------ ---------- ------------ ----------\n"); + } + else { + if (verbose) + /* PERMISSION UID GID SIZE RATIO STAMP LV */ + printf("---------- ----------- ------- ------ ------------ ---\n"); + else + /* PERMISSION UID GID SIZE RATIO STAMP NAME */ + printf("---------- ----------- ------- ------ ------------ --------------------\n"); + } } /* ------------------------------------------------------------------------ */ -/* */ +/* */ /* ------------------------------------------------------------------------ */ static void list_header() { - char *p, *q; - - if (verbose_listing) { - p = "PACKED SIZE RATIO METHOD CRC"; - q = " NAME"; - } - else { - p = " SIZE RATIO"; - q = " NAME"; - } - - if (verbose) - q = ""; - - printf(" PERMSSN UID GID %s STAMP%s\n", p, q); -#if 0 - printf(" PERMSSN UID GID %s SIZE RATIO%s %s STAMP%s%s\n", - verbose_listing ? " PACKED " : "", /* 8,0 */ - verbose_listing ? " CRC" : "", /* 5,0 */ - verbose_listing ? " " : "", /* 2,0 */ - verbose_listing ? " " : " ", /* 6,3 */ - verbose ? "" : " NAME"); -#endif - print_bar(); + if (verbose_listing) { + if (verbose) + printf("PERMISSION UID GID PACKED SIZE RATIO METHOD CRC STAMP LV\n"); + else + printf("PERMISSION UID GID PACKED SIZE RATIO METHOD CRC STAMP NAME\n"); + } + else { + if (verbose) + printf("PERMISSION UID GID SIZE RATIO STAMP LV\n"); + else + printf("PERMISSION UID GID SIZE RATIO STAMP NAME\n"); + } + print_bar(); } /* ------------------------------------------------------------------------ */ static void list_one(hdr) - register LzHeader *hdr; + register LzHeader *hdr; { - register int mode; - register char *p; - char method[6]; - char modebits[11]; - - if (verbose) - printf("%s\n", hdr->name); - - strncpy(method, hdr->method, 5); - method[5] = '\0'; - - switch (mode = hdr->extend_type) { - case EXTEND_UNIX: - mode = hdr->unix_mode; - - if (mode & UNIX_FILE_DIRECTORY) - modebits[0] = 'd'; - else if ((mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK) - modebits[0] = 'l'; - else - modebits[0] = '-'; - modebits[1] = ((mode & UNIX_OWNER_READ_PERM) ? 'r' : '-'); - modebits[2] = ((mode & UNIX_OWNER_WRITE_PERM) ? 'w' : '-'); - modebits[3] = (mode & UNIX_SETUID) ? 's' : - ((mode & UNIX_OWNER_EXEC_PERM) ? 'x' : '-'); - modebits[4] = ((mode & UNIX_GROUP_READ_PERM) ? 'r' : '-'); - modebits[5] = ((mode & UNIX_GROUP_WRITE_PERM) ? 'w' : '-'); - modebits[6] = (mode & UNIX_SETGID) ? 's' : - ((mode & UNIX_GROUP_EXEC_PERM) ? 'x' : '-'); - modebits[7] = ((mode & UNIX_OTHER_READ_PERM) ? 'r' : '-'); - modebits[8] = ((mode & UNIX_OTHER_WRITE_PERM) ? 'w' : '-'); - modebits[9] = (mode & UNIX_STYCKYBIT) ? 't' : - ((mode & UNIX_OTHER_EXEC_PERM) ? 'x' : '-'); - modebits[10] = 0; - - printf("%s %5d/%-5d ", modebits, - hdr->unix_uid, hdr->unix_gid); - break; - case EXTEND_OS68K: - /**/ case EXTEND_XOSK:/**/ - mode = hdr->unix_mode; - printf("%c%c%c%c%c%c%c%c %5d/%-5d", - ((mode & OSK_DIRECTORY_PERM) ? 'd' : '-'), - ((mode & OSK_SHARED_PERM) ? 's' : '-'), - ((mode & OSK_OTHER_EXEC_PERM) ? 'e' : '-'), - ((mode & OSK_OTHER_WRITE_PERM) ? 'w' : '-'), - ((mode & OSK_OTHER_READ_PERM) ? 'r' : '-'), - ((mode & OSK_OWNER_EXEC_PERM) ? 'e' : '-'), - ((mode & OSK_OWNER_WRITE_PERM) ? 'w' : '-'), - ((mode & OSK_OWNER_READ_PERM) ? 'r' : '-'), - hdr->unix_uid, hdr->unix_gid); - break; - default: - switch (hdr->extend_type) { /* max 18 characters */ - case EXTEND_GENERIC: - p = "[generic]"; - break; - case EXTEND_CPM: - p = "[CP/M]"; - break; - case EXTEND_FLEX: - p = "[FLEX]"; - break; - case EXTEND_OS9: - p = "[OS-9]"; - break; - case EXTEND_OS68K: - p = "[OS-9/68K]"; - break; - case EXTEND_MSDOS: - p = "[MS-DOS]"; - break; - case EXTEND_MACOS: - p = "[Mac OS]"; - break; - case EXTEND_OS2: - p = "[OS/2]"; - break; - case EXTEND_HUMAN: - p = "[Human68K]"; - break; - case EXTEND_OS386: - p = "[OS-386]"; - break; - case EXTEND_RUNSER: - p = "[Runser]"; - break; + register int mode = 0; + register char *p; + char method[6]; + char modebits[11]; + + if (verbose) { + if ((hdr->unix_mode & UNIX_FILE_SYMLINK) != UNIX_FILE_SYMLINK) + printf("%s\n", hdr->name); + else + printf("%s -> %s\n", hdr->name, hdr->realname); + } + + strncpy(method, hdr->method, 5); + method[5] = '\0'; + + switch (hdr->extend_type) { + case EXTEND_UNIX: + mode = hdr->unix_mode; + + if (mode & UNIX_FILE_DIRECTORY) + modebits[0] = 'd'; + else if ((mode & UNIX_FILE_SYMLINK) == UNIX_FILE_SYMLINK) + modebits[0] = 'l'; + else + modebits[0] = '-'; + modebits[1] = ((mode & UNIX_OWNER_READ_PERM) ? 'r' : '-'); + modebits[2] = ((mode & UNIX_OWNER_WRITE_PERM) ? 'w' : '-'); + modebits[3] = (mode & UNIX_SETUID) ? 's' : + ((mode & UNIX_OWNER_EXEC_PERM) ? 'x' : '-'); + modebits[4] = ((mode & UNIX_GROUP_READ_PERM) ? 'r' : '-'); + modebits[5] = ((mode & UNIX_GROUP_WRITE_PERM) ? 'w' : '-'); + modebits[6] = (mode & UNIX_SETGID) ? 's' : + ((mode & UNIX_GROUP_EXEC_PERM) ? 'x' : '-'); + modebits[7] = ((mode & UNIX_OTHER_READ_PERM) ? 'r' : '-'); + modebits[8] = ((mode & UNIX_OTHER_WRITE_PERM) ? 'w' : '-'); + modebits[9] = (mode & UNIX_STICKYBIT) ? 't' : + ((mode & UNIX_OTHER_EXEC_PERM) ? 'x' : '-'); + modebits[10] = 0; + + printf("%s ", modebits); + break; + case EXTEND_OS68K: + /**/ case EXTEND_XOSK:/**/ + mode = hdr->unix_mode; + printf("%c%c%c%c%c%c%c%c ", + ((mode & OSK_DIRECTORY_PERM) ? 'd' : '-'), + ((mode & OSK_SHARED_PERM) ? 's' : '-'), + ((mode & OSK_OTHER_EXEC_PERM) ? 'e' : '-'), + ((mode & OSK_OTHER_WRITE_PERM) ? 'w' : '-'), + ((mode & OSK_OTHER_READ_PERM) ? 'r' : '-'), + ((mode & OSK_OWNER_EXEC_PERM) ? 'e' : '-'), + ((mode & OSK_OWNER_WRITE_PERM) ? 'w' : '-'), + ((mode & OSK_OWNER_READ_PERM) ? 'r' : '-')); + + break; + default: + switch (hdr->extend_type) { /* max 18 characters */ + case EXTEND_GENERIC: + p = "[generic]"; + break; + case EXTEND_CPM: + p = "[CP/M]"; + break; + case EXTEND_FLEX: + p = "[FLEX]"; + break; + case EXTEND_OS9: + p = "[OS-9]"; + break; + case EXTEND_OS68K: + p = "[OS-9/68K]"; + break; + case EXTEND_MSDOS: + p = "[MS-DOS]"; + break; + case EXTEND_MACOS: + p = "[Mac OS]"; + break; + case EXTEND_OS2: + p = "[OS/2]"; + break; + case EXTEND_HUMAN: + p = "[Human68K]"; + break; + case EXTEND_OS386: + p = "[OS-386]"; + break; + case EXTEND_RUNSER: + p = "[Runser]"; + break; #ifdef EXTEND_TOWNSOS - /* This ID isn't fixed */ - case EXTEND_TOWNSOS: - p = "[TownsOS]"; - break; + /* This ID isn't fixed */ + case EXTEND_TOWNSOS: + p = "[TownsOS]"; + break; #endif - /* Ouch! Please customize it's ID. */ - default: - p = "[unknown]"; - break; - } - printf("%-23.23s", p); - break; - } - - print_size(hdr->packed_size, hdr->original_size); - - if (verbose_listing) - if (hdr->has_crc) - printf(" %s %04x", method, hdr->crc); - else - printf(" %s ****", method); - - printf(" "); - print_stamp(hdr->unix_last_modified_stamp); - - if (!verbose) - if ((mode & UNIX_FILE_SYMLINK) != UNIX_FILE_SYMLINK) - printf(" %s", hdr->name); - else { - char buf[256], *b1, *b2; - strcpy(buf, hdr->name); - b1 = strtok(buf, "|"); - b2 = strtok(NULL, "|"); - printf(" %s -> %s", b1, b2); - } - - if (verbose) - printf(" [%d]", hdr->header_level); - printf("\n"); + case EXTEND_JAVA: + p = "[JAVA]"; + break; + /* Ouch! Please customize it's ID. */ + default: + p = "[unknown]"; + break; + } + printf("%-11.11s", p); + break; + } + + switch (hdr->extend_type) { + case EXTEND_UNIX: + case EXTEND_OS68K: + case EXTEND_XOSK: + if (hdr->user[0]) + printf("%5.5s/", hdr->user); + else + printf("%5d/", hdr->unix_uid); + + if (hdr->group[0]) + printf("%-5.5s ", hdr->group); + else + printf("%-5d ", hdr->unix_gid); + break; + default: + printf("%12s", ""); + break; + } + + print_size(hdr->packed_size, hdr->original_size); + + if (verbose_listing) { + if (hdr->has_crc) + printf(" %s %04x", method, hdr->crc); + else + printf(" %s ****", method); + } + + printf(" "); + print_stamp(hdr->unix_last_modified_stamp); + + if (!verbose) { + if ((hdr->unix_mode & UNIX_FILE_SYMLINK) != UNIX_FILE_SYMLINK) + printf(" %s", hdr->name); + else { + printf(" %s -> %s", hdr->name, hdr->realname); + } + } + if (verbose) + printf(" [%d]", hdr->header_level); + printf("\n"); } /* ------------------------------------------------------------------------ */ static void -list_tailer() +list_tailer(list_files, packed_size_total, original_size_total) + int list_files; + unsigned long packed_size_total, original_size_total; { - struct stat stbuf; + struct stat stbuf; - print_bar(); + print_bar(); - printf(" Total %9d file%c ", - list_files, (list_files == 1) ? ' ' : 's'); - print_size(packed_size_total, original_size_total); - printf(" "); + printf(" Total %9d file%c ", + list_files, (list_files == 1) ? ' ' : 's'); + print_size(packed_size_total, original_size_total); + printf(" "); - if (verbose_listing) - printf(" "); + if (verbose_listing) + printf(" "); - if (stat(archive_name, &stbuf) < 0) - print_stamp((time_t) 0); - else - print_stamp(stbuf.st_mtime); + if (stat(archive_name, &stbuf) < 0) + print_stamp((time_t) 0); + else + print_stamp(stbuf.st_mtime); - printf("\n"); + printf("\n"); } /* ------------------------------------------------------------------------ */ -/* LIST COMMAND MAIN */ +/* LIST COMMAND MAIN */ /* ------------------------------------------------------------------------ */ void cmd_list() { - FILE *afp; - LzHeader hdr; - int i; - - /* initialize total count */ - packed_size_total = 0L; - original_size_total = 0L; - list_files = 0; - - /* open archive file */ - if ((afp = open_old_archive()) == NULL) { - error(archive_name, ""); - exit(1); - } - if (archive_is_msdos_sfx1(archive_name)) - skip_msdos_sfx1_code(afp); - - /* print header message */ - if (!quiet) - list_header(); - - /* print each file information */ - while (get_header(afp, &hdr)) { - if (need_file(hdr.name)) { - list_one(&hdr); - list_files++; - packed_size_total += hdr.packed_size; - original_size_total += hdr.original_size; - } - - if (afp != stdin) - fseek(afp, hdr.packed_size, SEEK_CUR); - else { - i = hdr.packed_size; - while (i--) - fgetc(afp); - } - } - - /* close archive file */ - fclose(afp); - - /* print tailer message */ - if (!quiet) - list_tailer(); + FILE *afp; + LzHeader hdr; + int i; + + unsigned long packed_size_total; + unsigned long original_size_total; + int list_files; + + /* initialize total count */ + packed_size_total = 0L; + original_size_total = 0L; + list_files = 0; + + /* open archive file */ + if ((afp = open_old_archive()) == NULL) { + error("Cannot open archive \"%s\"", archive_name); + exit(1); + } + if (archive_is_msdos_sfx1(archive_name)) + seek_lha_header(afp); + + /* print header message */ + if (!quiet) + list_header(); + + /* print each file information */ + while (get_header(afp, &hdr)) { + if (need_file(hdr.name)) { + list_one(&hdr); + list_files++; + packed_size_total += hdr.packed_size; + original_size_total += hdr.original_size; + } + + if (afp != stdin) + fseeko(afp, hdr.packed_size, SEEK_CUR); + else { + i = hdr.packed_size; + while (i--) + fgetc(afp); + } + } + + /* close archive file */ + fclose(afp); + + /* print tailer message */ + if (!quiet) + list_tailer(list_files, packed_size_total, original_size_total); - return; + return; } - -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* compile-command:"gcc -c lhlist.c" */ -/* End: */ diff -Nru lha-1.14i/src/Makefile lha-1.14i-acc20050924p1/src/Makefile --- lha-1.14i/src/Makefile 2000-12-15 12:13:15.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -############################################################################## -# Makefile for LHarc UNIX Archiver Driver -# Copyright(C) MCMLXXXIX Yooichi.Tagawa -# V0.01 Alpha Version 1989.05.28 Y.Tagawa -# V0.02 Alpha Version R2 1989.05.29 Y.Tagawa -# V0.03 Release #3 Beta Version 1989.07.02 Y.Tagawa -# V0.03b Modified 1989.07.13 Y.Tagawa -# V1.00 Fixed 1989.09.19 Y.Tagawa -# -# for OSK -# V1.08 1990.10.09 Sakura Tomozou -# V2.00 + lzhuf4/5 1990.10.26 -# -# LHa for UNIX -# V0.01 Alpha Version 1991.10.17 Masaru Oki -# V0.02 Alpha Version Rel.2 1991.11.26 Masaru Oki -# V0.03 Beta Version 1991.12.03 Masaru Oki -# V0.04 Beta Version Rel.2 1992.01.17 Masaru Oki -# V0.05 Beta Version Final 1992.02.17 Masaru Oki -############################################################################## - -LHOBJS = lharc$(O) lhadd$(O) lhlist$(O) lhext$(O) header$(O) -HUFOBJS = append$(O) crcio$(O) dhuf$(O) extract$(O) huf$(O) \ - larc$(O) maketbl$(O) maketree$(O) shuf$(O) slide$(O) \ - util$(O) - -OBJS = $(LHOBJS) $(HUFOBJS) $(LIBRARYOBJS) - -CFLAGS = $(OPTIMIZE) $(SWITCHES) $(MACHINE) - -all : lha - -lha : $(OBJS) - $(CC) -o $@ $(OBJS) $(LDFLAGS) - -$(LHOBJS) append$(O) slide$(O) extract$(O) : lha.h lha_macro.h - -$(HUFOBJS) : lha.h lha_macro.h -crcio$(O) extract$(O) slide$(O) : lha.h lha_macro.h - -lhdir$(O) : lhdir.h - -$(OBJS) : ../Makefile - -clean: - rm -f core lha $(OBJS) - -moreclean: - rm -f core *.o lha.tar lha.tar.Z *~ \#* *.orig - -install: - $(INSTALL) $(INSTALLBIN) lha $(BINDIR)/lha diff -Nru lha-1.14i/src/Makefile.am lha-1.14i-acc20050924p1/src/Makefile.am --- lha-1.14i/src/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/Makefile.am 2004-09-28 17:06:39.000000000 +0000 @@ -0,0 +1,9 @@ +## Process this file with automake to produce Makefile.in +bin_PROGRAMS = lha +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 +lha_LDADD = @LIBOBJS@ +EXTRA_DIST = lhdir.h fnmatch.h +AM_CPPFLAGS=$(DEF_KCODE) $(SUPPORT_LZHUFF_METHOD) diff -Nru lha-1.14i/src/Makefile.in lha-1.14i-acc20050924p1/src/Makefile.in --- lha-1.14i/src/Makefile.in 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/Makefile.in 2006-10-16 14:50:09.000000000 +0000 @@ -0,0 +1,443 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +LIBOBJDIR = +bin_PROGRAMS = lha$(EXEEXT) +subdir = src +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in fnmatch.c \ + lhdir.c vsnprintf.c +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_lha_OBJECTS = append.$(OBJEXT) bitio.$(OBJEXT) crcio.$(OBJEXT) \ + dhuf.$(OBJEXT) extract.$(OBJEXT) header.$(OBJEXT) \ + huf.$(OBJEXT) indicator.$(OBJEXT) larc.$(OBJEXT) \ + lhadd.$(OBJEXT) lharc.$(OBJEXT) lhext.$(OBJEXT) \ + lhlist.$(OBJEXT) maketbl.$(OBJEXT) maketree.$(OBJEXT) \ + patmatch.$(OBJEXT) shuf.$(OBJEXT) slide.$(OBJEXT) \ + util.$(OBJEXT) getopt_long.$(OBJEXT) +lha_OBJECTS = $(am_lha_OBJECTS) +lha_DEPENDENCIES = @LIBOBJS@ +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(lha_SOURCES) +DIST_SOURCES = $(lha_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEF_KCODE = @DEF_KCODE@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SUPPORT_LZHUFF_METHOD = @SUPPORT_LZHUFF_METHOD@ +U = @U@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +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 + +lha_LDADD = @LIBOBJS@ +EXTRA_DIST = lhdir.h fnmatch.h +AM_CPPFLAGS = $(DEF_KCODE) $(SUPPORT_LZHUFF_METHOD) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +lha$(EXEEXT): $(lha_OBJECTS) $(lha_DEPENDENCIES) + @rm -f lha$(EXEEXT) + $(LINK) $(lha_LDFLAGS) $(lha_OBJECTS) $(lha_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/fnmatch.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/lhdir.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/vsnprintf.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/append.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bitio.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crcio.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dhuf.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/extract.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt_long.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/header.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/huf.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/larc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lhadd.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lharc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lhext.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lhlist.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/maketbl.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/maketree.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/patmatch.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shuf.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slide.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -rf $(DEPDIR) ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: install-binPROGRAMS + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf $(DEPDIR) ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic ctags distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-binPROGRAMS uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff -Nru lha-1.14i/src/maketbl.c lha-1.14i-acc20050924p1/src/maketbl.c --- lha-1.14i/src/maketbl.c 2000-10-04 14:57:38.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/maketbl.c 2006-10-10 16:39:06.000000000 +0000 @@ -1,98 +1,109 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* maketbl.c -- makes decoding table */ -/* */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* LHa for UNIX */ +/* maketbl.c -- makes decoding table */ +/* */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ /* ------------------------------------------------------------------------ */ #include "lha.h" void make_table(nchar, bitlen, tablebits, table) - short nchar; - unsigned char bitlen[]; - short tablebits; - unsigned short table[]; + short nchar; + unsigned char bitlen[]; + short tablebits; + unsigned short table[]; { - unsigned short count[17]; /* count of bitlen */ - unsigned short weight[17]; /* 0x10000ul >> bitlen */ - unsigned short start[17]; /* first code of bitlen */ - unsigned short total; - unsigned int i, l; - int j, k, m, n, avail; - unsigned short *p; - - avail = nchar; - - /* initialize */ - for (i = 1; i <= 16; i++) { - count[i] = 0; - weight[i] = 1 << (16 - i); - } - - /* count */ - for (i = 0; i < nchar; i++) - count[bitlen[i]]++; - - /* calculate first code */ - total = 0; - for (i = 1; i <= 16; i++) { - start[i] = total; - total += weight[i] * count[i]; - } - if ((total & 0xffff) != 0) - error("make_table()", "Bad table (5)\n"); - - /* shift data for make table. */ - m = 16 - tablebits; - for (i = 1; i <= tablebits; i++) { - start[i] >>= m; - weight[i] >>= m; - } - - /* initialize */ - j = start[tablebits + 1] >> m; - k = 1 << tablebits; - if (j != 0) - for (i = j; i < k; i++) - table[i] = 0; - - /* create table and tree */ - for (j = 0; j < nchar; j++) { - k = bitlen[j]; - if (k == 0) - continue; - l = start[k] + weight[k]; - if (k <= tablebits) { - /* code in table */ - for (i = start[k]; i < l; i++) - table[i] = j; - } - else { - /* code not in table */ - p = &table[(i = start[k]) >> m]; - i <<= tablebits; - n = k - tablebits; - /* make tree (n length) */ - while (--n >= 0) { - if (*p == 0) { - right[avail] = left[avail] = 0; - *p = avail++; - } - if (i & 0x8000) - p = &right[*p]; - else - p = &left[*p]; - i <<= 1; - } - *p = j; - } - start[k] = l; - } + unsigned short count[17]; /* count of bitlen */ + unsigned short weight[17]; /* 0x10000ul >> bitlen */ + unsigned short start[17]; /* first code of bitlen */ + unsigned short total; + unsigned int i, l; + int j, k, m, n, avail; + unsigned short *p; + + avail = nchar; + + /* initialize */ + for (i = 1; i <= 16; i++) { + count[i] = 0; + weight[i] = 1 << (16 - i); + } + + /* count */ + for (i = 0; i < nchar; i++) { + if (bitlen[i] > 16) { + /* CVE-2006-4335 */ + error("Bad table (case a)"); + exit(1); + } + else + count[bitlen[i]]++; + } + + /* calculate first code */ + total = 0; + for (i = 1; i <= 16; i++) { + start[i] = total; + total += weight[i] * count[i]; + } + if ((total & 0xffff) != 0 || tablebits > 16) { /* 16 for weight below */ + error("make_table(): Bad table (case b)"); + exit(1); + } + + /* shift data for make table. */ + m = 16 - tablebits; + for (i = 1; i <= tablebits; i++) { + start[i] >>= m; + weight[i] >>= m; + } + + /* initialize */ + j = start[tablebits + 1] >> m; + k = MIN(1 << tablebits, 4096); + if (j != 0) + for (i = j; i < k; i++) + table[i] = 0; + + /* create table and tree */ + for (j = 0; j < nchar; j++) { + k = bitlen[j]; + if (k == 0) + continue; + l = start[k] + weight[k]; + if (k <= tablebits) { + /* code in table */ + l = MIN(l, 4096); + for (i = start[k]; i < l; i++) + table[i] = j; + } + else { + /* code not in table */ + i = start[k]; + if ((i >> m) > 4096) { + /* CVE-2006-4337 */ + error("Bad table (case c)"); + exit(1); + } + p = &table[i >> m]; + i <<= tablebits; + n = k - tablebits; + /* make tree (n length) */ + while (--n >= 0) { + if (*p == 0) { + right[avail] = left[avail] = 0; + *p = avail++; + } + if (i & 0x8000) + p = &right[*p]; + else + p = &left[*p]; + i <<= 1; + } + *p = j; + } + start[k] = l; + } } - -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* End: */ diff -Nru lha-1.14i/src/maketree.c lha-1.14i-acc20050924p1/src/maketree.c --- lha-1.14i/src/maketree.c 2000-10-04 14:57:38.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/maketree.c 2003-07-19 14:43:26.000000000 +0000 @@ -1,175 +1,179 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* maketree.c -- make Huffman tree */ -/* */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* LHa for UNIX */ +/* maketree.c -- make Huffman tree */ +/* */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ /* ------------------------------------------------------------------------ */ #include "lha.h" -/* ------------------------------------------------------------------------ */ -static short n, heapsize, heap[NC + 1]; -static unsigned short *freq, *sort; -static unsigned char *len; -static unsigned short len_cnt[17]; -/* ------------------------------------------------------------------------ */ -void -make_code(n, len, code) - int n; - unsigned char len[]; - unsigned short code[]; +static void +make_code(nchar, bitlen, code, leaf_num) + int nchar; + unsigned char *bitlen; + unsigned short *code; /* table */ + unsigned short *leaf_num; { - unsigned short weight[17]; /* 0x10000ul >> bitlen */ - unsigned short start[17]; /* start code */ - unsigned short j, k; - int i; - - j = 0; - k = 1 << (16 - 1); - for (i = 1; i <= 16; i++) { - start[i] = j; - j += (weight[i] = k) * len_cnt[i]; - k >>= 1; - } - for (i = 0; i < n; i++) { - j = len[i]; - code[i] = start[j]; - start[j] += weight[j]; - } + unsigned short weight[17]; /* 0x10000ul >> bitlen */ + unsigned short start[17]; /* start code */ + unsigned short total; + int i; + int c; + + total = 0; + for (i = 1; i <= 16; i++) { + start[i] = total; + weight[i] = 1 << (16 - i); + total += weight[i] * leaf_num[i]; + } + for (c = 0; c < nchar; c++) { + i = bitlen[c]; + code[c] = start[i]; + start[i] += weight[i]; + } } -/* ------------------------------------------------------------------------ */ static void -count_len(i) /* call with i = root */ - int i; +count_leaf(node, nchar, leaf_num, depth) /* call with node = root */ + int node; + int nchar; + unsigned short leaf_num[]; + int depth; { - static unsigned char depth = 0; - - if (i < n) - len_cnt[depth < 16 ? depth : 16]++; - else { - depth++; - count_len(left[i]); - count_len(right[i]); - depth--; - } + if (node < nchar) + leaf_num[depth < 16 ? depth : 16]++; + else { + count_leaf(left[node], nchar, leaf_num, depth + 1); + count_leaf(right[node], nchar, leaf_num, depth + 1); + } } -/* ------------------------------------------------------------------------ */ static void -make_len(root) - int root; +make_len(nchar, bitlen, sort, leaf_num) + int nchar; + unsigned char *bitlen; + unsigned short *sort; /* sorted characters */ + unsigned short *leaf_num; { - int i, k; - unsigned int cum; + int i, k; + unsigned int cum; - for (i = 0; i <= 16; i++) - len_cnt[i] = 0; - count_len(root); - cum = 0; - for (i = 16; i > 0; i--) { - cum += len_cnt[i] << (16 - i); - } + cum = 0; + for (i = 16; i > 0; i--) { + cum += leaf_num[i] << (16 - i); + } #if (UINT_MAX != 0xffff) - cum &= 0xffff; + cum &= 0xffff; #endif - /* adjust len */ - if (cum) { - fprintf(stderr, "17"); - len_cnt[16] -= cum; /* always len_cnt[16] > cum */ - do { - for (i = 15; i > 0; i--) { - if (len_cnt[i]) { - len_cnt[i]--; - len_cnt[i + 1] += 2; - break; - } - } - } while (--cum); - } - /* make len */ - for (i = 16; i > 0; i--) { - k = len_cnt[i]; - while (k > 0) { - len[*sort++] = i; - k--; - } - } + /* adjust len */ + if (cum) { + leaf_num[16] -= cum; /* always leaf_num[16] > cum */ + do { + for (i = 15; i > 0; i--) { + if (leaf_num[i]) { + leaf_num[i]--; + leaf_num[i + 1] += 2; + break; + } + } + } while (--cum); + } + /* make len */ + for (i = 16; i > 0; i--) { + k = leaf_num[i]; + while (k > 0) { + bitlen[*sort++] = i; + k--; + } + } } -/* ------------------------------------------------------------------------ */ -static void -downheap(i) /* priority queue; send i-th entry down heap */ - int i; +static void +downheap(i, heap, heapsize, freq) + int i; + short *heap; + size_t heapsize; + unsigned short *freq; { - short j, k; + short j, k; - k = heap[i]; - while ((j = 2 * i) <= heapsize) { - if (j < heapsize && freq[heap[j]] > freq[heap[j + 1]]) - j++; - if (freq[k] <= freq[heap[j]]) - break; - heap[i] = heap[j]; - i = j; - } - heap[i] = k; + k = heap[i]; + while ((j = 2 * i) <= heapsize) { + if (j < heapsize && freq[heap[j]] > freq[heap[j + 1]]) + j++; + if (freq[k] <= freq[heap[j]]) + break; + heap[i] = heap[j]; + i = j; + } + heap[i] = k; } -/* ------------------------------------------------------------------------ */ +/* make tree, calculate bitlen[], return root */ short -make_tree(nparm, freqparm, lenparm, codeparm) -/* make tree, calculate len[], return root */ - int nparm; - unsigned short freqparm[]; - unsigned char lenparm[]; - unsigned short codeparm[]; +make_tree(nchar, freq, bitlen, code) + int nchar; + unsigned short *freq; + unsigned char *bitlen; + unsigned short *code; { - short i, j, k, avail; + short i, j, avail, root; + unsigned short *sort; - n = nparm; - freq = freqparm; - len = lenparm; - avail = n; - heapsize = 0; - heap[1] = 0; - for (i = 0; i < n; i++) { - len[i] = 0; - if (freq[i]) - heap[++heapsize] = i; - } - if (heapsize < 2) { - codeparm[heap[1]] = 0; - return heap[1]; - } - for (i = heapsize / 2; i >= 1; i--) - downheap(i); /* make priority queue */ - sort = codeparm; - do { /* while queue has at least two entries */ - i = heap[1]; /* take out least-freq entry */ - if (i < n) - *sort++ = i; - heap[1] = heap[heapsize--]; - downheap(1); - j = heap[1]; /* next least-freq entry */ - if (j < n) - *sort++ = j; - k = avail++; /* generate new node */ - freq[k] = freq[i] + freq[j]; - heap[1] = k; - downheap(1); /* put into queue */ - left[k] = i; - right[k] = j; - } while (heapsize > 1); - sort = codeparm; - make_len(k); - make_code(nparm, lenparm, codeparm); - return k; /* return root */ -} + short heap[NC + 1]; /* NC >= nchar */ + size_t heapsize; + + avail = nchar; + heapsize = 0; + heap[1] = 0; + for (i = 0; i < nchar; i++) { + bitlen[i] = 0; + if (freq[i]) + heap[++heapsize] = i; + } + if (heapsize < 2) { + code[heap[1]] = 0; + return heap[1]; + } + + /* make priority queue */ + for (i = heapsize / 2; i >= 1; i--) + downheap(i, heap, heapsize, freq); + + /* make huffman tree */ + sort = code; + do { /* while queue has at least two entries */ + i = heap[1]; /* take out least-freq entry */ + if (i < nchar) + *sort++ = i; + heap[1] = heap[heapsize--]; + downheap(1, heap, heapsize, freq); + j = heap[1]; /* next least-freq entry */ + if (j < nchar) + *sort++ = j; + root = avail++; /* generate new node */ + freq[root] = freq[i] + freq[j]; + heap[1] = root; + downheap(1, heap, heapsize, freq); /* put into queue */ + left[root] = i; + right[root] = j; + } while (heapsize > 1); + + { + unsigned short leaf_num[17]; + + /* make leaf_num */ + memset(leaf_num, 0, sizeof(leaf_num)); + count_leaf(root, nchar, leaf_num, 0); + + /* make bitlen */ + make_len(nchar, bitlen, code, leaf_num); + + /* make code table */ + make_code(nchar, bitlen, code, leaf_num); + } -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* End: */ + return root; +} diff -Nru lha-1.14i/src/makezero.c lha-1.14i-acc20050924p1/src/makezero.c --- lha-1.14i/src/makezero.c 2000-10-04 14:57:38.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/makezero.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ - -#include - -main() -{ - int i; - - for (i=0; i<10000; i++) - fputc(0, stdout); - -} diff -Nru lha-1.14i/src/patmatch.c lha-1.14i-acc20050924p1/src/patmatch.c --- lha-1.14i/src/patmatch.c 2000-10-04 14:57:38.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/patmatch.c 2002-11-16 19:03:23.000000000 +0000 @@ -1,10 +1,10 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* patmatch.c -- path check */ -/* */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* LHa for UNIX */ +/* patmatch.c -- path check */ +/* */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ /* ------------------------------------------------------------------------ */ #include @@ -14,26 +14,26 @@ */ int patmatch(p, s, f) - register char *p; /* pattern */ - register char *s; /* string to match */ - int f; /* flag for case force */ + register char *p; /* pattern */ + register char *s; /* string to match */ + int f; /* flag for case force */ { - char pc; /* a single character from pattern */ + char pc; /* a single character from pattern */ - while (pc = ((f && islower(*p)) ? toupper(*p++) : *p++)) { - if (pc == '*') { - do { /* look for match till s exhausted */ - if (patmatch(p, s, f)) - return (1); - } while (*s++); - return (0); - } - else if (*s == 0) - return (0); /* s exhausted, p not */ - else if (pc == '?') - s++; /* matches all, just bump */ - else if (pc != ((f && islower(*s)) ? toupper(*s++) : *s++)) - return (0); - } - return (!*s); /* p exhausted, ret true if s exhausted */ + while (pc = ((f && islower(*p)) ? toupper(*p++) : *p++)) { + if (pc == '*') { + do { /* look for match till s exhausted */ + if (patmatch(p, s, f)) + return (1); + } while (*s++); + return (0); + } + else if (*s == 0) + return (0); /* s exhausted, p not */ + else if (pc == '?') + s++; /* matches all, just bump */ + else if (pc != ((f && islower(*s)) ? toupper(*s++) : *s++)) + return (0); + } + return (!*s); /* p exhausted, ret true if s exhausted */ } diff -Nru lha-1.14i/src/prototypes.h lha-1.14i-acc20050924p1/src/prototypes.h --- lha-1.14i/src/prototypes.h 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/prototypes.h 2006-10-10 16:27:51.000000000 +0000 @@ -0,0 +1,155 @@ +/* This file was generated by cproto. */ +#if PROTOTYPES /* defined in config.h */ +#define P_(s) s +#else +#define P_(s) () +#endif + +/* append.c */ +int encode_lzhuf P_((FILE *infp, FILE *outfp, size_t size, size_t *original_size_var, size_t *packed_size_var, char *name, char *hdr_method)); +/* bitio.c */ +void fillbuf P_((int n)); +unsigned short getbits P_((int n)); +void putcode P_((int n, int x)); +void putbits P_((int n, int x)); +void init_getbits P_((void)); +void init_putbits P_((void)); +/* crcio.c */ +void make_crctable P_((void)); +unsigned int calccrc P_((unsigned int crc, unsigned char *p, unsigned int n)); +int fread_crc P_((unsigned int *crcp, unsigned char *p, int n, FILE *fp)); +void fwrite_crc P_((unsigned int *crcp, unsigned char *p, int n, FILE *fp)); +void init_code_cache P_((void)); +int fwrite_txt P_((unsigned char *p, int n, FILE *fp)); +int fread_txt P_((unsigned char *p, int n, FILE *fp)); +/* dhuf.c */ +void start_c_dyn P_((void)); +void decode_start_dyn P_((void)); +unsigned short decode_c_dyn P_((void)); +unsigned short decode_p_dyn P_((void)); +void output_dyn P_((unsigned int code, unsigned int pos)); +void encode_end_dyn P_((void)); +/* extract.c */ +int decode_lzhuf P_((FILE *infp, FILE *outfp, size_t original_size, size_t packed_size, char *name, int method, size_t *read_sizep)); +/* header.c */ +int calc_sum P_((char *p, int len)); +void convert_filename P_((char *name, int len, int size, int from_code, int to_code, char *from_delim, char *to_delim, int case_to)); +boolean get_header P_((FILE *fp, LzHeader *hdr)); +int seek_lha_header P_((FILE *fp)); +void init_header P_((char *name, struct stat *v_stat, LzHeader *hdr)); +void write_header P_((FILE *fp, LzHeader *hdr)); +char *sjis_to_utf8 P_((char *dst, const char *src, size_t dstsize)); +char *utf8_to_sjis P_((char *dst, const char *src, size_t dstsize)); +void euc2sjis P_((int *p1, int *p2)); +void sjis2euc P_((int *p1, int *p2)); +int cap_to_sjis P_((char *dst, const char *src, size_t dstsize)); +int sjis_to_cap P_((char *dst, const char *src, size_t dstsize)); +/* huf.c */ +void output_st1 P_((int c, int p)); +unsigned char *alloc_buf P_((void)); +void encode_start_st1 P_((void)); +void encode_end_st1 P_((void)); +unsigned short decode_c_st1 P_((void)); +unsigned short decode_p_st1 P_((void)); +void decode_start_st1 P_((void)); +/* indicator.c */ +void start_indicator P_((char *name, size_t size, char *msg, long def_indicator_threshold)); +void put_indicator P_((long int count)); +void finish_indicator2 P_((char *name, char *msg, int pcnt)); +void finish_indicator P_((char *name, char *msg)); +/* larc.c */ +unsigned short decode_c_lzs P_((void)); +unsigned short decode_p_lzs P_((void)); +void decode_start_lzs P_((void)); +unsigned short decode_c_lz5 P_((void)); +unsigned short decode_p_lz5 P_((void)); +void decode_start_lz5 P_((void)); +/* lhadd.c */ +FILE *append_it P_((char *name, FILE *oafp, FILE *nafp)); +void temporary_to_new_archive_file P_((size_t new_archive_size)); +void cmd_add P_((void)); +void cmd_delete P_((void)); +/* lharc.c */ +void message P_((char *fmt, ...)); +void warning P_((char *fmt, ...)); +void error P_((char *fmt, ...)); +void fatal_error P_((char *fmt, ...)); +void cleanup P_((void)); +RETSIGTYPE interrupt P_((int signo)); +void *xmalloc P_((size_t size)); +void *xrealloc P_((void *old, size_t size)); +char *xstrdup P_((char *str)); +void init_sp P_((struct string_pool *sp)); +void add_sp P_((struct string_pool *sp, char *name, int len)); +void finish_sp P_((register struct string_pool *sp, int *v_count, char ***v_vector)); +void free_sp P_((char **vector)); +void cleaning_files P_((int *v_filec, char ***v_filev)); +boolean find_files P_((char *name, int *v_filec, char ***v_filev)); +void free_files P_((int filec, char **filev)); +int build_temporary_name P_((void)); +void build_backup_name P_((char *buffer, char *original, size_t size)); +void build_standard_archive_name P_((char *buffer, char *original, size_t size)); +boolean need_file P_((char *name)); +FILE *xfopen P_((char *name, char *mode)); +FILE *open_old_archive P_((void)); +int inquire P_((char *msg, char *name, char *selective)); +void write_archive_tail P_((FILE *nafp)); +void copy_old_one P_((FILE *oafp, FILE *nafp, LzHeader *hdr)); +void lha_exit P_((int status)); +/* lhext.c */ +void cmd_extract P_((void)); +int is_directory_traversal P_((char *path)); +/* lhlist.c */ +void cmd_list P_((void)); +/* maketbl.c */ +void make_table P_((int nchar, unsigned char bitlen[], int tablebits, unsigned short table[])); +/* maketree.c */ +short make_tree P_((int nchar, unsigned short *freq, unsigned char *bitlen, unsigned short *code)); +/* patmatch.c */ +int patmatch P_((register char *p, register char *s, int f)); +/* shuf.c */ +void decode_start_st0 P_((void)); +void encode_p_st0 P_((int j)); +void encode_start_fix P_((void)); +void decode_start_fix P_((void)); +unsigned short decode_c_st0 P_((void)); +unsigned short decode_p_st0 P_((void)); +/* slide.c */ +int encode_alloc P_((int method)); +unsigned int encode P_((struct interfacing *interface)); +unsigned int decode P_((struct interfacing *interface)); +/* util.c */ +size_t copyfile P_((FILE *f1, FILE *f2, size_t size, int text_flg, unsigned int *crcp)); +int encode_stored_crc P_((FILE *ifp, FILE *ofp, size_t size, size_t *original_size_var, size_t *write_size_var)); +boolean archive_is_msdos_sfx1 P_((char *name)); +int xsnprintf P_((char *dest, size_t size, char *fmt, ...)); +char *xstrchr P_((const char *s, int c)); +char *xstrrchr P_((const char *s, int c)); +char *xmemchr P_((const char *s, int c, size_t n)); +char *xmemrchr P_((const char *s, int c, size_t n)); +int str_safe_copy P_((char *dst, const char *src, int dstsz)); + +/* util.c */ +#if !HAVE_MEMMOVE +void *memmove P_((void *dst, const void *src, size_t cnt)); +#endif +#if !HAVE_STRDUP +char *strdup P_((const char *buf)); +#endif +#if !HAVE_MEMSET +char *memset P_((char *s, int c, size_t n)); +#endif +#if !HAVE_STRCASECMP +int strcasecmp P_((const char *p1, const char *p2)); +#endif +#if defined HAVE_DECL_BASENAME && !HAVE_DECL_BASENAME +char *basename P_((char *s)); +#endif + +/* vsnprintf.c */ +#if !HAVE_VSNPRINTF +int vsnprintf P_((char *str, size_t n, const char *fmt, va_list ap)); +int snprintf P_((char *str, size_t n, char const *fmt, ...)); +#endif + +#undef P_ diff -Nru lha-1.14i/src/shuf.c lha-1.14i-acc20050924p1/src/shuf.c --- lha-1.14i/src/shuf.c 2000-10-04 14:57:38.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/shuf.c 2003-07-21 20:56:03.000000000 +0000 @@ -1,10 +1,10 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* shuf.c -- extract static Huffman coding */ -/* */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* LHa for UNIX */ +/* shuf.c -- extract static Huffman coding */ +/* */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ /* ------------------------------------------------------------------------ */ #include "lha.h" @@ -12,205 +12,198 @@ #undef NP #undef NP2 -#define NP (8 * 1024 / 64) -#define NP2 (NP * 2 - 1) +#define NP (8 * 1024 / 64) +#define NP2 (NP * 2 - 1) /* ------------------------------------------------------------------------ */ static unsigned int np; int fixed[2][16] = { - {3, 0x01, 0x04, 0x0c, 0x18, 0x30, 0}, /* old compatible */ - {2, 0x01, 0x01, 0x03, 0x06, 0x0D, 0x1F, 0x4E, 0} /* 8K buf */ + {3, 0x01, 0x04, 0x0c, 0x18, 0x30, 0}, /* old compatible */ + {2, 0x01, 0x01, 0x03, 0x06, 0x0D, 0x1F, 0x4E, 0} /* 8K buf */ }; /* ------------------------------------------------------------------------ */ +/* lh3 */ void decode_start_st0( /*void*/ ) { - n_max = 286; - maxmatch = MAXMATCH; - init_getbits(); -#ifdef SUPPORT_LH7 - np = 1 << (MAX_DICBIT - 7); -#endif -#ifndef SUPPORT_LH7 - np = 1 << (MAX_DICBIT - 6); -#endif - + n_max = 286; + maxmatch = MAXMATCH; + init_getbits(); + init_code_cache(); + np = 1 << (LZHUFF3_DICBIT - 6); } /* ------------------------------------------------------------------------ */ void encode_p_st0(j) - unsigned short j; + unsigned short j; { - unsigned short i; + unsigned short i; - i = j >> 6; - putcode(pt_len[i], pt_code[i]); - putbits(6, j & 0x3f); + i = j >> 6; + putcode(pt_len[i], pt_code[i]); + putbits(6, j & 0x3f); } /* ------------------------------------------------------------------------ */ static void ready_made(method) - int method; + int method; { - int i, j; - unsigned int code, weight; - int *tbl; - - tbl = fixed[method]; - j = *tbl++; - weight = 1 << (16 - j); - code = 0; - for (i = 0; i < np; i++) { - while (*tbl == i) { - j++; - tbl++; - weight >>= 1; - } - pt_len[i] = j; - pt_code[i] = code; - code += weight; - } + int i, j; + unsigned int code, weight; + int *tbl; + + tbl = fixed[method]; + j = *tbl++; + weight = 1 << (16 - j); + code = 0; + for (i = 0; i < np; i++) { + while (*tbl == i) { + j++; + tbl++; + weight >>= 1; + } + pt_len[i] = j; + pt_code[i] = code; + code += weight; + } } /* ------------------------------------------------------------------------ */ +/* lh1 */ void encode_start_fix( /*void*/ ) { - n_max = 314; - maxmatch = 60; - np = 1 << (12 - 6); - init_putbits(); - start_c_dyn(); - ready_made(0); + n_max = 314; + maxmatch = 60; + np = 1 << (12 - 6); + init_putbits(); + init_code_cache(); + start_c_dyn(); + ready_made(0); } /* ------------------------------------------------------------------------ */ static void read_tree_c( /*void*/ ) -{ /* read tree from file */ - int i, c; +{ /* read tree from file */ + int i, c; - i = 0; - while (i < N1) { - if (getbits(1)) - c_len[i] = getbits(LENFIELD) + 1; - else - c_len[i] = 0; - if (++i == 3 && c_len[0] == 1 && c_len[1] == 1 && c_len[2] == 1) { - c = getbits(CBIT); - for (i = 0; i < N1; i++) - c_len[i] = 0; - for (i = 0; i < 4096; i++) - c_table[i] = c; - return; - } - } - make_table(N1, c_len, 12, c_table); + i = 0; + while (i < N1) { + if (getbits(1)) + c_len[i] = getbits(LENFIELD) + 1; + else + c_len[i] = 0; + if (++i == 3 && c_len[0] == 1 && c_len[1] == 1 && c_len[2] == 1) { + c = getbits(CBIT); + for (i = 0; i < N1; i++) + c_len[i] = 0; + for (i = 0; i < 4096; i++) + c_table[i] = c; + return; + } + } + make_table(N1, c_len, 12, c_table); } /* ------------------------------------------------------------------------ */ static void read_tree_p(/*void*/) -{ /* read tree from file */ - int i, c; +{ /* read tree from file */ + int i, c; - i = 0; - while (i < NP) { - pt_len[i] = getbits(LENFIELD); - if (++i == 3 && pt_len[0] == 1 && pt_len[1] == 1 && pt_len[2] == 1) { -#ifdef SUPPORT_LH7 - c = getbits(MAX_DICBIT - 7); -#else - c = getbits(MAX_DICBIT - 6); -#endif - for (i = 0; i < NP; i++) - c_len[i] = 0; - for (i = 0; i < 256; i++) - c_table[i] = c; - return; - } - } + i = 0; + while (i < NP) { + pt_len[i] = getbits(LENFIELD); + if (++i == 3 && pt_len[0] == 1 && pt_len[1] == 1 && pt_len[2] == 1) { + c = getbits(LZHUFF3_DICBIT - 6); + for (i = 0; i < NP; i++) + pt_len[i] = 0; + for (i = 0; i < 256; i++) + pt_table[i] = c; + return; + } + } } /* ------------------------------------------------------------------------ */ +/* lh1 */ void decode_start_fix(/*void*/) { - n_max = 314; - maxmatch = 60; - init_getbits(); - np = 1 << (12 - 6); - start_c_dyn(); - ready_made(0); - make_table(np, pt_len, 8, pt_table); + n_max = 314; + maxmatch = 60; + init_getbits(); + init_code_cache(); + np = 1 << (LZHUFF1_DICBIT - 6); + start_c_dyn(); + ready_made(0); + make_table(np, pt_len, 8, pt_table); } /* ------------------------------------------------------------------------ */ +/* lh3 */ unsigned short decode_c_st0(/*void*/) { - int i, j; - static unsigned short blocksize = 0; + int i, j; + static unsigned short blocksize = 0; - if (blocksize == 0) { /* read block head */ - blocksize = getbits(BUFBITS); /* read block blocksize */ - read_tree_c(); - if (getbits(1)) { - read_tree_p(); - } - else { - ready_made(1); - } - make_table(NP, pt_len, 8, pt_table); - } - blocksize--; - j = c_table[bitbuf >> 4]; - if (j < N1) - fillbuf(c_len[j]); - else { - fillbuf(12); - i = bitbuf; - do { - if ((short) i < 0) - j = right[j]; - else - j = left[j]; - i <<= 1; - } while (j >= N1); - fillbuf(c_len[j] - 12); - } - if (j == N1 - 1) - j += getbits(EXTRABITS); - return j; + if (blocksize == 0) { /* read block head */ + blocksize = getbits(BUFBITS); /* read block blocksize */ + read_tree_c(); + if (getbits(1)) { + read_tree_p(); + } + else { + ready_made(1); + } + make_table(NP, pt_len, 8, pt_table); + } + blocksize--; + j = c_table[peekbits(12)]; + if (j < N1) + fillbuf(c_len[j]); + else { + fillbuf(12); + i = bitbuf; + do { + if ((short) i < 0) + j = right[j]; + else + j = left[j]; + i <<= 1; + } while (j >= N1); + fillbuf(c_len[j] - 12); + } + if (j == N1 - 1) + j += getbits(EXTRABITS); + return j; } /* ------------------------------------------------------------------------ */ +/* lh1, 3 */ unsigned short decode_p_st0(/*void*/) { - int i, j; + int i, j; - j = pt_table[bitbuf >> 8]; - if (j < np) { - fillbuf(pt_len[j]); - } - else { - fillbuf(8); - i = bitbuf; - do { - if ((short) i < 0) - j = right[j]; - else - j = left[j]; - i <<= 1; - } while (j >= np); - fillbuf(pt_len[j] - 8); - } - return (j << 6) + getbits(6); -} - -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* End: */ + j = pt_table[peekbits(8)]; + if (j < np) { + fillbuf(pt_len[j]); + } + else { + fillbuf(8); + i = bitbuf; + do { + if ((short) i < 0) + j = right[j]; + else + j = left[j]; + i <<= 1; + } while (j >= np); + fillbuf(pt_len[j] - 8); + } + return (j << 6) + getbits(6); +} diff -Nru lha-1.14i/src/slide.c lha-1.14i-acc20050924p1/src/slide.c --- lha-1.14i/src/slide.c 2000-10-04 14:57:38.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/slide.c 2004-09-17 19:20:57.000000000 +0000 @@ -1,10 +1,10 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* slice.c -- sliding dictionary with percolating update */ -/* */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 1.14d Exchanging a search algorithm 1997.01.11 T.Okamoto */ +/* LHa for UNIX */ +/* slide.c -- sliding dictionary with percolating update */ +/* */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Ver. 1.14d Exchanging a search algorithm 1997.01.11 T.Okamoto */ /* ------------------------------------------------------------------------ */ #if 0 @@ -13,446 +13,469 @@ #include "lha.h" - #ifdef DEBUG FILE *fout = NULL; static int noslide = 1; #endif -/* ------------------------------------------------------------------------ */ - -static unsigned long encoded_origsize; - -/* ------------------------------------------------------------------------ */ - -static unsigned int *hash; -static unsigned int *prev; - -/* static unsigned char *text; */ -unsigned char *too_flag; - +/* variables for hash */ +struct hash { + unsigned int pos; + int too_flag; /* if 1, matching candidate is too many */ +} *hash; +static unsigned int *prev; /* previous posiion associated with hash */ + +/* hash function: it represents 3 letters from `pos' on `text' */ +#define INIT_HASH(pos) \ + ((( (text[(pos)] << 5) \ + ^ text[(pos) + 1] ) << 5) \ + ^ text[(pos) + 2] ) & (unsigned)(HSHSIZ - 1); +#define NEXT_HASH(hash,pos) \ + (((hash) << 5) \ + ^ text[(pos) + 2] ) & (unsigned)(HSHSIZ - 1); static struct encode_option encode_define[2] = { #if defined(__STDC__) || defined(AIX) - /* lh1 */ - {(void (*) ()) output_dyn, - (void (*) ()) encode_start_fix, - (void (*) ()) encode_end_dyn}, - /* lh4, 5,6 */ - {(void (*) ()) output_st1, - (void (*) ()) encode_start_st1, - (void (*) ()) encode_end_st1} + /* lh1 */ + {(void (*) ()) output_dyn, + (void (*) ()) encode_start_fix, + (void (*) ()) encode_end_dyn}, + /* lh4, 5, 6, 7 */ + {(void (*) ()) output_st1, + (void (*) ()) encode_start_st1, + (void (*) ()) encode_end_st1} #else - /* lh1 */ - {(int (*) ()) output_dyn, - (int (*) ()) encode_start_fix, - (int (*) ()) encode_end_dyn}, - /* lh4, 5,6 */ - {(int (*) ()) output_st1, - (int (*) ()) encode_start_st1, - (int (*) ()) encode_end_st1} + /* lh1 */ + {(int (*) ()) output_dyn, + (int (*) ()) encode_start_fix, + (int (*) ()) encode_end_dyn}, + /* lh4, 5, 6, 7 */ + {(int (*) ()) output_st1, + (int (*) ()) encode_start_st1, + (int (*) ()) encode_end_st1} #endif }; static struct decode_option decode_define[] = { - /* lh1 */ - {decode_c_dyn, decode_p_st0, decode_start_fix}, - /* lh2 */ - {decode_c_dyn, decode_p_dyn, decode_start_dyn}, - /* lh3 */ - {decode_c_st0, decode_p_st0, decode_start_st0}, - /* lh4 */ - {decode_c_st1, decode_p_st1, decode_start_st1}, - /* lh5 */ - {decode_c_st1, decode_p_st1, decode_start_st1}, - /* lh6 */ - {decode_c_st1, decode_p_st1, decode_start_st1}, - /* lh7 */ - {decode_c_st1, decode_p_st1, decode_start_st1}, - /* lzs */ - {decode_c_lzs, decode_p_lzs, decode_start_lzs}, - /* lz5 */ - {decode_c_lz5, decode_p_lz5, decode_start_lz5} + /* lh1 */ + {decode_c_dyn, decode_p_st0, decode_start_fix}, + /* lh2 */ + {decode_c_dyn, decode_p_dyn, decode_start_dyn}, + /* lh3 */ + {decode_c_st0, decode_p_st0, decode_start_st0}, + /* lh4 */ + {decode_c_st1, decode_p_st1, decode_start_st1}, + /* lh5 */ + {decode_c_st1, decode_p_st1, decode_start_st1}, + /* lh6 */ + {decode_c_st1, decode_p_st1, decode_start_st1}, + /* lh7 */ + {decode_c_st1, decode_p_st1, decode_start_st1}, + /* lzs */ + {decode_c_lzs, decode_p_lzs, decode_start_lzs}, + /* lz5 */ + {decode_c_lz5, decode_p_lz5, decode_start_lz5} }; static struct encode_option encode_set; static struct decode_option decode_set; -#if 0 -static node pos, matchpos, avail, *position, *parent, *prev; -static int remainder, matchlen; -static unsigned char *level, *childcount; -static unsigned long dicsiz; /* t.okamoto */ -static unsigned short max_hash_val; -static unsigned short hash1, hash2; -#endif - -#ifdef SUPPORT_LH7 -#define DICSIZ (1L << 16) -#define TXTSIZ (DICSIZ * 2L + MAXMATCH) -#else -#define DICSIZ (((unsigned long)1) << 15) -#define TXTSIZ (DICSIZ * 2 + MAXMATCH) -#endif - +#define TXTSIZ (MAX_DICSIZ * 2L + MAXMATCH) #define HSHSIZ (((unsigned long)1) <<15) #define NIL 0 -#define LIMIT 0x100 /* chain 長の limit */ +#define LIMIT 0x100 /* limit of hash chain */ static unsigned int txtsiz; - static unsigned long dicsiz; - -static unsigned int hval; -static int matchlen; -static unsigned int matchpos; -static unsigned int pos; static unsigned int remainder; +struct matchdata { + int len; + unsigned int off; +}; -/* ------------------------------------------------------------------------ */ int encode_alloc(method) - int method; + int method; { - if (method == LZHUFF1_METHOD_NUM) { /* Changed N.Watazaki */ - encode_set = encode_define[0]; - maxmatch = 60; - dicbit = 12; /* 12 Changed N.Watazaki */ - } else { /* method LH4(12),LH5(13),LH6(15) */ - encode_set = encode_define[1]; - maxmatch = MAXMATCH; - if (method == LZHUFF7_METHOD_NUM) - dicbit = MAX_DICBIT; /* 16 bits */ - else if (method == LZHUFF6_METHOD_NUM) - dicbit = MAX_DICBIT-1; /* 15 bits */ - else /* LH5 LH4 is not used */ - dicbit = MAX_DICBIT - 3; /* 13 bits */ - } - - dicsiz = (((unsigned long)1) << dicbit); - txtsiz = dicsiz*2+maxmatch; - - if (hash) return method; - - if (alloc_buf() == NULL) exit(207); /* I don't know this 207. */ - - hash = (unsigned int*)malloc(HSHSIZ * sizeof(unsigned int)); - prev = (unsigned int*)malloc(DICSIZ * sizeof(unsigned int)); - text = (unsigned char*)malloc(TXTSIZ); - too_flag = (unsigned char*)malloc(HSHSIZ); + switch (method) { + case LZHUFF1_METHOD_NUM: + encode_set = encode_define[0]; + maxmatch = 60; + dicbit = LZHUFF1_DICBIT; /* 12 bits Changed N.Watazaki */ + break; + case LZHUFF5_METHOD_NUM: + encode_set = encode_define[1]; + maxmatch = MAXMATCH; + dicbit = LZHUFF5_DICBIT; /* 13 bits */ + break; + case LZHUFF6_METHOD_NUM: + encode_set = encode_define[1]; + maxmatch = MAXMATCH; + dicbit = LZHUFF6_DICBIT; /* 15 bits */ + break; + case LZHUFF7_METHOD_NUM: + encode_set = encode_define[1]; + maxmatch = MAXMATCH; + dicbit = LZHUFF7_DICBIT; /* 16 bits */ + break; + default: + error("unknown method %d", method); + exit(1); + } + + dicsiz = (((unsigned long)1) << dicbit); + txtsiz = dicsiz*2+maxmatch; + + if (hash) return method; + + alloc_buf(); + + hash = (struct hash*)xmalloc(HSHSIZ * sizeof(struct hash)); + prev = (unsigned int*)xmalloc(MAX_DICSIZ * sizeof(unsigned int)); + text = (unsigned char*)xmalloc(TXTSIZ); - if (hash == NULL || prev == NULL || text == NULL || too_flag == NULL) - exit(207); - - return method; + return method; } -/* ------------------------------------------------------------------------ */ -/* ポインタの初期化 */ - -static void init_slide() +static void +init_slide() { - unsigned int i; + unsigned int i; - for (i = 0; i < HSHSIZ; i++) { - hash[i] = NIL; - too_flag[i] = 0; - } - /* - for (i = 0; i < DICSIZ; i++) { - prev[i] = NIL; - } - */ + for (i = 0; i < HSHSIZ; i++) { + hash[i].pos = NIL; + hash[i].too_flag = 0; + } } -/* 辞書を DICSIZ 分 前にずらす */ - -static void update() +/* update dictionary */ +static void +update_dict(pos, crc) + unsigned int *pos; + unsigned int *crc; { - unsigned int i, j; - unsigned int k; - long n; + unsigned int i, j; + long n; -#if 0 - memmove(&text[0], &text[dicsiz], (unsigned)(txtsiz - dicsiz)); -#else - { - int m; - i = 0; j = dicsiz; m = txtsiz-dicsiz; - while (m-- > 0) { - text[i++] = text[j++]; - } - } -#endif - n = fread_crc(&text[(unsigned)(txtsiz - dicsiz)], - (unsigned)dicsiz, infile); - - remainder += n; - encoded_origsize += n; - - pos -= dicsiz; - for (i = 0; i < HSHSIZ; i++) { - j = hash[i]; - hash[i] = (j > dicsiz) ? j - dicsiz : NIL; - too_flag[i] = 0; - } - for (i = 0; i < dicsiz; i++) { - j = prev[i]; - prev[i] = (j > dicsiz) ? j - dicsiz : NIL; - } -} + memmove(&text[0], &text[dicsiz], txtsiz - dicsiz); + + n = fread_crc(crc, &text[txtsiz - dicsiz], dicsiz, infile); + remainder += n; -/* 現在の文字列をチェーンに追加する */ + *pos -= dicsiz; + for (i = 0; i < HSHSIZ; i++) { + j = hash[i].pos; + hash[i].pos = (j > dicsiz) ? j - dicsiz : NIL; + hash[i].too_flag = 0; + } + for (i = 0; i < dicsiz; i++) { + j = prev[i]; + prev[i] = (j > dicsiz) ? j - dicsiz : NIL; + } +} -static void insert() +/* associate position with token */ +static void +insert_hash(token, pos) + unsigned int token; + unsigned int pos; { - prev[pos & (dicsiz - 1)] = hash[hval]; - hash[hval] = pos; + prev[pos & (dicsiz - 1)] = hash[token].pos; /* chain the previous pos. */ + hash[token].pos = pos; } +static void +search_dict_1(token, pos, off, max, m) + unsigned int token; + unsigned int pos; + unsigned int off; + unsigned int max; /* max. length of matching string */ + struct matchdata *m; +{ + unsigned int chain = 0; + unsigned int scan_pos = hash[token].pos; + int scan_beg = scan_pos - off; + int scan_end = pos - dicsiz; + unsigned int len; + + while (scan_beg > scan_end) { + chain++; + + if (text[scan_beg + m->len] == text[pos + m->len]) { + { + /* collate token */ + unsigned char *a = &text[scan_beg]; + unsigned char *b = &text[pos]; + + for (len = 0; len < max && *a++ == *b++; len++); + } + + if (len > m->len) { + m->off = pos - scan_beg; + m->len = len; + if (m->len == max) + break; + +#ifdef DEBUG + if (noslide) { + if (pos - m->off < dicsiz) { + printf("matchpos=%u scan_pos=%u dicsiz=%u\n", + pos - m->off, scan_pos, dicsiz); + } + } +#endif + } + } + scan_pos = prev[scan_pos & (dicsiz - 1)]; + scan_beg = scan_pos - off; + } -/* 現在の文字列と最長一致する文字列を検索し、チェーンに追加する */ + if (chain >= LIMIT) + hash[token].too_flag = 1; +} -static void match_insert() +/* search the longest token matching to current token */ +static void +search_dict(token, pos, min, m) + unsigned int token; /* search token */ + unsigned int pos; /* position of token */ + int min; /* min. length of matching string */ + struct matchdata *m; { - unsigned int scan_pos, scan_end, len; - unsigned char *a, *b; - unsigned int chain, off, h, max; - - max = maxmatch; /* MAXMATCH; */ - if (matchlen < THRESHOLD - 1) matchlen = THRESHOLD - 1; - matchpos = pos; - - off = 0; - for (h = hval; too_flag[h] && off < maxmatch - THRESHOLD; ) { - h = ((h << 5) ^ text[pos + (++off) + 2]) & (unsigned)(HSHSIZ - 1); - } - if (off == maxmatch - THRESHOLD) off = 0; - for (;;) { - chain = 0; - scan_pos = hash[h]; - scan_end = (pos > dicsiz) ? pos + off - dicsiz : off; - while (scan_pos > scan_end) { - chain++; - - if (text[scan_pos + matchlen - off] == text[pos + matchlen]) { - { - a = text + scan_pos - off; b = text + pos; - for (len = 0; len < max && *a++ == *b++; len++); - } - - if (len > matchlen) { - matchpos = scan_pos - off; - if ((matchlen = len) == max) { - break; - } -#ifdef DEBUG - if (noslide) { - if (matchpos < dicsiz) { - printf("matchpos=%u scan_pos=%u dicsiz=%u\n" - ,matchpos, scan_pos, dicsiz); - } - } -#endif - } - } - scan_pos = prev[scan_pos & (dicsiz - 1)]; - } - - if (chain >= LIMIT) - too_flag[h] = 1; - - if (matchlen > off + 2 || off == 0) - break; - max = off + 2; - off = 0; - h = hval; - } - prev[pos & (dicsiz - 1)] = hash[hval]; - hash[hval] = pos; -} + unsigned int off, tok, max; + if (min < THRESHOLD - 1) min = THRESHOLD - 1; -/* ポインタを進め、辞書を更新し、ハッシュ値を更新する */ + max = maxmatch; + m->off = 0; + m->len = min; + + off = 0; + for (tok = token; hash[tok].too_flag && off < maxmatch - THRESHOLD; ) { + /* If matching position is too many, The search key is + changed into following token from `off' (for speed). */ + ++off; + tok = NEXT_HASH(tok, pos+off); + } + if (off == maxmatch - THRESHOLD) { + off = 0; + tok = token; + } + + search_dict_1(tok, pos, off, max, m); + + if (off > 0 && m->len < off + 3) + /* re-search */ + search_dict_1(token, pos, 0, off+2, m); -static void get_next() + if (m->len > remainder) m->len = remainder; +} + +/* slide dictionary */ +static void +next_token(token, pos, crc) + unsigned int *token; + unsigned int *pos; + unsigned int *crc; { - remainder--; - if (++pos >= txtsiz - maxmatch) { - update(); + remainder--; + if (++*pos >= txtsiz - maxmatch) { + update_dict(pos, crc); #ifdef DEBUG - noslide = 0; + noslide = 0; #endif - } - hval = ((hval << 5) ^ text[pos + 2]) & (unsigned)(HSHSIZ - 1); + } + *token = NEXT_HASH(*token, *pos); } -void encode(interface) -struct interfacing *interface; +unsigned int +encode(interface) + struct interfacing *interface; { - int lastmatchlen; - unsigned int lastmatchoffset; + unsigned int token, pos, crc; + size_t count; + struct matchdata match, last; + +#ifdef DEBUG + if (!fout) + fout = xfopen("en", "wt"); + fprintf(fout, "[filename: %s]\n", reading_filename); +#endif + infile = interface->infile; + outfile = interface->outfile; + origsize = interface->original; + compsize = count = 0L; + unpackable = 0; + + INITIALIZE_CRC(crc); + + init_slide(); + + encode_set.encode_start(); + memset(text, ' ', TXTSIZ); + + remainder = fread_crc(&crc, &text[dicsiz], txtsiz-dicsiz, infile); + + match.len = THRESHOLD - 1; + match.off = 0; + if (match.len > remainder) match.len = remainder; + pos = dicsiz; + token = INIT_HASH(pos); + insert_hash(token, pos); /* associate token and pos */ + + while (remainder > 0 && ! unpackable) { + last = match; + + next_token(&token, &pos, &crc); + search_dict(token, pos, last.len-1, &match); + insert_hash(token, pos); + + if (match.len > last.len || last.len < THRESHOLD) { + /* output a letter */ + encode_set.output(text[pos - 1], 0); #ifdef DEBUG - unsigned int addr; + fprintf(fout, "%u C %02X\n", count, text[pos-1]); +#endif + count++; + } else { + /* output length and offset */ + encode_set.output(last.len + (256 - THRESHOLD), + (last.off-1) & (dicsiz-1) ); - addr = 0; +#ifdef DEBUG + { + int i; + unsigned char *ptr; + unsigned int offset = (last.off & (dicsiz-1)); + + fprintf(fout, "%u M <%u %u> ", + count, last.len, count - offset); - fout = fopen("en", "wt"); - if (fout == NULL) exit(1); -#endif - infile = interface->infile; - outfile = interface->outfile; - origsize = interface->original; - compsize = count = 0L; - crc = unpackable = 0; - - /* encode_alloc(); */ /* allocate_memory(); */ - init_slide(); - - encode_set.encode_start(); - memset(&text[0], ' ', (long)TXTSIZ); - - remainder = fread_crc(&text[dicsiz], txtsiz-dicsiz, infile); - encoded_origsize = remainder; - matchlen = THRESHOLD - 1; - - pos = dicsiz; - - if (matchlen > remainder) matchlen = remainder; - hval = ((((text[dicsiz] << 5) ^ text[dicsiz + 1]) << 5) - ^ text[dicsiz + 2]) & (unsigned)(HSHSIZ - 1); - - insert(); - while (remainder > 0 && ! unpackable) { - lastmatchlen = matchlen; lastmatchoffset = pos - matchpos - 1; - --matchlen; - get_next(); match_insert(); - if (matchlen > remainder) matchlen = remainder; - if (matchlen > lastmatchlen || lastmatchlen < THRESHOLD) { - encode_set.output(text[pos - 1], 0); -#ifdef DEBUG - fprintf(fout, "%u C %02X\n", addr, text[pos-1]); - addr++; -#endif - count++; - } else { - encode_set.output(lastmatchlen + (UCHAR_MAX + 1 - THRESHOLD), - (lastmatchoffset) & (dicsiz-1) ); - --lastmatchlen; - -#ifdef DEBUG - fprintf(fout, "%u M %u %u ", addr, - lastmatchoffset & (dicsiz-1), lastmatchlen+1); - addr += lastmatchlen +1 ; - - { - int t,cc; - for (t=0; t 0) { - get_next(); insert(); - count++; - } - get_next(); - matchlen = THRESHOLD - 1; - match_insert(); - if (matchlen > remainder) matchlen = remainder; - } - } - encode_set.encode_end(); + ptr = &text[pos-1 - offset]; + for (i=0; i < last.len; i++) + fprintf(fout, "%02X ", ptr[i]); + fprintf(fout, "\n"); + } +#endif + count += last.len; - interface->packed = compsize; - interface->original = encoded_origsize; + --last.len; + while (--last.len > 0) { + next_token(&token, &pos, &crc); + insert_hash(token, pos); + } + next_token(&token, &pos, &crc); + search_dict(token, pos, THRESHOLD - 1, &match); + insert_hash(token, pos); + } + } + encode_set.encode_end(); + + interface->packed = compsize; + interface->original = count; + + return crc; } -/* ------------------------------------------------------------------------ */ -void +unsigned int decode(interface) - struct interfacing *interface; + struct interfacing *interface; { - unsigned int i, j, k, c; - unsigned int dicsiz1, offset; - unsigned char *dtext; - - -#ifdef DEBUG - fout = fopen("de", "wt"); - if (fout == NULL) exit(1); -#endif - - infile = interface->infile; - outfile = interface->outfile; - dicbit = interface->dicbit; - origsize = interface->original; - compsize = interface->packed; - decode_set = decode_define[interface->method - 1]; - - crc = 0; - prev_char = -1; - dicsiz = 1L << dicbit; - dtext = (unsigned char *) malloc(dicsiz); - if (dtext == NULL) - /* error(MEMOVRERR, NULL); */ - exit(errno); - for (i=0; imethod == LARC_METHOD_NUM) ? 0x100 - 2 : 0x100 - 3; - count = 0; - loc = 0; - while (count < origsize) { - c = decode_set.decode_c(); - if (c <= UCHAR_MAX) { -#ifdef DEBUG - fprintf(fout, "%u C %02X\n", count, c); -#endif - dtext[loc++] = c; - if (loc == dicsiz) { - fwrite_crc(dtext, dicsiz, outfile); - loc = 0; - } - count++; - } - else { - j = c - offset; - i = (loc - decode_set.decode_p() - 1) & dicsiz1; -#ifdef DEBUG - fprintf(fout, "%u M %u %u ", count, (loc-1-i) & dicsiz1, j); -#endif - count += j; - for (k = 0; k < j; k++) { - c = dtext[(i + k) & dicsiz1]; - -#ifdef DEBUG - fprintf(fout, "%02X ", c & 0xff); -#endif - dtext[loc++] = c; - if (loc == dicsiz) { - fwrite_crc(dtext, dicsiz, outfile); - loc = 0; - } - } -#ifdef DEBUG - fprintf(fout, "\n"); -#endif - } - } - if (loc != 0) { - fwrite_crc(dtext, loc, outfile); - } + unsigned int i, c; + unsigned int dicsiz1, adjust; + unsigned char *dtext; + unsigned int crc; + +#ifdef DEBUG + if (!fout) + fout = xfopen("de", "wt"); + fprintf(fout, "[filename: %s]\n", writing_filename); +#endif + + infile = interface->infile; + outfile = interface->outfile; + dicbit = interface->dicbit; + origsize = interface->original; + compsize = interface->packed; + decode_set = decode_define[interface->method - 1]; + + INITIALIZE_CRC(crc); + dicsiz = 1L << dicbit; + dtext = (unsigned char *)xmalloc(dicsiz); + + if (extract_broken_archive) + + /* LHa for UNIX (autoconf) had a fatal bug since version + 1.14i-ac20030713 (slide.c revision 1.20). + + This bug is possible to make a broken archive, proper LHA + cannot extract it (probably it report CRC error). + + If the option "--extract-broken-archive" specified, extract + the broken archive made by old LHa for UNIX. */ + memset(dtext, 0, dicsiz); + else + memset(dtext, ' ', dicsiz); + decode_set.decode_start(); + dicsiz1 = dicsiz - 1; + adjust = 256 - THRESHOLD; + if (interface->method == LARC_METHOD_NUM) + adjust = 256 - 2; + + decode_count = 0; + loc = 0; + while (decode_count < origsize) { + c = decode_set.decode_c(); + if (c < 256) { +#ifdef DEBUG + fprintf(fout, "%u C %02X\n", decode_count, c); +#endif + dtext[loc++] = c; + if (loc == dicsiz) { + fwrite_crc(&crc, dtext, dicsiz, outfile); + loc = 0; + } + decode_count++; + } + else { + struct matchdata match; + unsigned int matchpos; + + 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); +#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 + dtext[loc++] = c; + if (loc == dicsiz) { + fwrite_crc(&crc, dtext, dicsiz, outfile); + loc = 0; + } + } +#ifdef DEBUG + fprintf(fout, "\n"); +#endif + } + } + if (loc != 0) { + fwrite_crc(&crc, dtext, loc, outfile); + } - free(dtext); -} + free(dtext); + + /* usually read size is interface->packed */ + interface->read_size = interface->packed - compsize; -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* End: */ + return crc; +} diff -Nru lha-1.14i/src/util.c lha-1.14i-acc20050924p1/src/util.c --- lha-1.14i/src/util.c 2000-10-04 14:57:38.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/util.c 2004-09-26 16:12:01.000000000 +0000 @@ -1,11 +1,11 @@ /* ------------------------------------------------------------------------ */ -/* LHa for UNIX */ -/* util.c -- LHarc Util */ -/* */ -/* Modified Nobutaka Watazaki */ -/* */ -/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ -/* Ver. 1.14e Support for sfx archives 1999.05.28 T.Okamoto */ +/* LHa for UNIX */ +/* util.c -- LHarc Util */ +/* */ +/* Modified Nobutaka Watazaki */ +/* */ +/* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */ +/* Ver. 1.14e Support for sfx archives 1999.05.28 T.Okamoto */ /* ------------------------------------------------------------------------ */ #include "lha.h" /* @@ -15,361 +15,321 @@ */ #include -/* ------------------------------------------------------------------------ */ -extern unsigned short crc; -extern int quiet; -/* ------------------------------------------------------------------------ */ -long -copyfile(f1, f2, size, crc_flg) /* return: size of source file */ - FILE *f1; - FILE *f2; - long size; - int crc_flg;/* 0: no crc, 1: crc check, 2: extract, 3: - * append */ -{ - unsigned short xsize; - char *buf; - long rsize = 0; - - if ((buf = (char *) malloc(BUFFERSIZE)) == NULL) - fatal_error("virtual memory exhausted.\n"); - crc = 0; - if ((crc_flg == 2 || crc_flg) && text_mode) - init_code_cache(); - while (size > 0) { - /* read */ - if (crc_flg == 3 && text_mode) { - xsize = fread_txt(buf, BUFFERSIZE, f1); - if (xsize == 0) - break; - if (ferror(f1)) { - fatal_error("file read error\n"); - } - } - else { - xsize = (size > BUFFERSIZE) ? BUFFERSIZE : size; - if (fread(buf, 1, xsize, f1) != xsize) { - fatal_error("file read error\n"); - } - } - /* write */ - if (f2) { - if (crc_flg == 2 && text_mode) { - if (fwrite_txt(buf, xsize, f2)) { - fatal_error("file write error\n"); - } - } - else { - if (fwrite(buf, 1, xsize, f2) != xsize) { - fatal_error("file write error\n"); - } - } - } - /* calculate crc */ - if (crc_flg) { - calccrc(buf, xsize); - } - rsize += xsize; - if (crc_flg != 3 || !text_mode) - size -= xsize; - } - free(buf); - return rsize; +size_t +copyfile(f1, f2, size, text_flg, crcp) /* return: size of source file */ + FILE *f1; + FILE *f2; + size_t size; + int text_flg; /* 0: binary, 1: read text, 2: write text */ + unsigned int *crcp; +{ + unsigned short xsize; + char *buf; + size_t rsize = 0; + + if (!text_mode) + text_flg = 0; + + buf = (char *)xmalloc(BUFFERSIZE); + if (crcp) + INITIALIZE_CRC(*crcp); + if (text_flg) + init_code_cache(); + while (size > 0) { + /* read */ + if (text_flg & 1) { + xsize = fread_txt(buf, BUFFERSIZE, f1); + if (xsize == 0) + break; + if (ferror(f1)) { + fatal_error("file read error"); + } + } + else { + xsize = (size > BUFFERSIZE) ? BUFFERSIZE : size; + if (fread(buf, 1, xsize, f1) != xsize) { + fatal_error("file read error"); + } + if (size < xsize) + size = 0; + else + size -= xsize; + } + + /* write */ + if (f2) { + if (text_flg & 2) { + if (fwrite_txt(buf, xsize, f2)) { + fatal_error("file write error"); + } + } + else { + if (fwrite(buf, 1, xsize, f2) != xsize) { + fatal_error("file write error"); + } + } + } + + /* calculate crc */ + if (crcp) { + *crcp = calccrc(*crcp, buf, xsize); +#ifdef NEED_INCREMENTAL_INDICATOR + put_indicator(xsize); +#endif + } + rsize += xsize; + } + free(buf); + return rsize; } -/* ------------------------------------------------------------------------ */ int encode_stored_crc(ifp, ofp, size, original_size_var, write_size_var) - FILE *ifp, *ofp; - long size; - long *original_size_var; - long *write_size_var; -{ - int save_quiet; - - save_quiet = quiet; - quiet = 1; - size = copyfile(ifp, ofp, size, 3); - *original_size_var = *write_size_var = size; - quiet = save_quiet; - return crc; + FILE *ifp, *ofp; + size_t size; + size_t *original_size_var; + size_t *write_size_var; +{ + int save_quiet; + unsigned int crc; + + save_quiet = quiet; + quiet = 1; + size = copyfile(ifp, ofp, size, 1, &crc); + *original_size_var = *write_size_var = size; + quiet = save_quiet; + return crc; } -/* ------------------------------------------------------------------------ */ -/* convert path delimit - erreturns *filename */ -/* ------------------------------------------------------------------------ */ -unsigned char * -convdelim(path, delim) - unsigned char *path; - unsigned char delim; -{ - unsigned char c; - unsigned char *p; -#ifdef MULTIBYTE_CHAR - int kflg; - - kflg = 0; -#endif - for (p = path; (c = *p) != 0; p++) { -#ifdef MULTIBYTE_CHAR - if (kflg) { - kflg = 0; - } - else if (MULTIBYTE_FIRST_P(c)) { - kflg = 1; - } - else -#endif - if (c == '\\' || c == DELIM || c == DELIM2) { - *p = delim; - path = p + 1; - } - } - return path; -} - -/* ------------------------------------------------------------------------ */ /* If TRUE, archive file name is msdos SFX file name. */ boolean archive_is_msdos_sfx1(name) - char *name; + char *name; { - int len = strlen(name); + int len = strlen(name); - return ((len >= 4) && - (strucmp(".COM", name + len - 4) == 0 || - strucmp(".EXE", name + len - 4) == 0)) || - ((len >= 2) && - (strucmp(".x", name + len - 2) == 0)); -} + if (len >= 4) { + if (strcasecmp(".COM", name + len - 4) == 0 || + strcasecmp(".EXE", name + len - 4) == 0) + return 1; + } -/* ------------------------------------------------------------------------ */ -/* skip SFX header */ -boolean -skip_msdos_sfx1_code(fp) - FILE *fp; -{ - unsigned char buffer[MAXSFXCODE]; - unsigned char *p, *q; - int n; - - n = fread(buffer, sizeof(char), MAXSFXCODE, fp); - - for (p = buffer + 2, q = buffer + n - /* 5 */ (I_HEADER_LEVEL+1)-2; p < q; p++) { - /* found "-l??-" keyword (as METHOD type string) */ - if (p[0] == '-' && p[1] == 'l' && p[4] == '-') { - /* size and checksum validate check */ - if ( (p[I_HEADER_LEVEL-2] == 0 || p[I_HEADER_LEVEL-2] == 0) - && p[I_HEADER_SIZE-2] > 20 - && p[I_HEADER_CHECKSUM-2] == calc_sum(p, p[-2])) { - fseek(fp, ((p - 2) - buffer) - n, SEEK_CUR); - return TRUE; - } else if (p[I_HEADER_LEVEL-2] == 2 && p[I_HEADER_SIZE-2] >= 24 - && p[I_ATTRIBUTE-2] == 0x20) { - fseek(fp, ((p - 2) - buffer) - n, SEEK_CUR); - return TRUE; - } - } - } + if (len >= 2 && strcasecmp(".x", name + len - 2) == 0) + return 1; - fseek(fp, -n, SEEK_CUR); - return FALSE; + return 0; } /* * strdup(3) */ - -/* ------------------------------------------------------------------------ */ -#ifdef NOSTRDUP -char * +#ifndef HAVE_STRDUP +char * strdup(buf) - char *buf; + const char *buf; { - char *p; + char *p; - if ((p = (char *) malloc(strlen(buf) + 1)) == NULL) - return NULL; - strcpy(p, buf); - return p; + if ((p = (char *) malloc(strlen(buf) + 1)) == NULL) + return NULL; + strcpy(p, buf); /* ok */ + return p; } #endif /* * memmove( char *dst , char *src , size_t cnt ) */ - -/* ------------------------------------------------------------------------ */ -#if defined(NOBSTRING) && !defined(__STDC__) -void * +#ifndef HAVE_MEMMOVE +void * memmove(dst, src, cnt) - register char *dst, *src; - register int cnt; + register char *dst, *src; + register int cnt; { - if (dst == src) - return dst; - if (src > dst) { - while (--cnt >= 0) - *dst++ = *src++; - } - else { - dst += cnt; - src += cnt; - while (--cnt >= 0) - *--dst = *--src; - } - return dst; + if (dst == src) + return dst; + if (src > dst) { + while (--cnt >= 0) + *dst++ = *src++; + } + else { + dst += cnt; + src += cnt; + while (--cnt >= 0) + *--dst = *--src; + } + return dst; } #endif -/* - * rename - change the name of file 91.11.02 by Tomohiro Ishikawa - * (ishikawa@gaia.cow.melco.CO.JP) 92.01.20 little modified (added #ifdef) by - * Masaru Oki 92.01.28 added mkdir() and rmdir() by Tomohiro Ishikawa - */ +#ifndef HAVE_STRCASECMP +/* public domain rewrite of strcasecmp(3) */ -#if defined(NOFTRUNCATE) && !defined(_MINIX) +#include -/* ------------------------------------------------------------------------ */ int -rename(from, to) - char *from, *to; +strcasecmp(p1, p2) + const char *p1, *p2; { - struct stat s1, s2; - extern int errno; - - if (stat(from, &s1) < 0) - return (-1); - /* is 'FROM' file a directory? */ - if ((s1.st_mode & S_IFMT) == S_IFDIR) { - errno = ENOTDIR; - return (-1); - } - if (stat(to, &s2) >= 0) { /* 'TO' exists! */ - /* is 'TO' file a directory? */ - if ((s2.st_mode & S_IFMT) == S_IFDIR) { - errno = EISDIR; - return (-1); - } - if (unlink(to) < 0) - return (-1); - } - if (link(from, to) < 0) - return (-1); - if (unlink(from) < 0) - return (-1); - return (0); + while (*p1 && *p2) { + if (toupper(*p1) != toupper(*p2)) + return toupper(*p1) - toupper(*p2); + p1++; + p2++; + } + return strlen(p1) - strlen(p2); } -#endif /* NOFTRUNCATE */ -/* ------------------------------------------------------------------------ */ - -#ifdef NOMKDIR -#ifndef MKDIRPATH -#define MKDIRPATH "/bin/mkdir" #endif -#ifndef RMDIRPATH -#define RMDIRPATH "/bin/rmdir" + +#ifndef HAVE_MEMSET +/* Public Domain memset(3) */ +char * +memset(s, c, n) + char *s; + int c; + size_t n; +{ + char *p = s; + + while (n--) + *p++ = (char) c; + return s; +} #endif + int -rmdir(path) - char *path; +#if STDC_HEADERS +xsnprintf(char *dest, size_t size, char *fmt, ...) +#else +xsnprintf(dest, size, fmt, va_alist) + char *dest, *fmt; + size_t size; + va_dcl +#endif { - int stat, rtn = 0; - char *cmdname; - if ((cmdname = (char *) malloc(strlen(RMDIRPATH) + 1 + strlen(path) + 1)) - == 0) - return (-1); - strcpy(cmdname, RMDIRPATH); - *(cmdname + strlen(RMDIRPATH)) = ' '; - strcpy(cmdname + strlen(RMDIRPATH) + 1, path); - if ((stat = system(cmdname)) < 0) - rtn = -1; /* fork or exec error */ - else if (stat) { /* RMDIR command error */ - errno = EIO; - rtn = -1; - } - free(cmdname); - return (rtn); + int len; + va_list v; + + va_init(v, fmt); + len = vsnprintf(dest, size, fmt, v); + va_end(v); + + if (len == -1) + return -1; + + if (len >= size) { + dest[size-1] = 0; + return -1; + } + + return 0; } -/* ------------------------------------------------------------------------ */ -int -mkdir(path, mode) - char *path; - int mode; -{ - int child, stat; - char *cmdname, *cmdpath = MKDIRPATH; - if ((cmdname = (char *) strrchr(cmdpath, '/')) == (char *) 0) - cmdname = cmdpath; - if ((child = fork()) < 0) - return (-1); /* fork error */ - else if (child) { /* parent process */ - while (child != wait(&stat)) /* ignore signals */ - continue; - } - else { /* child process */ - int maskvalue; - maskvalue = umask(0); /* get current umask() value */ - umask(maskvalue | (0777 & ~mode)); /* set it! */ - execl(cmdpath, cmdname, path, (char *) 0); - /* never come here except execl is error */ - return (-1); - } - if (stat != 0) { - errno = EIO; /* cannot get error num. */ - return (-1); - } - return (0); +#if !STRCHR_8BIT_CLEAN +/* 8 bit clean strchr()/strrchr()/memchr()/memrchr() */ +char * +xstrchr(const char *s, int c) +{ + if (c == 0) + return s + strlen(s); + + while (*s) { + if ((unsigned char)*s == (unsigned char)c) + return (char*)s; + s++; + } + + return 0; } -#endif -/* - * strucmp modified: Oct 29 1991 by Masaru Oki - */ +char * +xstrrchr(const char *s, int c) +{ + char *p = 0; -#ifndef USESTRCASECMP -static int -my_toupper(n) - register int n; -{ - if (n >= 'a' && n <= 'z') - return n & (~('a' - 'A')); - return n; + while (*s) { + if ((unsigned char)*s == (unsigned char)c) + p = (char*)s; + s++; + } + + return p; } -/* ------------------------------------------------------------------------ */ -int -strucmp(s, t) - register char *s, *t; +char * +xmemchr(const char *s, int c, size_t n) { - while (my_toupper(*s++) == my_toupper(*t++)) - if (!*s || !*t) - break; - if (!*s && !*t) - return 0; - return 1; + char *end = (char*)s + n; + + while (s != end) { + if ((unsigned char)*s == (unsigned char)c) + return (char*)s; + s++; + } + + return 0; } -#endif -/* ------------------------------------------------------------------------ */ -#ifdef NOMEMSET -/* Public Domain memset(3) */ -char * -memset(s, c, n) - char *s; - int c, n; +char * +xmemrchr(const char *s, int c, size_t n) { - char *p = s; - while (n--) - *p++ = (char) c; - return s; + char *end = (char*)s-1; + char *p = 0; + + s += n-1; + while (s != end) { + if ((unsigned char)*s == (unsigned char)c) + p = (char*)s; + s--; + } + + return p; +} +#endif + +#ifndef HAVE_BASENAME +char * +basename(char *s) +{ + int len; + char *t; + + if (!s || *s == 0) + return "."; + + /* strip trailing slashs */ + t = s + strlen(s) - 1; + while (s != t && *t == '/') + *t-- = '\0'; + if (s == t) + return s; + + t = strrchr(s, '/'); + if (t) + return t + 1; + else + return s; + } #endif -/* Local Variables: */ -/* mode:c */ -/* tab-width:4 */ -/* compile-command:"gcc -c util.c" */ -/* End: */ +/* This function is similar to strncpy() but `dst' is always + terminated by '\0'. Return the copied string length. */ +int +str_safe_copy(char *dst, const char *src, int dstsz) +{ + int i; + + if (dstsz < 1) return 0; + + for (i = 0; i < dstsz; i++) { + if ((dst[i] = src[i]) == '\0') + return i; + } + + /* here is i == dstsz */ + dst[--i] = '\0'; /* if eliminated this line, + this function was same as strncpy(). */ + + return i; +} diff -Nru lha-1.14i/src/vsnprintf.c lha-1.14i-acc20050924p1/src/vsnprintf.c --- lha-1.14i/src/vsnprintf.c 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/src/vsnprintf.c 2006-10-10 16:27:51.000000000 +0000 @@ -0,0 +1,1131 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * IMPORTANT NOTE: + * -------------- + * From ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change + * paragraph 3 above is now null and void. + */ + +/* SNPRINTF.C + * fjc 7-31-97 Modified by Mib Software to be a standalone snprintf.c module. + * http://www.mibsoftware.com + * Mib Software does not warrant this software any differently than the + * University of California, Berkeley as described above. All warranties + * are disclaimed. Use this software at your own risk. + * + * All code referencing FILE * functions was eliminated, since it could + * never be called. All header files and necessary files are collapsed + * into one file, internal functions are declared static. This should + * allow inclusion into libraries with less chance of namespace collisions. + * + * snprintf should be the only externally visible item. + * + * As of 7-31-97 FLOATING_POINT is NOT provided. The code is somewhat + * non-portable, so it is disabled. + */ + +/* Define FLOATING_POINT to get floating point. */ +/* +#define FLOATING_POINT +*/ + +#include +#define u_long unsigned long +#define u_short unsigned short +#define u_int unsigned int + +#undef __P +#if defined(__STDC__) +# include +# if !defined(__P) +# define __P(x) x +# endif +#else +# define __P(x) () +# if !defined(const) +# define const +# endif +# include +#endif +#ifndef _BSD_VA_LIST_ +#define _BSD_VA_LIST_ va_list +#endif + +#ifdef __STDC__ +# include +#else +# ifndef LONG_MAX +# ifdef HAVE_LIMITS_H +# include +# else + /* assuming 32bit(2's compliment) long */ +# define LONG_MAX 2147483647 +# endif +# endif +#endif + +#if defined(__hpux) && !defined(__GNUC__) +#define const +#endif + +#if defined(sgi) +#undef __const +#define __const +#endif /* People who don't like const sys_error */ + +#include + +#ifndef NULL +#define NULL 0 +#endif + +/* + * NB: to fit things in six character monocase externals, the stdio + * code uses the prefix `__s' for stdio objects, typically followed + * by a three-character attempt at a mnemonic. + */ + +/* stdio buffers */ +struct __sbuf { + unsigned char *_base; + int _size; +}; + + +/* + * stdio state variables. + * + * The following always hold: + * + * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR), + * _lbfsize is -_bf._size, else _lbfsize is 0 + * if _flags&__SRD, _w is 0 + * if _flags&__SWR, _r is 0 + * + * This ensures that the getc and putc macros (or inline functions) never + * try to write or read from a file that is in `read' or `write' mode. + * (Moreover, they can, and do, automatically switch from read mode to + * write mode, and back, on "r+" and "w+" files.) + * + * _lbfsize is used only to make the inline line-buffered output stream + * code as compact as possible. + * + * _ub, _up, and _ur are used when ungetc() pushes back more characters + * than fit in the current _bf, or when ungetc() pushes back a character + * that does not match the previous one in _bf. When this happens, + * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff + * _ub._base!=NULL) and _up and _ur save the current values of _p and _r. + * + * NB: see WARNING above before changing the layout of this structure! + */ +typedef struct __sFILE { + unsigned char *_p; /* current position in (some) buffer */ + int _r; /* read space left for getc() */ + int _w; /* write space left for putc() */ + short _flags; /* flags, below; this FILE is free if 0 */ + short _file; /* fileno, if Unix descriptor, else -1 */ + struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ + int _lbfsize; /* 0 or -_bf._size, for inline putc */ +} FILE; + + +#define __SLBF 0x0001 /* line buffered */ +#define __SNBF 0x0002 /* unbuffered */ +#define __SRD 0x0004 /* OK to read */ +#define __SWR 0x0008 /* OK to write */ + /* RD and WR are never simultaneously asserted */ +#define __SRW 0x0010 /* open for reading & writing */ +#define __SEOF 0x0020 /* found EOF */ +#define __SERR 0x0040 /* found error */ +#define __SMBF 0x0080 /* _buf is from malloc */ +#define __SAPP 0x0100 /* fdopen()ed in append mode */ +#define __SSTR 0x0200 /* this is an sprintf/snprintf string */ +#define __SOPT 0x0400 /* do fseek() optimisation */ +#define __SNPT 0x0800 /* do not do fseek() optimisation */ +#define __SOFF 0x1000 /* set iff _offset is in fact correct */ +#define __SMOD 0x2000 /* true => fgetln modified _p text */ + + +#define EOF (-1) + + +#define __sfeof(p) (((p)->_flags & __SEOF) != 0) +#define __sferror(p) (((p)->_flags & __SERR) != 0) +#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF))) +#define __sfileno(p) ((p)->_file) + +#define feof(p) __sfeof(p) +#define ferror(p) __sferror(p) +#define clearerr(p) __sclearerr(p) + +#ifndef _ANSI_SOURCE +#define fileno(p) __sfileno(p) +#endif + + +#if defined(__hpux) && !defined(__GNUC__) || defined(__DECC) +#include +#endif + +/* + * I/O descriptors for __sfvwrite(). + */ +struct __siov { + void *iov_base; + size_t iov_len; +}; +struct __suio { + struct __siov *uio_iov; + int uio_iovcnt; + int uio_resid; +}; + +/* + * Write some memory regions. Return zero on success, EOF on error. + * + * This routine is large and unsightly, but most of the ugliness due + * to the three different kinds of output buffering is handled here. + */ +static BSD__sfvwrite(fp, uio) + register FILE *fp; + register struct __suio *uio; +{ + register size_t len; + register char *p; + register struct __siov *iov; + register int w; + + if ((len = uio->uio_resid) == 0) + return (0); +#ifndef __hpux +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif +#define COPY(n) (void)memcpy((void *)fp->_p, (void *)p, (size_t)(n)) + + iov = uio->uio_iov; + p = iov->iov_base; + len = iov->iov_len; + iov++; +#define GETIOV(extra_work) \ + while (len == 0) { \ + extra_work; \ + p = iov->iov_base; \ + len = iov->iov_len; \ + iov++; \ + } + if (fp->_flags & __SNBF) { + /* fjc 7-31-97 Will never happen. We are working with + strings only + */ + } else if ((fp->_flags & __SLBF) == 0) { + /* + * Fully buffered: fill partially full buffer, if any, + * and then flush. If there is no partial buffer, write + * one _bf._size byte chunk directly (without copying). + * + * String output is a special case: write as many bytes + * as fit, but pretend we wrote everything. This makes + * snprintf() return the number of bytes needed, rather + * than the number used, and avoids its write function + * (so that the write function can be invalid). + */ + do { + GETIOV(;); + w = fp->_w; + if (fp->_flags & __SSTR) { + if (len < w) + w = len; + COPY(w); /* copy MIN(fp->_w,len), */ + fp->_w -= w; + fp->_p += w; + w = len; /* but pretend copied all */ + } else { + /* fjc 7-31-97 Will never happen. We are working with + strings only + */ + } + p += w; + len -= w; + } while ((uio->uio_resid -= w) != 0); + } else { + /* fjc 7-31-97 Will never happen. We are working with + strings only + */ + } + return (0); + +err: + fp->_flags |= __SERR; + return (EOF); +} + +/* + * Actual printf innards. + * + * This code is large and complicated... + */ + +#if !defined(__CYGWIN32__) && defined(__hpux) && !defined(__GNUC__) +#include +#endif + +/* + * Flush out all the vectors defined by the given uio, + * then reset it so that it can be reused. + */ +static int +BSD__sprint(fp, uio) + FILE *fp; + register struct __suio *uio; +{ + register int err; + + if (uio->uio_resid == 0) { + uio->uio_iovcnt = 0; + return (0); + } + err = BSD__sfvwrite(fp, uio); + uio->uio_resid = 0; + uio->uio_iovcnt = 0; + return (err); +} + + +/* + * Helper function for `fprintf to unbuffered unix file': creates a + * temporary buffer. We only work on write-only files; this avoids + * worries about ungetc buffers and so forth. + */ +static int +BSD__sbprintf(fp, fmt, ap) + register FILE *fp; + const char *fmt; + va_list ap; +{ +/* We don't support files. */ + return 0; +} + + +/* + * Macros for converting digits to letters and vice versa + */ +#define to_digit(c) ((c) - '0') +#define is_digit(c) ((unsigned)to_digit(c) <= 9) +#define to_char(n) ((n) + '0') + +/* + * Convert an unsigned long to ASCII for printf purposes, returning + * a pointer to the first character of the string representation. + * Octal numbers can be forced to have a leading zero; hex numbers + * use the given digits. + */ +static char * +BSD__ultoa(val, endp, base, octzero, xdigs) + register u_long val; + char *endp; + int base, octzero; + char *xdigs; +{ + register char *cp = endp; + register long sval; + + /* + * Handle the three cases separately, in the hope of getting + * better/faster code. + */ + switch (base) { + case 10: + if (val < 10) { /* many numbers are 1 digit */ + *--cp = to_char(val); + return (cp); + } + /* + * On many machines, unsigned arithmetic is harder than + * signed arithmetic, so we do at most one unsigned mod and + * divide; this is sufficient to reduce the range of + * the incoming value to where signed arithmetic works. + */ + if (val > LONG_MAX) { + *--cp = to_char(val % 10); + sval = val / 10; + } else + sval = val; + do { + *--cp = to_char(sval % 10); + sval /= 10; + } while (sval != 0); + break; + + case 8: + do { + *--cp = to_char(val & 7); + val >>= 3; + } while (val); + if (octzero && *cp != '0') + *--cp = '0'; + break; + + case 16: + do { + *--cp = xdigs[val & 15]; + val >>= 4; + } while (val); + break; + + default: /* oops */ + /* + abort(); + */ + break; /* fjc 7-31-97. Don't reference abort() here */ + } + return (cp); +} + +#ifdef FLOATING_POINT +#include +/* #include "floatio.h" */ + +#ifndef MAXEXP +# define MAXEXP 1024 +#endif + +#ifndef MAXFRACT +# define MAXFRACT 64 +#endif + +#define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */ +#define DEFPREC 6 + +static char *cvt __P((double, int, int, char *, int *, int, int *)); +static int exponent __P((char *, int, int)); + +#else /* no FLOATING_POINT */ + +#define BUF 68 + +#endif /* FLOATING_POINT */ + + +/* + * Flags used during conversion. + */ +#define ALT 0x001 /* alternate form */ +#define HEXPREFIX 0x002 /* add 0x or 0X prefix */ +#define LADJUST 0x004 /* left adjustment */ +#define LONGDBL 0x008 /* long double; unimplemented */ +#define LONGINT 0x010 /* long integer */ + +#ifdef _HAVE_SANE_QUAD_ +#define QUADINT 0x020 /* quad integer */ +#endif /* _HAVE_SANE_QUAD_ */ + +#define SHORTINT 0x040 /* short integer */ +#define ZEROPAD 0x080 /* zero (as opposed to blank) pad */ +#define FPT 0x100 /* Floating point number */ +static int +BSD_vfprintf(fp, fmt0, ap) + FILE *fp; + const char *fmt0; + va_list ap; +{ + register char *fmt; /* format string */ + register int ch; /* character from fmt */ + register int n; /* handy integer (short term usage) */ + register char *cp; /* handy char pointer (short term usage) */ + register struct __siov *iovp;/* for PRINT macro */ + register int flags; /* flags as above */ + int ret; /* return value accumulator */ + int width; /* width from format (%8d), or 0 */ + int prec; /* precision from format (%.3d), or -1 */ + char sign; /* sign prefix (' ', '+', '-', or \0) */ +#ifdef FLOATING_POINT + char softsign; /* temporary negative sign for floats */ + double _double; /* double precision arguments %[eEfgG] */ + int expt; /* integer value of exponent */ + int expsize; /* character count for expstr */ + int ndig; /* actual number of digits returned by cvt */ + char expstr[7]; /* buffer for exponent string */ +#endif + u_long ulval; /* integer arguments %[diouxX] */ +#ifdef _HAVE_SANE_QUAD_ + u_quad_t uqval; /* %q integers */ +#endif /* _HAVE_SANE_QUAD_ */ + int base; /* base for [diouxX] conversion */ + int dprec; /* a copy of prec if [diouxX], 0 otherwise */ + int fieldsz; /* field size expanded by sign, etc */ + int realsz; /* field size expanded by dprec */ + int size; /* size of converted field or string */ + char *xdigs; /* digits for [xX] conversion */ +#define NIOV 8 + struct __suio uio; /* output information: summary */ + struct __siov iov[NIOV];/* ... and individual io vectors */ + char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */ + char ox[2]; /* space for 0x hex-prefix */ + + /* + * Choose PADSIZE to trade efficiency vs. size. If larger printf + * fields occur frequently, increase PADSIZE and make the initialisers + * below longer. + */ +#define PADSIZE 16 /* pad chunk size */ + static char blanks[PADSIZE] = + {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}; + static char zeroes[PADSIZE] = + {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'}; + + /* + * BEWARE, these `goto error' on error, and PAD uses `n'. + */ +#define PRINT(ptr, len) { \ + iovp->iov_base = (ptr); \ + iovp->iov_len = (len); \ + uio.uio_resid += (len); \ + iovp++; \ + if (++uio.uio_iovcnt >= NIOV) { \ + if (BSD__sprint(fp, &uio)) \ + goto error; \ + iovp = iov; \ + } \ +} +#define PAD(howmany, with) { \ + if ((n = (howmany)) > 0) { \ + while (n > PADSIZE) { \ + PRINT(with, PADSIZE); \ + n -= PADSIZE; \ + } \ + PRINT(with, n); \ + } \ +} +#define FLUSH() { \ + if (uio.uio_resid && BSD__sprint(fp, &uio)) \ + goto error; \ + uio.uio_iovcnt = 0; \ + iovp = iov; \ +} + + /* + * To extend shorts properly, we need both signed and unsigned + * argument extraction methods. + */ +#define SARG() \ + (flags&LONGINT ? va_arg(ap, long) : \ + flags&SHORTINT ? (long)(short)va_arg(ap, int) : \ + (long)va_arg(ap, int)) +#define UARG() \ + (flags&LONGINT ? va_arg(ap, u_long) : \ + flags&SHORTINT ? (u_long)(u_short)va_arg(ap, int) : \ + (u_long)va_arg(ap, u_int)) + + /* optimise fprintf(stderr) (and other unbuffered Unix files) */ + if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) && + fp->_file >= 0) + return (BSD__sbprintf(fp, fmt0, ap)); + + fmt = (char *)fmt0; + uio.uio_iov = iovp = iov; + uio.uio_resid = 0; + uio.uio_iovcnt = 0; + ret = 0; + + /* + * Scan the format for conversions (`%' character). + */ + for (;;) { + for (cp = fmt; (ch = *fmt) != '\0' && ch != '%'; fmt++) + /* void */; + if ((n = fmt - cp) != 0) { + PRINT(cp, n); + ret += n; + } + if (ch == '\0') + goto done; + fmt++; /* skip over '%' */ + + flags = 0; + dprec = 0; + width = 0; + prec = -1; + sign = '\0'; + +rflag: ch = *fmt++; +reswitch: switch (ch) { + case ' ': + /* + * ``If the space and + flags both appear, the space + * flag will be ignored.'' + * -- ANSI X3J11 + */ + if (!sign) + sign = ' '; + goto rflag; + case '#': + flags |= ALT; + goto rflag; + case '*': + /* + * ``A negative field width argument is taken as a + * - flag followed by a positive field width.'' + * -- ANSI X3J11 + * They don't exclude field widths read from args. + */ + if ((width = va_arg(ap, int)) >= 0) + goto rflag; + width = -width; + /* FALLTHROUGH */ + case '-': + flags |= LADJUST; + goto rflag; + case '+': + sign = '+'; + goto rflag; + case '.': + if ((ch = *fmt++) == '*') { + n = va_arg(ap, int); + prec = n < 0 ? -1 : n; + goto rflag; + } + n = 0; + while (is_digit(ch)) { + n = 10 * n + to_digit(ch); + ch = *fmt++; + } + prec = n < 0 ? -1 : n; + goto reswitch; + case '0': + /* + * ``Note that 0 is taken as a flag, not as the + * beginning of a field width.'' + * -- ANSI X3J11 + */ + flags |= ZEROPAD; + goto rflag; + case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + n = 0; + do { + n = 10 * n + to_digit(ch); + ch = *fmt++; + } while (is_digit(ch)); + width = n; + goto reswitch; +#ifdef FLOATING_POINT + case 'L': + flags |= LONGDBL; + goto rflag; +#endif + case 'h': + flags |= SHORTINT; + goto rflag; + case 'l': + flags |= LONGINT; + goto rflag; +#ifdef _HAVE_SANE_QUAD_ + case 'q': + flags |= QUADINT; + goto rflag; +#endif /* _HAVE_SANE_QUAD_ */ + case 'c': + *(cp = buf) = va_arg(ap, int); + size = 1; + sign = '\0'; + break; + case 'D': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'd': + case 'i': +#ifdef _HAVE_SANE_QUAD_ + if (flags & QUADINT) { + uqval = va_arg(ap, quad_t); + if ((quad_t)uqval < 0) { + uqval = -uqval; + sign = '-'; + } + } else { +#else /* _HAVE_SANE_QUAD_ */ + { +#endif /* _HAVE_SANE_QUAD_ */ + ulval = SARG(); + if ((long)ulval < 0) { + ulval = -ulval; + sign = '-'; + } + } + base = 10; + goto number; +#ifdef FLOATING_POINT + case 'e': /* anomalous precision */ + case 'E': + prec = (prec == -1) ? + DEFPREC + 1 : prec + 1; + /* FALLTHROUGH */ + goto fp_begin; + case 'f': /* always print trailing zeroes */ + if (prec != 0) + flags |= ALT; + case 'g': + case 'G': + if (prec == -1) + prec = DEFPREC; +fp_begin: _double = va_arg(ap, double); + /* do this before tricky precision changes */ + if (isinf(_double)) { + if (_double < 0) + sign = '-'; + cp = "Inf"; + size = 3; + break; + } + if (isnan(_double)) { + cp = "NaN"; + size = 3; + break; + } + flags |= FPT; + cp = cvt(_double, prec, flags, &softsign, + &expt, ch, &ndig); + if (ch == 'g' || ch == 'G') { + if (expt <= -4 || expt > prec) + ch = (ch == 'g') ? 'e' : 'E'; + else + ch = 'g'; + } + if (ch <= 'e') { /* 'e' or 'E' fmt */ + --expt; + expsize = exponent(expstr, expt, ch); + size = expsize + ndig; + if (ndig > 1 || flags & ALT) + ++size; + } else if (ch == 'f') { /* f fmt */ + if (expt > 0) { + size = expt; + if (prec || flags & ALT) + size += prec + 1; + } else /* "0.X" */ + size = prec + 2; + } else if (expt >= ndig) { /* fixed g fmt */ + size = expt; + if (flags & ALT) + ++size; + } else + size = ndig + (expt > 0 ? + 1 : 2 - expt); + + if (softsign) + sign = '-'; + break; +#endif /* FLOATING_POINT */ + case 'n': +#ifdef _HAVE_SANE_QUAD_ + if (flags & QUADINT) + *va_arg(ap, quad_t *) = ret; + else if (flags & LONGINT) +#else /* _HAVE_SANE_QUAD_ */ + if (flags & LONGINT) +#endif /* _HAVE_SANE_QUAD_ */ + *va_arg(ap, long *) = ret; + else if (flags & SHORTINT) + *va_arg(ap, short *) = ret; + else + *va_arg(ap, int *) = ret; + continue; /* no output */ + case 'O': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'o': +#ifdef _HAVE_SANE_QUAD_ + if (flags & QUADINT) + uqval = va_arg(ap, u_quad_t); + else +#endif /* _HAVE_SANE_QUAD_ */ + ulval = UARG(); + base = 8; + goto nosign; + case 'p': + /* + * ``The argument shall be a pointer to void. The + * value of the pointer is converted to a sequence + * of printable characters, in an implementation- + * defined manner.'' + * -- ANSI X3J11 + */ + ulval = (u_long)va_arg(ap, void *); + base = 16; + xdigs = "0123456789abcdef"; +#ifdef _HAVE_SANE_QUAD_ + flags = (flags & ~QUADINT) | HEXPREFIX; +#else /* _HAVE_SANE_QUAD_ */ + flags = (flags) | HEXPREFIX; +#endif /* _HAVE_SANE_QUAD_ */ + ch = 'x'; + goto nosign; + case 's': + if ((cp = va_arg(ap, char *)) == NULL) + cp = "(null)"; + if (prec >= 0) { + /* + * can't use strlen; can only look for the + * NUL in the first `prec' characters, and + * strlen() will go further. + */ + char *p = (char *)memchr(cp, 0, prec); + + if (p != NULL) { + size = p - cp; + if (size > prec) + size = prec; + } else + size = prec; + } else + size = strlen(cp); + sign = '\0'; + break; + case 'U': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'u': +#ifdef _HAVE_SANE_QUAD_ + if (flags & QUADINT) + uqval = va_arg(ap, u_quad_t); + else +#endif /* _HAVE_SANE_QUAD_ */ + ulval = UARG(); + base = 10; + goto nosign; + case 'X': + xdigs = "0123456789ABCDEF"; + goto hex; + case 'x': + xdigs = "0123456789abcdef"; +hex: +#ifdef _HAVE_SANE_QUAD_ + if (flags & QUADINT) + uqval = va_arg(ap, u_quad_t); + else +#endif /* _HAVE_SANE_QUAD_ */ + ulval = UARG(); + base = 16; + /* leading 0x/X only if non-zero */ + if (flags & ALT && +#ifdef _HAVE_SANE_QUAD_ + (flags & QUADINT ? uqval != 0 : ulval != 0)) +#else /* _HAVE_SANE_QUAD_ */ + ulval != 0) +#endif /* _HAVE_SANE_QUAD_ */ + flags |= HEXPREFIX; + + /* unsigned conversions */ +nosign: sign = '\0'; + /* + * ``... diouXx conversions ... if a precision is + * specified, the 0 flag will be ignored.'' + * -- ANSI X3J11 + */ +number: if ((dprec = prec) >= 0) + flags &= ~ZEROPAD; + + /* + * ``The result of converting a zero value with an + * explicit precision of zero is no characters.'' + * -- ANSI X3J11 + */ + cp = buf + BUF; +#ifdef _HAVE_SANE_QUAD_ + if (flags & QUADINT) { + if (uqval != 0 || prec != 0) + cp = __uqtoa(uqval, cp, base, + flags & ALT, xdigs); + } else { +#else /* _HAVE_SANE_QUAD_ */ + { +#endif /* _HAVE_SANE_QUAD_ */ + if (ulval != 0 || prec != 0) + cp = BSD__ultoa(ulval, cp, base, + flags & ALT, xdigs); + } + size = buf + BUF - cp; + break; + default: /* "%?" prints ?, unless ? is NUL */ + if (ch == '\0') + goto done; + /* pretend it was %c with argument ch */ + cp = buf; + *cp = ch; + size = 1; + sign = '\0'; + break; + } + + /* + * All reasonable formats wind up here. At this point, `cp' + * points to a string which (if not flags&LADJUST) should be + * padded out to `width' places. If flags&ZEROPAD, it should + * first be prefixed by any sign or other prefix; otherwise, + * it should be blank padded before the prefix is emitted. + * After any left-hand padding and prefixing, emit zeroes + * required by a decimal [diouxX] precision, then print the + * string proper, then emit zeroes required by any leftover + * floating precision; finally, if LADJUST, pad with blanks. + * + * Compute actual size, so we know how much to pad. + * fieldsz excludes decimal prec; realsz includes it. + */ + fieldsz = size; + if (sign) + fieldsz++; + else if (flags & HEXPREFIX) + fieldsz += 2; + realsz = dprec > fieldsz ? dprec : fieldsz; + + /* right-adjusting blank padding */ + if ((flags & (LADJUST|ZEROPAD)) == 0) + PAD(width - realsz, blanks); + + /* prefix */ + if (sign) { + PRINT(&sign, 1); + } else if (flags & HEXPREFIX) { + ox[0] = '0'; + ox[1] = ch; + PRINT(ox, 2); + } + + /* right-adjusting zero padding */ + if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD) + PAD(width - realsz, zeroes); + + /* leading zeroes from decimal precision */ + PAD(dprec - fieldsz, zeroes); + + /* the string or number proper */ +#ifdef FLOATING_POINT + if ((flags & FPT) == 0) { + PRINT(cp, size); + } else { /* glue together f_p fragments */ + if (ch >= 'f') { /* 'f' or 'g' */ + if (_double == 0) { + /* kludge for __dtoa irregularity */ + if (prec == 0 || + (flags & ALT) == 0) { + PRINT("0", 1); + } else { + PRINT("0.", 2); + PAD(ndig - 1, zeroes); + } + } else if (expt <= 0) { + PRINT("0.", 2); + PAD(-expt, zeroes); + PRINT(cp, ndig); + } else if (expt >= ndig) { + PRINT(cp, ndig); + PAD(expt - ndig, zeroes); + if (flags & ALT) + PRINT(".", 1); + } else { + PRINT(cp, expt); + cp += expt; + PRINT(".", 1); + PRINT(cp, ndig-expt); + } + } else { /* 'e' or 'E' */ + if (ndig > 1 || flags & ALT) { + ox[0] = *cp++; + ox[1] = '.'; + PRINT(ox, 2); + if (_double || flags & ALT == 0) { + PRINT(cp, ndig-1); + } else /* 0.[0..] */ + /* __dtoa irregularity */ + PAD(ndig - 1, zeroes); + } else /* XeYYY */ + PRINT(cp, 1); + PRINT(expstr, expsize); + } + } +#else + PRINT(cp, size); +#endif + /* left-adjusting padding (always blank) */ + if (flags & LADJUST) + PAD(width - realsz, blanks); + + /* finally, adjust ret */ + ret += width > realsz ? width : realsz; + + FLUSH(); /* copy out the I/O vectors */ + } +done: + FLUSH(); +error: + return (__sferror(fp) ? EOF : ret); + /* NOTREACHED */ +} + +#ifdef FLOATING_POINT + +extern char *BSD__dtoa __P((double, int, int, int *, int *, char **)); + +static char * +cvt(value, ndigits, flags, sign, decpt, ch, length) + double value; + int ndigits, flags, *decpt, ch, *length; + char *sign; +{ + int mode, dsgn; + char *digits, *bp, *rve; + + if (ch == 'f') + mode = 3; + else { + mode = 2; + } + if (value < 0) { + value = -value; + *sign = '-'; + } else + *sign = '\000'; + digits = BSD__dtoa(value, mode, ndigits, decpt, &dsgn, &rve); + if (flags & ALT) { /* Print trailing zeros */ + bp = digits + ndigits; + if (ch == 'f') { + if (*digits == '0' && value) + *decpt = -ndigits + 1; + bp += *decpt; + } + if (value == 0) /* kludge for __dtoa irregularity */ + rve = bp; + while (rve < bp) + *rve++ = '0'; + } + *length = rve - digits; + return (digits); +} + +static int +exponent(p0, exp, fmtch) + char *p0; + int exp, fmtch; +{ + register char *p, *t; + char expbuf[MAXEXP]; + + p = p0; + *p++ = fmtch; + if (exp < 0) { + exp = -exp; + *p++ = '-'; + } + else + *p++ = '+'; + t = expbuf + MAXEXP; + if (exp > 9) { + do { + *--t = to_char(exp % 10); + } while ((exp /= 10) > 9); + *--t = to_char(exp); + for (; t < expbuf + MAXEXP; *p++ = *t++); + } + else { + *p++ = '0'; + *p++ = to_char(exp); + } + return (p - p0); +} +#endif /* FLOATING_POINT */ + +int +vsnprintf(str, n, fmt, ap) + char *str; + size_t n; + const char *fmt; + _BSD_VA_LIST_ ap; +{ + int ret; + FILE f; + + if ((int)n < 1) + return (EOF); + f._flags = __SWR | __SSTR; + f._bf._base = f._p = (unsigned char *)str; + f._bf._size = f._w = n - 1; + ret = BSD_vfprintf(&f, fmt, ap); + *f._p = 0; + return (ret); +} + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)snprintf.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#if defined(__STDC__) +# include +#else +# include +#endif + +int +#if defined(__STDC__) +snprintf(char *str, size_t n, char const *fmt, ...) +#else +snprintf(str, n, fmt, va_alist) +char *str, *fmt; +size_t n; +va_dcl +#endif +{ + int ret; + va_list ap; + FILE f; + + if ((int)n < 1) + return (EOF); + +#if defined(__STDC__) + va_start(ap, fmt); +#else + va_start(ap); +#endif + f._flags = __SWR | __SSTR; + f._bf._base = f._p = (unsigned char *)str; + f._bf._size = f._w = n - 1; + ret = BSD_vfprintf(&f, fmt, ap); + *f._p = 0; + va_end(ap); + return (ret); +} diff -Nru lha-1.14i/tests/lha-test1 lha-1.14i-acc20050924p1/tests/lha-test1 --- lha-1.14i/tests/lha-test1 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/tests/lha-test1 2003-07-27 09:35:47.000000000 +0000 @@ -0,0 +1,41 @@ +# -*- shell-script -*- +message testing to create/list/extract lha archive. + +i=0 +while (( i < 100 )) +do + echo foo + ((i = i + 1)) +done > test-a +sed 's/foo/bar/g' < test-a > test-b +sed 's/foo/baz/g' < test-a > test-c + +$lha c test-1.lzh test-a test-b test-c + check $? $LINENO +test -s test-1.lzh + check $? $LINENO + +$lha l test-1.lzh + check $? $LINENO + +test -d test-1 || mkdir test-1 +mv test-[abc] test-1 +$lha x test-1.lzh + check $? $LINENO +diff test-1/test-a test-a + check $? $LINENO +diff test-1/test-b test-b + check $? $LINENO +diff test-1/test-c test-c + check $? $LINENO + +# followings are test data for remaining tests. +test -f test-1.lzh && +test -f test-a && +test -f test-b && +test -f test-c && +test -d test-1 && +test -f test-1/test-a && +test -f test-1/test-b && +test -f test-1/test-c + check $? $LINENO diff -Nru lha-1.14i/tests/lha-test10 lha-1.14i-acc20050924p1/tests/lha-test10 --- lha-1.14i/tests/lha-test10 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/tests/lha-test10 2003-07-27 09:35:47.000000000 +0000 @@ -0,0 +1,166 @@ +# -*- shell-script -*- +message testing header level 0, 1, 2 and each generic headers +$lha c0 test-tmp-h0.lzh test-1 + check $? $LINENO +$lha c1 test-tmp-h1.lzh test-1 + check $? $LINENO +$lha c2 test-tmp-h2.lzh test-1 + check $? $LINENO +$lha xw=test-tmp-h0 test-tmp-h0.lzh + check $? $LINENO +$lha xw=test-tmp-h1 test-tmp-h1.lzh + check $? $LINENO +$lha xw=test-tmp-h2 test-tmp-h2.lzh + check $? $LINENO +$lha vv test-tmp-h0.lzh + check $? $LINENO +$lha vv test-tmp-h1.lzh + check $? $LINENO +$lha vv test-tmp-h2.lzh + check $? $LINENO +$lha vv test-tmp-h0.lzh | egrep '\[0\].?$' + check $? $LINENO +$lha vv test-tmp-h1.lzh | egrep '\[1\].?$' + check $? $LINENO +$lha vv test-tmp-h2.lzh | egrep '\[2\].?$' + check $? $LINENO +diff -r test-1 test-tmp-h0/test-1 + check $? $LINENO +diff -r test-1 test-tmp-h1/test-1 + check $? $LINENO +diff -r test-1 test-tmp-h2/test-1 + check $? $LINENO +# contains directory header (-lhd-) +mkdir test-tmp-d1 && +cp test-a test-tmp-d1 && +mkdir test-tmp-d1/d2 && +cp test-b test-tmp-d1/d2 && +mkdir test-tmp-d1/d2/d3 && +cp test-c test-tmp-d1/d2/d3 + check $? $LINENO +$lha c0 test-tmp2-h0.lzh test-tmp-d1 + check $? $LINENO +$lha c1 test-tmp2-h1.lzh test-tmp-d1 + check $? $LINENO +$lha c2 test-tmp2-h2.lzh test-tmp-d1 + check $? $LINENO +$lha xw=test-tmp2-h0 test-tmp2-h0.lzh + check $? $LINENO +$lha xw=test-tmp2-h1 test-tmp2-h1.lzh + check $? $LINENO +$lha xw=test-tmp2-h2 test-tmp2-h2.lzh + check $? $LINENO +$lha vv test-tmp2-h0.lzh + check $? $LINENO +$lha vv test-tmp2-h1.lzh + check $? $LINENO +$lha vv test-tmp2-h2.lzh + check $? $LINENO +$lha vv test-tmp2-h0.lzh | egrep '\[0\].?$' + check $? $LINENO +$lha vv test-tmp2-h1.lzh | egrep '\[1\].?$' + check $? $LINENO +$lha vv test-tmp2-h2.lzh | egrep '\[2\].?$' + check $? $LINENO +diff test-a test-tmp2-h0/test-tmp-d1/test-a + check $? $LINENO +diff test-b test-tmp2-h0/test-tmp-d1/d2/test-b + check $? $LINENO +diff test-c test-tmp2-h0/test-tmp-d1/d2/d3/test-c + check $? $LINENO +diff test-a test-tmp2-h1/test-tmp-d1/test-a + check $? $LINENO +diff test-b test-tmp2-h1/test-tmp-d1/d2/test-b + check $? $LINENO +diff test-c test-tmp2-h1/test-tmp-d1/d2/d3/test-c + check $? $LINENO +diff test-a test-tmp2-h2/test-tmp-d1/test-a + check $? $LINENO +diff test-b test-tmp2-h2/test-tmp-d1/d2/test-b + check $? $LINENO +diff test-c test-tmp2-h2/test-tmp-d1/d2/d3/test-c + check $? $LINENO + +# generic archive + +$lha cg0 test-tmp-hg0.lzh test-1 + check $? $LINENO +$lha cg1 test-tmp-hg1.lzh test-1 + check $? $LINENO +$lha cg2 test-tmp-hg2.lzh test-1 + check $? $LINENO +$lha xw=test-tmp-hg0 test-tmp-hg0.lzh + check $? $LINENO +$lha xw=test-tmp-hg1 test-tmp-hg1.lzh + check $? $LINENO +$lha xw=test-tmp-hg2 test-tmp-hg2.lzh + check $? $LINENO +$lha vv test-tmp-hg0.lzh + check $? $LINENO +$lha vv test-tmp-hg1.lzh + check $? $LINENO +$lha vv test-tmp-hg2.lzh + check $? $LINENO +$lha vv test-tmp-hg0.lzh | egrep '\[0\].?$' + check $? $LINENO +$lha vv test-tmp-hg1.lzh | egrep '\[1\].?$' + check $? $LINENO +$lha vv test-tmp-hg2.lzh | egrep '\[2\].?$' + check $? $LINENO +diff -r test-1 test-tmp-hg0/test-1 + check $? $LINENO +diff -r test-1 test-tmp-hg1/test-1 + check $? $LINENO +diff -r test-1 test-tmp-hg2/test-1 + check $? $LINENO +# contains directory header (-lhd-) +mkdir test-tmp-gd1 && +cp test-a test-tmp-gd1 && +mkdir test-tmp-gd1/d2 && +cp test-b test-tmp-gd1/d2 && +mkdir test-tmp-gd1/d2/d3 && +cp test-c test-tmp-gd1/d2/d3 && + check $? $LINENO + +$lha cg0 test-tmp2-hg0.lzh test-tmp-gd1 + check $? $LINENO +$lha cg1 test-tmp2-hg1.lzh test-tmp-gd1 + check $? $LINENO +$lha cg2 test-tmp2-hg2.lzh test-tmp-gd1 + check $? $LINENO +$lha xw=test-tmp2-hg0 test-tmp2-hg0.lzh + check $? $LINENO +$lha xw=test-tmp2-hg1 test-tmp2-hg1.lzh + check $? $LINENO +$lha xw=test-tmp2-hg2 test-tmp2-hg2.lzh + check $? $LINENO +$lha vv test-tmp2-hg0.lzh + check $? $LINENO +$lha vv test-tmp2-hg1.lzh + check $? $LINENO +$lha vv test-tmp2-hg2.lzh + check $? $LINENO +$lha vv test-tmp2-hg0.lzh | egrep '\[0\].?$' + check $? $LINENO +$lha vv test-tmp2-hg1.lzh | egrep '\[1\].?$' + check $? $LINENO +$lha vv test-tmp2-hg2.lzh | egrep '\[2\].?$' + check $? $LINENO +diff test-a test-tmp2-hg0/test-tmp-gd1/test-a + check $? $LINENO +diff test-b test-tmp2-hg0/test-tmp-gd1/d2/test-b + check $? $LINENO +diff test-c test-tmp2-hg0/test-tmp-gd1/d2/d3/test-c + check $? $LINENO +diff test-a test-tmp2-hg1/test-tmp-gd1/test-a + check $? $LINENO +diff test-b test-tmp2-hg1/test-tmp-gd1/d2/test-b + check $? $LINENO +diff test-c test-tmp2-hg1/test-tmp-gd1/d2/d3/test-c + check $? $LINENO +diff test-a test-tmp2-hg2/test-tmp-gd1/test-a + check $? $LINENO +diff test-b test-tmp2-hg2/test-tmp-gd1/d2/test-b + check $? $LINENO +diff test-c test-tmp2-hg2/test-tmp-gd1/d2/d3/test-c + check $? $LINENO diff -Nru lha-1.14i/tests/lha-test11 lha-1.14i-acc20050924p1/tests/lha-test11 --- lha-1.14i/tests/lha-test11 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/tests/lha-test11 2006-10-10 16:27:51.000000000 +0000 @@ -0,0 +1,92 @@ +# -*- shell-script -*- +message testing the long filename support +# long long filename +# assume that we are allowed to create 255 bytes filename (not path name). +# the _POSIX_PATH_MAX (the maximam length of relative path name) value may +# be 255. +# +# Note that on Cygwin/MinGW, on NTFS, the maximam length of whole path +# name (contain the drive letter) is limited probably. it seems to be 259 (?) +# +mkdir test-tmp1 +case $(uname) in +CYGWIN*) + # 190 bytes + file=1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 ;; +*) + # 255 bytes + file=123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 ;; +esac +(cd test-tmp1 && touch $file) + check $? $LINENO +$lha cg test-tmp1-hg.lzh test-tmp1 2> test-stderr + check $? $LINENO +# on Cygwin/MinGW, skip this test. +# the length of pathname does not amount to the limit of level 0 header. +case $(uname) in +CYGWIN*) true ;; +*) test -s test-stderr ;; +esac + check $? $LINENO +$lha c0 test-tmp1-h0.lzh test-tmp1 2> test-stderr + check $? $LINENO +# on Cygwin/MinGW, skip this test. +# the length of pathname does not amount to the limit of level 0 header. +case $(uname) in +CYGWIN*) true ;; +*) test -s test-stderr ;; +esac + check $? $LINENO +$lha c1 test-tmp1-h1.lzh test-tmp1 + check $? $LINENO +$lha c2 test-tmp1-h2.lzh test-tmp1 + check $? $LINENO +$lha xw=test-tmp1-hg test-tmp1-hg.lzh + check $? $LINENO +$lha xw=test-tmp1-h0 test-tmp1-h0.lzh + check $? $LINENO +$lha xw=test-tmp1-h1 test-tmp1-h1.lzh + check $? $LINENO +$lha xw=test-tmp1-h2 test-tmp1-h2.lzh + check $? $LINENO +# for logging +$lha vv test-tmp1-hg.lzh + check $? $LINENO +$lha vv test-tmp1-h0.lzh + check $? $LINENO +$lha vv test-tmp1-h1.lzh + check $? $LINENO +$lha vv test-tmp1-h2.lzh + check $? $LINENO +$lha vv test-tmp1-hg.lzh | egrep '\[0\].?$' + check $? $LINENO +$lha vv test-tmp1-h0.lzh | egrep '\[0\].?$' + check $? $LINENO +$lha vv test-tmp1-h1.lzh | egrep '\[1\].?$' + check $? $LINENO +$lha vv test-tmp1-h2.lzh | egrep '\[2\].?$' + check $? $LINENO +test -f test-tmp1-hg/$(echo test-tmp1/$file | cut -c-233) + check $? $LINENO +test -f test-tmp1-h0/$(echo test-tmp1/$file | cut -c-221) + check $? $LINENO +test -f test-tmp1-h1/test-tmp1/$file + check $? $LINENO +test -f test-tmp1-h2/test-tmp1/$file + check $? $LINENO +# 0x100 is never set on the header size field on level 2 header +file=test-tmp9012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 +touch $file + check $? $LINENO +$lha c2 test-tmp4-h2.lzh $file + check $? $LINENO +$lha vv test-tmp4-h2.lzh + check $? $LINENO +$lha vv test-tmp4-h2.lzh | egrep '\[2\].?$' + check $? $LINENO +$lha xw=test-tmp4 test-tmp4-h2.lzh + check $? $LINENO +test x"`$lha vvvq test-tmp4-h2.lzh | head -1`" = x"00 2: 257(0x0101)" + check $? $LINENO +test -f test-tmp4/$file + check $? $LINENO diff -Nru lha-1.14i/tests/lha-test12 lha-1.14i-acc20050924p1/tests/lha-test12 --- lha-1.14i/tests/lha-test12 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/tests/lha-test12 2006-10-10 16:27:51.000000000 +0000 @@ -0,0 +1,31 @@ +# -*- shell-script -*- +message testing the end of line conversion. + +# NL to CR NL in archive +$lha ct test-tmp-crnl.lzh test-a test-b test-c + check $? $LINENO +# no convert +$lha xw=test-tmp-crnl test-tmp-crnl.lzh + check $? $LINENO +diff -r test-1 test-tmp-crnl +test $? -ne 0 + check $? $LINENO +sed -e 's/$/ /' < test-a | diff test-tmp-crnl/test-a - + check $? $LINENO +sed -e 's/$/ /' < test-b | diff test-tmp-crnl/test-b - + check $? $LINENO +sed -e 's/$/ /' < test-c | diff test-tmp-crnl/test-c - + check $? $LINENO +# CR NL to NL +$lha xtw=test-tmp-nl test-tmp-crnl.lzh + check $? $LINENO +diff -r test-1 test-tmp-nl + check $? $LINENO +# no convert +$lha c test-tmp-nl.lzh test-a test-b test-c + check $? $LINENO +# CR NL to NL (cannot convert) +$lha xtw=test-tmp-nl2 test-tmp-nl.lzh + check $? $LINENO +diff -r test-1 test-tmp-nl2 + check $? $LINENO diff -Nru lha-1.14i/tests/lha-test13 lha-1.14i-acc20050924p1/tests/lha-test13 --- lha-1.14i/tests/lha-test13 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/tests/lha-test13 2003-07-29 12:15:43.000000000 +0000 @@ -0,0 +1,96 @@ +# -*- shell-script -*- +message testing the kanji code conversion. + +# printf '\xb4\xc1\xbb\xfa\n' > test-tmp-euc +echo abcd | LANG=C tr abcd '\264\301\273\372' > test-tmp-euc + check $? $LINENO +# printf '\x8a\xbf\x8e\x9a\n' > test-tmp-sjis +echo abcd | LANG=C tr abcd '\212\277\216\232' > test-tmp-sjis + check $? $LINENO +# no convert +$lha c test-tmp-euc.lzh test-tmp-euc + check $? $LINENO +# file size is too small, so no compressed +$lha v test-tmp-euc.lzh | egrep lh0 + check $? $LINENO +# no convert +$lha xw=test-tmp-euc-d test-tmp-euc.lzh + check $? $LINENO +diff -r test-tmp-euc test-tmp-euc-d/test-tmp-euc + check $? $LINENO +# sjis to euc +$lha xew=test-tmp-unknown-d test-tmp-euc.lzh + check $? $LINENO +diff -r test-tmp-euc test-tmp-unknown-d/test-tmp-euc +test $? -ne 0 + check $? $LINENO +diff -r test-tmp-sjis test-tmp-unknown-d/test-tmp-euc +test $? -ne 0 + check $? $LINENO + +# euc to sjis (NL to CR NL) +$lha ce test-tmp-sjis.lzh test-tmp-euc + check $? $LINENO +# file size is too small, so no compressed +$lha v test-tmp-euc.lzh | egrep lh0 + check $? $LINENO +# no convert (CR NL to NL) +$lha xtw=test-tmp-sjis-d test-tmp-sjis.lzh + check $? $LINENO +diff test-tmp-sjis test-tmp-sjis-d/test-tmp-euc + check $? $LINENO +# sjis to euc (CR NL to NL) +$lha xew=test-tmp-euc-d2 test-tmp-sjis.lzh + check $? $LINENO +diff test-tmp-euc test-tmp-euc-d2/test-tmp-euc + check $? $LINENO + +i=0 +while ((i < 10)) +do + cat test-tmp-euc + ((i = i + 1)) +done > test-tmp-euc2 + +i=0 +while ((i < 10)) +do + cat test-tmp-sjis + ((i = i + 1)) +done > test-tmp-sjis2 + +# no convert +$lha c test-tmp-euc2.lzh test-tmp-euc2 + check $? $LINENO +$lha v test-tmp-euc2.lzh | egrep 'lh[567]' + check $? $LINENO +# no convert +$lha xw=test-tmp-euc2-d test-tmp-euc2.lzh + check $? $LINENO +diff -r test-tmp-euc2 test-tmp-euc2-d/test-tmp-euc2 + check $? $LINENO +# sjis to euc +$lha xew=test-tmp-unknown2-d test-tmp-euc2.lzh + check $? $LINENO +diff -r test-tmp-euc2 test-tmp-unknown2-d/test-tmp-euc2 +test $? -ne 0 + check $? $LINENO +diff -r test-tmp-sjis2 test-tmp-unknown2-d/test-tmp-euc2 +test $? -ne 0 + check $? $LINENO + +# euc to sjis (NL to CR NL) +$lha ce test-tmp-sjis2.lzh test-tmp-euc2 + check $? $LINENO +$lha v test-tmp-euc2.lzh | egrep 'lh[567]' + check $? $LINENO +# no convert (CR NL to NL) +$lha xtw=test-tmp-sjis2-d test-tmp-sjis2.lzh + check $? $LINENO +diff test-tmp-sjis2 test-tmp-sjis2-d/test-tmp-euc2 + check $? $LINENO +# sjis to euc (CR NL to NL) +$lha xew=test-tmp-euc2-d2 test-tmp-sjis2.lzh + check $? $LINENO +diff test-tmp-euc2 test-tmp-euc2-d2/test-tmp-euc2 + check $? $LINENO diff -Nru lha-1.14i/tests/lha-test14 lha-1.14i-acc20050924p1/tests/lha-test14 --- lha-1.14i/tests/lha-test14 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/tests/lha-test14 2006-10-02 12:21:53.000000000 +0000 @@ -0,0 +1,74 @@ +# -*- shell-script -*- +message testing to handle symbolic links + +ln -s test-a test-tmp-a && +ln -s test-b test-tmp-b && +ln -s test-c test-tmp-c + check $? $LINENO +$lha c test-tmp-1.lzh test-tmp-[abc] + check $? $LINENO +$lha v test-tmp-1.lzh + check $? $LINENO +$lha xw=test-tmp-1 test-tmp-1.lzh 2> test-tmp-stderr + check $? $LINENO +# LHa: Symbolic Link test-a -> test-tmp-1/test-tmp-a +# LHa: Symbolic Link test-b -> test-tmp-1/test-tmp-b +# LHa: Symbolic Link test-c -> test-tmp-1/test-tmp-c +test -s test-tmp-stderr + check $? $LINENO +test -L test-tmp-1/test-tmp-a && +test -L test-tmp-1/test-tmp-b && +test -L test-tmp-1/test-tmp-c + check $? $LINENO +# symbolic link is broken +test ! -f test-tmp-1/test-tmp-a && +test ! -f test-tmp-1/test-tmp-b && +test ! -f test-tmp-1/test-tmp-c + check $? $LINENO + +# symbolic link filename contains '|' +case `$lha --version 2>&1` in +*-pc-cygwin*|*-pc-mingw*) + # On MS Windows, '|' is invalid character as filename. + ;; +*) +ln -s test-a test-tmp-\|foo + check $? $LINENO +$lha c test-tmp-2.lzh test-tmp-\|foo 2> test-tmp-stderr +test $? -ne 0 + check $? $LINENO +#LHa: Error: symlink name "test-tmp-|foo" contains '|' char. change it into '_' +test -s test-tmp-stderr + check $? $LINENO +# '|' was changed into '_'. +$lha v test-tmp-2.lzh + check $? $LINENO +$lha v test-tmp-2.lzh | egrep 'test-tmp-_foo -> test-a' + check $? $LINENO +$lha xw=test-tmp-2 test-tmp-2.lzh 2> test-tmp-stderr + check $? $LINENO +test -s test-tmp-stderr + check $? $LINENO +test -L test-tmp-2/test-tmp-_foo && +test ! -f test-tmp-1/test-tmp-_foo + check $? $LINENO +# linked filename contains '|' +touch test-tmp-\|bar && +ln -s test-tmp-\|bar test-tmp-foo + check $? $LINENO +$lha c test-tmp-3.lzh test-tmp-foo + check $? $LINENO +$lha v test-tmp-3.lzh + check $? $LINENO +$lha v test-tmp-3.lzh | egrep 'test-tmp-foo -> test-tmp-\|bar' + check $? $LINENO +$lha xw=test-tmp-3 test-tmp-3.lzh 2> test-tmp-stderr + check $? $LINENO +# LHa: Symbolic Link test-tmp-3/test-tmp-foo -> test-tmp-|bar +test -s test-tmp-stderr + check $? $LINENO +test -L test-tmp-3/test-tmp-foo && +test ! -f test-tmp-1/test-tmp-foo + check $? $LINENO +;; +esac diff -Nru lha-1.14i/tests/lha-test15 lha-1.14i-acc20050924p1/tests/lha-test15 --- lha-1.14i/tests/lha-test15 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/tests/lha-test15 2003-07-27 09:35:47.000000000 +0000 @@ -0,0 +1,54 @@ +# -*- shell-script -*- +message testing to self extracting archive + +if test -c /dev/zero; then + # Usually, size of SFX code is less than 20K + dd if=/dev/zero of=test-tmp-hg.exe bs=1024 count=20 2>/dev/null +else + # dummy header + echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx > test-tmp-hg.exe +fi + check $? $LINENO +cp test-tmp-hg.exe test-tmp-h0.exe && +cp test-tmp-hg.exe test-tmp-h1.exe && +cp test-tmp-hg.exe test-tmp-h2.exe + check $? $LINENO +# generic header +$lha cg - test-[abc] >> test-tmp-hg.exe + check $? $LINENO +$lha vv test-tmp-hg.exe + check $? $LINENO +$lha xw=test-tmp-hg test-tmp-hg.exe + check $? $LINENO +diff -r test-1 test-tmp-hg + check $? $LINENO + +# level 0 header +$lha c0 - test-[abc] >> test-tmp-h0.exe + check $? $LINENO +$lha vv test-tmp-h0.exe + check $? $LINENO +$lha xw=test-tmp-h0 test-tmp-h0.exe + check $? $LINENO +diff -r test-1 test-tmp-h0 + check $? $LINENO + +# level 1 header +$lha c1 - test-[abc] >> test-tmp-h1.exe + check $? $LINENO +$lha vv test-tmp-h1.exe + check $? $LINENO +$lha xw=test-tmp-h1 test-tmp-h1.exe + check $? $LINENO +diff -r test-1 test-tmp-h1 + check $? $LINENO + +# level 2 header +$lha c2 - test-[abc] >> test-tmp-h2.exe + check $? $LINENO +$lha vv test-tmp-h2.exe + check $? $LINENO +$lha xw=test-tmp-h2 test-tmp-h2.exe + check $? $LINENO +diff -r test-1 test-tmp-h2 + check $? $LINENO diff -Nru lha-1.14i/tests/lha-test2 lha-1.14i-acc20050924p1/tests/lha-test2 --- lha-1.14i/tests/lha-test2 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/tests/lha-test2 2003-07-27 09:35:47.000000000 +0000 @@ -0,0 +1,90 @@ +# -*- shell-script -*- +message testing to lh0, lh1, lh5, lh6 and lh7 method archive. +$lha cz test-tmp-m0.lzh test-a test-b test-c + check $? $LINENO +$lha co test-tmp-m1.lzh test-a test-b test-c + check $? $LINENO +$lha co5 test-tmp-m5.lzh test-a test-b test-c + check $? $LINENO +$lha co6 test-tmp-m6.lzh test-a test-b test-c + check $? $LINENO +$lha co7 test-tmp-m7.lzh test-a test-b test-c + check $? $LINENO +$lha v test-tmp-m0.lzh && +$lha v test-tmp-m1.lzh && +$lha v test-tmp-m5.lzh && +$lha v test-tmp-m6.lzh && +$lha v test-tmp-m7.lzh + check $? $LINENO +$lha v test-tmp-m0.lzh | grep lh0 + check $? $LINENO +$lha v test-tmp-m1.lzh | grep lh1 + check $? $LINENO +$lha v test-tmp-m5.lzh | grep lh5 + check $? $LINENO +$lha v test-tmp-m6.lzh | grep lh6 + check $? $LINENO +$lha v test-tmp-m7.lzh | grep lh7 + check $? $LINENO +$lha xw=test-tmp-m0 test-tmp-m0.lzh + check $? $LINENO +$lha xw=test-tmp-m1 test-tmp-m1.lzh + check $? $LINENO +$lha xw=test-tmp-m5 test-tmp-m5.lzh + check $? $LINENO +$lha xw=test-tmp-m6 test-tmp-m6.lzh + check $? $LINENO +$lha xw=test-tmp-m7 test-tmp-m7.lzh + check $? $LINENO + +diff -r test-1 test-tmp-m0 + check $? $LINENO +diff -r test-1 test-tmp-m1 + check $? $LINENO +diff -r test-1 test-tmp-m5 + check $? $LINENO +diff -r test-1 test-tmp-m6 + check $? $LINENO +diff -r test-1 test-tmp-m7 + check $? $LINENO + +$lha pq test-tmp-m0.lzh test-a | diff test-a - + check $? $LINENO +$lha pq test-tmp-m1.lzh test-a | diff test-a - + check $? $LINENO +$lha pq test-tmp-m5.lzh test-a | diff test-a - + check $? $LINENO +$lha pq test-tmp-m6.lzh test-a | diff test-a - + check $? $LINENO +$lha pq test-tmp-m7.lzh test-a | diff test-a - + check $? $LINENO + +cat test-[abc] > test-tmp-abc +$lha pq test-tmp-m0.lzh | diff test-tmp-abc - + check $? $LINENO +$lha pq test-tmp-m1.lzh | diff test-tmp-abc - + check $? $LINENO +$lha pq test-tmp-m5.lzh | diff test-tmp-abc - + check $? $LINENO +$lha pq test-tmp-m6.lzh | diff test-tmp-abc - + check $? $LINENO +$lha pq test-tmp-m7.lzh | diff test-tmp-abc - + check $? $LINENO +# empty file should be frozen with the -lh0- method. +touch test-tmp-0byte + check $? $LINENO +$lha c test-tmp-0byte.lzh test-tmp-0byte + check $? $LINENO +$lha v test-tmp-0byte.lzh + check $? $LINENO +$lha v test-tmp-0byte.lzh | grep lh0 + check $? $LINENO +# uncompressed file should be frozen with the -lh0- method. +echo foobar > test-tmp-small + check $? $LINENO +$lha c test-tmp-small.lzh test-tmp-small + check $? $LINENO +$lha v test-tmp-small.lzh + check $? $LINENO +$lha v test-tmp-small.lzh | grep lh0 + check $? $LINENO diff -Nru lha-1.14i/tests/lha-test3 lha-1.14i-acc20050924p1/tests/lha-test3 --- lha-1.14i/tests/lha-test3 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/tests/lha-test3 2003-07-27 09:35:47.000000000 +0000 @@ -0,0 +1,73 @@ +# -*- shell-script -*- +message testing to generic format archive. +$lha czg test-tmp-m0g.lzh test-a test-b test-c + check $? $LINENO +$lha cgo test-tmp-m1g.lzh test-a test-b test-c + check $? $LINENO +$lha co5g test-tmp-m5g.lzh test-a test-b test-c + check $? $LINENO +$lha co6g test-tmp-m6g.lzh test-a test-b test-c + check $? $LINENO +$lha co7g test-tmp-m7g.lzh test-a test-b test-c + check $? $LINENO +$lha v test-tmp-m0g.lzh && +$lha v test-tmp-m1g.lzh && +$lha v test-tmp-m5g.lzh && +$lha v test-tmp-m6g.lzh && +$lha v test-tmp-m7g.lzh + check $? $LINENO +$lha v test-tmp-m0g.lzh | grep 'generic.*lh0' + check $? $LINENO +$lha v test-tmp-m1g.lzh | grep 'generic.*lh1' + check $? $LINENO +$lha v test-tmp-m5g.lzh | grep 'generic.*lh5' + check $? $LINENO +$lha v test-tmp-m6g.lzh | grep 'generic.*lh6' + check $? $LINENO +$lha v test-tmp-m7g.lzh | grep 'generic.*lh7' + check $? $LINENO + +$lha xw=test-tmp-m0g test-tmp-m0g.lzh + check $? $LINENO +$lha xw=test-tmp-m1g test-tmp-m1g.lzh + check $? $LINENO +$lha xw=test-tmp-m5g test-tmp-m5g.lzh + check $? $LINENO +$lha xw=test-tmp-m6g test-tmp-m6g.lzh + check $? $LINENO +$lha xw=test-tmp-m7g test-tmp-m7g.lzh + check $? $LINENO + +diff -r test-1 test-tmp-m0g + check $? $LINENO +diff -r test-1 test-tmp-m1g + check $? $LINENO +diff -r test-1 test-tmp-m5g + check $? $LINENO +diff -r test-1 test-tmp-m6g + check $? $LINENO +diff -r test-1 test-tmp-m7g + check $? $LINENO + +$lha pq test-tmp-m0g.lzh test-a | diff test-a - + check $? $LINENO +$lha pq test-tmp-m1g.lzh test-a | diff test-a - + check $? $LINENO +$lha pq test-tmp-m5g.lzh test-a | diff test-a - + check $? $LINENO +$lha pq test-tmp-m6g.lzh test-a | diff test-a - + check $? $LINENO +$lha pq test-tmp-m7g.lzh test-a | diff test-a - + check $? $LINENO + +cat test-[abc] > test-tmp-abc +$lha pq test-tmp-m0g.lzh | diff test-tmp-abc - + check $? $LINENO +$lha pq test-tmp-m1g.lzh | diff test-tmp-abc - + check $? $LINENO +$lha pq test-tmp-m5g.lzh | diff test-tmp-abc - + check $? $LINENO +$lha pq test-tmp-m6g.lzh | diff test-tmp-abc - + check $? $LINENO +$lha pq test-tmp-m7g.lzh | diff test-tmp-abc - + check $? $LINENO diff -Nru lha-1.14i/tests/lha-test4 lha-1.14i-acc20050924p1/tests/lha-test4 --- lha-1.14i/tests/lha-test4 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/tests/lha-test4 2003-07-27 09:35:47.000000000 +0000 @@ -0,0 +1,38 @@ +# -*- shell-script -*- +message testing to delete files from archive. + +cp test-1.lzh test-tmp.lzh + +# do nothing +$lha d test-tmp.lzh 2> test-stderr + check $? $LINENO +test -s test-stderr + check $? $LINENO +$lha d test-tmp.lzh test-a 2> test-stderr + check $? $LINENO +test -s test-stderr + check $? $LINENO +$lha xw=test-tmp test-tmp.lzh && +test ! -f test-tmp/test-a && +diff test-1/test-b test-tmp/test-b && +diff test-1/test-c test-tmp/test-c + check $? $LINENO +rm -rf test-tmp + check $? $LINENO +$lha d test-tmp.lzh test-b 2> test-stderr + check $? $LINENO +test -s test-stderr + check $? $LINENO +$lha xw=test-tmp test-tmp.lzh && +test ! -f test-tmp/test-a && +test ! -f test-tmp/test-b && +diff test-1/test-c test-tmp/test-c + check $? $LINENO +rm -rf test-tmp + check $? $LINENO +$lha d test-tmp.lzh test-c 2> test-stderr + check $? $LINENO +test -s test-stderr + check $? $LINENO +test ! -f test-tmp.lzh + check $? $LINENO diff -Nru lha-1.14i/tests/lha-test5 lha-1.14i-acc20050924p1/tests/lha-test5 --- lha-1.14i/tests/lha-test5 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/tests/lha-test5 2003-07-27 09:35:47.000000000 +0000 @@ -0,0 +1,24 @@ +# -*- shell-script -*- +message testing to treat stdin/stdout as archive file. + +$lha c - test-a test-b test-c > test-tmp.lzh + check $? $LINENO +cat test-tmp.lzh | $lha xw=test-tmp - + check $? $LINENO +diff -r test-1 test-tmp + check $? $LINENO +# output to pipe +$lha c - test-a test-b test-c | $lha xw=test-tmp2 - + check $? $LINENO +diff -r test-1 test-tmp2 + check $? $LINENO +# skip to extract existent files when archive file is stdin +rm test-tmp/test-b + check $? $LINENO +cat test-tmp.lzh | $lha xw=test-tmp - 2> test-stderr + check $? $LINENO +diff -r test-1 test-tmp + check $? $LINENO +# 2 files will be skipped. +test 2 = `grep skip test-stderr | wc -l` + check $? $LINENO diff -Nru lha-1.14i/tests/lha-test6 lha-1.14i-acc20050924p1/tests/lha-test6 --- lha-1.14i/tests/lha-test6 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/tests/lha-test6 2003-07-27 09:35:47.000000000 +0000 @@ -0,0 +1,15 @@ +# -*- shell-script -*- +message testing to treat stdin/stdout as file list. +message Warning: On MinGW, these tests will fail for now. +cat < test-a + echo bar > test-b + echo baz > test-c + + # update with new files + $lha u ../test-tmp.lzh test-[abc] +) + check $? $LINENO + +# old files are in test-1 and in current directory +# new files are in test-tmp +$lha vv test-1.lzh + check $? $LINENO +$lha vv test-tmp.lzh + check $? $LINENO + +$lha xw=test-tmp2 test-tmp.lzh + check $? $LINENO +diff -r test-tmp test-tmp2 + check $? $LINENO +# no update with old files +$lha u test-tmp.lzh test-[abc] + +$lha xw=test-tmp3 test-tmp.lzh + check $? $LINENO +diff -r test-tmp test-tmp3 + check $? $LINENO +# replace with old files +$lha a test-tmp.lzh test-[abc] + +$lha xw=test-tmp4 test-tmp.lzh + check $? $LINENO +diff -r test-1 test-tmp4 + check $? $LINENO +# replace with new files +(cd test-tmp && + $lha a ../test-tmp.lzh test-[abc] +) + +$lha xw=test-tmp5 test-tmp.lzh + check $? $LINENO +diff -r test-tmp test-tmp5 + check $? $LINENO diff -Nru lha-1.14i/tests/lha-test8 lha-1.14i-acc20050924p1/tests/lha-test8 --- lha-1.14i/tests/lha-test8 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/tests/lha-test8 2003-07-27 09:35:47.000000000 +0000 @@ -0,0 +1,117 @@ +# -*- shell-script -*- +message testing timestamp +# level 0 header +$lha c0 test-tmp-h0.lzh test-[abc] + check $? $LINENO +# show time stamp +$lha vv test-tmp-h0.lzh +ls -l test-[abc] + +$lha xw=test-tmp-h0 test-tmp-h0.lzh + check $? $LINENO +diff -r test-1 test-tmp-h0 + check $? $LINENO +test test-a -nt test-tmp-h0/test-a || +test test-a -ot test-tmp-h0/test-a || +test test-b -nt test-tmp-h0/test-b || +test test-b -ot test-tmp-h0/test-b || +test test-c -nt test-tmp-h0/test-c || +test test-c -ot test-tmp-h0/test-c +test $? -ne 0 + check $? $LINENO + +# level 1 header +$lha c1 test-tmp-h1.lzh test-[abc] + check $? $LINENO +# show time stamp +$lha vv test-tmp-h1.lzh +ls -l test-[abc] + +$lha xw=test-tmp-h1 test-tmp-h1.lzh + check $? $LINENO +diff -r test-1 test-tmp-h1 + check $? $LINENO +test test-a -nt test-tmp-h1/test-a || +test test-a -ot test-tmp-h1/test-a || +test test-b -nt test-tmp-h1/test-b || +test test-b -ot test-tmp-h1/test-b || +test test-c -nt test-tmp-h1/test-c || +test test-c -ot test-tmp-h1/test-c +test $? -ne 0 + check $? $LINENO + +# level 2 header +$lha c1 test-tmp-h2.lzh test-[abc] + check $? $LINENO +# show time stamp +$lha vv test-tmp-h2.lzh +ls -l test-[abc] + +$lha xw=test-tmp-h2 test-tmp-h2.lzh + check $? $LINENO +diff -r test-1 test-tmp-h2 + check $? $LINENO +test test-a -nt test-tmp-h2/test-a || +test test-a -ot test-tmp-h2/test-a || +test test-b -nt test-tmp-h2/test-b || +test test-b -ot test-tmp-h2/test-b || +test test-c -nt test-tmp-h2/test-c || +test test-c -ot test-tmp-h2/test-c +test $? -ne 0 + check $? $LINENO + +# Note: level 0, 1 header (generic) format use the MS-DOS `ftime' +# structure, so it cannot save odd seconds. + +# set even seconds timestamp +cp test-a test-tmp-a && +cp test-b test-tmp-b && +cp test-c test-tmp-c && +change_timestamp 01020304.02 test-tmp-a && +change_timestamp 01020304.04 test-tmp-b && +change_timestamp 01020304.06 test-tmp-c + check $? $LINENO + +# level 0 header (generic) +$lha cg0 test-tmp-hg0.lzh test-tmp-[abc] + check $? $LINENO +# show time stamp +$lha vv test-tmp-hg0.lzh +ls -l test-tmp-[abc] + +$lha xw=test-tmp-hg0 test-tmp-hg0.lzh + check $? $LINENO +diff test-tmp-a test-tmp-hg0/test-tmp-a && +diff test-tmp-b test-tmp-hg0/test-tmp-b && +diff test-tmp-c test-tmp-hg0/test-tmp-c + check $? $LINENO +test test-tmp-a -nt test-tmp-hg0/test-tmp-a || +test test-tmp-a -ot test-tmp-hg0/test-tmp-a || +test test-tmp-b -nt test-tmp-hg0/test-tmp-b || +test test-tmp-b -ot test-tmp-hg0/test-tmp-b || +test test-tmp-c -nt test-tmp-hg0/test-tmp-c || +test test-tmp-c -ot test-tmp-hg0/test-tmp-c +test $? -ne 0 + check $? $LINENO + +# level 1 header (generic) +$lha cg1 test-tmp-hg1.lzh test-tmp-[abc] + check $? $LINENO +# show time stamp +$lha vv test-tmp-hg1.lzh +ls -l test-tmp-[abc] + +$lha xw=test-tmp-hg1 test-tmp-hg1.lzh + check $? $LINENO +diff test-tmp-a test-tmp-hg0/test-tmp-a && +diff test-tmp-b test-tmp-hg0/test-tmp-b && +diff test-tmp-c test-tmp-hg0/test-tmp-c + check $? $LINENO +test test-tmp-a -nt test-tmp-hg1/test-tmp-a || +test test-tmp-a -ot test-tmp-hg1/test-tmp-a || +test test-tmp-b -nt test-tmp-hg1/test-tmp-b || +test test-tmp-b -ot test-tmp-hg1/test-tmp-b || +test test-tmp-c -nt test-tmp-hg1/test-tmp-c || +test test-tmp-c -ot test-tmp-hg1/test-tmp-c +test $? -ne 0 + check $? $LINENO diff -Nru lha-1.14i/tests/lha-test9 lha-1.14i-acc20050924p1/tests/lha-test9 --- lha-1.14i/tests/lha-test9 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/tests/lha-test9 2003-07-27 09:35:47.000000000 +0000 @@ -0,0 +1,72 @@ +# -*- shell-script -*- +message 'testing overriding existing files (this test need the Ruby interpreter http://www.ruby-lang.org/)' + +pty() +{ + count=$1; shift + input=$1; shift # y, n, a or s + + ruby <> 8 + end + } +EOF +} + +mkdir test-tmp && +echo foo > test-tmp/test-a && +echo bar > test-tmp/test-b && +echo baz > test-tmp/test-c && +cp -pr test-tmp test-tmp2 && +$lha c test-tmp.lzh test-tmp + check $? $LINENO +$lha v test-tmp.lzh && +$lha v test-1.lzh + check $? $LINENO + +# skip file +rm -rf test-tmp && +cp -pr test-tmp2 test-tmp && +pty 3 n $lha xw=test-tmp test-1.lzh + check $? $LINENO +diff -r test-tmp test-tmp2 + check $? $LINENO +# overwrite +rm -rf test-tmp && +cp -pr test-tmp2 test-tmp && +pty 3 y $lha xw=test-tmp test-1.lzh + check $? $LINENO +diff -r test-1 test-tmp + check $? $LINENO +# overwrite all +rm -rf test-tmp && +cp -pr test-1 test-tmp && +pty 1 a $lha x test-tmp.lzh + check $? $LINENO +diff -r test-tmp test-tmp2 + check $? $LINENO +# skip all +rm -rf test-tmp && +cp -pr test-tmp2 test-tmp && +pty 1 s $lha xw=test-tmp test-1.lzh + check $? $LINENO +diff -r test-tmp test-tmp2 + check $? $LINENO diff -Nru lha-1.14i/tests/lha-test.in lha-1.14i-acc20050924p1/tests/lha-test.in --- lha-1.14i/tests/lha-test.in 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/tests/lha-test.in 2006-10-10 16:27:51.000000000 +0000 @@ -0,0 +1,109 @@ +#!/bin/bash + +: ${lha_dir=@top_builddir@/src} +: ${lha_cmd=$(cd $lha_dir && pwd)/lha} +: ${srcdir=@srcdir@} + +trap '_stat=$?; rm -rf test-*; exit $_stat' 0 1 2 3 15 + +typeset -i i # for loop +typeset -i test_number=0 error_num=0 +error_tests="" + +# fd 1: for logging +# fd 2: output screen +# fd 5: for logging +exec 5>test.log >&5 + +lha=exec_lha +exec_lha() +{ + echo "$ lha $@" >&5 # for logging (stdout(fd 1) may be redirected) + $lha_cmd "$@" +} + +message() +{ + echo "$@" >&2 + echo "$@" +} + +check() +{ + ((test_number = test_number + 1)) + typeset status=$1 + typeset lineno=$2 + if [[ $status -eq 0 ]]; then + echo "$FILENAME #$test_number ... ok" >&2 + echo "$FILENAME #$test_number ... ok at line $lineno" + else + message "$FILENAME #$test_number ... failed at line $lineno" + ((error_num = error_num + 1)) + error_tests="$error_tests $FILENAME #$test_number" + result=1 + fi +} + +cleanup() +{ + rm -rf test-tmp* +} + +testsuite() +{ + # the `FILENAME' variable should be set the each test filename. + FILENAME=$1 test_number=0 + + . $srcdir/$FILENAME + + cleanup +} + +# utility functions + +change_timestamp() +{ + typeset time=$1; shift + + # assume that `touch' command supports POSIX's -t switch. + + # -t [[CC]YY]MMDDhhmm[.ss] + touch -t $time "$@" + + # [[CC]YY]MMDDhhmm + # touch $time "$@" +} + +# test start + +message testing $lha +message `$lha --version 2>&1` + +testsuite lha-test1 # create test data. it is needed for each test +testsuite lha-test2 +testsuite lha-test3 +testsuite lha-test4 +testsuite lha-test5 +#testsuite lha-test6 # this feature was removed. +testsuite lha-test7 +testsuite lha-test8 +#testsuite lha-test9 # incomplete +testsuite lha-test10 +testsuite lha-test11 +testsuite lha-test12 +testsuite lha-test13 +case `$lha --version 2>&1` in +*-pc-mingw*) + message testing to handle symbolic links ... skip + ;; +*) + testsuite lha-test14 +esac +testsuite lha-test15 + +if (( $error_num != 0 )); then + message $error_num tests failed! + message test number: $error_tests +fi + +exit $result diff -Nru lha-1.14i/tests/Makefile.am lha-1.14i-acc20050924p1/tests/Makefile.am --- lha-1.14i/tests/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/tests/Makefile.am 2006-10-10 16:27:51.000000000 +0000 @@ -0,0 +1,25 @@ +## Process this file with automake to produce Makefile.in +check_SCRIPTS = lha-test +EXTRA_DIST = lha-test1 \ + lha-test2 \ + lha-test3 \ + lha-test4 \ + lha-test5 \ + lha-test6 \ + lha-test7 \ + lha-test8 \ + lha-test9 \ + lha-test10 \ + lha-test11 \ + lha-test12 \ + lha-test13 \ + lha-test14 \ + lha-test15 + +DISTCLEANFILES = test.log + +check-local: + bash ./lha-test + +lha-test: $(top_builddir)/config.status $(srcdir)/lha-test.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ diff -Nru lha-1.14i/tests/Makefile.in lha-1.14i-acc20050924p1/tests/Makefile.in --- lha-1.14i/tests/Makefile.in 1970-01-01 00:00:00.000000000 +0000 +++ lha-1.14i-acc20050924p1/tests/Makefile.in 2006-10-16 14:50:10.000000000 +0000 @@ -0,0 +1,320 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +LIBOBJDIR = +subdir = tests +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(srcdir)/lha-test.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = lha-test +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEF_KCODE = @DEF_KCODE@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SUPPORT_LZHUFF_METHOD = @SUPPORT_LZHUFF_METHOD@ +U = @U@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +check_SCRIPTS = lha-test +EXTRA_DIST = lha-test1 \ + lha-test2 \ + lha-test3 \ + lha-test4 \ + lha-test5 \ + lha-test6 \ + lha-test7 \ + lha-test8 \ + lha-test9 \ + lha-test10 \ + lha-test11 \ + lha-test12 \ + lha-test13 \ + lha-test14 \ + lha-test15 + +DISTCLEANFILES = test.log +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu tests/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +lha-test: $(top_builddir)/config.status $(srcdir)/lha-test.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +uninstall-info-am: +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_SCRIPTS) + $(MAKE) $(AM_MAKEFLAGS) check-local +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: all all-am check check-am check-local clean clean-generic \ + distclean distclean-generic distdir dvi dvi-am html html-am \ + info info-am install install-am install-data install-data-am \ + install-exec install-exec-am install-info install-info-am \ + install-man install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \ + uninstall-am uninstall-info-am + + +check-local: + bash ./lha-test + +lha-test: $(top_builddir)/config.status $(srcdir)/lha-test.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: