~ubuntu-branches/ubuntu/natty/diffutils/natty

« back to all changes in this revision

Viewing changes to lib/wctype.in.h

  • Committer: Bazaar Package Importer
  • Author(s): Santiago Vila
  • Date: 2010-05-04 20:38:00 UTC
  • mfrom: (2.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100504203800-f67xd9rsa9xl9qqj
Tags: 1:3.0-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- buffer-read-only: t -*- vi: set ro: */
 
2
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
 
3
/* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
 
4
 
 
5
   Copyright (C) 2006-2010 Free Software Foundation, Inc.
 
6
 
 
7
   This program is free software; you can redistribute it and/or modify
 
8
   it under the terms of the GNU General Public License as published by
 
9
   the Free Software Foundation; either version 3, or (at your option)
 
10
   any later version.
 
11
 
 
12
   This program is distributed in the hope that it will be useful,
 
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
   GNU General Public License for more details.
 
16
 
 
17
   You should have received a copy of the GNU General Public License
 
18
   along with this program; if not, write to the Free Software Foundation,
 
19
   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
20
 
 
21
/* Written by Bruno Haible and Paul Eggert.  */
 
22
 
 
23
/*
 
24
 * ISO C 99 <wctype.h> for platforms that lack it.
 
25
 * <http://www.opengroup.org/susv3xbd/wctype.h.html>
 
26
 *
 
27
 * iswctype, towctrans, towlower, towupper, wctrans, wctype,
 
28
 * wctrans_t, and wctype_t are not yet implemented.
 
29
 */
 
30
 
 
31
#ifndef _GL_WCTYPE_H
 
32
 
 
33
#if __GNUC__ >= 3
 
34
@PRAGMA_SYSTEM_HEADER@
 
35
#endif
 
36
 
 
37
#if @HAVE_WINT_T@
 
38
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>.
 
39
   Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
 
40
   <wchar.h>.
 
41
   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
 
42
   included before <wchar.h>.  */
 
43
# include <stddef.h>
 
44
# include <stdio.h>
 
45
# include <time.h>
 
46
# include <wchar.h>
 
47
#endif
 
48
 
 
49
/* Include the original <wctype.h> if it exists.
 
50
   BeOS 5 has the functions but no <wctype.h>.  */
 
51
/* The include_next requires a split double-inclusion guard.  */
 
52
#if @HAVE_WCTYPE_H@
 
53
# @INCLUDE_NEXT@ @NEXT_WCTYPE_H@
 
54
#endif
 
55
 
 
56
#ifndef _GL_WCTYPE_H
 
57
#define _GL_WCTYPE_H
 
58
 
 
59
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
60
 
 
61
/* The definition of _GL_WARN_ON_USE is copied here.  */
 
62
 
 
63
/* Define wint_t and WEOF.  (Also done in wchar.in.h.)  */
 
64
#if !@HAVE_WINT_T@ && !defined wint_t
 
65
# define wint_t int
 
66
# ifndef WEOF
 
67
#  define WEOF -1
 
68
# endif
 
69
#else
 
70
# ifndef WEOF
 
71
#  define WEOF ((wint_t) -1)
 
72
# endif
 
73
#endif
 
74
 
 
75
 
 
76
/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
 
77
   Linux libc5 has <wctype.h> and the functions but they are broken.
 
78
   Assume all 11 functions (all isw* except iswblank) are implemented the
 
79
   same way, or not at all.  */
 
80
#if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
 
81
 
 
82
/* IRIX 5.3 has macros but no functions, its isw* macros refer to an
 
83
   undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
 
84
   refer to system functions like _iswctype that are not in the
 
85
   standard C library.  Rather than try to get ancient buggy
 
86
   implementations like this to work, just disable them.  */
 
87
# undef iswalnum
 
88
# undef iswalpha
 
89
# undef iswblank
 
90
# undef iswcntrl
 
91
# undef iswdigit
 
92
# undef iswgraph
 
93
# undef iswlower
 
94
# undef iswprint
 
95
# undef iswpunct
 
96
# undef iswspace
 
97
# undef iswupper
 
98
# undef iswxdigit
 
99
# undef towlower
 
100
# undef towupper
 
101
 
 
102
/* Linux libc5 has <wctype.h> and the functions but they are broken.  */
 
103
# if @REPLACE_ISWCNTRL@
 
104
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
105
#   define iswalnum rpl_iswalnum
 
106
#   define iswalpha rpl_iswalpha
 
107
#   define iswblank rpl_iswblank
 
108
#   define iswcntrl rpl_iswcntrl
 
109
#   define iswdigit rpl_iswdigit
 
110
#   define iswgraph rpl_iswgraph
 
111
#   define iswlower rpl_iswlower
 
112
#   define iswprint rpl_iswprint
 
113
#   define iswpunct rpl_iswpunct
 
114
#   define iswspace rpl_iswspace
 
115
#   define iswupper rpl_iswupper
 
116
#   define iswxdigit rpl_iswxdigit
 
117
#   define towlower rpl_towlower
 
118
#   define towupper rpl_towupper
 
119
#  endif
 
120
# endif
 
121
 
 
122
static inline int
 
123
# if @REPLACE_ISWCNTRL@
 
124
rpl_iswalnum
 
125
# else
 
126
iswalnum
 
127
# endif
 
128
         (wint_t wc)
 
129
{
 
130
  return ((wc >= '0' && wc <= '9')
 
131
          || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
 
132
}
 
133
 
 
134
static inline int
 
135
# if @REPLACE_ISWCNTRL@
 
136
rpl_iswalpha
 
137
# else
 
138
iswalpha
 
139
# endif
 
140
         (wint_t wc)
 
141
{
 
142
  return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
 
143
}
 
144
 
 
145
static inline int
 
146
# if @REPLACE_ISWCNTRL@
 
147
rpl_iswblank
 
148
# else
 
149
iswblank
 
150
# endif
 
151
         (wint_t wc)
 
152
{
 
153
  return wc == ' ' || wc == '\t';
 
154
}
 
155
 
 
156
static inline int
 
157
# if @REPLACE_ISWCNTRL@
 
158
rpl_iswcntrl
 
159
# else
 
160
iswcntrl
 
161
# endif
 
162
        (wint_t wc)
 
163
{
 
164
  return (wc & ~0x1f) == 0 || wc == 0x7f;
 
165
}
 
166
 
 
167
static inline int
 
168
# if @REPLACE_ISWCNTRL@
 
169
rpl_iswdigit
 
170
# else
 
171
iswdigit
 
172
# endif
 
173
         (wint_t wc)
 
174
{
 
175
  return wc >= '0' && wc <= '9';
 
176
}
 
177
 
 
178
static inline int
 
179
# if @REPLACE_ISWCNTRL@
 
180
rpl_iswgraph
 
181
# else
 
182
iswgraph
 
183
# endif
 
184
         (wint_t wc)
 
185
{
 
186
  return wc >= '!' && wc <= '~';
 
187
}
 
188
 
 
189
static inline int
 
190
# if @REPLACE_ISWCNTRL@
 
191
rpl_iswlower
 
192
# else
 
193
iswlower
 
194
# endif
 
195
         (wint_t wc)
 
196
{
 
197
  return wc >= 'a' && wc <= 'z';
 
198
}
 
199
 
 
200
static inline int
 
201
# if @REPLACE_ISWCNTRL@
 
202
rpl_iswprint
 
203
# else
 
204
iswprint
 
205
# endif
 
206
         (wint_t wc)
 
207
{
 
208
  return wc >= ' ' && wc <= '~';
 
209
}
 
210
 
 
211
static inline int
 
212
# if @REPLACE_ISWCNTRL@
 
213
rpl_iswpunct
 
214
# else
 
215
iswpunct
 
216
# endif
 
217
         (wint_t wc)
 
218
{
 
219
  return (wc >= '!' && wc <= '~'
 
220
          && !((wc >= '0' && wc <= '9')
 
221
               || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
 
222
}
 
223
 
 
224
static inline int
 
225
# if @REPLACE_ISWCNTRL@
 
226
rpl_iswspace
 
227
# else
 
228
iswspace
 
229
# endif
 
230
         (wint_t wc)
 
231
{
 
232
  return (wc == ' ' || wc == '\t'
 
233
          || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
 
234
}
 
235
 
 
236
static inline int
 
237
# if @REPLACE_ISWCNTRL@
 
238
rpl_iswupper
 
239
# else
 
240
iswupper
 
241
# endif
 
242
         (wint_t wc)
 
243
{
 
244
  return wc >= 'A' && wc <= 'Z';
 
245
}
 
246
 
 
247
static inline int
 
248
# if @REPLACE_ISWCNTRL@
 
249
rpl_iswxdigit
 
250
# else
 
251
iswxdigit
 
252
# endif
 
253
          (wint_t wc)
 
254
{
 
255
  return ((wc >= '0' && wc <= '9')
 
256
          || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
 
257
}
 
258
 
 
259
static inline wint_t
 
260
# if @REPLACE_ISWCNTRL@
 
261
rpl_towlower
 
262
# else
 
263
towlower
 
264
# endif
 
265
         (wint_t wc)
 
266
{
 
267
  return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc);
 
268
}
 
269
 
 
270
static inline wint_t
 
271
# if @REPLACE_ISWCNTRL@
 
272
rpl_towupper
 
273
# else
 
274
towupper
 
275
# endif
 
276
         (wint_t wc)
 
277
{
 
278
  return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc);
 
279
}
 
280
 
 
281
#elif ! @HAVE_ISWBLANK@
 
282
/* Only the iswblank function is missing.  */
 
283
 
 
284
static inline int
 
285
iswblank (wint_t wc)
 
286
{
 
287
  return wc == ' ' || wc == '\t';
 
288
}
 
289
 
 
290
#endif
 
291
 
 
292
#if defined __MINGW32__
 
293
 
 
294
/* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t.
 
295
   The functions towlower and towupper are implemented in the MSVCRT library
 
296
   to take a wchar_t argument and return a wchar_t result.  mingw declares
 
297
   these functions to take a wint_t argument and return a wint_t result.
 
298
   This means that:
 
299
   1. When the user passes an argument outside the range 0x0000..0xFFFF, the
 
300
      function will look only at the lower 16 bits.  This is allowed according
 
301
      to POSIX.
 
302
   2. The return value is returned in the lower 16 bits of the result register.
 
303
      The upper 16 bits are random: whatever happened to be in that part of the
 
304
      result register.  We need to fix this by adding a zero-extend from
 
305
      wchar_t to wint_t after the call.  */
 
306
 
 
307
static inline wint_t
 
308
rpl_towlower (wint_t wc)
 
309
{
 
310
  return (wint_t) (wchar_t) towlower (wc);
 
311
}
 
312
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
313
#  define towlower rpl_towlower
 
314
# endif
 
315
 
 
316
static inline wint_t
 
317
rpl_towupper (wint_t wc)
 
318
{
 
319
  return (wint_t) (wchar_t) towupper (wc);
 
320
}
 
321
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
322
#  define towupper rpl_towupper
 
323
# endif
 
324
 
 
325
#endif /* __MINGW32__ */
 
326
 
 
327
#if @REPLACE_ISWCNTRL@
 
328
_GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc));
 
329
_GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc));
 
