summaryrefslogtreecommitdiff
path: root/sysdeps/unix/common/glue-ctype.c
blob: 977f9d25bfbe71311d1ec390d9943a37994f05f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* Copyright (C) 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with the GNU C Library; see the file COPYING.LIB.  If not,
   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */

/* Different systems have different names for the array.
   This order is important for some systems.  */

#if !defined(TABLE) && defined(HAVE__LOCP)
/* OSF/1 has the name _ctype defined as a macro, which points down into
   the _locp structure.  Jesus.  We'll hope this works.  We need to
   check for LOCP first, since there is no symbol actually named _ctype
   in their library.  */
#include <sys/types.h> /* for wchar_t used by localdef.h */
#include <sys/localedef.h>
extern loc_t *_locp;
#define TABLE		(_locp->lc_chrtbl)->lc_ctype
#undef _ctype
#define TABLE_NAME	_ctype
#endif
#ifdef	HAVE__CTYPE__
#define	TABLE	_ctype__
#endif
#if !defined(TABLE) && defined(HAVE__CTYPE)
#define TABLE   _ctype
#endif
#if !defined(TABLE) && defined(HAVE__CTYPE_)
#define	TABLE	_ctype_
#endif
#if !defined(TABLE) && defined(HAVE___CTYPE_)
#define	TABLE	__ctype_
#endif
#if !defined(TABLE) && defined(HAVE___CTYPE)
#define	TABLE	__ctype
#endif

#if defined (__STDC__) && __STDC__
#define	STRINGIFY(arg)	#arg
#else
#define	STRINGIFY(arg)	"arg"
#endif

#define EVALLED_STRINGIFY(x)	STRINGIFY (x)

int
main ()
{
#ifdef TABLE

  int i;

#ifndef HAVE__LOCP
  /* This won't work for the define to look into _locp.  */
  extern unsigned char TABLE[];
#endif

#ifdef TABLE_NAME
  printf ("const unsigned char %s[] =\n  {\n", EVALLED_STRINGIFY (TABLE_NAME));
#else
  printf ("const unsigned char %s[] =\n  {\n", EVALLED_STRINGIFY (TABLE));
#endif

  for (i = -1; i < 256; ++i)
    printf ("    %d,\n", (int) ((TABLE+1)[i]));

  puts ("  };");

#else

  puts ("/* I don't know what the ctype table is called on this system.");
  puts ("   If there is a table, and you want the ctype glue to work,");
  puts ("   edit configure.in and glue-ctype.c in sysdeps/unix/common/");
  puts ("   to check for the right name.  */");

#endif

  exit (0);
}