unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* setlocale - incorrect error signalled
@ 2005-01-21 12:15 Bruno Haible
  2005-01-21 21:49 ` Kevin Ryde
  0 siblings, 1 reply; 4+ messages in thread
From: Bruno Haible @ 2005-01-21 12:15 UTC (permalink / raw)


When setlocale is called with a locale name that doesn't exist,
the C function setlocale() returns NULL, and guile signals an error.
This is OK. But guile presents incorrect error details:

  $ guile
  guile> (setlocale LC_ALL "uk_UK.UTF-8")

  Backtrace:
  In standard input:
     1: 0* [setlocale 6 "uk_UK.UTF-8"]

  standard input:1:1: In procedure setlocale in expression (setlocale LC_ALL "uk_UK.UTF-8"):
  standard input:1:1: No such file or directory

"No such file or directory" is incorrect. setlocale() is not required to
set errno when it fails, see
http://www.opengroup.org/onlinepubs/009695399/functions/setlocale.html
Therefore guile should not look at errno when it signals an error.

libguile/posix.c:

  rv = setlocale (scm_i_to_lc_category (category, 1), clocale);
  if (rv == NULL)
    SCM_SYSERROR;     <=== This is the problem.

Bruno



_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: setlocale - incorrect error signalled
  2005-01-21 12:15 setlocale - incorrect error signalled Bruno Haible
@ 2005-01-21 21:49 ` Kevin Ryde
  2005-01-23 21:57   ` Kevin Ryde
  2005-01-24 15:19   ` Bruno Haible
  0 siblings, 2 replies; 4+ messages in thread
From: Kevin Ryde @ 2005-01-21 21:49 UTC (permalink / raw)
  Cc: guile-devel

Bruno Haible <bruno@clisp.org> writes:
>
> "No such file or directory" is incorrect.

glibc does end up setting that, it's not just what was left there from
before.

> setlocale() is not required to set errno when it fails,

Yep.

>   rv = setlocale (scm_i_to_lc_category (category, 1), clocale);
>   if (rv == NULL)
>     SCM_SYSERROR;     <=== This is the problem.

Could force an errno=EINVAL in there, so that's always the error
given.  Or alternately put errno=EINVAL before the setlocale, as a
default if setlocale doesn't change errno.  I suppose the former might
be most standards-compliant.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: setlocale - incorrect error signalled
  2005-01-21 21:49 ` Kevin Ryde
@ 2005-01-23 21:57   ` Kevin Ryde
  2005-01-24 15:19   ` Bruno Haible
  1 sibling, 0 replies; 4+ messages in thread
From: Kevin Ryde @ 2005-01-23 21:57 UTC (permalink / raw)
  Cc: guile-devel

I wrote:
>
> Could force an errno=EINVAL in there, so that's always the error
> given.

I made that change.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: setlocale - incorrect error signalled
  2005-01-21 21:49 ` Kevin Ryde
  2005-01-23 21:57   ` Kevin Ryde
@ 2005-01-24 15:19   ` Bruno Haible
  1 sibling, 0 replies; 4+ messages in thread
From: Bruno Haible @ 2005-01-24 15:19 UTC (permalink / raw)
  Cc: guile-devel

Kevin Ryde wrote:
> >   rv = setlocale (scm_i_to_lc_category (category, 1), clocale);
> >   if (rv == NULL)
> >     SCM_SYSERROR;     <=== This is the problem.
>
> Could force an errno=EINVAL in there, so that's always the error
> given.

Yes, this is good. Thanks.

Bruno



_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-01-24 15:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-21 12:15 setlocale - incorrect error signalled Bruno Haible
2005-01-21 21:49 ` Kevin Ryde
2005-01-23 21:57   ` Kevin Ryde
2005-01-24 15:19   ` Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).