Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jdee/xmas
Restoration of a classic K&R C program
https://github.com/jdee/xmas
c k-and-r
Last synced: 2 months ago
JSON representation
Restoration of a classic K&R C program
- Host: GitHub
- URL: https://github.com/jdee/xmas
- Owner: jdee
- Created: 2019-07-23T07:41:12.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-07-26T16:01:15.000Z (over 5 years ago)
- Last Synced: 2024-09-30T01:22:44.303Z (3 months ago)
- Topics: c, k-and-r
- Language: C
- Homepage:
- Size: 12.7 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This is without a doubt one of the greatest computer programs ever written
and will forever stand as a monument to skill and artistry in defiance of
standards, maintainability and productivity. Note the entire program is a
single line of code.It is regrettably difficult to compile K&R C in 2019, so I've updated it to
ANSI C to build and run cleanly with GCC, Clang & Visual C.Some changes were necessary to compile. Others suppress warnings without
resorting to compiler options or pragmata. All changes have been made in
limited ways to minimize the intrusion and preserve the opacity and spirit
of the original code.This surgery is limited to
1. Some preprocessor directives and a typedef before main() for the purpose of
type conversion.
2. Conversion of argument syntax from K&R to ANSI.
3. Conformity with the ANSI signature of main().
4. Some stack variables at the start of main to facilitate type safety
and conformity.
5. Explicitly casting the return value of main.Jimmy Dee
July 23, 2019To build and run, simply type:
Unix:
```bash
make hay
```Windows:
```
cl xmas.c
xmas
```
or use the Visual Studio Solution xmas.sln in the repo.The original K&R:
```c
/*
LEAST LIKELY TO COMPILE SUCCESSFULLY:
Ian Phillipps, Cambridge Consultants Ltd., Cambridge, EnglandAn appropriate program for December 25th, this consists primarily of
calls to main() combined by a lot of the ternary conditional (?:)
operators. Have you ever seen a more forceful return? The judges note
that this program looked like what you would get by pounding on the keys
of a type writer at random.Note -- I have made a minor correction (for spelling) to line 47, where I
added a missing comma at column 59.
*/main(t,_,a)
char
*
a;
{
return!0