From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11695 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Different scanf behaviour compared to glibc Date: Fri, 7 Jul 2017 16:41:30 -0400 Message-ID: <20170707204130.GI1627@brightrain.aerifal.cx> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1499460106 14001 195.159.176.226 (7 Jul 2017 20:41:46 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 7 Jul 2017 20:41:46 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-11708-gllmg-musl=m.gmane.org@lists.openwall.com Fri Jul 07 22:41:42 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1dTa4J-0003KY-IW for gllmg-musl@m.gmane.org; Fri, 07 Jul 2017 22:41:39 +0200 Original-Received: (qmail 3921 invoked by uid 550); 7 Jul 2017 20:41:43 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 3900 invoked from network); 7 Jul 2017 20:41:42 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:11695 Archived-At: On Fri, Jul 07, 2017 at 10:53:34PM +0300, Evgeni Stebaev wrote: > Hi! > > sscanf returns 0 for the following code using musl, but glibc returns 1. > %15s cannot be used here since it stops on whitespace, but it's required to > get all remaining data after getting other fields with sscanf (not included > in this example). > > #include > #include > > int main(void) { > char data[16]; > memset(data, '\0', sizeof(data)); > int res = sscanf("abcde", "%15c", data); > printf("parse: %d %s\n", res, data); > return 0; > } This is a known glibc bug (at least #12701, maybe duplicated in others) that they were historically unwilling to fix. musl's behavior matches what's required by the C standard. You might be able to use %[ to achieve what you want. Rich