Subversion Repositories Kolibri OS

Rev

Rev 4874 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1.  
  2. /*
  3. FUNCTION
  4.         <<isprint>>, <<isgraph>>---printable character predicates
  5.  
  6. INDEX
  7.         isprint
  8. INDEX
  9.         isgraph
  10.  
  11. ANSI_SYNOPSIS
  12.         #include <ctype.h>
  13.         int isprint(int <[c]>);
  14.         int isgraph(int <[c]>);
  15.  
  16. TRAD_SYNOPSIS
  17.         #include <ctype.h>
  18.         int isprint(<[c]>);
  19.         int isgraph(<[c]>);
  20.  
  21.  
  22. DESCRIPTION
  23. <<isprint>> is a macro which classifies ASCII integer values by table
  24. lookup.  It is a predicate returning non-zero for printable
  25. characters, and 0 for other character arguments.
  26. It is defined only if <[c]> is representable as an unsigned char or if
  27. <[c]> is EOF.
  28.  
  29. You can use a compiled subroutine instead of the macro definition by
  30. undefining either macro using `<<#undef isprint>>' or `<<#undef isgraph>>'.
  31.  
  32. RETURNS
  33. <<isprint>> returns non-zero if <[c]> is a printing character,
  34. (<<0x20>>--<<0x7E>>).
  35. <<isgraph>> behaves identically to <<isprint>>, except that the space
  36. character (<<0x20>>) is excluded.
  37.  
  38. PORTABILITY
  39. <<isprint>> and <<isgraph>> are ANSI C.
  40.  
  41. No supporting OS subroutines are required.
  42. */
  43.  
  44. #include <_ansi.h>
  45. #include <ctype.h>
  46.  
  47. #undef isgraph
  48. int
  49. _DEFUN(isgraph,(c),int c)
  50. {
  51.         return(__ctype_ptr__[c+1] & (_P|_U|_L|_N));
  52. }
  53.  
  54.  
  55. #undef isprint
  56. int
  57. _DEFUN(isprint,(c),int c)
  58. {
  59.         return(__ctype_ptr__[c+1] & (_P|_U|_L|_N|_B));
  60. }
  61.  
  62.