bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: branch master updated: * info/info.c (get_initial_file), * info/info


From: Gavin Smith
Subject: Re: branch master updated: * info/info.c (get_initial_file), * info/infodoc.c (info_get_info_help_node), * info/nodes.c (info_get_node_with_defaults): Use strcmp or strcasecmp instead of mbscasecmp in several cases where we do not care about case-insensitive matching with non-ASCII characters.
Date: Thu, 19 Oct 2023 14:10:56 +0100

On Thu, Oct 19, 2023 at 03:26:51PM +0300, Eli Zaretskii wrote:
> > diff --git a/info/info.c b/info/info.c
> > index 8ca4a17e58..d7a6afaa2c 100644
> > --- a/info/info.c
> > +++ b/info/info.c
> > @@ -250,7 +250,7 @@ get_initial_file (int *argc, char ***argv, char **error)
> >      {
> >        /* If they say info info (or info -O info, etc.), show them 
> >           info-stnd.texi.  (Get info.texi with info -f info.) */
> > -      if ((*argv)[0] && mbscasecmp ((*argv)[0], "info") == 0)
> > +      if ((*argv)[0] && strcmp ((*argv)[0], "info") == 0)
> >          (*argv)[0] = "info-stnd";
> 
> This could produce regressions on case-insensitive filesystems, where
> we could have INFO.EXE, for example.  Do we really no longer care
> about those?

(*argv)[0] here is not the name of the program but what was given on the
command line.  It should mean that "INFO.EXE info" works as before if
"INFO.EXE" is the name of the info program, whereas "INFO.EXE INFO" wouldn't.

I have no problem with changing it to strcasecmp to support "INFO.EXE INFO".

> 
> > --- a/info/infodoc.c
> > +++ b/info/infodoc.c
> > @@ -357,8 +357,7 @@ DECLARE_INFO_COMMAND (info_get_info_help_node, _("Visit 
> > Info node '(info)Help'")
> >      for (win = windows; win; win = win->next)
> >        {
> >          if (win->node && win->node->fullpath
> > -            && !mbscasecmp ("info",
> > -                            filename_non_directory (win->node->fullpath))
> > +            && !strcmp (filename_non_directory (win->node->fullpath), 
> > "info")
> >              && (!strcmp (win->node->nodename, "Help")
> >                  || !strcmp (win->node->nodename, "Help-Small-Screen")))
> 
> Likewise here.

I'll change this one to strcasecmp instead, in case the file is on the
system as "INFO.INFO" and somehow gets loaded as "INFO" rather than "info".

I was using strcasecmp in an attempt to avoid caring about non-ASCII strings.


> 
> >    /* If the node not found was "Top", try again with different case. */
> > -  if (!node && (nodename && mbscasecmp (nodename, "Top") == 0))
> > +  if (!node && (nodename && strcasecmp (nodename, "Top") == 0))
> 
> Are there no Info manuals that have "Top" with a different
> letter-case?

It is strcasecmp here, not strcmp.  This should support other
capitalisations, like "TOP" or "ToP".  But we do not care about non-ASCII
variants like "🄣ـoـ𝖕" that might compare equal (I haven't checked).  The
change here was an attempt to simplify these parts of the code where
only ASCII case variants matter.

strcasecmp is still potentially locale-dependent, but I don't expect the
results to change when comparing against ASCII strings only.  It allows
us to avoid using the obscure gnulib mbscasecmp function.  We still use
mbscasecmp in other parts of the code when comparing text from Info
files, for example when doing case-insensitive searches.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]