| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: vfwprintf.c,v 1.15 2009/02/20 09:23:37 roy Exp $ */ | | 1 | /* $NetBSD: vfwprintf.c,v 1.16 2009/08/05 20:46:01 dsl Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1990, 1993 | | 4 | * Copyright (c) 1990, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to Berkeley by | | 7 | * This code is derived from software contributed to Berkeley by |
8 | * Chris Torek. | | 8 | * Chris Torek. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -28,27 +28,27 @@ | | | @@ -28,27 +28,27 @@ |
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
32 | * SUCH DAMAGE. | | 32 | * SUCH DAMAGE. |
33 | */ | | 33 | */ |
34 | | | 34 | |
35 | #include <sys/cdefs.h> | | 35 | #include <sys/cdefs.h> |
36 | #if defined(LIBC_SCCS) && !defined(lint) | | 36 | #if defined(LIBC_SCCS) && !defined(lint) |
37 | #if 0 | | 37 | #if 0 |
38 | static char sccsid[] = "@(#)vfprintf.c 8.1 (Berkeley) 6/4/93"; | | 38 | static char sccsid[] = "@(#)vfprintf.c 8.1 (Berkeley) 6/4/93"; |
39 | __FBSDID("$FreeBSD: src/lib/libc/stdio/vfwprintf.c,v 1.27 2007/01/09 00:28:08 imp Exp $"); | | 39 | __FBSDID("$FreeBSD: src/lib/libc/stdio/vfwprintf.c,v 1.27 2007/01/09 00:28:08 imp Exp $"); |
40 | #else | | 40 | #else |
41 | __RCSID("$NetBSD: vfwprintf.c,v 1.15 2009/02/20 09:23:37 roy Exp $"); | | 41 | __RCSID("$NetBSD: vfwprintf.c,v 1.16 2009/08/05 20:46:01 dsl Exp $"); |
42 | #endif | | 42 | #endif |
43 | #endif /* LIBC_SCCS and not lint */ | | 43 | #endif /* LIBC_SCCS and not lint */ |
44 | | | 44 | |
45 | /* | | 45 | /* |
46 | * Actual {w,}printf innards. | | 46 | * Actual {w,}printf innards. |
47 | */ | | 47 | */ |
48 | | | 48 | |
49 | #include "namespace.h" | | 49 | #include "namespace.h" |
50 | #include <sys/types.h> | | 50 | #include <sys/types.h> |
51 | | | 51 | |
52 | #include <assert.h> | | 52 | #include <assert.h> |
53 | #include <ctype.h> | | 53 | #include <ctype.h> |
54 | #include <limits.h> | | 54 | #include <limits.h> |
| @@ -887,26 +887,32 @@ reswitch: switch (ch) { | | | @@ -887,26 +887,32 @@ reswitch: switch (ch) { |
887 | goto rflag; | | 887 | goto rflag; |
888 | width = -width; | | 888 | width = -width; |
889 | /* FALLTHROUGH */ | | 889 | /* FALLTHROUGH */ |
890 | case '-': | | 890 | case '-': |
891 | flags |= LADJUST; | | 891 | flags |= LADJUST; |
892 | goto rflag; | | 892 | goto rflag; |
893 | case '+': | | 893 | case '+': |
894 | sign = '+'; | | 894 | sign = '+'; |
895 | goto rflag; | | 895 | goto rflag; |
896 | case '\'': | | 896 | case '\'': |
897 | flags |= GROUPING; | | 897 | flags |= GROUPING; |
898 | thousands_sep = *(localeconv()->thousands_sep); | | 898 | thousands_sep = *(localeconv()->thousands_sep); |
899 | grouping = localeconv()->grouping; | | 899 | grouping = localeconv()->grouping; |
| | | 900 | /* If the locale doesn't define the above, use sane |
| | | 901 | * defaults - otherwise silly things happen! */ |
| | | 902 | if (thousands_sep == 0) |
| | | 903 | thousands_sep = ','; |
| | | 904 | if (!grouping || !*grouping) |
| | | 905 | grouping = "\3"; |
900 | goto rflag; | | 906 | goto rflag; |
901 | case '.': | | 907 | case '.': |
902 | if ((ch = *fmt++) == '*') { | | 908 | if ((ch = *fmt++) == '*') { |
903 | GETASTER (prec); | | 909 | GETASTER (prec); |
904 | goto rflag; | | 910 | goto rflag; |
905 | } | | 911 | } |
906 | prec = 0; | | 912 | prec = 0; |
907 | while (is_digit(ch)) { | | 913 | while (is_digit(ch)) { |
908 | prec = 10 * prec + to_digit(ch); | | 914 | prec = 10 * prec + to_digit(ch); |
909 | ch = *fmt++; | | 915 | ch = *fmt++; |
910 | } | | 916 | } |
911 | goto reswitch; | | 917 | goto reswitch; |
912 | case '0': | | 918 | case '0': |