[comp.sources.apple2] v001SRC016: show -- Display Non-Printing Characters

jac@yoko.rutgers.edu (Jonathan A. Chandross) (12/02/90)

Submitted-by: NONE
Posting-number: Volume 1, Source:16
Archive-name: util/show
Architecture: ANY_2
Version-number: 1.00

This utility displays non-rpinting characters in a file.

Enjoy.


=show.c
-
-/*
- * show.c
- *
- * Display non-printing chars in a file.
- *	Non-printing character mappings:
- *		CHARACTER	DISPLAYED AS
- * 		tab 		>
- * 		newline 	$
- * 		control X 	~X	where X is any control character
- * 		delete 		~~
- * 	Newlines and tabs are also echoed to output as control characters.
- *
- * Usage:
- * 	show [file_1] [file_2] [file_3] [...]
- *
- * 	If no file is specified, show reads from standard in. 
- *
- * Contributed Anonymously.  Written: November 1983
- *
- * Version 1.00
- *
- */
-
-#include "stdio.h"
-
-#define BLANK ' '
-#define TAB   '\t'
-#define NL    '\n'
-
-main(argc, argv)
-int argc ;
-char *argv[] ;
-{
-	FILE *input ;
-
-
-	argc-- ; argv++ ;
-
-	if( argc == 0 )
-		show( stdin ) ;
-
-	else
-		for( ; argc>0 ; argc--,argv++)
-			if( (input=fopen(*argv,"r")) == NULL ) {
-				fprintf(stderr, "show: can't open %s\n", *argv) ;
-				exit(1) ;
-			}
-			else {
-				show(input) ;
-				fclose( input ) ;
-			}
-
-	exit(0) ;
-
-} /* end main */
-
-/* show - print invisible chars */
-
-show( in )
-FILE *in ;
-{
-	int c ;
-
-
-	while( (c=agetc(in)) != EOF )
-		if( c == NL ) {
-			aputc( '$', stdout ) ;
-			aputc( NL, stdout ) ;
-		}
-		else if( c == TAB )
-			aputc( '>', stdout ) ;
-		else if( c < BLANK ) {
-			aputc( '~', stdout ) ;
-			aputc( c+'@', stdout ) ;
-		}
-		else if( c == 0x7f ) {
-			aputc( '~', stdout ) ;
-			aputc( '~', stdout ) ;
-		}
-		else
-			aputc( c, stdout ) ;
-
-} /* end show */
-
+ END OF ARCHIVE