Justin,

> > > Any suggestions about other pages whose SEE ALSO should mention this
> > > page?
> > Not really ... I'll have to think about it.
> I'm including patches to add a SEE ALSO, and also to fix and tweak the
> page based on some new\-found understanding ..
> 
> If you tell me where to get your most recent copy, then I'll provide a
> patch against that.
> 
> Justin
> 
> --- - 2006-05-17 16:39:22.208205000 -0400
> +++ /tmp/setlocale3.gz.2087   2006-05-17 16:39:22.000000000 -0400
> @@ -186,5 +186,6 @@
>  .BR nl_langinfo (3),
>  .BR strcoll (3),
>  .BR strftime (3),
> +.BR rpmatch (3),
>  .BR charsets (4),
>  .BR locale (7)

Applied

> --- rpmatch.3 2006-05-05 17:55:55.000000000 -0400
> +++ new/rpmatch.3     2006-05-17 20:55:14.000000000 -0400
> @@ -21,7 +21,7 @@
>  .\"
>  .\" References:
>  .\"   glibc manual and source
> -.TH ERROR 3 "2006-05-05" GNU
> +.TH RPMATCH 3 "2006-05-17" GNU

Applied

>  .SH NAME
>  rpmatch \- parse the response to a boolean question
>  .SH SYNOPSIS
> @@ -32,21 +32,25 @@
>  \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.
> +support for internationalization.

Applied

> -\fIresponse\fP should be a \fBNULL\fP-terminated string containing a
> -user-supplied response, perhaps obtained with \fBfgets\fP(3) or
> +\fIresponse\fP should be a null\-terminated string containing a
> +user\-supplied response, perhaps obtained with \fBfgets\fP(3) or

The \- here is wrong!  A real hyphen does not get quoted.

>  \fBgetline\fP(3).
> +
> +The user's language preference is taken into account per the
> +environment variables \fBLANG\fP, \fBLC_MESSAGES\fP, and \fBLC_ALL\fP
> +if the program has called \fBsetlocale\fP() to effect their changes.

Applied (and nicely worded).

>  .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
> +\fBrpmatch\fP() returns 0 for a recognized negative response
> (\*(lqno\*(rq), 1
> +for a recognized positive response (\*(lqyes\*(rq), and \-1 when the

I prefer plain old ""

> 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
> +nonzero.
> +
> +\fBrpmatch\fP() can fail for any of the reasons that

Applied

>  \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
> @@ -55,9 +59,15 @@
>  \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:
> +\fBrpmatch\fP() is implemented with \fBregex\fP(), using the
> +locale\-specific regular expressions \fBYESEXPR\fP and \fBNOEXPR\fP;

The above mentions constants that are effctively hidden
from the programmer.  the manual page shouldn't describe
this implementation detail.

> +only the first character of \fIresponse\fP is considered significant.
> +Responses matching \fBm/^[Yy]/i\fP are always accepted as affirmative
> +(in any locale), and those matching
> +\fBm/^[Nn]/i\fP are always accepted as negative.

This is more detail than I think is really required to explain 
the point.  You already say that just the first character is 
significant.  The additional RE isn't needed.

> +\*(lqnyes\*(rq returns 0, and the following
> +all return 1:

This is more detail than I think is really required to explain 
the point.  You already say that just the first character is 
significant.  The additional RE isn't needed.

>  .RS
>  .sp
>  \*(lqyno, never; not in a million years\*(rq
> @@ -69,10 +79,10 @@
>  \*(lqywhenever hell freezes over\*(rq
>  .sp
>  .RE
> -It would be preferrable to accept parse input strings much more
> +It would be preferable to parse input strings much more

I had already made this just "accept".

>  strictly, for example: \fBm/^y(es?)$/i\fP and \fBm/^n(o?)$/i\fP.

Please no Perl in my pages.  I made this into standard regex(7)
REs...

>  .SH SEE ALSO
> -.br
> +.BR setlocale (3),

Applied

>  .BR regex (3),
>  .BR fgets (3),
>  .BR getline (3)


Thanks for the update!

My current version of the page below.

Cheers,

Michael


.\" 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 RPMATCH 3 "2006-05-17" GNU
.SH NAME
rpmatch \- determine if the answer to a question is affirmative or negative
.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.

\fIresponse\fP should be a null-terminated string containing a
user-supplied response, perhaps obtained with \fBfgets\fP(3) or
\fBgetline\fP(3).

The user's language preference is taken into account per the
environment variables \fBLANG\fP, \fBLC_MESSAGES\fP, and \fBLC_ALL\fP,
if the program has called \fBsetlocale\fP() to effect their changes.
.SH "RETURN VALUE"
After examining
.IR response ,
\fBrpmatch\fP() returns 0 for a recognized negative response ("no"), 1
for a recognized positive response ("yes"), and \-1 when the value
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 standard, but
is available on a few other systems.
.\" It is available on at least AIX 5.1 and FreeBSD 6.0.
.SH BUGS
The \fBrpmatch\fP() implementation looks at only the first character
of \fIresponse\fP.  As a consequence, "nyes" returns 0, and
"ynever; not in a million years" returns 1.
It would be preferable to accept input strings much more
strictly, for example (using the extended regular
expression notation described in \fBregex\fP(7)):
\fB([yY]|yes|YES)\fP and \fB([nN]|no|NO)\fP.
.SH EXAMPLE PROGRAM
The following program displays the results when
.BR rpmatch ()
is applied to the string given in the program's command-line argument.
.nf

#define _SVID_SOURCE
#include <locale.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

int
main(int argc, char *argv[])
{
    if (argc != 2 || strcmp(argv[1], "--help") == 0) {
        fprintf(stderr, "%s response\\n", argv[0]);
        exit(EXIT_FAILURE);
    }

    setlocale(LC_ALL, "");
    printf("rpmatch() returns: %d\\n", rpmatch(argv[1]));
    exit(EXIT_SUCCESS);
}
.fi
.SH SEE ALSO
.BR regcomp (3),
.BR fgets (3),
.BR getline (3),
.BR nl_langinfo (3),
.BR setlocale (3)

-- 
Michael Kerrisk
maintainer of Linux man pages Sections 2, 3, 4, 5, and 7 

Want to help with man page maintenance?  
Grab the latest tarball at
ftp://ftp.win.tue.nl/pub/linux-local/manpages/, 
read the HOWTOHELP file and grep the source 
files for 'FIXME'.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to