allprint.c 458 B

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