xref: /plan9-contrib/sys/src/ape/lib/l/allprint.c (revision 219b2ee8daee37f4aad58d63f21287faa8e4ffdc)
1 #include	<libl.h>
2 #include	<stdio.h>
3 
4 extern	FILE*	yyout;
5 
6 int
7 printable(int c)
8 {
9 	return 040 < c && c < 0177;
10 }
11 
12 void
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