This is the mail archive of the cygwin-developers mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: "C" character set (again)


On Jan  8 12:40, Andy Koppe wrote:
> But I think it would actually be quite easy to wave invalid bytes
> through anyway: print the byte, reset the multibyte conversion state,
> and continue processing the string. Still valid according to POSIX,
> but also Linux-compatible. I'll propose a patch.

I hacked a patch already yesterday:

Index: libc/stdio/vfprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vfprintf.c,v
retrieving revision 1.76
diff -u -p -r1.76 vfprintf.c
--- libc/stdio/vfprintf.c	18 Nov 2009 09:49:56 -0000	1.76
+++ libc/stdio/vfprintf.c	8 Jan 2010 12:47:31 -0000
@@ -724,8 +724,12 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap)
 	        cp = fmt;
 #ifdef _MB_CAPABLE
 	        while ((n = __mbtowc (data, &wc, fmt, MB_CUR_MAX,
-				      __locale_charset (), &state)) > 0) {
-                    if (wc == '%')
+				      __locale_charset (), &state)) != 0) {
+		    if (n < 0) {
+			memset (&state, 0, sizeof state);
+			n = 1;
+		    }
+                    else if (wc == '%')
                         break;
                     fmt += n;
 		}

It works, but I'm feeling uneasy about this.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]