OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc2/] [newlib/] [libc/] [ctype/] [iswpunct.c] - Blame information for rev 207

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/* Copyright (c) 2002 Red Hat Incorporated.
2
   All rights reserved.
3
 
4
   Redistribution and use in source and binary forms, with or without
5
   modification, are permitted provided that the following conditions are met:
6
 
7
     Redistributions of source code must retain the above copyright
8
     notice, this list of conditions and the following disclaimer.
9
 
10
     Redistributions in binary form must reproduce the above copyright
11
     notice, this list of conditions and the following disclaimer in the
12
     documentation and/or other materials provided with the distribution.
13
 
14
     The name of Red Hat Incorporated may not be used to endorse
15
     or promote products derived from this software without specific
16
     prior written permission.
17
 
18
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
   ARE DISCLAIMED.  IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
22
   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
*/
29
 
30
/*
31
FUNCTION
32
        <<iswpunct>>---punctuation wide character test
33
 
34
INDEX
35
        iswpunct
36
 
37
ANSI_SYNOPSIS
38
        #include <wctype.h>
39
        int iswpunct(wint_t <[c]>);
40
 
41
TRAD_SYNOPSIS
42
        #include <wctype.h>
43
        int iswpunct(<[c]>)
44
        wint_t <[c]>;
45
 
46
DESCRIPTION
47
<<iswpunct>> is a function which classifies wide-character values that
48
are punctuation.
49
 
50
RETURNS
51
<<iswpunct>> returns non-zero if <[c]> is a punctuation wide character.
52
 
53
PORTABILITY
54
<<iswpunct>> is C99.
55
 
56
No supporting OS subroutines are required.
57
*/
58
#include <_ansi.h>
59
#include <newlib.h>
60
#include <wctype.h>
61
#include <string.h>
62
#include <ctype.h>
63
#include "local.h"
64
 
65
#ifdef _MB_CAPABLE
66
#include "utf8punct.h"
67
#endif /* _MB_CAPABLE */
68
 
