public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: "Alejandro Colomar (man-pages)" <alx.manpages@gmail.com>
To: наб <nabijaczleweli@nabijaczleweli.xyz>
Cc: linux-man@vger.kernel.org
Subject: Re: [PATCH 1/2] rpmatch.3: remove first-character-only FUD
Date: Tue, 21 Sep 2021 17:20:32 +0200	[thread overview]
Message-ID: <be1eaa87-3fa3-2e1f-7e6c-80362adbb935@gmail.com> (raw)
In-Reply-To: <8f5f9b7d4f067a4a479fe400dee99120bf0a1abd.1632231952.git.nabijaczleweli@nabijaczleweli.xyz>

Hi, наб!

On 9/21/21 3:46 PM, наб wrote:
> It's plain not true; locales can and do provide longer matches
> (Aramaic has a "አዎን" alternative, for example)
> 
> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>

Are you sure?

I just checked the glibc implementation, and it uses YESEXPR and NOEXPR 
(instead of YESSTR and NOSTR, which would match complete strings).


// stdlib/rpmatch.c
int
rpmatch (const char *response)
{
   /* We cache the response patterns and compiled regexps here.  */
   static const char *yesexpr, *noexpr;
   static regex_t yesre, nore;

   return (try (response, YESEXPR, 1, 0, &yesexpr, &yesre) ?:
	  try (response, NOEXPR, 0, -1, &noexpr, &nore));
}


$ grep -rn define.*YESEXPR;
locale/langinfo.h:570:#define YESEXPR			__YESEXPR


$ grep -rn __YESEXPR;
locale/langinfo.h:569:  __YESEXPR = _NL_ITEM (__LC_MESSAGES, 0), /* 
Regex matching ``yes'' input.  */
locale/langinfo.h:570:#define YESEXPR			__YESEXPR


$ grep -rn 'define _NL_ITEM(';
locale/langinfo.h:34:#define _NL_ITEM(category, index)	(((category) << 
16) | (index))


$ grep -rn LC_MESSAGES localedata/ | grep es_ES
localedata/locales/es_ES@euro:37:category "i18n:2012";LC_MESSAGES
localedata/locales/es_ES@euro:53:LC_MESSAGES
localedata/locales/es_ES@euro:55:END LC_MESSAGES
localedata/locales/es_ES:45:category "i18n:2012";LC_MESSAGES
localedata/locales/es_ES:113:LC_MESSAGES
localedata/locales/es_ES:118:END LC_MESSAGES


$ sed -n '/^LC_MESSAGES/,/END LC_MESSAGES/p' localedata/locales/es_ES;
LC_MESSAGES
yesexpr "^[+1sSyY]"
noexpr  "^[-0nN]"
yesstr  "sí"
nostr   "no"
END LC_MESSAGES



So, it seems to me that by using {yes,no}expr and not {yes,no}str, it is 
limiting itself to the first letter, as the current BUGS section 
specifies.  Right?

Thanks,

Alex


> ---
>   man3/rpmatch.3 | 15 ---------------
>   1 file changed, 15 deletions(-)
> 
> diff --git a/man3/rpmatch.3 b/man3/rpmatch.3
> index 846c492b7..e0f92a20d 100644
> --- a/man3/rpmatch.3
> +++ b/man3/rpmatch.3
> @@ -123,21 +123,6 @@ T}	Thread safety	MT-Safe locale
>   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
> -.BR rpmatch ()
> -implementation looks at only the first character
> -of
> -.IR response .
> -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
> -.BR regex (7)):
> -.B \(ha([yY]|yes|YES)$
> -and
> -.BR \(ha([nN]|no|NO)$ .
>   .SH EXAMPLES
>   The following program displays the results when
>   .BR rpmatch ()
> 


-- 
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/

  parent reply	other threads:[~2021-09-21 15:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-21 13:46 [PATCH 1/2] rpmatch.3: remove first-character-only FUD наб
2021-09-21 13:46 ` [PATCH 2/2] rpmatch.3: clarify availability to glibc, Fx, and AIX наб
2021-09-21 15:20 ` Alejandro Colomar (man-pages) [this message]
2021-09-21 16:06   ` [PATCH 1/2] rpmatch.3: remove first-character-only FUD наб
2021-09-21 23:25     ` Alejandro Colomar (man-pages)
2021-09-22  9:12       ` Alejandro Colomar (man-pages)
2021-10-02 12:18 ` [PATCH v2 1/2] rpmatch.3: clarify " наб
2021-10-02 17:32   ` Alejandro Colomar (man-pages)
2021-10-02 12:18 ` [PATCH v2 2/2] rpmatch.3: clarify availability to glibc, Fx, and AIX наб

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=be1eaa87-3fa3-2e1f-7e6c-80362adbb935@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=linux-man@vger.kernel.org \
    --cc=nabijaczleweli@nabijaczleweli.xyz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox