summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2019-01-11 09:53:27 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2019-01-11 09:53:27 +0000
commit28055e4e4061da9ec8d1edb6ad9895745ce4bc60 (patch)
tree97c2ed329e781bf1ec709f01f92d403858898a1e /lib/libc
parent59c97c2a9e339fc5b74b81ecb65a913c99bc941f (diff)
Clarify that OpenBSD ignores the dangerous category LC_NUMERIC,
and explain best practice for portable programs below CAVEATS. Triggered by a smaller diff from Jan Stary <hans at stare dot cz>. Emphatic OKs from cheloha@ and tedu@.
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/stdio/wprintf.346
1 files changed, 30 insertions, 16 deletions
diff --git a/lib/libc/stdio/wprintf.3 b/lib/libc/stdio/wprintf.3
index 98711c21cfb..2914716e692 100644
--- a/lib/libc/stdio/wprintf.3
+++ b/lib/libc/stdio/wprintf.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: wprintf.3,v 1.5 2017/12/01 10:56:07 schwarze Exp $
+.\" $OpenBSD: wprintf.3,v 1.6 2019/01/11 09:53:26 schwarze Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -33,7 +33,7 @@
.\"
.\" @(#)printf.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd $Mdocdate: December 1 2017 $
+.Dd $Mdocdate: January 11 2019 $
.Dt WPRINTF 3
.Os
.Sh NAME
@@ -225,17 +225,17 @@ A
.Cm +
overrides a space if both are used.
.It Sq Cm '
-Decimal conversions
-.Cm ( d , u ,
+On
+.Ox ,
+this flag has no effect.
+On other systems, it may cause the insertion of
+.Xr locale 1 Ns -dependent
+thousands separator characters into the integral parts of arguments
+of the
+.Cm d , i , u , f ,
or
-.Cm i )
-or the integral portion of a floating point conversion
-.Cm ( f
-or
-.Cm F )
-should be grouped and separated by thousands using
-the non-monetary separator returned by
-.Xr localeconv 3 .
+.Cm F
+conversions.
.El
.It
An optional decimal digit string specifying a minimum field width.
@@ -578,10 +578,6 @@ is
.Ql %% .
.El
.Pp
-The decimal point
-character is defined in the program's locale (category
-.Dv LC_NUMERIC ) .
-.Pp
In no case does a non-existent or small field width cause truncation of
a numeric field; if the result of a conversion is wider than the field
width, the
@@ -605,3 +601,21 @@ and
functions
conform to
.St -isoC-99 .
+.Sh CAVEATS
+On systems other than
+.Ox ,
+the
+.Dv LC_NUMERIC
+.Xr locale 1
+category can cause erratic output, for example different characters
+substituted for the decimal point or thousands separator characters
+inserted into numbers.
+For security reasons, make sure that portable programs calling these
+functions never call
+.Xr setlocale 3
+with the
+.Dv LC_ALL
+or
+.Dv LC_NUMERIC
+categories but only use
+.Dv LC_CTYPE .