Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++,comp.lang.c Subject: Re: Text editor project in C Date: Mon, 26 Apr 2021 16:07:46 -0700 Organization: None to speak of Lines: 71 Message-ID: <87eeewbq65.fsf@nosuchdomain.example.com> References: <877dkohi65.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="a57ae5a4f402968e927cf79882d3975a"; logging-data="4042"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+HjTggdlIsLruBQbRAtzb9" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cancel-Lock: sha1:jNE0CUtcVrNFJJS7Bt7LdOYPboA= sha1:SO97PIHgENIj8fhj7QlhUbhk0LY= Xref: csiph.com comp.lang.c++:79310 comp.lang.c:160384 Eli the Bearded <*@eli.users.panix.com> writes: > In comp.lang.c, Ben Bacarisse wrote: >> There was no C code 50 years ago. This is a bit of a quibble since >> there was C code we'd just about recognise in about 1973 or 4, but some >> of it would fool even gcc today. The biggest change was the great = >> to = switch. This silently changed the meaning of a lot of code. > > Maybe five years ago I tried to compile some C code I found in buried > in a tar file on a dusty ftp server[*]. The READ_ME implied it was last > touched in June of 1980, the filename agreed with the year. > > Things I found tricky about the code: > > 1. It predated printf being called that. I think it was just using > print(). And that used "-lS" in the Makefile. I believe printf is older than C. A form of it existed by that name in B, and it's used (with an implementation presented) in the 1974 and 1975 editions of the C manual. But a particular program might have chosen to use something else. > 2. Prototypes? Who needs em? ("#include "? What, why?) Prototypes still aren't mandatory, though calling printf without a visible declaration has been a constraint violation since 1999 (and undefined behavior in C89/C90, but very likely to work). > 3. No need to declare ints, eg: > main(argc, argv) > char **argv; > { Valid in C90. Add "int" to main and argc and it's still valid (but obsolescent). > 4. Structs are implicitly unions: > struct plot { > char p_x; > char p_y; > } p_plot[LIM_PLOTS]; > > /* ... */ > > struct { > int p_xy; /* used to set/transfer entire plot */ > }; A struct member name implied a type and offset, and was not tied to the struct type. That's why a lot of member names have unique prefixes, like tm_sec and friends. I think C89/C90 changed that. > 5. Implicit in above: seems like there is the expectation that > sizeof(int) == 2. There were implementations with sizeof(int)!=2 as early as the late 1980s, but there's never been any shortage of non-portable code. > Items 1 to 3 made things difficult. Items 4 and 5 meant actual code > audits were needed. > > [*] I last saw it here, but that 404's today: > http://mirror.cc.vt.edu/pub2/Ancient_Unix/Applications/Shoppa_Tapes/usenix_80_delaware.tar.gz > > Elijah > ------ > the .c files were easier to make sense of than the .o files included -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Philips Healthcare void Void(void) { Void(); } /* The recursive call of the void */