delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/08/07/14:23:53

Date: Thu, 7 Aug 2003 17:32:34 +0200 (MET DST)
X-Sybari-Space: 00000000 00000000 00000000 00000000
From: Martin Stromberg <eplmst AT epl DOT ericsson DOT se>
Message-Id: <200308071532.RAA17010@lws256.lu.erisoft.se>
To: djgpp-workers AT delorie DOT com
Subject: (fwd) Re: sscanf's return value
Newsgroups: comp.std.c
Reply-To: djgpp-workers AT delorie DOT com

Path: antares.lu.erisoft.se!atik.lu.erisoft.se!erinews.ericsson.se!newsfeed.sunet.se!news01.sunet.se!uninett.no!newsfeed1.enitel.no!newsfeed1.e.nsc.no!nsc.no!nextra.com!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!news-stu1.dfn.de!news.belwue.de!news-ge.switch.ch!switch.ch!cern.ch!news
From: Dan DOT Pop AT cern DOT ch (Dan Pop)
Newsgroups: comp.std.c
Subject: Re: sscanf's return value
Date: 4 Aug 2003 12:02:18 GMT
Organization: DESY Zeuthen
Lines: 46
Message-ID: <bgli0a$qi8$2 AT sunnews DOT cern DOT ch>
References: <bgatrp$r0u$5 AT sunnews DOT cern DOT ch> <3f29164b DOT 214278 AT news DOT siemens DOT at>     <Pine DOT LNX DOT 4 DOT 55L-032 DOT 0307311425590 DOT 8512 AT unix48 DOT andrew DOT cmu DOT edu> <bgbsd2$7ch$1 AT news DOT tuwien DOT ac DOT at> <Pine DOT LNX DOT 4 DOT 55L-032 DOT 0307312225220 DOT 25522 AT unix46 DOT andrew DOT cmu DOT edu>
NNTP-Posting-Host: lxplus011.cern.ch
X-Trace: sunnews.cern.ch 1059998538 27208 (None) 137.138.161.74
X-Complaints-To: news AT sunnews DOT cern DOT ch
User-Agent: nn/6.6.2
Xref: antares.lu.erisoft.se comp.std.c:38916

In <Pine DOT LNX DOT 4 DOT 55L-032 DOT 0307312225220 DOT 25522 AT unix46 DOT andrew DOT cmu DOT edu> "Arthur J. O'Dwyer" <ajo AT andrew DOT cmu DOT edu> writes:


>On Thu, 31 Jul 2003, Stefan Farfeleder wrote:
>>
>> Arthur J. O'Dwyer wrote:
>> > On Thu, 31 Jul 2003, Bruce Wheeler wrote:
>> >> On 31 Jul 2003 11:17:13 GMT, Dan DOT Pop AT cern DOT ch (Dan Pop) wrote:
>> >> >
>> >> >    #include <stdio.h>
>> >> >
>> >> >    int main()
>> >> >    {
>> >> >        int rc = sscanf("123", "%*[0123456789]%*c");
>> >> >        printf("%d\n", rc);
>> >> >        return 0;
>> >> >    }
>>
>> > gcc, presumably the compiler Dan used too, reports -1 and 1.
>> > I hadn't thought to try the second case when I posted in c.l.c,
>> > so now I agree that gcc's implementation must be broken, although
>> > I'm still not sure what the "right" answers should be.
>>
>> GCC alone is not a complete C implementation, it needs your system's C
>> library which seems to be broken.
>>
>>     $ uname -rs
>>     FreeBSD 5.1-CURRENT
>
> % uname -rs
> Linux 2.4.21
>
>Thanks for the correction.  I must have been extra clueless today,
>because I see DJGPP produces the right answers (0 and 1) - which
>means I must've only tested the code on the Linux implementation.
>... I wonder how one would go about rectifying such a thing...

OTOH, DJGPP will output 0 even if the input string is "" in the code
quoted above.  So, DJGPP's sscanf is broken, too, just in a different
way :-)

Dan
-- 
Dan Pop
DESY Zeuthen, RZ group
Email: Dan DOT Pop AT ifh DOT de

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019