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)):
46 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
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 ¤Î¼ÁÌä¤ËÂФ¹¤ë¥æ¡¼¥¶¤«¤é¤Î±þÅú¤ò½èÍý¤¹¤ë¡£
60 ¹ñºÝ²½ (I18N) ¤ËÂбþ¤·¤Æ¤¤¤ë¡£
62 .\"O \fIresponse\fP should be a null-terminated string containing a
63 .\"O user-supplied response, perhaps obtained with
68 ¤Ë¤Ï¥æ¡¼¥¶¤«¤é¤Î±þÅú¤ò³ÊǼ¤·¤¿ NULL ½ªÃ¼Ê¸»úÎó¤¬Æþ¤Ã¤Æ¤¤¤ëɬÍפ¬¤¢¤ë¡£
73 ¤Ç¼è¤ê¹þ¤ó¤À¤â¤Î¤Ç¤¢¤í¤¦¡£
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 ¤¬
84 ¥æ¡¼¥¶¤Î¸À¸ìÀßÄê¤È¤·¤Æ¹Í褵¤ì¤ë¡£
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 ¤¬¼ºÇÔ¤¹¤ëÍýͳ¤Î¤É¤ì¤«¤Ç¼ºÇÔ¤¹¤ë¤³¤È¤¬¤¢¤ë¡£
132 ¤ä¾¤Î²¿¤«¤ÇÃΤ뤳¤È¤Ï¤Ç¤¤Ê¤¤¤¬¡¢
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.
144 ¤Ï¤É¤Îɸ½à¤Ç¤âɬ¿Ü¤È¤Ê¤Ã¤Æ¤¤¤Ê¤¤¤¬¡¢
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 ÆþÎÏʸ»úÎó¤ò¤â¤Ã¤È¸·Ì©¤Ë²ò¼á¤·¤¿Êý¤¬¤è¤¤¤À¤í¤¦¡£
170 ¤ÇÀâÌÀ¤µ¤ì¤Æ¤¤¤ë³ÈÄ¥Àµµ¬É½¸½¤ò»È¤Ã¤Æ)
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 °Ê²¼¤Î¥×¥í¥°¥é¥à¤Ï¡¢¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¤¿ô¤Ç
181 ¤ËÅϤ·¤¿¾ì¹ç¤Î·ë²Ì¤òɽ¼¨¤¹¤ë¡£
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]));