.\" Copyright (c) 1980, 1991, 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. .\" .\" @(#)re_comp.3 8.1 (Berkeley) 6/4/93 .\" %FreeBSD: src/lib/libcompat/4.3/re_comp.3,v 1.6.2.4 2001/12/17 10:08:29 ru Exp % .\" .\" $FreeBSD$ .Dd June 4, 1993 .Dt RE_COMP 3 .Os .Sh 名称 .Nm re_comp , .Nm re_exec .Nd 定型数式ハンドラ .Sh ライブラリ .Lb libcompat .Sh 書式 .Fd #include .Ft char * .Fn re_comp "const char *s" .Ft int .Fn re_exec "const char *s" .Sh 解説 .Bf -symbolic このインタフェースは、 .Xr regex 3 に置き換えられました。 .Ef .Pp .Fn re_comp 関数は、パターンマッチングに合う内部形式にストリングをコンパイルします。 .Fn re_exec 関数は、 .Fn re_comp に渡された最後のストリングと引数ストリングを照合します。 .Pp .Fn re_comp 関数は、ストリング .Fa s が問題なくコンパイルされると 0 を戻します。問題が発生した場合は、エラー メッセージを含むストリングが戻されます。0 かヌルストリングが渡された .Fn re_comp は、現在コンパイルされている定型数式を変更せずに戻ります。 .Pp .Fn re_exec 関数は、最後にコンパイルされた定型数式とストリング .Fa s が一致すると 1 を戻します。最後にコンパイルされた定型数式とストリング .Fa s が一致しない場合は 0 を戻します。 コンパイルされた定型数式が正しくない場合は \-1 を戻します (内部エラー)。 .Pp .Fn re_comp と .Fn re_exec の両方に渡すストリングには、最後に改行文字が付いていたり、改行文字 が埋め込まれていたりすることがありますが、これらは .Dv NUL で終端されます。 認識される定型数式については、上記のような違いがありますが、 .Xr ed 1 のマニュアルエントリを参照してください。 .Sh 診断 .Fn re_exec 関数は、内部エラーが発生した場合、-1 を戻します。 .Pp .Fn re_comp 関数は、エラーが発生した場合、以下のストリングのうち 1 つを戻します。 .Bd -unfilled -offset indent No previous regular expression, Regular expression too long, nmatched \e(, missing ], too many \e(\e) pairs, unmatched \e). .Sh 関連項目 .Xr ed 1 , .Xr egrep 1 , .Xr ex 1 , .Xr fgrep 1 , .Xr grep 1 , .Xr regex 3 .Sh 歴史 .Fn re_comp 関数と .Fn re_exec 関数は、 .Bx 4.0 に追加されました。