PostgreSQL Source Code  git master
test-ctype.c File Reference
#include <stdio.h>
#include <locale.h>
#include <ctype.h>
Include dependency graph for test-ctype.c:

Go to the source code of this file.

Functions

char * flag (int b)
 
void describe_char (int c)
 
int main ()
 

Function Documentation

◆ describe_char()

void describe_char ( int  c)

Definition at line 43 of file test-ctype.c.

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 }
#define printf(...)
Definition: port.h:244
char * c
char * flag(int b)
Definition: test-ctype.c:33

References flag(), and printf.

Referenced by main().

◆ flag()

◆ main()

int main ( void  )

Definition at line 60 of file test-ctype.c.

61 {
62  short c;
63  char *cur_locale;
64 
65  cur_locale = setlocale(LC_ALL, "");
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
Definition: port.h:242
void describe_char(int c)
Definition: test-ctype.c:43
#define setlocale(a, b)
Definition: win32_port.h:485

References describe_char(), fprintf, printf, and setlocale.