This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [PATCH] gethex doesn't cope with multibyte decimalpoints
On Feb 6 12:31, Howland Craig D (Craig) wrote:
> A question related to the decimal point search, new method:
> + while (s0 < s1) {
> + if (!strncmp ((char *) s0, (char *) decimalpoint,
> dplen)) {
> + s0 += dplen;
>
> This appears to assume that the decimal is either a single normal or
> multi-byte character--as opposed to the original code which assumed that
> it was a single byte (plain char). (It also assumes that if it is mb,
Well, sure. Isn't that what I wrote in my OP? Treating decimalpoint
as singlebyte char is not working in multibyte charsets. That's the
whole reason for my patch.
> So perhaps should it be the following instead?
> + while (s0 < s1) {
> + if (!strncmp ((char *) s0, (char *) decimalpoint,
> dplen)) {
> + s0++;
> (That is, step through 1 byte at a time instead of by dlen at a time?)
That's incorrect. If decimalpoint is some multibyte char you will hit
the next followup byte of the MB char in the next iteration. It will be
incorrectly converted to a hex digit. If you recognize a certain MB
char, you must skip it entirely.
Corinna
--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat