isctype.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* $OpenBSD: isctype.c,v 1.11 2005/08/08 08:05:34 espie Exp $ */
  2. /*
  3. * Copyright (c) 1989 The Regents of the University of California.
  4. * All rights reserved.
  5. * (c) UNIX System Laboratories, Inc.
  6. * All or some portions of this file are derived from material licensed
  7. * to the University of California by American Telephone and Telegraph
  8. * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  9. * the permission of UNIX System Laboratories, Inc.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions and the following disclaimer.
  16. * 2. Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the distribution.
  19. * 3. Neither the name of the University nor the names of its contributors
  20. * may be used to endorse or promote products derived from this software
  21. * without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  24. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  27. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  29. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  30. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  32. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  33. * SUCH DAMAGE.
  34. */
  35. #include <ctype.h>
  36. #include <stdio.h>
  37. #include "ctype_private.h"
  38. #undef isalnum
  39. int
  40. isalnum(int c)
  41. {
  42. return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & (_U|_L|_N)));
  43. }
  44. #undef isalpha
  45. int
  46. isalpha(int c)
  47. {
  48. return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & (_U|_L)));
  49. }
  50. #undef isblank
  51. int
  52. isblank(int c)
  53. {
  54. return (c == ' ' || c == '\t');
  55. }
  56. #undef iscntrl
  57. int
  58. iscntrl(int c)
  59. {
  60. return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _C));
  61. }
  62. #undef isdigit
  63. int
  64. isdigit(int c)
  65. {
  66. return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _N));
  67. }
  68. #undef isgraph
  69. int
  70. isgraph(int c)
  71. {
  72. return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & (_P|_U|_L|_N)));
  73. }
  74. #undef islower
  75. int
  76. islower(int c)
  77. {
  78. return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _L));
  79. }
  80. #undef isprint
  81. int
  82. isprint(int c)
  83. {
  84. return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & (_P|_U|_L|_N|_B)));
  85. }
  86. #undef ispunct
  87. int
  88. ispunct(int c)
  89. {
  90. return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _P));
  91. }
  92. #undef isspace
  93. int
  94. isspace(int c)
  95. {
  96. return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _S));
  97. }
  98. #undef isupper
  99. int
  100. isupper(int c)
  101. {
  102. return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & _U));
  103. }
  104. #undef isxdigit
  105. int
  106. isxdigit(int c)
  107. {
  108. return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)c] & (_N|_X)));
  109. }