OpenVMS Source Code Demos

UNIX_HATER

//--------------------------------------------------------------------------------
// title  : unix_hater.c
// author : Neil Rieck
// created: 2012-11-28
// purpose: does the example program shown in the "UNIX Haters Hand Book" compile?
//--------------------------------------------------------------------------------
//
//	declarations to enable compilation of the same code (not necessarily useful)
//
#include <stdio.h>
#include <stdlib.h>

int e;
int C;
int R;
int you;
int *u;

int P(char* yada){
	printf("%s", yada);
	return(1);
}

main() {
	u = &you;					// initialize pointer

//-----------------------------------------------------------------------------
//	This syntax is from our "UNIX Hater's Hand Book" PDF
//	which does not compile (look at the middle term in the for statement)
//	This happens all the time when copying to/from PDF (the author
//	probably did not double-check after pasting into Adobe Publisher)
//
//	for(; P("\n"),R=; P("|"))
//		for(e=C; e=P("_"+(*u++/8)%2))P("|"+(*u/4)%2);
//-----------------------------------------------------------------------------
//	this syntax is from the web
//		http://soup.fin.io/post/87786406/We-stopped-when-we-got-a-clean
//	and it does compile.
//
	for(; P("\n"),R--;P("|"))
		for(e=C;e--;P("_"+(*u++/8)%2))P("| "+(*u/4)%2);
//-----------------------------------------------------------------------------
}