Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: can this be done recursively |
| Date | 2015-04-22 18:56 -0400 |
| Organization | Self |
| Message-ID | <55382705.7090007@verizon.net> (permalink) |
| References | <b0319922-1b5e-48d2-8cc7-5cd1a5e866e6@googlegroups.com> <e07362d0-5d7e-4243-acc6-bcf384298b69@googlegroups.com> <87egnc9brp.fsf@bsb.me.uk> <5538009B.9090306@verizon.net> <87383rak09.fsf@bsb.me.uk> |
On 04/22/2015 06:14 PM, Ben Bacarisse wrote: > James Kuyper <jameskuyper@verizon.net> writes: ... >> In the unlikely event that UCHAR_MAX > INT_MAX, getchar()'s definition >> combined with the reversibility requirements for I/O on binary streams >> (7.21.2p3) imply that getchar() must return EOF when reading a byte that >> was written by calling putchar(EOF). > > I am not sure this 100% right. The reversibility is phrased in terms of > characters and I can't persuade myself that putchar(EOF) must write a > character that will result in EOF being returned by getchar. Might such > an implementation not use a character set smaller than the set of char > values -- for example, masking off one or more bits? What do such > implementations normally do, or aren't there any? I've always assumed that 7.21.2p3 was using "character" with the meaning specified by 3.7.1: "〈C〉 bit representation that fits in a byte", or perhaps 3.7 itself: "〈abstract〉 member of a set of elements used for the organization, control, or representation of data." The definition of "multibyte character" refers to the extended character set, and the definition of "wide character" refers to the current locale, but neither the <abstract> nor the <C> definition of "character" itself are text-oriented; they refer only to bits, byte, and data. All C I/O, including binary I/O of non-character types by functions such as fwrite() and fread(), is ultimately defined in terms of the behavior of fputc() and fgetc() operating on the individual bytes of the representation of those object. I think it would therefore be inappropriate to interpret "character", as it is used in the definition of those functions, as restricted to those values of char type that are actually defined as representing text characters. Writing a double to a binary file with fwrite(), and reading it back again with fread(), would not be guaranteed to produce a result representing the same value, if fputc() or fgetc() were allowed to, as you suggest, mask off bits. That would break an awful lot of my code.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
can this be done recursively G G <gdotone@gmail.com> - 2015-04-19 09:50 -0700
Re: can this be done recursively Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-19 21:14 +0100
Re: can this be done recursively G G <gdotone@gmail.com> - 2015-04-19 14:20 -0700
Re: can this be done recursively Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2015-04-19 16:32 -0400
Re: can this be done recursively G G <gdotone@gmail.com> - 2015-04-19 14:25 -0700
Re: can this be done recursively Keith Thompson <kst-u@mib.org> - 2015-04-19 14:09 -0700
Re: can this be done recursively G G <gdotone@gmail.com> - 2015-04-19 14:35 -0700
Re: can this be done recursively jt@toerring.de (Jens Thoms Toerring) - 2015-04-19 22:57 +0000
Re: can this be done recursively G G <gdotone@gmail.com> - 2015-04-20 04:30 -0700
Re: can this be done recursively Richard Heathfield <rjh@cpax.org.uk> - 2015-04-20 12:49 +0100
Re: can this be done recursively G G <gdotone@gmail.com> - 2015-04-20 05:28 -0700
Re: can this be done recursively jt@toerring.de (Jens Thoms Toerring) - 2015-04-20 13:09 +0000
Re: can this be done recursively G G <gdotone@gmail.com> - 2015-04-22 09:42 -0700
Re: can this be done recursively Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-22 10:12 -0700
Re: can this be done recursively James Kuyper <jameskuyper@verizon.net> - 2015-04-22 13:29 -0400
Re: can this be done recursively Ben Bacarisse <ben.lists@bsb.me.uk> - 2015-04-22 20:57 +0100
Re: can this be done recursively James Kuyper <jameskuyper@verizon.net> - 2015-04-22 16:12 -0400
Re: can this be done recursively Ben Bacarisse <ben.lists@bsb.me.uk> - 2015-04-22 23:14 +0100
Re: can this be done recursively James Kuyper <jameskuyper@verizon.net> - 2015-04-22 18:56 -0400
Re: can this be done recursively G G <gdotone@gmail.com> - 2015-04-23 07:59 -0700
csiph-web