1 .\" Copyright (C) 2006 Justin Pryzby <pryzbyj@justinpryzby.com>
3 .\" Permission is hereby granted, free of charge, to any person obtaining
4 .\" a copy of this software and associated documentation files (the
5 .\" "Software"), to deal in the Software without restriction, including
6 .\" without limitation the rights to use, copy, modify, merge, publish,
7 .\" distribute, sublicense, and/or sell copies of the Software, and to
8 .\" permit persons to whom the Software is furnished to do so, subject to
9 .\" the following conditions:
11 .\" The above copyright notice and this permission notice shall be
12 .\" included in all copies or substantial portions of the Software.
14 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 .\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 .\" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 .\" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 .\" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 .\" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 .\" glibc manual and source
25 .\" 2006-05-19, mtk, various edits and example program
27 .\" Japanese Version Copyright (c) 2006 Akihiro MOTOKI all rights reserved.
28 .\" Translated 2006-07-31, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
30 .TH RPMATCH 3 2007-07-26 "GNU" "Linux Programmer's Manual"
33 .\"O rpmatch \- determine if the answer to a question is affirmative or negative
34 rpmatch \- 質問への応答が肯定か否定かを判定する
38 .B #include <stdlib.h>
40 .BI "int rpmatch(const char *" response );
44 .\"O Feature Test Macro Requirements for glibc (see
45 .\"O .BR feature_test_macros (7)):
47 .RB ( feature_test_macros (7)
56 .\"O handles a user response to yes or no questions, with
57 .\"O support for internationalization.
59 は yes/no の質問に対するユーザからの応答を処理する。
62 .\"O \fIresponse\fP should be a null-terminated string containing a
63 .\"O user-supplied response, perhaps obtained with
68 にはユーザからの応答を格納した NULL 終端文字列が入っている必要がある。
75 .\"O The user's language preference is taken into account per the
76 .\"O environment variables \fBLANG\fP, \fBLC_MESSAGES\fP, and \fBLC_ALL\fP,
77 .\"O if the program has called
78 .\"O .BR setlocale (3)
79 .\"O to effect their changes.
82 を呼び出して環境変数の変更を有効にした場合、
83 環境変数 \fBLANG\fP, \fBLC_MESSAGES\fP, \fBLC_ALL\fP が
86 .\"O Regardless of the locale, responses matching \fB^[Yy]\fP are always
87 .\"O accepted as affirmative, and those matching \fB^[Nn]\fP are always
88 .\"O accepted as negative.
89 ロケールに関わらず、\fB^[Yy]\fP にマッチする応答は常に肯定だと解釈され、
90 \fB^[Nn]\fP にマッチする応答は常に否定だと解釈される。
91 .\"O .SH "RETURN VALUE"
96 .\"O returns 0 for a recognized negative response ("no"), 1
97 .\"O for a recognized positive response ("yes"), and \-1 when the value
98 .\"O of \fIresponse\fP is unrecognized.
102 は否定的な応答 ("no") と認識した場合は 0 を返し、
103 肯定的な応答 ("yes") と認識した場合は 1 を返す。
105 の値を解釈できなかった場合は \-1 を返す。
108 .\"O A return value of \-1 may indicate either an invalid input, or some
110 .\"O It is incorrect to only test if the return value is nonzero.
111 返り値 \-1 が返った場合、入力が不正であったか、他の何らかのエラーが
112 あったことを意味する。返り値が 0 以外かどうかを確認するだけでは
116 .\"O can fail for any of the reasons that
120 .\"O can fail; the cause of the error
121 .\"O is not available from \fIerrno\fP or anywhere else, but indicates a
122 .\"O failure of the regex engine (but this case is indistinguishable from
123 .\"O that of an unrecognized value of \fIresponse\fP).
129 が失敗する理由のどれかで失敗することがある。
134 は正規表現エンジンの失敗の原因を示している
137 の値を認識できずに失敗した場合を区別することはできない)。
138 .\"O .SH "CONFORMING TO"
141 .\"O is not required by any standard, but
142 .\"O is available on a few other systems.
145 Linux 以外にも利用できるシステムもいくつかは存在する。
146 .\"O .\" It is available on at least AIX 5.1 and FreeBSD 6.0.
147 .\" 少なくとも AIX 5.1 と FreeBSD 6.0 では利用できる。
152 .\"O implementation looks at only the first character
153 .\"O of \fIresponse\fP.
154 .\"O As a consequence, "nyes" returns 0, and
155 .\"O "ynever; not in a million years" returns 1.
156 .\"O It would be preferable to accept input strings much more
157 .\"O strictly, for example (using the extended regular
158 .\"O expression notation described in
160 .\"O \fB^([yY]|yes|YES)$\fP and \fB^([nN]|no|NO)$\fP.
164 の最初の 1 文字だけを見ているようである。その結果、
166 "ynever; not in a million years" は 1 を返すことになる。
167 入力文字列をもっと厳密に解釈した方がよいだろう。
171 .BR ^([yY]|yes|YES)$ " や " ^([nN]|no|NO)$
175 .\"O The following program displays the results when
177 .\"O is applied to the string given in the program's command-line argument.
178 以下のプログラムは、コマンドライン引き数で
191 main(int argc, char *argv[])
193 if (argc != 2 || strcmp(argv[1], "\-\-help") == 0) {
194 fprintf(stderr, "%s response\\n", argv[0]);
198 setlocale(LC_ALL, "");
199 printf("rpmatch() returns: %d\\n", rpmatch(argv[1]));