Back to index

glibc  2.9
Defines | Functions
test_ctype.c File Reference
#include <limits.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>

Go to the source code of this file.

Defines

#define ISLOWER(c)   ('a' <= (c) && (c) <= 'z')
#define TOUPPER(c)   (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#define XOR(e, f)   (((e) && !(f)) || (!(e) && (f)))
#define TRYEM
#define TRY(isfoo)   if (isfoo (c)) fputs (" " #isfoo, stdout)
#define TRY(isfoo)   if (isfoo (EOF)) fputs (" " #isfoo, stdout), ++lose

Functions

static void print_char (unsigned char c)
int main (int argc, char **argv)

Define Documentation

#define ISLOWER (   c)    ('a' <= (c) && (c) <= 'z')

Definition at line 24 of file test_ctype.c.

#define TOUPPER (   c)    (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))

Definition at line 25 of file test_ctype.c.

#define TRY (   isfoo)    if (isfoo (c)) fputs (" " #isfoo, stdout)
#define TRY (   isfoo)    if (isfoo (EOF)) fputs (" " #isfoo, stdout), ++lose
#define TRYEM
Value:
do {                                                   \
      TRY (isascii);                                                 \
      TRY (isalnum);                                                 \
      TRY (isalpha);                                                 \
      TRY (iscntrl);                                                 \
      TRY (isdigit);                                                 \
      TRY (isgraph);                                                 \
      TRY (islower);                                                 \
      TRY (isprint);                                                 \
      TRY (ispunct);                                                 \
      TRY (isspace);                                                 \
      TRY (isupper);                                                 \
      TRY (isxdigit);                                                       \
      TRY (isblank);                                                 \
    } while (0)
#define XOR (   e,
  f 
)    (((e) && !(f)) || (!(e) && (f)))

Definition at line 26 of file test_ctype.c.


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 42 of file test_ctype.c.

{
  unsigned short int c;
  int lose = 0;

#define TRYEM do {                                                   \
      TRY (isascii);                                                 \
      TRY (isalnum);                                                 \
      TRY (isalpha);                                                 \
      TRY (iscntrl);                                                 \
      TRY (isdigit);                                                 \
      TRY (isgraph);                                                 \
      TRY (islower);                                                 \
      TRY (isprint);                                                 \
      TRY (ispunct);                                                 \
      TRY (isspace);                                                 \
      TRY (isupper);                                                 \
      TRY (isxdigit);                                                       \
      TRY (isblank);                                                 \
    } while (0)

  for (c = 0; c <= UCHAR_MAX; ++c)
    {
      print_char (c);

      if (XOR (islower (c), ISLOWER (c)) || toupper (c) != TOUPPER (c))
       {
         fputs (" BOGUS", stdout);
         ++lose;
       }

#define TRY(isfoo) if (isfoo (c)) fputs (" " #isfoo, stdout)
      TRYEM;
#undef TRY

      fputs("; lower = ", stdout);
      print_char(tolower(c));
      fputs("; upper = ", stdout);
      print_char(toupper(c));
      putchar('\n');
    }

  fputs ("EOF", stdout);
  if (tolower (EOF) != EOF)
    {
      ++lose;
      printf (" tolower BOGUS %d;", tolower (EOF));
    }
  if (toupper (EOF) != EOF)
    {
      ++lose;
      printf (" toupper BOGUS %d;", toupper (EOF));
    }

#define TRY(isfoo) if (isfoo (EOF)) fputs (" " #isfoo, stdout), ++lose
  TRYEM;
#undef TRY

  return lose ? EXIT_FAILURE : EXIT_SUCCESS;
}

Here is the call graph for this function:

static void print_char ( unsigned char  c) [static]

Definition at line 32 of file test_ctype.c.

{
  printf("%d/", (int) c);
  if (isgraph(c))
    printf("'%c'", c);
  else
    printf("'\\%.3o'", c);
}

Here is the call graph for this function:

Here is the caller graph for this function: