public inbox for newlib-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org, newlib-cvs@sourceware.org Subject: [newlib-cygwin] Implement missing POSIX-1.2008 function strerror_l Date: Tue, 23 Aug 2016 15:55:00 -0000 [thread overview] Message-ID: <20160823155557.65142.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=463a8afaa58b80926b0236e14a6171f45c1b784f commit 463a8afaa58b80926b0236e14a6171f45c1b784f Author: Corinna Vinschen <corinna@vinschen.de> Date: Tue Aug 23 17:49:24 2016 +0200 Implement missing POSIX-1.2008 function strerror_l Signed-off-by: Corinna Vinschen <corinna@vinschen.de> Diff: --- newlib/libc/string/strerror.c | 19 ++++++++++++++++++- winsup/cygwin/common.din | 1 + winsup/cygwin/errno.cc | 7 +++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/newlib/libc/string/strerror.c b/newlib/libc/string/strerror.c index fcef33e..49e5f7e 100644 --- a/newlib/libc/string/strerror.c +++ b/newlib/libc/string/strerror.c @@ -7,14 +7,18 @@ /* FUNCTION - <<strerror>>---convert error number to string + <<strerror>>, <<strerror_l>>---convert error number to string INDEX strerror +INDEX + strerror_l + ANSI_SYNOPSIS #include <string.h> char *strerror(int <[errnum]>); + char *strerror_l(int <[errnum]>, locale_t locale); char *_strerror_r(struct _reent <[ptr]>, int <[errnum]>, int <[internal]>, int *<[error]>); @@ -29,6 +33,10 @@ string. The value of <[errnum]> is usually a copy of <<errno>>. If <<errnum>> is not a known error number, the result points to an empty string. +<<strftime_l>> is like <<strftime>> but creates a string in a format +as expected in locale <[locale]>. If <[locale]> is LC_GLOBAL_LOCALE or +not a valid locale object, the behaviour is undefined. + This implementation of <<strerror>> prints out the following strings for each of the values defined in `<<errno.h>>': @@ -330,6 +338,8 @@ PORTABILITY ANSI C requires <<strerror>>, but does not specify the strings used for each error number. +<<strerror_l>> is POSIX-1.2008. + Although this implementation of <<strerror>> is reentrant (depending on <<_user_strerror>>), ANSI C declares that subsequent calls to <<strerror>> may overwrite the result string; therefore portable @@ -893,3 +903,10 @@ _DEFUN(strerror, (int), { return _strerror_r (_REENT, errnum, 0, NULL); } + +char * +strerror_l (int errnum, locale_t locale) +{ + /* We don't support per-locale error messages. */ + return _strerror_r (_REENT, errnum, 0, NULL); +} diff --git a/winsup/cygwin/common.din b/winsup/cygwin/common.din index 8f7a282..7fce587 100644 --- a/winsup/cygwin/common.din +++ b/winsup/cygwin/common.din @@ -1345,6 +1345,7 @@ strcpy NOSIGFE strcspn NOSIGFE strdup SIGFE strerror SIGFE +strerror_l SIGFE strerror_r SIGFE strfmon SIGFE strfmon_l SIGFE diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc index 7e07a61..9168e9b 100644 --- a/winsup/cygwin/errno.cc +++ b/winsup/cygwin/errno.cc @@ -403,6 +403,13 @@ strerror (int errnum) return result; } +extern "C" char * +strerror_l (int errnum, locale_t locale) +{ + /* We don't provide localized system error messages (yet?). */ + return strerror (errnum); +} + /* Newlib's <string.h> provides declarations for two strerror_r variants, according to preprocessor feature macros. However, it returns "" instead of "Unknown error ...", so we override both
reply other threads:[~2016-08-23 15:55 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20160823155557.65142.qmail@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ --cc=newlib-cvs@sourceware.org \ /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: linkBe 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).