public inbox for libc-locales@sourceware.org
 help / color / mirror / Atom feed
From: "law at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: libc-locales@sources.redhat.com
Subject: [Bug localedata/14247] New: newlocale doesn't always set errno upon failure return
Date: Fri, 15 Jun 2012 03:49:00 -0000	[thread overview]
Message-ID: <bug-14247-716@http.sourceware.org/bugzilla/> (raw)

http://sourceware.org/bugzilla/show_bug.cgi?id=14247

             Bug #: 14247
           Summary: newlocale doesn't always set errno upon failure return
           Product: glibc
           Version: 2.15
            Status: NEW
          Severity: normal
          Priority: P2
         Component: localedata
        AssignedTo: unassigned@sourceware.org
        ReportedBy: law@redhat.com
                CC: libc-locales@sources.redhat.com
    Classification: Unclassified


Created attachment 6449
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6449
Potential fix

newlocale() neglects to set errno to an appropriate value when failing, if it
has already been asked about the same incorrect locale name.

#include <stdio.h>
#include <errno.h>
#include <locale.h>

int
main(int argc, char **argv)
{
  locale_t loc;

  setlocale(LC_ALL, "C");

  errno = 0;
  loc = newlocale(LC_COLLATE_MASK | LC_CTYPE_MASK,
          "nb_no.utf8",
          0);
  printf("result = %p errno = %d\n", loc, errno);

  errno = 0;
  loc = newlocale(LC_COLLATE_MASK | LC_CTYPE_MASK,
          "nb_no.utf8",
          0);
  printf("result = %p errno = %d\n", loc, errno);

  return 0;
}


Actual results:
result = (nil) errno = 2
result = (nil) errno = 0

Expected results:
result = (nil) errno = 2
result = (nil) errno = 2     (or at least something other than 0)

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

             reply	other threads:[~2012-06-15  3:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-15  3:49 law at redhat dot com [this message]
2014-06-19 14:44 ` [Bug localedata/14247] " fweimer at redhat dot com
2015-08-27 22:00 ` [Bug locale/14247] " jsm28 at gcc dot gnu.org
2021-05-23 17:43 ` kristian.spangsege at gmail dot com
2023-12-01 13:35 ` carlos at redhat dot com
2023-12-01 17:12 ` carlos at redhat dot com
2023-12-01 17:26 ` schwab@linux-m68k.org
2023-12-01 17:39 ` carlos at redhat dot com
2024-02-27 15:36 ` carlos at redhat dot com
2024-02-27 15:39 ` carlos at redhat dot com
2024-02-27 15:40 ` carlos at redhat dot com
2024-02-27 15:41 ` carlos at redhat dot com

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=bug-14247-716@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=libc-locales@sources.redhat.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).