mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH] Byte-based C locale, draft 2
Date: Tue, 16 Jun 2015 00:35:02 -0400	[thread overview]
Message-ID: <20150616043502.GF1173@brightrain.aerifal.cx> (raw)
In-Reply-To: <20150616042639.GE1173@brightrain.aerifal.cx>

[-- Attachment #1: Type: text/plain, Size: 834 bytes --]

On Tue, Jun 16, 2015 at 12:26:39AM -0400, Rich Felker wrote:
> On Sat, Jun 13, 2015 at 03:06:55AM -0400, Rich Felker wrote:
> > diff --git a/src/multibyte/btowc.c b/src/multibyte/btowc.c
> > index 9d2c3b1..8de060f 100644
> > --- a/src/multibyte/btowc.c
> > +++ b/src/multibyte/btowc.c
> > @@ -1,7 +1,10 @@
> > -#include <stdio.h>
> >  #include <wchar.h>
> > +#include <stdlib.h>
> > +#include "internal.h"
> >  
> >  wint_t btowc(int c)
> >  {
> > -	return c<128U ? c : EOF;
> > +	if (c < 128U) return c;
> > +	if (MB_CUR_MAX==1) return CODEUNIT(c);
> > +	return WEOF;
> >  }
> 
> This was mildly buggy before the patch, and worse with it -- c==EOF
> will no longer produce WEOF. Fixed the old bug and updating the patch.

Updated version of this file's patch (against the fixed old code which
I already committed) is attached.

Rich

[-- Attachment #2: bytelocale_new_btowc.diff --]
[-- Type: text/plain, Size: 447 bytes --]

diff --git a/src/multibyte/btowc.c b/src/multibyte/btowc.c
index 29cb798..a7369a1 100644
--- a/src/multibyte/btowc.c
+++ b/src/multibyte/btowc.c
@@ -1,8 +1,11 @@
 #include <stdio.h>
 #include <wchar.h>
+#include <stdlib.h>
+#include "internal.h"
 
 wint_t btowc(int c)
 {
-	c = (unsigned char)c;
-	return c<128U ? c : EOF;
+	if ((unsigned char)c < 128) return (unsigned char)c;
+	if (MB_CUR_MAX==1 && c!=EOF) return CODEUNIT(c);
+	return WEOF;
 }

      reply	other threads:[~2015-06-16  4:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-06 21:40 [PATCH] Byte-based C locale, draft 1 Rich Felker
2015-06-06 22:39 ` Harald Becker
2015-06-06 23:10   ` Rich Felker
2015-06-06 23:59     ` Harald Becker
2015-06-07  0:24       ` Rich Felker
2015-06-07 23:59         ` Build option to disable locale [was: Byte-based C locale, draft 1] Harald Becker
2015-06-08  0:28           ` Josiah Worcester
2015-06-08  1:57             ` Harald Becker
2015-06-08  2:36               ` Rich Felker
2015-06-08  3:35                 ` Harald Becker
2015-06-08  3:51                   ` Josiah Worcester
2015-06-08  0:33           ` Rich Felker
2015-06-08  2:46             ` Harald Becker
2015-06-08  4:06               ` Rich Felker
2015-06-09  3:20               ` Isaac Dunham
2015-06-09  4:27                 ` Rich Felker
2015-06-07  1:17 ` [PATCH] Byte-based C locale, draft 1 Rich Felker
2015-06-07  2:50 ` Rich Felker
2015-06-13  7:06   ` [PATCH] Byte-based C locale, draft 2 Rich Felker
2015-06-16  4:26     ` Rich Felker
2015-06-16  4:35       ` Rich Felker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150616043502.GF1173@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).