330
_GL_CXXALIAS_RPL (iswblank, int, (wint_t wc));
 
331
_GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc));
 
332
_GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc));
 
333
_GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc));
 
334
_GL_CXXALIAS_RPL (iswlower, int, (wint_t wc));
 
335
_GL_CXXALIAS_RPL (iswprint, int, (wint_t wc));
 
336
_GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc));
 
337
_GL_CXXALIAS_RPL (iswspace, int, (wint_t wc));
 
338
_GL_CXXALIAS_RPL (iswupper, int, (wint_t wc));
 
339
_GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc));
 
340
#else
 
341
_GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc));
 
342
_GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc));
 
343
_GL_CXXALIAS_SYS (iswblank, int, (wint_t wc));
 
344
_GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc));
 
345
_GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc));
 
346
_GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc));
 
347
_GL_CXXALIAS_SYS (iswlower, int, (wint_t wc));
 
348
_GL_CXXALIAS_SYS (iswprint, int, (wint_t wc));
 
349
_GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc));
 
350
_GL_CXXALIAS_SYS (iswspace, int, (wint_t wc));
 
351
_GL_CXXALIAS_SYS (iswupper, int, (wint_t wc));
 
352
_GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc));
 
353
#endif
 
354
_GL_CXXALIASWARN (iswalnum);
 
355
_GL_CXXALIASWARN (iswalpha);
 
356
_GL_CXXALIASWARN (iswblank);
 
357
_GL_CXXALIASWARN (iswcntrl);
 
358
_GL_CXXALIASWARN (iswdigit);
 
359
_GL_CXXALIASWARN (iswgraph);
 
360
_GL_CXXALIASWARN (iswlower);
 
361
_GL_CXXALIASWARN (iswprint);
 
362
_GL_CXXALIASWARN (iswpunct);
 
363
_GL_CXXALIASWARN (iswspace);
 
364
_GL_CXXALIASWARN (iswupper);
 
365
_GL_CXXALIASWARN (iswxdigit);
 
366
 
 
367
#if @REPLACE_ISWCNTRL@ || defined __MINGW32__
 
368
_GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc));
 
369
_GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc));
 
370
#else
 
371
_GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc));
 
372
_GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc));
 
373
#endif
 
374
_GL_CXXALIASWARN (towlower);
 
375
_GL_CXXALIASWARN (towupper);
 
376
 
 
377
 
 
378
#endif /* _GL_WCTYPE_H */
 
379
#endif /* _GL_WCTYPE_H */