69
int
70
_DEFUN(iswpunct,(c), wint_t c)
71
{
72
#ifdef _MB_CAPABLE
73
  unsigned const char *table;
74
  unsigned char *ptr;
75
  unsigned char ctmp;
76
  int size;
77
  wint_t x;
78
 
79
  c = _jp2uc (c);
80
 
81
  x = (c >> 8);
82
  /* for some large sections, all characters are punctuation so handle them here */
83
  if ((x >= 0xe0 && x <= 0xf8) ||
84
      (x >= 0xf00 && x <= 0xffe) ||
85
      (x >= 0x1000 && x <= 0x10fe))
86
    return 1;
87
 
88
  switch (x)
89
    {
90
    case 0x22:
91
    case 0x25:
92
    case 0x28:
93
    case 0x29:
94
    case 0x2a:
95
      return 1;
96
    case 0x00:
97
      table = u0;
98
      size = sizeof(u0);
99
      break;
100
    case 0x02:
101
      table = u2;
102
      size = sizeof(u2);
103
      break;
104
    case 0x03:
105
      table = u3;
106
      size = sizeof(u3);
107
      break;
108
    case 0x04:
109
      table = u4;
110
      size = sizeof(u4);
111
      break;
112
    case 0x05:
113
      table = u5;
114
      size = sizeof(u5);
115
      break;
116
    case 0x06:
117
      table = u6;
118
      size = sizeof(u6);
119
      break;
120
    case 0x07:
121
      table = u7;
122
      size = sizeof(u7);
123
      break;
124
    case 0x09:
125
      table = u9;
126
      size = sizeof(u9);
127
      break;
128
    case 0x0a:
129
      table = ua;
130
      size = sizeof(ua);
131
      break;
132
    case 0x0b:
133
      table = ub;
134
      size = sizeof(ub);
135
      break;
136
    case 0x0c:
137
      table = uc;
138
      size = sizeof(uc);
139
      break;
140
    case 0x0d:
141
      table = ud;
142
      size = sizeof(ud);
143
      break;
144
    case 0x0e:
145
      table = ue;
146
      size = sizeof(ue);
147
      break;
148
    case 0x0f:
149
      table = uf;
150
      size = sizeof(uf);
151
      break;
152
    case 0x10:
153
      table = u10;
154
      size = sizeof(u10);
155
      break;
156
    case 0x13:
157
      table = u13;
158
      size = sizeof(u13);
159
      break;
160
    case 0x16:
161
      table = u16;
162
      size = sizeof(u16);
163
      break;
164
    case 0x17:
165
      table = u17;
166
      size = sizeof(u17);
167
      break;
168
    case 0x18:
169
      table = u18;
170
      size = sizeof(u18);
171
      break;
172
    case 0x1f:
173
      table = u1f;
174
      size = sizeof(u1f);
175
      break;
176
    case 0x20:
177
      table = u20;
178
      size = sizeof(u20);
179
      break;
180
    case 0x21:
181
      table = u21;
182
      size = sizeof(u21);
183
      break;
184
    case 0x23:
185
      table = u23;
186
      size = sizeof(u23);
187
      break;
188
    case 0x24:
189
      table = u24;
190
      size = sizeof(u24);
191
      break;
192
    case 0x26:
193
      table = u26;
194
      size = sizeof(u26);
195
      break;
196
    case 0x27:
197
      table = u27;
198
      size = sizeof(u27);
199
      break;
200
    case 0x2e:
201
      table = u2e;
202
      size = sizeof(u2e);
203
      break;
204
    case 0x2f:
205
      table = u2f;
206
      size = sizeof(u2f);
207
      break;
208
    case 0x30:
209
      table = u30;
210
      size = sizeof(u30);
211
      break;
212
    case 0x31:
213
      table = u31;
214
      size = sizeof(u31);
215
      break;
216
    case 0x32:
217
      table = u32;
218
      size = sizeof(u32);
219
      break;
220
    case 0x33:
221
      table = u33;
222
      size = sizeof(u33);
223
      break;
224
    case 0xa4:
225
      table = ua4;
226
      size = sizeof(ua4);
227
      break;
228
    case 0xfb:
229
      table = ufb;
230
      size = sizeof(ufb);
231
      break;
232
    case 0xfd:
233
      table = ufd;
234
      size = sizeof(ufd);
235
      break;
236
    case 0xfe:
237
      table = ufe;
238
      size = sizeof(ufe);
239
      break;
240
    case 0xff:
241
      table = uff;
242
      size = sizeof(uff);
243
      break;
244
    case 0x103:
245
      table = u103;
246
      size = sizeof(u103);
247
      break;
248
    case 0x1d0:
249
      table = u1d0;
250
      size = sizeof(u1d0);
251
      break;
252
    case 0x1d1:
253
      table = u1d1;
254
      size = sizeof(u1d1);
255
      break;
256
    case 0x1d6:
257
      table = u1d6;
258
      size = sizeof(u1d6);
259
      break;
260
    case 0x1d7:
261
      table = u1d7;
262
      size = sizeof(u1d7);
263
      break;
264
    case 0xe00:
265
      table = ue00;
266
      size = sizeof(ue00);
267
      break;
268
    case 0xfff:
269
      table = ufff;
270
      size = sizeof(ufff);
271
      break;
272
    case 0x10ff:
273
      table = u10ff;
274
      size = sizeof(u10ff);
275
      break;
276
    default:
277
      return 0;
278
    }
279
  /* we have narrowed down to a section of 256 characters to check */
280
  /* now check if c matches the punctuation wide-chars within that section */
281
  ptr = (unsigned char *)table;
282
  ctmp = (unsigned char)c;
283
  while (ptr < table + size)
284
    {
285
      if (ctmp == *ptr)
286
        return 1;
287
      if (ctmp < *ptr)
288
        return 0;
289
      /* otherwise c > *ptr */
290
      /* look for 0x0 as next element which indicates a range */
291
      ++ptr;
292
      if (*ptr == 0x0)
293
        {
294
          /* we have a range..see if c falls within range */
295
          ++ptr;
296
          if (ctmp <= *ptr)
297
            return 1;
298
          ++ptr;
299
        }
300
    }
301
  /* not in table */
302
  return 0;
303
#else
304
  return (c < (wint_t)0x100 ? ispunct (c) : 0);
305
#endif /* _MB_CAPABLE */
306
}
307
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.