9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Geoff Collyer <geoff@collyer.net>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] gcc/plan9
Date: Wed, 16 Jul 2003 17:10:52 -0700	[thread overview]
Message-ID: <18e61d55c20c0b4c1a12231e91b0c831@collyer.net> (raw)
In-Reply-To: <003301c34b6c$b1fe9ab0$2a8be793@gli.cas.cz>

Testing that *scanf found exactly the number of items you expected is
usually the right thing to do.  scanf and fscanf can return EOF (-1),
so a test against zero will usually be inappropriate.
So the last example you gave,

	if (sscanf(str+(*pos),"%d",&tag)==1)

should be used everywhere, including linux (and tag should be an int,
not a long nor a short).

strings.h is an archaism and shouldn't be needed nor included.  All
ANSI C implementations (hosted ones, anyway) must provide string.h,
and it's been 13 years since the first ANSI C standard, so everybody
really ought to have string.h by now.

GNU configure and much GNU software go out of their way to support
aged or deficient C implementations.  I think it's no longer worth
worrying about pre-ANSI implementations, except for amusement (e.g.,
running V7 on a PDP-11 simulator).  As for broken implementations,
with C News, we found that it was generally better not to contort our
code to accommodate bugs in somebody's C implementation, but to
publish the bug (perhaps including a pointer to the section of the
current C standard that forbids the erroneous behaviour), a test case
to demonstrate it, and a workaround, and to distribute the whole
bundle widely.  Once a vendor realises that it really is his bug and
the customers know it and demand a fix, he tends to fix the bug pretty
quickly.  We found astonishing bugs in production C implementations,
some of which had been around for a long time, and I think helped to
get them fixed.



  reply	other threads:[~2003-07-17  0:10 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-16  7:34 pac
2003-07-17  0:10 ` Geoff Collyer [this message]
2003-07-17  0:15   ` boyd, rounin
2003-07-17  0:35     ` Geoff Collyer
2003-07-17  0:49       ` boyd, rounin
2003-07-17  2:07       ` Russ Cox
2003-07-17  2:22         ` Dan Cross
2003-07-17  2:33           ` William Josephson
2003-07-17  2:44             ` Dan Cross
2003-07-17  2:57               ` boyd, rounin
2003-07-17  2:59             ` Skip Tavakkolian
2003-07-18  8:45           ` Clint Olsen
2003-07-18  9:14             ` boyd, rounin
2003-07-18  9:20               ` boyd, rounin
2003-07-18 17:38                 ` Clint Olsen
2003-07-18 20:39                   ` boyd, rounin
2003-07-18 21:05                     ` Jack Johnson
2003-07-18 22:12                       ` northern snowfall
2003-07-21  8:27                       ` Douglas A. Gwyn
2003-07-17  2:31       ` William Josephson
2003-07-17  0:24   ` boyd, rounin
2003-07-17  0:40   ` boyd, rounin
2003-07-18 11:55 pac

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=18e61d55c20c0b4c1a12231e91b0c831@collyer.net \
    --to=geoff@collyer.net \
    --cc=9fans@cse.psu.edu \
    /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.
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).