tag 268121 patch
thanks
Attached is a patch to document rpmatch; please consider including it.
.\" Copyright (C) 2006 Justin Pryzby <[EMAIL PROTECTED]>
.\"
.\" 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.
.\"
.\" References:
.\" glibc manual and source
.TH ERROR 3 "2006-05-05" GNU
.SH NAME
rpmatch \- parse the response to a boolean question
.SH SYNOPSIS
\fB#define _SVID_SOURCE
\fB#include <stdlib.h>
\fBint rpmatch (const char *\fIresponse\fB);
.SH DESCRIPTION
\fBrpmatch\fP() handles a user response to yes or no questions, with
support for internationalization. The user's language preferrence is
taken into account per the values of \fBLANG\fP, \fBLC_MESSAGES\fP,
and \fBLC_ALL\fP.
\fIresponse\fP should be a \fBNULL\fP-terminated string containing a
user-supplied response, perhaps obtained with \fBfgets\fP(3) or
\fBgetline\fP(3).
.SH "RETURN VALUE"
\fBrpmatch\fP() returns 0 for a recognized negative response ("no"), 1
for a recognized positive response ("yes"), and \-1 when the contents
of \fIresponse\fP is unrecognized.
.SH ERRORS
A return value of \-1 may indicate either an invalid input, or some
other error. It is incorrect to only test if the return value is
nonzero. \fBrpmatch\fP() can fail for any of the reasons that
\fBregcomp\fP(3) or \fBregexec\fP(3) can fail; the cause of the error
is not available from \fIerrno\fP or anywhere else, but indicates a
failure of the regex engine (but this case is indistinguishable from
that of an unrecognized value of \fIresponse\fP).
.SH "CONFORMING TO"
\fBrpmatch\fP() is not required by any standards document, and should
not be used in programs intended to be portable.
.SH BUGS
The \fBrpmatch\fP() implementation looks at only the first character
of \fIresponse\fP. As a consequence, "nyes" returns 0, and the
following all return 1:
.RS
.sp
\*(lqyno, never; not in a million years\*(rq
.br
.TP
\*(lqyover my dead body\*(rq
.br
.TP
\*(lqywhenever hell freezes over\*(rq
.sp
.RE
It would be preferrable to accept parse input strings much more
strictly, for example: \fBm/^y(es?)$/i\fP and \fBm/^n(o?)$/i\fP.
.SH SEE ALSO
.br
.BR regex (3),
.BR fgets (3),
.BR getline (3)
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]