linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Patch V2]  add strerror_l(3) to strerror(3)
@ 2014-03-01 10:41 walter harms
       [not found] ` <5311B958.9050002-fPG8STNUNVg@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: walter harms @ 2014-03-01 10:41 UTC (permalink / raw)
  To: linux-man, Michael Kerrisk

Hi list,
There is a lot of documentation missing for localisation functions.
This patch adds strerror_l() to the strerror(3) page.

This version should fix a few typos that came with the last version.
Thx to Stefan Puiu for reporting.

re,
 wh

--- /usr/local/share/man/man3/strerror.3	2014-02-11 09:20:17.000000000 +0100
+++ strerror.3	2014-03-01 11:32:27.000000000 +0100
@@ -50,6 +50,10 @@
 .sp
 .BI "char *strerror_r(int " errnum ", char *" buf ", size_t " buflen );
             /* GNU-specific */
+.sp
+.B #include <locale.h>
+.sp
+.BI "char *strerror_l(int " errnum, " locale_t " loc );
 .fi
 .sp
 .in -4n
@@ -133,6 +137,11 @@
 .I errnum
 is unknown).
 The string always includes a terminating null byte (\(aq\\0\(aq).
+
+To get an error message in a specific locale you need
+.BR strerror_l ()
+it takes an additional argument that defines to locale in what the message is returned.
+The function is thread-safe.
 .SH RETURN VALUE
 The
 .BR strerror ()
@@ -180,6 +189,8 @@
 .LP
 The
 .BR strerror_r ()
+and
+.BR strerror_l ()
 function is thread-safe.
 .SH CONFORMING TO
 .BR strerror ()
@@ -210,6 +221,41 @@
 .B EINVAL
 if the error number is unknown.
 C99 and POSIX.1-2008 require the return value to be non-NULL.
+.sp
+.BR strerror_l ()
+is a POSIX.1-2008 requirement, but available as GNU-specific function
+at least since glibc 2.6.1.
+.SH EXAMPLE
+The program below demonstrates the use of the
+.BR strerror* ()
+functions. The first line of output should be
+.I strerror_l(13)=Permission denied
+the others should print this in a locale as specified by
+.B LANG
+variable.
+.nf
+
+#include <stdio.h>
+#include <string.h>
+#include <locale.h>
+
+int main()
+{
+  int e=13;    // errornumber
+  char buf[255];
+  locale_t loc;
+
+  setlocale(LC_ALL, "");
+  loc = newlocale (LC_MESSAGES_MASK, "C", NULL);
+  printf("strerror_l(13)=%s\\n",strerror_l(e,loc));
+  freelocale (loc);
+  // this will be translated automaticly
+  printf("strerror(13)=%s\\n",strerror(e));
+  strerror_r(e,buf,sizeof(buf)-1);
+  printf("strerror_r(13)=%s\\n",buf);
+  return 0;
+}
+.fi
 .SH SEE ALSO
 .BR err (3),
 .BR errno (3),

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* ping Re: [Patch V2]  add strerror_l(3) to strerror(3)
       [not found] ` <5311B958.9050002-fPG8STNUNVg@public.gmane.org>
@ 2014-03-10 12:34   ` walter harms
  0 siblings, 0 replies; 2+ messages in thread
From: walter harms @ 2014-03-10 12:34 UTC (permalink / raw)
  Cc: linux-man, Michael Kerrisk



Am 01.03.2014 11:41, schrieb walter harms:
> Hi list,
> There is a lot of documentation missing for localisation functions.
> This patch adds strerror_l() to the strerror(3) page.
> 
> This version should fix a few typos that came with the last version.
> Thx to Stefan Puiu for reporting.

ping ?
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2014-03-10 12:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-01 10:41 [Patch V2] add strerror_l(3) to strerror(3) walter harms
     [not found] ` <5311B958.9050002-fPG8STNUNVg@public.gmane.org>
2014-03-10 12:34   ` ping " walter harms

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 NNTP newsgroup(s).