PostgreSQL Source Code git master
Loading...
Searching...
No Matches
test-ctype.c
Go to the documentation of this file.
1/*
2 * src/test/locale/test-ctype.c
3 */
4
5/*
6 *
7 * test-ctype.c
8 *
9 * Written by Oleg BroytMann, phd2@earthling.net
10 * with help from Oleg Bartunov, oleg@sai.msu.su
11 * Copyright (C) 1998 PhiloSoft Design
12 *
13 * This is copyrighted but free software. You can use it, modify and distribute
14 * in original or modified form providing that the author's names and the above
15 * copyright notice will remain.
16 *
17 * Disclaimer, legal notice and absence of warranty.
18 * This software provided "as is" without any kind of warranty. In no event
19 * the author shall be liable for any damage, etc.
20 *
21 */
22
23#include <stdio.h>
24#include <locale.h>
25#include <ctype.h>
26
27char *flag(int b);
28void describe_char(int c);
29
30#undef LONG_FLAG
31
32char *
33flag(int b)
34{
35#ifdef LONG_FLAG
36 return b ? "yes" : "no";
37#else
38 return b ? "+" : " ";
39#endif
40}
41
42void
44{
45 unsigned char cp = c,
46 up = toupper(c),
47 lo = tolower(c);
48
49 if (!isprint(cp))
50 cp = ' ';
51 if (!isprint(up))
52 up = ' ';
53 if (!isprint(lo))
54 lo = ' ';
55
56 printf("chr#%-4d%2c%6s%6s%6s%6s%6s%6s%6s%6s%6s%6s%6s%4c%4c\n", c, cp, flag(isalnum(c)), flag(isalpha(c)), flag(iscntrl(c)), flag(isdigit(c)), flag(islower(c)), flag(isgraph(c)), flag(isprint(c)), flag(ispunct(c)), flag(isspace(c)), flag(isupper(c)), flag(isxdigit(c)), lo, up);
57}
58
59int
61{
62 short c;
63 char *cur_locale;
64
66 if (cur_locale)
67 fprintf(stderr, "Successfully set locale to \"%s\"\n", cur_locale);
68 else
69 {
70 fprintf(stderr, "Cannot setup locale. Either your libc does not provide\nlocale support, or your locale data is corrupt, or you have not set\nLANG or LC_CTYPE environment variable to proper value. Program aborted.\n");
71 return 1;
72 }
73
74 printf("char# char alnum alpha cntrl digit lower graph print punct space upper xdigit lo up\n");
75 for (c = 0; c <= 255; c++)
77
78 return 0;
79}
#define fprintf(file, fmt, msg)
Definition cubescan.l:21
int b
Definition isn.c:74
#define printf(...)
Definition port.h:267
char * c
static int fb(int x)
char * flag(int b)
Definition test-ctype.c:33
int main()
Definition test-ctype.c:60
void describe_char(int c)
Definition test-ctype.c:43
#define setlocale(a, b)
Definition win32_port.h:472