etc.c 950 B

123456789101112131415161718192021222324252627282930
  1. #include "etc.h"
  2. #include <ctype.h>
  3. /*===========================================================================*/
  4. /* "true", "false" 及妐儂昫毛忒允 */
  5. /*===========================================================================*/
  6. char * wonx_true_false(int b)
  7. {
  8. char * s[] = {"false", "true"};
  9. b = b ? 1 : 0;
  10. return (s[b]);
  11. }
  12. /*===========================================================================*/
  13. /* 妐儂及請恘 */
  14. /*===========================================================================*/
  15. int wonx_print_character(FILE * fp, unsigned char c)
  16. {
  17. if (c == '\n') fprintf(fp, "\\n");
  18. else if (c == '\r') fprintf(fp, "\\r");
  19. else if (c == '\t') fprintf(fp, "\\t");
  20. else if (c == ' ' ) fprintf(fp, "\\s");
  21. else if (isprint(c)) fputc(c, fp);
  22. else fprintf(fp, "^%02x", (int)c);
  23. fflush(fp);
  24. return (0);
  25. }