This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [PATCH] stdio/vfscanf.c: Handle non-ASCII chars and invalid bytes in format string
- From: Corinna Vinschen <vinschen at redhat dot com>
- To: newlib at sourceware dot org
- Date: Tue, 19 Jan 2010 22:15:43 +0100
- Subject: Re: [PATCH] stdio/vfscanf.c: Handle non-ASCII chars and invalid bytes in format string
- References: <416096c61001121410x6047bd4aj4ee374c4e913befb@mail.gmail.com>
- Reply-to: newlib at sourceware dot org
Jeff? Ping?
On Jan 12 22:10, Andy Koppe wrote:
> Similarly to Corinna's patch for vfprintf, here's a patch for vfscanf
> that corrects its handling of non-ASCII chars and allows invalid bytes
> in the format string.
>
> The code currently has a comparison between a signed and an unsigned
> char at line 552, which causes matching of any non-ASCII characters in
> the format string to always fail. It also wrongly resets the multibyte
> conversion state after every character. (The standard at
> http://www.opengroup.org/onlinepubs/000095399/functions/fscanf.html
> says "the format is a character string, beginning and ending in its
> initial shift state"). Finally, %lc and %ls conversions use the same
> conversion state as is used for the format string, thereby clobbering
> the format string state.
>
> The patch addresses those issues and also allows invalid bytes in the
> format string to be matched. (Invalid bytes currently cause the format
> string parsing to go backwards, since __mbtowc in line 510 will return
> -1 in that case.)
>
> ChangeLog:
> * libc/stdio/vfscanf.c (__SVFSCANF_R): Fix handling of non-ASCII
> characters and allow invalid bytes in format string.
>
> Andy
--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat