[uClibc-cvs] uClibc/libc/stdio printf.c,1.44,1.45 stdio.c,1.62,1.63
Manuel Novoa III
mjn3 at uclibc.org
Fri Dec 20 19:27:06 UTC 2002
Update of /var/cvs/uClibc/libc/stdio
In directory winder:/tmp/cvs-serv18665/libc/stdio
Modified Files:
printf.c stdio.c
Log Message:
The big thing is locale dependent collation support.
Also added outdigit support and (legacy) YESSTR/NOSTR support.
Index: printf.c
===================================================================
RCS file: /var/cvs/uClibc/libc/stdio/printf.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- printf.c 27 Nov 2002 22:02:37 -0000 1.44
+++ printf.c 20 Dec 2002 19:26:30 -0000 1.45
@@ -2331,11 +2331,16 @@
}
if (ppfs->conv_num <= CONV_i) { /* pointer or (un)signed int */
alphacase = __UIM_LOWER;
- if (((base = spec_base[(int)(ppfs->conv_num - CONV_p)]) == 10)
- && (PRINT_INFO_FLAG_VAL(&(ppfs->info),group))
- ) {
- alphacase = __UIM_GROUP;
+#ifndef __LOCALE_C_ONLY
+ if ((base = spec_base[(int)(ppfs->conv_num - CONV_p)]) == 10) {
+ if (PRINT_INFO_FLAG_VAL(&(ppfs->info),group)) {
+ alphacase = __UIM_GROUP;
+ }
+ if (PRINT_INFO_FLAG_VAL(&(ppfs->info),i18n)) {
+ alphacase |= 0x80;
+ }
}
+#endif /* __LOCALE_C_ONLY */
if (ppfs->conv_num <= CONV_u) { /* pointer or unsigned int */
if (ppfs->conv_num == CONV_X) {
alphacase = __UIM_UPPER;
@@ -2350,6 +2355,9 @@
if (ppfs->info.prec < 0) { /* Ignore '0' flag if prec specified. */
padchar = ppfs->info.pad;
}
+#ifdef __UCLIBC_MJN3_ONLY__
+#warning if using outdigits and/or grouping, how should we interpret precision?
+#endif
s = _uintmaxtostr(buf + sizeof(buf) - 1,
(uintmax_t)
_load_inttype(*argtype & __PA_INTMASK,
@@ -2557,6 +2565,9 @@
return -1;
}
+#ifdef __UCLIBC_MJN3_ONLY__
+#warning if using outdigits and/or grouping, how should we pad?
+#endif
{
size_t t;
Index: stdio.c
===================================================================
RCS file: /var/cvs/uClibc/libc/stdio/stdio.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- stdio.c 22 Nov 2002 03:05:23 -0000 1.62
+++ stdio.c 20 Dec 2002 19:26:30 -0000 1.63
@@ -319,11 +319,11 @@
UNLOCKED(int,fileno,(register FILE *stream),(stream))
{
#ifdef __STDIO_GLIBC_CUSTOM_STREAMS
- return ( ((stream->cookie == &(stream->filedes)) && (stream->filedes >= 0))
+ return ( (stream && (stream->cookie == &(stream->filedes)) && (stream->filedes >= 0))
? stream->filedes
: (__set_errno(EBADF), -1) );
#else /* __STDIO_GLIBC_CUSTOM_STREAMS */
- return (stream->filedes >= 0) ? stream->filedes : (__set_errno(EBADF), -1);
+ return ((stream && stream->filedes >= 0)) ? stream->filedes : (__set_errno(EBADF), -1);
#endif /* __STDIO_GLIBC_CUSTOM_STREAMS */
}
@@ -3331,7 +3331,7 @@
unsigned int H, L, high, low, rh;
#endif
#ifndef __LOCALE_C_ONLY
- int grouping;
+ int grouping, outdigit;
size_t gslen; /* This does not need to be initialized. */
const char *g; /* This does not need to be initialized. */
#endif /* __LOCALE_C_ONLY */
@@ -3350,6 +3350,11 @@
#ifndef __LOCALE_C_ONLY
grouping = -1;
+ outdigit = 0x80 & alphacase;
+ alphacase ^= outdigit;
+#ifdef __UCLIBC_MJN3_ONLY_
+#warning implement outdigit... need digit lengths! (put it in locale struct)
+#endif
if (alphacase == __UIM_GROUP) {
assert(base == 10);
if (*(g = CUR_LOCALE.grouping)
@@ -3391,7 +3396,18 @@
digit = uval % base;
uval /= base;
- *--bufend = ( (digit < 10) ? digit + '0' : digit + alphacase );
+#ifndef __LOCALE_C_ONLY
+ if (outdigit) {
+ outdigit = CUR_LOCALE.outdigit_length[digit];
+ do {
+ *--bufend = (&CUR_LOCALE.outdigit0_mb)[digit][--outdigit];
+ } while (outdigit);
+ outdigit = 1;
+ } else
+#endif
+ {
+ *--bufend = ( (digit < 10) ? digit + '0' : digit + alphacase );
+ }
} while (uval);
#else /* ************************************************** */
@@ -3437,7 +3453,18 @@
low = (low / base) + (H * rh) + (digit / base);
digit %= base;
- *--bufend = ( (digit < 10) ? digit + '0' : digit + alphacase );
+#ifndef __LOCALE_C_ONLY
+ if (outdigit) {
+ outdigit = CUR_LOCALE.outdigit_length[digit];
+ do {
+ *--bufend = (&CUR_LOCALE.outdigit0_mb)[digit][--outdigit];
+ } while (outdigit);
+ outdigit = 1;
+ } else
+#endif
+ {
+ *--bufend = ( (digit < 10) ? digit + '0' : digit + alphacase );
+ }
} while (low | high);
#endif /******************************************************/
More information about the uClibc-cvs
mailing list