xref: /plan9/sys/src/ape/lib/l/allprint.c (revision 3e12c5d1bb89fc02707907988834ef147769ddaf)
1 #include	<libl.h>
2 #include	<stdio.h>
3 
4 extern	FILE*	yyout;
5 
6 int
printable(int c)7 printable(int c)
8 {
9 	return 040 < c && c < 0177;
10 }
11 
12 void
allprint(char c)13 allprint(char c)
14 {
15 
16 	switch(c) {
17 	case '\n':
18 		fprintf(yyout,"\\n");
19 		break;
20 	case '\t':
21 		fprintf(yyout,"\\t");
22 		break;
23 	case '\b':
24 		fprintf(yyout,"\\b");
25 		break;
26 	case ' ':
27 		fprintf(yyout,"\\\bb");
28 		break;
29 	default:
30 		if(!printable(c))
31 			fprintf(yyout,"\\%-3o",c);
32 		else
33 			c = putc(c,yyout);
34 			USED(c);
35 		break;
36 	}
37 	return;
38 }
39