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/] [towlower.c] - Blame information for rev 802

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
        <<towlower>>---translate wide characters to lowercase
33
 
34
INDEX
35
        towlower
36
 
37
ANSI_SYNOPSIS
38
        #include <wctype.h>
39
        wint_t towlower(wint_t <[c]>);
40
 
41
TRAD_SYNOPSIS
42
        #include <wctype.h>
43
        wint_t towlower(<[c]>)
44
        wint_t <[c]>;
45
 
46
 
47
DESCRIPTION
48
<<towlower>> is a function which converts uppercase wide characters to
49
lowercase, leaving all other characters unchanged.
50
 
51
RETURNS
52
<<towlower>> returns the lowercase equivalent of <[c]> when it is a
53
uppercase wide character; otherwise, it returns the input character.
54
 
55
PORTABILITY
56
<<towlower>> is C99.
57
 
58
No supporting OS subroutines are required.
59
*/
60
 
61
#include <_ansi.h>
62
#include <newlib.h>
63
#include <string.h>
64
#include <reent.h>
65
#include <ctype.h>
66
#include <wctype.h>
67
#include "local.h"
68
 
69
wint_t
70
_DEFUN(towlower,(c), wint_t c)
71
{
72
#ifdef _MB_CAPABLE
73
  c = _jp2uc (c);
74
  if (c < 0x100)
75
    {
76
      if ((c >= 0x0041 && c <= 0x005a) ||
77
          (c >= 0x00c0 && c <= 0x00de))
78
        return (c + 0x20);
79
 
80
      if (c == 0x00b5)
81
        return 0x03bc;
82
 
83
      return c;
84
    }
85
  else if (c < 0x300)
86
    {
87
      if ((c >= 0x0100 && c <= 0x012e) ||
88
          (c >= 0x0132 && c <= 0x0136) ||
89
          (c >= 0x014a && c <= 0x0176) ||
90
          (c >= 0x01de && c <= 0x01ee) ||
91
          (c >= 0x01f8 && c <= 0x021e) ||
92
          (c >= 0x0222 && c <= 0x0232))
93
        {
94
          if (!(c & 0x01))
95
            return (c + 1);
96
          return c;
97
        }
98
 
99
      if ((c >= 0x0139 && c <= 0x0147) ||
100
          (c >= 0x01cd && c <= 0x91db))
101
        {
102
          if (c & 0x01)
103
            return (c + 1);
104
          return c;
105
        }
106
 
107
      if (c >= 0x178 && c <= 0x01f7)
108
        {
109
          wint_t k;
110
          switch (c)
111
            {
112
            case 0x0178:
113
              k = 0x00ff;
114
              break;
115
            case 0x0179:
116
            case 0x017b:
117
            case 0x017d:
118
            case 0x0182:
119
            case 0x0184:
120
            case 0x0187:
121
            case 0x018b:
122
            case 0x0191:
123
            case 0x0198:
124
            case 0x01a0:
125
            case 0x01a2:
126
            case 0x01a4:
127
            case 0x01a7:
128
            case 0x01ac:
129
            case 0x01af:
130
            case 0x01b3:
131
            case 0x01b5:
132
            case 0x01b8:
133
            case 0x01bc:
134
            case 0x01c5:
135
            case 0x01c8:
136
            case 0x01cb:
137
            case 0x01cd:
138
            case 0x01cf:
139
            case 0x01d1:
140
            case 0x01d3:
141
            case 0x01d5:
142
            case 0x01d7:
143
            case 0x01d9:
144
            case 0x01db:
145
            case 0x01f2:
146
            case 0x01f4:
147
              k = c + 1;
148
              break;
149
            case 0x017f:
150
              k = 0x0073;
151
              break;
152
            case 0x0181:
153
              k = 0x0253;
154
              break;
155
            case 0x0186:
156
              k = 0x0254;
157
              break;
158
            case 0x0189:
159
              k = 0x0256;
160
              break;
161
            case 0x018a:
162
              k = 0x0257;
163
              break;
164
            case 0x018e:
165
              k = 0x01dd;
166
              break;
167
            case 0x018f:
168
              k = 0x0259;
169
              break;
170
            case 0x0190:
171
              k = 0x025b;
172
              break;
173
            case 0x0193:
174
              k = 0x0260;
175
              break;
176
            case 0x0194:
177
              k = 0x0263;
178
              break;
179
            case 0x0196:
180
              k = 0x0269;
181
              break;
182
            case 0x0197:
183
              k = 0x0268;
184
              break;
185
            case 0x019c:
186
              k = 0x026f;
187
              break;
188
            case 0x019d:
189
              k = 0x0272;
190
              break;
191
            case 0x019f:
192
              k = 0x0275;
193
              break;
194
            case 0x01a6:
195
              k = 0x0280;
196
              break;
197
            case 0x01a9:
198
              k = 0x0283;
199
              break;
200
            case 0x01ae:
201
              k = 0x0288;
202
              break;
203
            case 0x01b1:
204
              k = 0x028a;
205
              break;
206
            case 0x01b2:
207
              k = 0x028b;
208
              break;
209
            case 0x01b7:
210
              k = 0x0292;
211
              break;
212
            case 0x01c4:
213
            case 0x01c7:
214
            case 0x01ca:
215
            case 0x01f1:
216
              k = c + 2;
217
              break;
218
            case 0x01f6:
219
              k = 0x0195;
220
              break;
221
            case 0x01f7:
222
              k = 0x01bf;
223
              break;
224
            default:
225
              k = 0;
226
            }
227
          if (k != 0)
228
            return k;
229
        }
230
 
231
      if (c == 0x0220)
232
        return 0x019e;
233
    }
234
  else if (c < 0x0400)
235
    {
236
      if (c >= 0x0391 && c <= 0x03ab && c != 0x03a2)
237
        return (c + 0x20);
238
      if (c >= 0x03d8 && c <= 0x03ee && !(c & 0x01))
239
        return (c + 1);
240
      if (c >= 0x0386 && c <= 0x03f5)
241
        {
242
          wint_t k;
243
          switch (c)
244
            {
245
            case 0x0386:
246
              k = 0x03ac;
247
              break;
248
            case 0x0388:
249
              k = 0x03ad;
250
              break;
251
            case 0x0389:
252
              k = 0x03ae;
253
              break;
254
            case 0x038a:
255
              k = 0x03af;
256
              break;
257
            case 0x038c:
258
              k = 0x03cc;
259
              break;
260
            case 0x038e:
261
              k = 0x03cd;
262
              break;
263
            case 0x038f:
264
              k = 0x038f;
265
              break;
266
            case 0x03c2:
267
              k = 0x03c3;
268
              break;
269
            case 0x03d0:
270
              k = 0x03b2;
271
              break;
272
            case 0x03d1:
273
              k = 0x03b8;
274
              break;
275
            case 0x03d5:
276
              k = 0x03c6;
277
              break;
278
            case 0x03d6:
279
              k = 0x03c0;
280
              break;
281
            case 0x03f0:
282
              k = 0x03ba;
283
              break;
284
            case 0x03f1:
285
              k = 0x03c1;
286
              break;
287
            case 0x03f2:
288
              k = 0x03c3;
289
              break;
290
            case 0x03f4:
291
              k = 0x03b8;
292
              break;
293
            case 0x03f5:
294
              k = 0x03b5;
295
              break;
296
            default:
297
              k = 0;
298
            }
299
          if (k != 0)
300
            return k;
301
        }
302
 
303
      if (c == 0x0345)
304
        return 0x03b9;
305
    }
306
  else if (c < 0x500)
307
    {
308
      if (c >= 0x0400 && c <= 0x040f)
309
        return (c + 0x50);
310
 
311
      if (c >= 0x0410 && c <= 0x042f)
312
        return (c + 0x20);
313
 
314
      if ((c >= 0x0460 && c <= 0x0480) ||
315
          (c >= 0x048a && c <= 0x04be) ||
316
          (c >= 0x04d0 && c <= 0x04f4) ||
317
          (c == 0x04f8))
318
        {
319
          if (!(c & 0x01))
320
            return (c + 1);
321
          return c;
322
        }
323
 
324
      if (c >= 0x04c1 && c <= 0x04cd)
325
        {
326
          if (c & 0x01)
327
            return (c + 1);
328
          return c;
329
        }
330
    }
331
  else if (c < 0x1f00)
332
    {
333
      if ((c >= 0x0500 && c <= 0x050e) ||
334
          (c >= 0x1e00 && c <= 0x1e94) ||
335
          (c >= 0x1ea0 && c <= 0x1ef8))
336
        {
337
          if (!(c & 0x01))
338
            return (c + 1);
339
          return c;
340
        }
341
 
342
      if (c >= 0x0531 && c <= 0x0556)
343
        return (c + 0x30);
344
 
345
      if (c == 0x1e9b)
346
        return 0x1e61;
347
    }
348
  else if (c < 0x2000)
349
    {
350
      if ((c >= 0x1f08 && c <= 0x1f0f) ||
351
          (c >= 0x1f18 && c <= 0x1f1d) ||
352
          (c >= 0x1f28 && c <= 0x1f2f) ||
353
          (c >= 0x1f38 && c <= 0x1f3f) ||
354
          (c >= 0x1f48 && c <= 0x1f4d) ||
355
          (c >= 0x1f68 && c <= 0x1f6f) ||
356
          (c >= 0x1f88 && c <= 0x1f8f) ||
357
          (c >= 0x1f98 && c <= 0x1f9f) ||
358
          (c >= 0x1fa8 && c <= 0x1faf))
359
        return (c - 0x08);
360
 
361
      if (c >= 0x1f59 && c <= 0x1f5f)
362
        {
363
          if (c & 0x01)
364
            return (c - 0x08);
365
          return c;
366
        }
367
 
368
      if (c >= 0x1fb8 && c <= 0x1ffc)
369
        {
370
          wint_t k;
371
          switch (c)
372
            {
373
            case 0x1fb8:
374
            case 0x1fb9:
375
            case 0x1fd8:
376
            case 0x1fd9:
377
            case 0x1fe8:
378
            case 0x1fe9:
379
              k = c - 0x08;
380
              break;
381
            case 0x1fba:
382
            case 0x1fbb:
383
              k = c - 0x4a;
384
              break;
385
            case 0x1fbc:
386
              k = 0x1fb3;
387
              break;
388
            case 0x1fbe:
389
              k = 0x03b9;
390
              break;
391
            case 0x1fc8:
392
            case 0x1fc9:
393
            case 0x1fca:
394
            case 0x1fcb:
395
              k = c - 0x56;
396
              break;
397
            case 0x1fcc:
398
              k = 0x1fc3;
399
              break;
400
            case 0x1fda:
401
            case 0x1fdb:
402
              k = c - 0x64;
403
              break;
404
            case 0x1fea:
405
            case 0x1feb:
406
              k = c - 0x70;
407
              break;
408
            case 0x1fec:
409
              k = 0x1fe5;
410
              break;
411
            case 0x1ffa:
412
            case 0x1ffb:
413
              k = c - 0x7e;
414
              break;
415
            case 0x1ffc:
416
              k = 0x1ff3;
417
              break;
418
            default:
419
              k = 0;
420
            }
421
          if (k != 0)
422
            return k;
423
        }
424
    }
425
  else
426
    {
427
      if (c >= 0x2160 && c <= 0x216f)
428
        return (c + 0x10);
429
 
430
      if (c >= 0x24b6 && c <= 0x24cf)
431
        return (c + 0x1a);
432
 
433
      if (c >= 0xff21 && c <= 0xff3a)
434
        return (c + 0x20);
435
 
436
      if (c >= 0x10400 && c <= 0x10425)
437
        return (c + 0x28);
438
 
439
      if (c == 0x2126)
440
        return 0x03c9;
441
      if (c == 0x212a)
442
        return 0x006b;
443
      if (c == 0x212b)
444
        return 0x00e5;
445
    }
446
  return c;
447
#else
448
  return (c < 0x00ff ? (wint_t)(tolower ((int)c)) : c);
449
#endif /* _MB_CAPABLE */
450
}
451
 

powered by: WebSVN 2.1.0

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