[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

4. 全てのプログラムの振る舞い

この節では、頑丈なソフトウェアの書き方を記述する。また、 エラーメッセージや、コマンドラインのインターフェース、ライブラリの挙動 の、汎用的な標準についても記述する。

4.1 頑丈なプログラムの作成  
4.2 ライブラリの挙動  
4.3 エラーメッセージの書式  
4.4 コマンドラインのインターフェースの標準  
4.5 長いオプションの表  
4.6 メモリの使用  


4.1 頑丈なプログラムの作成

動的に全てのデータ構造を確保することによって、ファイル名、行、ファイル、 シンボルを含む、いかなるデータ構造の長さや数についても、勝手な 制限を避けなさい。 ほとんどのUnixユーティリティでは、"長い行は黙って切り詰める"。 これはGNUユーティリティでは許容できない。

ファイルを読むユーティリティはNUL文字や、0177以上のコードを持つ 文字を含むあらゆる他の印字できない文字も、落とすべきではない。 唯一意味のある例外は、そういった文字を扱えない、ある種のプリンタへのイ ンターフェースを特別に意図したユーティリティだろう。 可能な限りいつでも、UTF-8やその他のエンコーディングを使って、 多バイト文字を表すバイト列を適切に扱えるようにしなさい。

エラーを無視したいと思っているのでなければ、あらゆるシステムコールのエ ラーを確認しなさい。失敗したシステムコールから発生するあらゆる エラーメッセージに、もしあればファイルの名前とそのユーティリティの名前 だけでなく、(perrorや同等のものから得られる)システムエラー文字 列を含めなさい。単なる"cannot open foo.c"や"stat failed"は十分でな い。

mallocreallocのすべての呼び出しを、ゼロを返したかどう か確認しなさい。例えそのブロックをもっと小さくしようとしていても、 reallocの確認をしなさい。2の階乗にブロックサイズを丸めるシステム では、reallocはもっと小さい領域を要求する場合に異なるブロックを 得ることがある。

Unixでは、reallocがゼロを返す場合、記憶領域を破壊してしまう。 GNU reallocはこのバグを持たない。失敗すると、元のブロックは変更 されない。そのバグは直っているとみなしても構わない。もしあなたのプログ ラムをUnix上で走らせたくて、こういう損失を避けたいなら、GNU malloc を使うことができる。

freeは解放されたブロックの中身を変えてしまうと考えなければなら ない。そのブロックの値を取り出したかったら、必ずfreeを呼ぶ前に 取り出さなくてはならない。

もしmallocが対話的でないプログラムで失敗したら、それを致命的な エラーにしなさい。対話的なプログラム(ユーザからコマンドを呼んでくるも の)では、そのコマンドを中止して、コマンド読み込みループから返るのがよ り良い。こうすると、そのユーザは仮想メモリを解放するために他のプロセス を殺して、再びそのコマンドを試すことができる。

もし引数の文法が上手く行かなくなるわけでないなら、引数の解読に getopt_longを使いなさい。

静的な記憶領域がプログラムの実行中に書き込まれるためであるとき、それを 初期化するための、明示的なCのコードを使いなさい。変更されないデータに 対する、Cの初期化付き宣言を残しておきなさい。

(ファイルディレクトリや、utmp、カーネルメモリの配置のような)Unixのデー タ構造を見えにくくする、低水準のインターフェースを避けるよう努めなさい。 これらは互換性を失いがちだからだ。もしあるディレクトリの全ファイルを見 付ける必要があるなら、readdirや他の高水準のインターフェースを使 いなさい。これらはGNUによって互換性を持ってサポートされるだろう。

好ましいシグナルハンドリングの機能はBSD流のsignalと POSIX sigaction関数である。別にあるUSGのsignalは 劣った設計だ。

今日では、POSIXシグナル関数の使用がプログラムを移植しやすくする 一番簡単な方法かもしれない。signalを使うと、GNU libc version 1 を使うGNU/Linuxシステム上でBSDの振る舞いを得るために、`signal.h' ではなく`bsd/signal.h'をincludeすべきだ。signalがUSGの振る 舞いしか持たないシステムをサポートするか、あるいは、それらを諦めてしま うかはあなた次第だ。

"あり得ない"状態を検出するエラーチェックでは、単に中止しなさい。メッ セージを出力する意味は普通ない。これらのチェックはバグの存在を示している。 そのバグを直したい人なら誰でも、そのソースコードを読み、デバッガを走ら せないといけないだろう。だから、そのソースにコメントでその問題を説明し なさい。関係のあるデータは変数の中で、それはデバッガで検査するのは容易 だろう。だから、それらをどこか他の位置に移す意味はない。

プログラムの終了状態として、エラーのカウントを使ってはならない。 これは上手く行かない。なぜなら、終了状態の値は(0から255までの) 8ビットに制限されているからだ。そのプログラムが一回走る間に256のエラー が起きるかもしれない。もし終了状態として256を返そうとすると、親プロセ スはその状態として0を見ることになり、そのプログラムが成功したかのよう に見えるだろう。

もし一時ファイルを作るなら、TMPDIR環境変数を確認しなさい。この 変数が定義されていれば、`/tmp'ではなく、指定されたディレクトリを 使いなさい。


4.2 ライブラリの挙動

ライブラリ関数を再入可能にするよう努力しなさい。それらが動的な記憶領域 の確保を必要とするなら、少なくともmalloc自体は別として、再入 不能を避けるよう努力しなさい。

名前がぶつかるのを避けるために、ライブラリ用の名前付けの取り決めがある。

二文字以上の長さで、そのライブラリ用の接頭辞を決めなさい。外部に見せる 関数と変数の名前すべてに、この接頭辞を付けるべきだ。さらに、どの特定のラ イブラリ・メンバーでも、これらのうち一つだけが入っているべきだ。これは通 常それぞれを別のソースファイルに置くことを意味する。

二つの外部シンボルが常に一緒に使われ、片方を使ってもう片方を使わない ような意味のあるプログラムがあり得ないようなときには、例外となる。それ らは両方とも同じファイルに入れられる。

ユーザにエントリ・ポイントとして記述されない外部シンボルは、`_'で 始まる名前を持つべきだ。それらはまた、他のライブラリと衝突するのを防ぐ ために、そのライブラリのために選ばれた接頭辞を含むべきだ。これらは、好 むなら、ユーザのエントリ・ポイントと同じファイルの中に含めても良い。

静的な関数や変数は好きなように使って良く、どんな名前付け規則にも当ては まらなくていい。


4.3 エラーメッセージの書式

コンパイラからのエラーメッセージは次のようであるべきだ。

 
source-file-name:lineno: message

適切なソースファイルがあるときには、 他の対話的でないプログラムからのエラーメッセージは次のようであるべきだ。

 
program:source-file-name:lineno: message

関連のあるソースファイルがないときには、次のようだ。

 
program: message

対話的なプログラム(端末からコマンドを読んでいるもの)では、エラーメッセ ージにプログラム名を含めない方が良い。どのプログラムが走っているかを示 す場所は、プロンプトか、スクリーンのレイアウトだ。(同じプログラムが端 末以外のソースから入力を受け取って走るとき、それは対話的ではなく、対話 的でない形式を使ってエラーメッセージを出力するのが一番良いだろう。)

文字列messageは、プログラム名やファイル名に続くときには、大文字 で始めるべきではない。また、ピリオドで終わるべきではない。

対話的なプログラムからのエラーメッセージや使い方のメッセージのような他 のメッセージは大文字で始めるべきだ。しかしピリオドで終わるべきではない。


4.4 コマンドラインのインターフェースの標準

ユーティリティの挙動をそれを起動した名前に依存させないでください。あ るユーティリティに別の名前をリンクすることは、ときどき有用で、そのこと で何をやるのかを換えるべきでない。

代わりに、動作時のオプションか、コンパイルするときのスィッチか、両方を 別の挙動を選択するために使いなさい。

同様に、プログラムの挙動をそれが使う出力デバイスの種類に依存しないよう にしてください。デバイス独立はシステム設計の重要な原理だ。単に誰かがと きどきオプションを打ち込むのを省略することに妥協してはならない。(端末 を使うときのエラーメッセージの文法を変化させるのは構わない。なぜなら、 それは人々が依存していない別な問題だからだ。)

もし出力が端末に向かうときある挙動が最も有用で、出力がファイルかパイプ なら他の挙動が最も有用なら、端末への出力で有用な挙動をデフォルトにして、 他の挙動のオプションを持つのが通常一番良い。

互換性のために、出力デバイスの種類に依存するプログラムを必要とする。 もしlsshが、あらゆるユーザが期待する方法で働かなかった ら、それはひどいだろう。これらの場合のうちいくつかでは、出力デバイスの 種類に依存しない、より好ましい別バージョンを我々は補う。例えば、 lsにとても似ているが、デフォルトの出力形式が常に複数欄形式であ る、dirプログラムを提供する。

プログラムのコマンドライン・オプションをPOSIXのガイドラインに従わ せるのは良い考えだ。これを行う一番簡単な方法は、それらを解析するのに getoptを使うことだ。getoptのGNUバージョンは、特別な引数 `--'が使われなければ、通常オプションが引数のどこにあっても良いこ とに注意しなさい。これはPOSIXが規定していることではない。GNUの拡 張だ。

一文字のUnix形式オプションと等価な長い名前のオプションを定義してくださ い。我々はこの方法でGNUをよりユーザに親しみやすいものにしたいと思って いる。これはGNUの関数getopt_logを使えば簡単だ。

長い名前のオプションの利点の一つはどのプログラムでも一貫したものにでき るからだ。例えば、ユーザは"verbose"オプションを持つどのGNUプログラム もそれが正確に`--verbose'と綴られると期待することができるべきだ。 この不変性を成すために、あなたのプログラムのオプション名を選ぶとき、共 通の長いオプション名の表を見なさい (see section 4.5 長いオプションの表)。

普通の引数として与えられるファイル名が入力ファイルだけにするのは普通良い 考えだ。どんな出力ファイルでも(願わくは`-o'や`--output'のよう な)オプションによって指定されるだろう。互換性のために普通の引数として出 力ファイル名を許す場合でも、それを指定する他の方法としてオプションを与え てみなさい。これはGNUユーティリティの一貫性を増し、そしてユーザが覚える べき独自性を減らすであろう。

あらゆるプログラムは次の二つの標準的なオプションをサポートすべきだ。 `--version'と`--help'だ。

--version
このオプションはそのプログラムに、その名前、バージョン、出所と法的な状態 に関する情報を、すべて標準出力に出させ、そして成功状態で終了させるべきだ。 他のオプションや引数はこれが現れたら無視されるべきで、そのプログラムはそ の通常の機能を行うべきではない。

最初の行をプログラムが解析しやすくする。そのバージョン・ナンバーを最後の スペースの後に始める。加えて、このプログラムの正しい名前を次の形式で含め る。

 
GNU Emacs 19.30

プログラム名は固定文字列であるべきだ。それをargv[0]から計算しては いけない。その考えは、そのファイル名ではなく、そのプログラムの標 準的、あるいは、正統な名前を表明することである。コマンドをPATHか ら見付けることで、正確なファイル名を見付け出す他の方法があるのだ。

もしプログラムが大きいパッケージの補助的な部分なら、次のようにそのプログ ラム名を括弧の中で記述しなさい。

 
emacsserver (GNU Emacs) 19.30

もしそのパッケージがこのプログラムのバージョン・ナンバーとは違うバージョ ン・ナンバーを持っているなら、閉じ括弧の直前にそのパッケージのバージョン・ ナンバーを記述して良い。

もしこのプログラムを含むパッケージとは別に配布されるライブラリのバージョ ン・ナンバーを記述したいのなら、記述したいそれぞれのライブラ リ毎に行を追加して、バージョン情報を出力することで、そうして良い。それら の行に最初の行と同じ形式を使いなさい。

そのプログラムが使うライブラリ全てを、"単に完全であるためだけに"記述し ないでください。---そうすると、たくさんの役に立たない乱雑さを生み出して しまうだろう。あなたがデバッグをするのに非常に重要であると実際に見出し た場合にだけ、ライブラリのバージョン・ナンバーを記述してください。

バージョン・ナンバーの行の後の、次の行は著作権通知であるべきだ。二つ以上の 著作権通知が必要なら、それぞれ別の行に入れなさい。

次は、そのプログラムがフリーソフトウェアであり、ユーザは自由に複製したり、 ある条件でそれを改変して良いという、簡単な記述が続くべきだ。もしそのプロ グラムがGNU GPLによって保護されているなら、ここでそう言いなさい。また、 法に認められる範囲に対し、無保証であることを書きなさい。

名誉を与える方法として、そのプログラムの主要な作者の名簿を出力して終わら せて構わない。

これらの規則に従う出力の例を示そう。

 
GNU Emacs 19.34.5
Copyright (C) 1996 Free Software Foundation, Inc.
GNU Emacs comes with NO WARRANTY,
to the extent permitted by law.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters,
see the files named COPYING.

これをあなたのプログラムに一致させるべきだ。当然、適切な年、著作権者、プ ログラムの名前、そして、配布条件の言及を入れ、必要に応じて残りの言葉遣い を換えるべきだ。

この著作権通知は変更がなされた一番最近の年を記述するだけでいい。---以前 のバージョンの変更に対して年を列挙する必要はない。もし不便なら、プログラ ムの名前をこの通知の中で記述しなくて良い。最初の行に現れているから。

--help
このオプションはそのプログラムをどのように起動するかを、標準出力上に、簡 単な解説を出力し、成功終了すべきだ。他のオプションや引数はこれが現れたら 無視すべきで、そのプログラムはその通常の機能を行うべきではない。

`--help'オプションの出力の最後の辺りで、バグ報告をどこにメールする かを表す行があるべきだ。こういう書式を持つ。

 
Report bugs to mailing-address.


4.5 長いオプションの表

GNUプログラムによって使われる長いオプションの表をここで示す。きっと不完 全ではあるが、新しいプログラムが互換性を持ちたいであろうオプションをすべ て列挙するつもりだ。もしこの表にまだない名前を使うなら、それらの表と、そ れらの意味をgnu@gnu.orgに送ってください。我々がこの表を更新でき るので(3)

`after-date'
`-N' in tar.

`all'
`-a' in du, ls, nm, stty, uname, and unexpand.

`all-text'
`-a' in diff.

`almost-all'
`-A' in ls.

`append'
`-a' in etags, tee, time; `-r' in tar.

`archive'
`-a' in cp.

`archive-name'
`-n' in shar.

`arglength'
`-l' in m4.

`ascii'
`-a' in diff.

`assign'
`-v' in gawk.

`assume-new'
`-W' in Make.

`assume-old'
`-o' in Make.

`auto-check'
`-a' in recode.

`auto-pager'
`-a' in wdiff.

`auto-reference'
`-A' in ptx.

`avoid-wraps'
`-n' in wdiff.

`background'
For server programs, run in the background.

`backward-search'
`-B' in ctags.

`basename'
`-f' in shar.

`batch'
Used in GDB.

`baud'
Used in GDB.

`before'
`-b' in tac.

`binary'
`-b' in cpio and diff.

`bits-per-code'
`-b' in shar.

`block-size'
Used in cpio and tar.

`blocks'
`-b' in head and tail.

`break-file'
`-b' in ptx.

`brief'
Used in various programs to make output shorter.

`bytes'
`-c' in head, split, and tail.

`c++'
`-C' in etags.

`catenate'
`-A' in tar.

`cd'
Used in various programs to specify the directory to use.

`changes'
`-c' in chgrp and chown.

`classify'
`-F' in ls.

`colons'
`-c' in recode.

`command'
`-c' in su; `-x' in GDB.

`compare'
`-d' in tar.

`compat'
Used in gawk.

`compress'
`-Z' in tar and shar.

`concatenate'
`-A' in tar.

`confirmation'
`-w' in tar.

`context'
Used in diff.

`copyleft'
`-W copyleft' in gawk.

`copyright'
`-C' in ptx, recode, and wdiff; `-W copyright' in gawk.

`core'
Used in GDB.

`count'
`-q' in who.

`count-links'
`-l' in du.

`create'
Used in tar and cpio.

`cut-mark'
`-c' in shar.

`cxref'
`-x' in ctags.

`date'
`-d' in touch.

`debug'
`-d' in Make and m4; `-t' in Bison.

`define'
`-D' in m4.

`defines'
`-d' in Bison and ctags.

`delete'
`-D' in tar.

`dereference'
`-L' in chgrp, chown, cpio, du, ls, and tar.

`dereference-args'
`-D' in du.

`diacritics'
`-d' in recode.

`dictionary-order'
`-d' in look.

`diff'
`-d' in tar.

`digits'
`-n' in csplit.

`directory'
Specify the directory to use, in various programs. In ls, it means to show directories themselves rather than their contents. In rm and ln, it means to not treat links to directories specially.

`discard-all'
`-x' in strip.

`discard-locals'
`-X' in strip.

`dry-run'
`-n' in Make.

`ed'
`-e' in diff.

`elide-empty-files'
`-z' in csplit.

`end-delete'
`-x' in wdiff.

`end-insert'
`-z' in wdiff.

`entire-new-file'
`-N' in diff.

`environment-overrides'
`-e' in Make.

`eof'
`-e' in xargs.

`epoch'
Used in GDB.

`error-limit'
Used in makeinfo.

`error-output'
`-o' in m4.

`escape'
`-b' in ls.

`exclude-from'
`-X' in tar.

`exec'
Used in GDB.

`exit'
`-x' in xargs.

`exit-0'
`-e' in unshar.

`expand-tabs'
`-t' in diff.

`expression'
`-e' in sed.

`extern-only'
`-g' in nm.

`extract'
`-i' in cpio; `-x' in tar.

`faces'
`-f' in finger.

`fast'
`-f' in su.

`fatal-warnings'
`-E' in m4.

`file'
`-f' in info, gawk, Make, mt, and tar; `-n' in sed; `-r' in touch.

`field-separator'
`-F' in gawk.

`file-prefix'
`-b' in Bison.

`file-type'
`-F' in ls.

`files-from'
`-T' in tar.

`fill-column'
Used in makeinfo.

`flag-truncation'
`-F' in ptx.

`fixed-output-files'
`-y' in Bison.

`follow'
`-f' in tail.

`footnote-style'
Used in makeinfo.

`force'
`-f' in cp, ln, mv, and rm.

`force-prefix'
`-F' in shar.

`foreground'
For server programs, run in the foreground; in other words, don't do anything special to run the server in the background.

`format'
Used in ls, time, and ptx.

`freeze-state'
`-F' in m4.

`fullname'
Used in GDB.

`gap-size'
`-g' in ptx.

`get'
`-x' in tar.

`graphic'
`-i' in ul.

`graphics'
`-g' in recode.

`group'
`-g' in install.

`gzip'
`-z' in tar and shar.

`hashsize'
`-H' in m4.

`header'
`-h' in objdump and recode

`heading'
`-H' in who.

`help'
Used to ask for brief usage information.

`here-delimiter'
`-d' in shar.

`hide-control-chars'
`-q' in ls.

`idle'
`-u' in who.

`ifdef'
`-D' in diff.

`ignore'
`-I' in ls; `-x' in recode.

`ignore-all-space'
`-w' in diff.

`ignore-backups'
`-B' in ls.

`ignore-blank-lines'
`-B' in diff.

`ignore-case'
`-f' in look and ptx; `-i' in diff and wdiff.

`ignore-errors'
`-i' in Make.

`ignore-file'
`-i' in ptx.

`ignore-indentation'
`-I' in etags.

`ignore-init-file'
`-f' in Oleo.

`ignore-interrupts'
`-i' in tee.

`ignore-matching-lines'
`-I' in diff.

`ignore-space-change'
`-b' in diff.

`ignore-zeros'
`-i' in tar.

`include'
`-i' in etags; `-I' in m4.

`include-dir'
`-I' in Make.

`incremental'
`-G' in tar.

`info'
`-i', `-l', and `-m' in Finger.

`initial'
`-i' in expand.

`initial-tab'
`-T' in diff.

`inode'
`-i' in ls.

`interactive'
`-i' in cp, ln, mv, rm; `-e' in m4; `-p' in xargs; `-w' in tar.

`intermix-type'
`-p' in shar.

`jobs'
`-j' in Make.

`just-print'
`-n' in Make.

`keep-going'
`-k' in Make.

`keep-files'
`-k' in csplit.

`kilobytes'
`-k' in du and ls.

`language'
`-l' in etags.

`less-mode'
`-l' in wdiff.

`level-for-gzip'
`-g' in shar.

`line-bytes'
`-C' in split.

`lines'
Used in split, head, and tail.

`link'
`-l' in cpio.

`lint'
`lint-old'
Used in gawk.

`list'
`-t' in cpio; `-l' in recode.

`list'
`-t' in tar.

`literal'
`-N' in ls.

`load-average'
`-l' in Make.

`login'
Used in su.

`machine'
No listing of which programs already use this; someone should check to see if any actually do, and tell gnu@gnu.org.

`macro-name'
`-M' in ptx.

`mail'
`-m' in hello and uname.

`make-directories'
`-d' in cpio.

`makefile'
`-f' in Make.

`mapped'
Used in GDB.

`max-args'
`-n' in xargs.

`max-chars'
`-n' in xargs.

`max-lines'
`-l' in xargs.

`max-load'
`-l' in Make.

`max-procs'
`-P' in xargs.

`mesg'
`-T' in who.

`message'
`-T' in who.

`minimal'
`-d' in diff.

`mixed-uuencode'
`-M' in shar.

`mode'
`-m' in install, mkdir, and mkfifo.

`modification-time'
`-m' in tar.

`multi-volume'
`-M' in tar.

`name-prefix'
`-a' in Bison.

`nesting-limit'
`-L' in m4.

`net-headers'
`-a' in shar.

`new-file'
`-W' in Make.

`no-builtin-rules'
`-r' in Make.

`no-character-count'
`-w' in shar.

`no-check-existing'
`-x' in shar.

`no-common'
`-3' in wdiff.

`no-create'
`-c' in touch.

`no-defines'
`-D' in etags.

`no-deleted'
`-1' in wdiff.

`no-dereference'
`-d' in cp.

`no-inserted'
`-2' in wdiff.

`no-keep-going'
`-S' in Make.

`no-lines'
`-l' in Bison.

`no-piping'
`-P' in shar.

`no-prof'
`-e' in gprof.

`no-regex'
`-R' in etags.

`no-sort'
`-p' in nm.

`no-split'
Used in makeinfo.

`no-static'
`-a' in gprof.

`no-time'
`-E' in gprof.

`no-timestamp'
`-m' in shar.

`no-validate'
Used in makeinfo.

`no-wait'
Used in emacsclient.

`no-warn'
Used in various programs to inhibit warnings.

`node'
`-n' in info.

`nodename'
`-n' in uname.

`nonmatching'
`-f' in cpio.

`nstuff'
`-n' in objdump.

`null'
`-0' in xargs.

`number'
`-n' in cat.

`number-nonblank'
`-b' in cat.

`numeric-sort'
`-n' in nm.

`numeric-uid-gid'
`-n' in cpio and ls.

`nx'
Used in GDB.

`old-archive'
`-o' in tar.

`old-file'
`-o' in Make.

`one-file-system'
`-l' in tar, cp, and du.

`only-file'
`-o' in ptx.

`only-prof'
`-f' in gprof.

`only-time'
`-F' in gprof.

`output'
In various programs, specify the output file name.

`output-prefix'
`-o' in shar.

`override'
`-o' in rm.

`overwrite'
`-c' in unshar.

`owner'
`-o' in install.

`paginate'
`-l' in diff.

`paragraph-indent'
Used in makeinfo.

`parents'
`-p' in mkdir and rmdir.

`pass-all'
`-p' in ul.

`pass-through'
`-p' in cpio.

`port'
`-P' in finger.

`portability'
`-c' in cpio and tar.

`posix'
Used in gawk.

`prefix-builtins'
`-P' in m4.

`prefix'
`-f' in csplit.

`preserve'
Used in tar and cp.

`preserve-environment'
`-p' in su.

`preserve-modification-time'
`-m' in cpio.

`preserve-order'
`-s' in tar.

`preserve-permissions'
`-p' in tar.

`print'
`-l' in diff.

`print-chars'
`-L' in cmp.

`print-data-base'
`-p' in Make.

`print-directory'
`-w' in Make.

`print-file-name'
`-o' in nm.

`print-symdefs'
`-s' in nm.

`printer'
`-p' in wdiff.

`prompt'
`-p' in ed.

`query-user'
`-X' in shar.

`question'
`-q' in Make.

`quiet'
Used in many programs to inhibit the usual output. Note: every program accepting `--quiet' should accept `--silent' as a synonym.

`quiet-unshar'
`-Q' in shar

`quote-name'
`-Q' in ls.

`rcs'
`-n' in diff.

`re-interval'
Used in gawk.

`read-full-blocks'
`-B' in tar.

`readnow'
Used in GDB.

`recon'
`-n' in Make.

`record-number'
`-R' in tar.

`recursive'
Used in chgrp, chown, cp, ls, diff, and rm.

`reference-limit'
Used in makeinfo.

`references'
`-r' in ptx.

`regex'
`-r' in tac and etags.

`release'
`-r' in uname.

`reload-state'
`-R' in m4.

`relocation'
`-r' in objdump.

`rename'
`-r' in cpio.

`replace'
`-i' in xargs.

`report-identical-files'
`-s' in diff.

`reset-access-time'
`-a' in cpio.

`reverse'
`-r' in ls and nm.

`reversed-ed'
`-f' in diff.

`right-side-defs'
`-R' in ptx.

`same-order'
`-s' in tar.

`same-permissions'
`-p' in tar.

`save'
`-g' in stty.

`se'
Used in GDB.

`sentence-regexp'
`-S' in ptx.

`separate-dirs'
`-S' in du.

`separator'
`-s' in tac.

`sequence'
Used by recode to chose files or pipes for sequencing passes.

`shell'
`-s' in su.

`show-all'
`-A' in cat.

`show-c-function'
`-p' in diff.

`show-ends'
`-E' in cat.

`show-function-line'
`-F' in diff.

`show-tabs'
`-T' in cat.

`silent'
Used in many programs to inhibit the usual output. Note: every program accepting `--silent' should accept `--quiet' as a synonym.

`size'
`-s' in ls.

`socket'
Specify a file descriptor for a network server to use for its socket, instead of opening and binding a new socket. This provides a way to run, in a nonpriveledged process, a server that normally needs a reserved port number.

`sort'
Used in ls.

`source'
`-W source' in gawk.

`sparse'
`-S' in tar.

`speed-large-files'
`-H' in diff.

`split-at'
`-E' in unshar.

`split-size-limit'
`-L' in shar.

`squeeze-blank'
`-s' in cat.

`start-delete'
`-w' in wdiff.

`start-insert'
`-y' in wdiff.

`starting-file'
Used in tar and diff to specify which file within a directory to start processing with.

`statistics'
`-s' in wdiff.

`stdin-file-list'
`-S' in shar.

`stop'
`-S' in Make.

`strict'
`-s' in recode.

`strip'
`-s' in install.

`strip-all'
`-s' in strip.

`strip-debug'
`-S' in strip.

`submitter'
`-s' in shar.

`suffix'
`-S' in cp, ln, mv.

`suffix-format'
`-b' in csplit.

`sum'
`-s' in gprof.

`summarize'
`-s' in du.

`symbolic'
`-s' in ln.

`symbols'
Used in GDB and objdump.

`synclines'
`-s' in m4.

`sysname'
`-s' in uname.

`tabs'
`-t' in expand and unexpand.

`tabsize'
`-T' in ls.

`terminal'
`-T' in tput and ul. `-t' in wdiff.

`text'
`-a' in diff.

`text-files'
`-T' in shar.

`time'
Used in ls and touch.

`to-stdout'
`-O' in tar.

`total'
`-c' in du.

`touch'
`-t' in Make, ranlib, and recode.

`trace'
`-t' in m4.

`traditional'
`-t' in hello; `-W traditional' in gawk; `-G' in ed, m4, and ptx.

`tty'
Used in GDB.

`typedefs'
`-t' in ctags.

`typedefs-and-c++'
`-T' in ctags.

`typeset-mode'
`-t' in ptx.

`uncompress'
`-z' in tar.

`unconditional'
`-u' in cpio.

`undefine'
`-U' in m4.

`undefined-only'
`-u' in nm.

`update'
`-u' in cp, ctags, mv, tar.

`usage'
Used in gawk; same as `--help'.

`uuencode'
`-B' in shar.

`vanilla-operation'
`-V' in shar.

`verbose'
Print more information about progress. Many programs support this.

`verify'
`-W' in tar.

`version'
Print the version number.

`version-control'
`-V' in cp, ln, mv.

`vgrind'
`-v' in ctags.

`volume'
`-V' in tar.

`what-if'
`-W' in Make.

`whole-size-limit'
`-l' in shar.

`width'
`-w' in ls and ptx.

`word-regexp'
`-W' in ptx.

`writable'
`-T' in who.

`zeros'
`-z' in gprof.


4.6 メモリの使用

概して、たった数メガしかメモリを使わないなら、メモリの使用を減らす努力を 行うことに悩まないように。例えば、数メガ以上のファイルを扱うことが他の 事情で実際的でなかったら、それらを処理するのに入力ファイル全体をコアに読 み込むことは理に適っている。

しかしながら、普通に非常に大きいファイルを扱うことのある、cattailのようなプログラムにとって、それが処理できるファイルの大きさ を人為的に制限する手法の使用は避けることが重要だ。もしプログラムが行毎に 働き、ユーザが提供する任意の入力ファイルが与えられるならば、一行だけをメ モリに保持するべきだ。なぜなら、これは大して難しくなく、全て一度にコアに 入るよりも大きいファイルを扱えることをユーザが望むだろうからだ。

もしあなたのプログラムが複雑なデータ構造を作るなら、単にコアにそれを作っ て、もしmallocがゼロを返したら致命的なエラーにしてしまいなさい。


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Akihiro Sagawa on January, 21 2003 using texi2html