1 // 2 // aegis - project change supervisor 3 // Copyright (C) 1996, 1998, 2004-2008 Peter Miller 4 // 5 // This program is free software; you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation; either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program. If not, see 17 // <http://www.gnu.org/licenses/>. 18 // 19 20 #include <common/ac/stddef.h> 21 #include <common/ac/ctype.h> 22 #include <common/ac/wctype.h> 23 24 25 #ifndef HAVE_ISWPRINT 26 27 #ifdef iswprint 28 #undef iswprint 29 #endif 30 31 int iswprint(wint_t c)32iswprint(wint_t c) 33 { 34 // 35 // Assume characters over 256 are printable. Assume characters 36 // under 256 are either ASCII or Latin-1. These are dumb 37 // assumptions, but real i18n support will provide a real 38 // iswprint function. 39 // 40 return (c >= 256 || isprint((unsigned char)c)); 41 } 42 43 44 #ifdef iswspace 45 #undef iswspace 46 #endif 47 48 int iswspace(wint_t c)49iswspace(wint_t c) 50 { 51 // 52 // Assume characters over 256 are letters. Assume characters 53 // under 256 are either ASCII or Latin-1. These are dumb 54 // assumptions, but real i18n support will provide a real 55 // iswspace function. 56 // 57 return (c < 256 && isspace((unsigned char)c)); 58 } 59 60 61 #ifdef iswpunct 62 #undef iswpunct 63 #endif 64 65 int iswpunct(wint_t c)66iswpunct(wint_t c) 67 { 68 // 69 // Assume characters over 256 are letters. Assume characters 70 // under 256 are either ASCII or Latin-1. These are dumb 71 // assumptions, but real i18n support will provide a real 72 // iswpunct function. 73 // 74 return (c < 256 && ispunct((unsigned char)c)); 75 } 76 77 78 #ifdef iswupper 79 #undef iswupper 80 #endif 81 82 int iswupper(wint_t c)83iswupper(wint_t c) 84 { 85 return (c < 256 && isupper((unsigned char)c)); 86 } 87 88 89 #ifdef iswlower 90 #undef iswlower 91 #endif 92 93 int iswlower(wint_t c)94iswlower(wint_t c) 95 { 96 return (c < 256 && islower((unsigned char)c)); 97 } 98 99 100 #ifdef iswdigit 101 #undef iswdigit 102 #endif 103 104 int iswdigit(wint_t c)105iswdigit(wint_t c) 106 { 107 return (c < 256 && isdigit((unsigned char)c)); 108 } 109 110 111 #ifdef iswalnum 112 #undef iswalnum 113 #endif 114 115 int iswalnum(wint_t c)116iswalnum(wint_t c) 117 { 118 return (c < 256 && isalnum((unsigned char)c)); 119 } 120 121 122 #ifdef towupper 123 #undef towupper 124 #endif 125 126 wint_t towupper(wint_t c)127towupper(wint_t c) 128 { 129 if (c < 256 && islower((unsigned char)c)) 130 return toupper((unsigned char)c); 131 return c; 132 } 133 134 135 #ifdef towlower 136 #undef towlower 137 #endif 138 139 wint_t towlower(wint_t c)140towlower(wint_t c) 141 { 142 if (c < 256 && isupper((unsigned char)c)) 143 return tolower((unsigned char)c); 144 return c; 145 } 146 147 #endif // !HAVE_ISWPRINT 148