/* rev.c - reverse chars within each line */
/* ufilter2.c - prototype filter program - line (actually record) oriented */
#include <stdio.h>
#include <algol68.h>
#define BUFSIZ 4096
char buffer[BUFSIZ];
extern int $$ferr;
main(argc,argv)
char **argv;
BEGIN
register int	howlong;	/* char length of this record */
register char temp,*p,*q;
	WHILE	(!feof(stdin))
	DO	howlong = fget(buffer,BUFSIZ,stdin);
		IF	(ferror(stdin))
		THEN	error("read failure $$ferr=%oo\7\n",$$ferr);
		FI;
		IF	(feof(stdin))
		THEN	exit();
		FI;
		FOR	(p=buffer,q=buffer+howlong-2;	p<q;	p++,q--)
		DO	temp = *q;
			*q = *p;
			*p = temp;
		OD;
		fput(buffer,howlong,stdout);
		IF	(ferror(stdout))
		THEN	error("write failed $$ferr=%oo\7\n",$$ferr);
		FI;
	OD;
END
/* end: ufilter2.c */
/* end: rev.c */
