From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,df854b5838c3e14 X-Google-Attributes: gid109fba,public X-Google-Thread: 1014db,df854b5838c3e14 X-Google-Attributes: gid1014db,public X-Google-Thread: 103376,df854b5838c3e14 X-Google-Attributes: gid103376,public X-Google-Thread: 10db24,fec75f150a0d78f5 X-Google-Attributes: gid10db24,public From: dewar@cs.nyu.edu (Robert Dewar) Subject: Re: ANSI C and POSIX (was Re: C/C++ knocks the crap out of Ada) Date: 1996/04/10 Message-ID: #1/1 X-Deja-AN: 146861950 references: <4k9qhe$65r@solutions.solon.com> <4kb2j8$an0@solutions.solon.com> <4khevn$26a@janus.pec.co.nz> organization: Courant Institute of Mathematical Sciences newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++,comp.edu Date: 1996-04-10T00:00:00+00:00 List-Id: John suggested " /* Try to protect the user a little bit from left over garbage: */ memset(&buf[avail], nbytes-avail, 0); /* zero out buf[avail..nbytes-1] */ return avail;" Interesting, the spec is really not clear on whether this is a valid implementation. I can easily imagine a programmer whose unwritten rules would rule out this interpretation and who might assume that code which (a) preinitialized the buffer to blanks (b) used read to read into part of this buffer should be able to expect trailing spaces and not zeroes, but here again, the spec is insufficiently clear I would say, so this is another nice example of possible portability problems that come from a vague spec. That trailing spaces code will probably work in most (all) implementations of read, and I can imagine some (injudicious? or perhaps informed by a different set of "unwritten rules") programmer assuming it would work. Then an implementatoin would do as John suggested, which certainly is not unreasonable, and lo and behold, another portability problem that could have been prevented by a precise spec.