linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* resend: add strerror_l() to strerror()
@ 2014-02-28  9:35 walter harms
       [not found] ` <53105855.6000206-fPG8STNUNVg@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: walter harms @ 2014-02-28  9:35 UTC (permalink / raw)
  To: linux-man; +Cc: Michael Kerrisk

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

re,
 wh

ps: this is a resend since i never got an answer for my last patch


--- strerror.3.org	2013-09-19 13:50:48.000000000 +0200
+++ strerror.3	2013-09-19 15:00:10.000000000 +0200
@@ -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 given locale you need
+.BR strerror_l ()
+it takes an additional arument 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_r ()
 function is thread-safe.
 .SH CONFORMING TO
 .BR strerror ()
@@ -210,6 +221,39 @@
 .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
+atleast since glibc 2.6.1.
+.SH EXAMPLE
+The program below demonstrates the use of the
+.BR strerror* ()
+functions. The first line should be
+.I sterror_l(13)=Permission denied
+the others should print this in a locale specific version.
+.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("sterror_l(13)=%s\\n",strerror_l(e,loc));
+  freelocale (loc);
+  // this will be translated automaticly
+  printf("sterror(13)=%s\\n",strerror(e));
+  strerror_r(e,buf,sizeof(buf)-1);
+  printf("sterror(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] 3+ messages in thread

* Re: resend: add strerror_l() to strerror()
       [not found] ` <53105855.6000206-fPG8STNUNVg@public.gmane.org>
@ 2014-02-28 21:26   ` Stefan Puiu
       [not found]     ` <CACKs7VBG_O4qdrkOsK9RkEUfvkMHSMnXON=a4nCtjNGNN00MKg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Puiu @ 2014-02-28 21:26 UTC (permalink / raw)
  To: wharms-fPG8STNUNVg; +Cc: linux-man, Michael Kerrisk

Hi Walter,

I spotted some typos in your patch, I thought I'd send you some
feedback before Michael catches up on this...

On Fri, Feb 28, 2014 at 11:35 AM, walter harms <wharms-fPG8STNUNVg@public.gmane.org> wrote:
[...]
> @@ -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 given locale you need
> +.BR strerror_l ()
> +it takes an additional arument that defines to locale in what the message is returned.

s/arument/argument

> +The function is thread-safe.

This sentence seems redundant, you also mention this below (ATTRIBUTES
section?).

>  .SH RETURN VALUE
>  The
>  .BR strerror ()
> @@ -180,6 +189,8 @@
>  .LP
>  The
>  .BR strerror_r ()
> +and
> +.BR strerror_r ()

I suppose you mean strerror_l()?

> @@ -210,6 +221,39 @@
>  .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
> +atleast since glibc 2.6.1.

s/atleast/at least

> +.SH EXAMPLE
> +The program below demonstrates the use of the
> +.BR strerror* ()
> +functions. The first line should be
> +.I sterror_l(13)=Permission denied

s/sterror/strerror. This is also repeated below a few times... Also,
don't you need to call strerror_l() with a different locale in order
to get a translated error message? You are calling strerror_l() and
then strerror() and strerror_r()...

> +the others should print this in a locale specific version.
> +.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("sterror_l(13)=%s\\n",strerror_l(e,loc));
> +  freelocale (loc);
> +  // this will be translated automaticly
> +  printf("sterror(13)=%s\\n",strerror(e));
> +  strerror_r(e,buf,sizeof(buf)-1);
> +  printf("sterror(13)=%s\\n",buf);
> +  return 0;
> +}
> +.fi

Thanks,
Stefan.
--
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] 3+ messages in thread

* Re: resend: add strerror_l() to strerror()
       [not found]     ` <CACKs7VBG_O4qdrkOsK9RkEUfvkMHSMnXON=a4nCtjNGNN00MKg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2014-03-01 10:35       ` walter harms
  0 siblings, 0 replies; 3+ messages in thread
From: walter harms @ 2014-03-01 10:35 UTC (permalink / raw)
  To: Stefan Puiu; +Cc: linux-man, Michael Kerrisk



Am 28.02.2014 22:26, schrieb Stefan Puiu:
> Hi Walter,
> 
> I spotted some typos in your patch, I thought I'd send you some
> feedback before Michael catches up on this...

thats good, i am terrible at finding my own typos.

> On Fri, Feb 28, 2014 at 11:35 AM, walter harms <wharms-fPG8STNUNVg@public.gmane.org> wrote:
> [...]
>> @@ -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 given locale you need
>> +.BR strerror_l ()
>> +it takes an additional arument that defines to locale in what the message is returned.
> 
> s/arument/argument
> 

fixed

>> +The function is thread-safe.
> 
> This sentence seems redundant, you also mention this below (ATTRIBUTES
> section?).
> 

This is from the original page, IMHO in this special circumstances it is resonable
to repeat this


>>  .SH RETURN VALUE
>>  The
>>  .BR strerror ()
>> @@ -180,6 +189,8 @@
>>  .LP
>>  The
>>  .BR strerror_r ()
>> +and
>> +.BR strerror_r ()
> 

fixed

> I suppose you mean strerror_l()?
> 
>> @@ -210,6 +221,39 @@
>>  .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
>> +atleast since glibc 2.6.1.
> 
> s/atleast/at least
> 
fixed
>> +.SH EXAMPLE
>> +The program below demonstrates the use of the
>> +.BR strerror* ()
>> +functions. The first line should be
>> +.I sterror_l(13)=Permission denied
> 
> s/sterror/strerror. This is also repeated below a few times... Also,

fixed,

> don't you need to call strerror_l() with a different locale in order
> to get a translated error message? You are calling strerror_l() and
> then strerror() and strerror_r()...

I do not get the point, the rationale of strerror_l is that the program
specifies a locale for a error message. In contrast to the other functions
that are influenced by LANG. I have changed the wording a bit to make that
more clear.

re,
 wh

>> +the others should print this in a locale specific version.
>> +.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("sterror_l(13)=%s\\n",strerror_l(e,loc));
>> +  freelocale (loc);
>> +  // this will be translated automaticly
>> +  printf("sterror(13)=%s\\n",strerror(e));
>> +  strerror_r(e,buf,sizeof(buf)-1);
>> +  printf("sterror(13)=%s\\n",buf);
>> +  return 0;
>> +}
>> +.fi
> 
> Thanks,
> Stefan.
--
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] 3+ messages in thread

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-28  9:35 resend: add strerror_l() to strerror() walter harms
     [not found] ` <53105855.6000206-fPG8STNUNVg@public.gmane.org>
2014-02-28 21:26   ` Stefan Puiu
     [not found]     ` <CACKs7VBG_O4qdrkOsK9RkEUfvkMHSMnXON=a4nCtjNGNN00MKg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-03-01 10:35       ` 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).