Back to index

plt-scheme  4.2.1
Defines | Functions | Variables
char.c File Reference
#include "schpriv.h"
#include <ctype.h>
#include "schuchar.inc"

Go to the source code of this file.

Defines

#define charSTD_FOLDCASE(nl)   nl;
#define charNO_FOLDCASE(nl)   /* empty */
#define GEN_CHAR_COMP(func_name, scheme_name, comp, FOLDCASE)
#define GEN_CHAR_TEST(func_name, scheme_name, pred)
#define GEN_RECASE(func_name, scheme_name, cvt)
#define cons   scheme_make_pair

Functions

static Scheme_Objectchar_p (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_eq (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_lt (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_gt (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_lt_eq (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_gt_eq (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_eq_ci (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_lt_ci (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_gt_ci (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_lt_eq_ci (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_gt_eq_ci (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_alphabetic (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_numeric (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_whitespace (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_symbolic (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_graphic (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_blank (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_control (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_punctuation (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_upper_case (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_lower_case (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_title_case (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_to_integer (int argc, Scheme_Object *argv[])
static Scheme_Objectinteger_to_char (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_upcase (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_downcase (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_titlecase (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_foldcase (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_general_category (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_utf8_length (int argc, Scheme_Object *argv[])
static Scheme_Objectchar_map_list (int argc, Scheme_Object *argv[])
void scheme_init_portable_case (void)
void scheme_init_char (Scheme_Env *env)
Scheme_Objectscheme_make_char (mzchar ch)
Scheme_Objectscheme_make_char_or_nul (mzchar v)

Variables

Scheme_Object ** scheme_char_constants
static Scheme_Objectgeneral_category_symbols [NUM_GENERAL_CATEGORIES]

Define Documentation

#define charNO_FOLDCASE (   nl)    /* empty */

Definition at line 289 of file char.c.

#define charSTD_FOLDCASE (   nl)    nl;

Definition at line 288 of file char.c.

#define cons   scheme_make_pair
#define GEN_CHAR_COMP (   func_name,
  scheme_name,
  comp,
  FOLDCASE 
)
Value:
static Scheme_Object *func_name(int argc, Scheme_Object *argv[])     \
 { int c, prev, i; Scheme_Object *rv = scheme_true; \
   if (!SCHEME_CHARP(argv[0]))      \
     scheme_wrong_type(#scheme_name, "character", 0, argc, argv);     \
   prev = SCHEME_CHAR_VAL(argv[0]);     \
   FOLDCASE(prev = scheme_tofold(prev)) \
   for (i = 1; i < argc; i++) {     \
     if (!SCHEME_CHARP(argv[i]))      \
       scheme_wrong_type(#scheme_name, "character", i, argc, argv);     \
     c = SCHEME_CHAR_VAL(argv[i]);     \
     FOLDCASE(c = scheme_tofold(c)) \
     if (!(prev comp c)) rv = scheme_false;   \
     prev = c;     \
   }     \
   return rv;     \
 }

Definition at line 291 of file char.c.

#define GEN_CHAR_TEST (   func_name,
  scheme_name,
  pred 
)
Value:
static Scheme_Object *func_name (int argc, Scheme_Object *argv[]) \
{ \
  mzchar c;    \
  if (!SCHEME_CHARP(argv[0]))  \
    scheme_wrong_type(scheme_name, "character", 0, argc, argv); \
  c = SCHEME_CHAR_VAL(argv[0]);                    \
  return (pred(c) ? scheme_true : scheme_false);   \
}

Definition at line 321 of file char.c.

#define GEN_RECASE (   func_name,
  scheme_name,
  cvt 
)
Value:
static Scheme_Object *func_name (int argc, Scheme_Object *argv[]) \
{ \
  mzchar c, nc;    \
  if (!SCHEME_CHARP(argv[0]))  \
    scheme_wrong_type(scheme_name, "character", 0, argc, argv); \
  c = SCHEME_CHAR_VAL(argv[0]);                    \
  nc = cvt(c);                                      \
  if (nc == c) return argv[0];       \
  return scheme_make_character(nc);  \
}

Definition at line 382 of file char.c.


Function Documentation

static Scheme_Object* char_alphabetic ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object* char_blank ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object* char_control ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object* char_downcase ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object* char_eq ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object* char_eq_ci ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object* char_foldcase ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object * char_general_category ( int  argc,
Scheme_Object argv[] 
) [static]

Definition at line 399 of file char.c.

{
  mzchar c;
  int cat;

  if (!SCHEME_CHARP(argv[0]))
    scheme_wrong_type("char-general-category", "character", 0, argc, argv);

  c = SCHEME_CHAR_VAL(argv[0]);
  cat = scheme_general_category(c);
  if (!general_category_symbols[cat]) {
    Scheme_Object *s;
    s = scheme_intern_symbol(general_category_names[cat]);
    general_category_symbols[cat] = s;
  }

  return general_category_symbols[cat];
}

Here is the caller graph for this function:

static Scheme_Object* char_graphic ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object* char_gt ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object* char_gt_ci ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object* char_gt_eq ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object* char_gt_eq_ci ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object* char_lower_case ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object* char_lt ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object* char_lt_ci ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object* char_lt_eq ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object* char_lt_eq_ci ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object * char_map_list ( int  argc,
Scheme_Object argv[] 
) [static]

Definition at line 440 of file char.c.

{
  int i, bottom, top, uniform;
  Scheme_Object *l = scheme_null;

# define cons scheme_make_pair

  for (i = 2 * (NUM_UCHAR_RANGES - 1); i >= 0; i -= 2) {
    bottom = mapped_uchar_ranges[i];
    top = mapped_uchar_ranges[i + 1];
    if (top & URANGE_VARIES) {
      top -= URANGE_VARIES;
      uniform = 0;
    } else
      uniform = 1;
    l = cons(cons(scheme_make_integer_value(bottom),
                  cons(scheme_make_integer_value(top),
                       cons((uniform ? scheme_true : scheme_false),
                            scheme_null))),
             l);
  }

  return l;
}

Here is the caller graph for this function:

static Scheme_Object* char_numeric ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object * char_p ( int  argc,
Scheme_Object argv[] 
) [static]

Definition at line 283 of file char.c.

{
  return (SCHEME_CHARP(argv[0]) ? scheme_true : scheme_false);
}

Here is the caller graph for this function:

static Scheme_Object* char_punctuation ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object* char_symbolic ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object* char_title_case ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object* char_titlecase ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object * char_to_integer ( int  argc,
Scheme_Object argv[] 
) [static]

Definition at line 344 of file char.c.

{
  mzchar c;

  if (!SCHEME_CHARP(argv[0]))
    scheme_wrong_type("char->integer", "character", 0, argc, argv);

  c = SCHEME_CHAR_VAL(argv[0]);

  return scheme_make_integer_value(c);
}

Here is the caller graph for this function:

static Scheme_Object* char_upcase ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object* char_upper_case ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object * char_utf8_length ( int  argc,
Scheme_Object argv[] 
) [static]

Definition at line 418 of file char.c.

{
  mzchar wc;
  if (!SCHEME_CHARP(argv[0]))
    scheme_wrong_type("char-utf-8-length", "character", 0, argc, argv);

  wc = SCHEME_CHAR_VAL(argv[0]);
  if (wc < 0x80) {
    return scheme_make_integer(1);
  } else if (wc < 0x800) {
    return scheme_make_integer(2);
  } else if (wc < 0x10000) {
    return scheme_make_integer(3);
  } else if (wc < 0x200000) {
    return scheme_make_integer(4);
  } else if (wc < 0x4000000) {
    return scheme_make_integer(5);
  } else {
    return scheme_make_integer(6);
  }
}

Here is the caller graph for this function:

static Scheme_Object* char_whitespace ( int  argc,
Scheme_Object argv[] 
) [static]

Here is the caller graph for this function:

static Scheme_Object * integer_to_char ( int  argc,
Scheme_Object argv[] 
) [static]

Definition at line 357 of file char.c.

{
  if (SCHEME_INTP(argv[0])) {
    long v;
    v = SCHEME_INT_VAL(argv[0]);
    if ((v >= 0) 
       && (v <= 0x10FFFF)
       && ((v < 0xD800) || (v > 0xDFFF)))
      return _scheme_make_char(v);
  } else if (SCHEME_BIGNUMP(argv[0])
            && SCHEME_BIGPOS(argv[0])) {
    /* On 32-bit machines, there's still a chance... */
    long y;
    if (scheme_get_int_val(argv[0], &y)) {
      if (y <= 0x10FFFF)
       return _scheme_make_char(y);
    }
  }

  scheme_wrong_type("integer->char", 
                  "exact integer in [0,#x10FFFF], not in [#xD800,#xDFFF]", 
                  0, argc, argv);
  return NULL;
}

Here is the caller graph for this function:

Definition at line 73 of file char.c.

{
  Scheme_Object *p;
  int i;

  REGISTER_SO(scheme_char_constants);
  REGISTER_SO(general_category_symbols);

  scheme_char_constants = 
    (Scheme_Object **)scheme_malloc_eternal(256 * sizeof(Scheme_Object*));
    
  for (i = 0; i < 256; i++) {
    Scheme_Object *sc;
    sc = scheme_alloc_eternal_small_object();
    sc->type = scheme_char_type;
    SCHEME_CHAR_VAL(sc) = i;
    
    scheme_char_constants[i] = sc;
  }

  p = scheme_make_folding_prim(char_p, "char?", 1, 1, 1);
  SCHEME_PRIM_PROC_FLAGS(p) |= SCHEME_PRIM_IS_UNARY_INLINED;
  scheme_add_global_constant("char?", p, env);

  p = scheme_make_folding_prim(char_eq, "char=?", 2, -1, 1);
  SCHEME_PRIM_PROC_FLAGS(p) |= SCHEME_PRIM_IS_BINARY_INLINED;
  scheme_add_global_constant("char=?", p, env);

  scheme_add_global_constant("char<?", 
                          scheme_make_folding_prim(char_lt, 
                                                "char<?", 
                                                2, -1, 1), 
                          env);
  scheme_add_global_constant("char>?", 
                          scheme_make_folding_prim(char_gt, 
                                                "char>?", 
                                                2, -1, 1), 
                          env);
  scheme_add_global_constant("char<=?", 
                          scheme_make_folding_prim(char_lt_eq, 
                                                "char<=?", 
                                                2, -1, 1), 
                          env);
  scheme_add_global_constant("char>=?", 
                          scheme_make_folding_prim(char_gt_eq, 
                                                "char>=?", 
                                                2, -1, 1), 
                          env);
  scheme_add_global_constant("char-ci=?", 
                          scheme_make_folding_prim(char_eq_ci, 
                                                "char-ci=?", 
                                                2, -1, 1), 
                          env);
  scheme_add_global_constant("char-ci<?", 
                          scheme_make_folding_prim(char_lt_ci, 
                                                "char-ci<?", 
                                                2, -1, 1), 
                          env);
  scheme_add_global_constant("char-ci>?", 
                          scheme_make_folding_prim(char_gt_ci, 
                                                "char-ci>?", 
                                                2, -1, 1), 
                          env);
  scheme_add_global_constant("char-ci<=?", 
                          scheme_make_folding_prim(char_lt_eq_ci, 
                                                "char-ci<=?", 
                                                2, -1, 1), 
                          env);
  scheme_add_global_constant("char-ci>=?", 
                          scheme_make_folding_prim(char_gt_eq_ci, 
                                                "char-ci>=?", 
                                                2, -1, 1), 
                          env);
  scheme_add_global_constant("char-alphabetic?", 
                          scheme_make_folding_prim(char_alphabetic, 
                                                "char-alphabetic?", 
                                                1, 1, 1), 
                          env);
  scheme_add_global_constant("char-numeric?", 
                          scheme_make_folding_prim(char_numeric, 
                                                "char-numeric?", 
                                                1, 1, 1), 
                          env);
  scheme_add_global_constant("char-symbolic?", 
                          scheme_make_folding_prim(char_symbolic, 
                                                "char-symbolic?", 
                                                1, 1, 1), 
                          env);
  scheme_add_global_constant("char-graphic?", 
                          scheme_make_folding_prim(char_graphic, 
                                                "char-graphic?", 
                                                1, 1, 1), 
                          env);
  scheme_add_global_constant("char-whitespace?", 
                          scheme_make_folding_prim(char_whitespace, 
                                                "char-whitespace?", 
                                                1, 1, 1), 
                          env);
  scheme_add_global_constant("char-blank?", 
                          scheme_make_folding_prim(char_blank, 
                                                "char-blank?", 
                                                1, 1, 1), 
                          env);
  scheme_add_global_constant("char-iso-control?", 
                          scheme_make_folding_prim(char_control, 
                                                "char-iso-control?", 
                                                1, 1, 1), 
                          env);
  scheme_add_global_constant("char-punctuation?", 
                          scheme_make_folding_prim(char_punctuation, 
                                                "char-punctuation?", 
                                                1, 1, 1), 
                          env);
  scheme_add_global_constant("char-upper-case?", 
                          scheme_make_folding_prim(char_upper_case, 
                                                "char-upper-case?", 
                                                1, 1, 1),
                          env);
  scheme_add_global_constant("char-title-case?", 
                          scheme_make_folding_prim(char_title_case, 
                                                "char-title-case?", 
                                                1, 1, 1),
                          env);
  scheme_add_global_constant("char-lower-case?", 
                          scheme_make_folding_prim(char_lower_case, 
                                                "char-lower-case?", 
                                                1, 1, 1), 
                          env);
  scheme_add_global_constant("char-title-case?", 
                          scheme_make_folding_prim(char_title_case, 
                                                "char-title-case?", 
                                                1, 1, 1), 
                          env);
  scheme_add_global_constant("char->integer", 
                          scheme_make_folding_prim(char_to_integer, 
                                                "char->integer", 
                                                1, 1, 1),
                          env);
  scheme_add_global_constant("integer->char",
                          scheme_make_folding_prim(integer_to_char, 
                                                "integer->char",
                                                1, 1, 1), 
                          env);
  scheme_add_global_constant("char-upcase", 
                          scheme_make_folding_prim(char_upcase, 
                                                "char-upcase", 
                                                1, 1, 1), 
                          env);
  scheme_add_global_constant("char-downcase", 
                          scheme_make_folding_prim(char_downcase, 
                                                "char-downcase", 
                                                1, 1, 1),
                          env);
  scheme_add_global_constant("char-titlecase", 
                          scheme_make_folding_prim(char_titlecase, 
                                                "char-titlecase", 
                                                1, 1, 1),
                          env);
  scheme_add_global_constant("char-foldcase", 
                          scheme_make_folding_prim(char_foldcase, 
                                                "char-foldcase", 
                                                1, 1, 1),
                          env);
  scheme_add_global_constant("char-general-category", 
                          scheme_make_folding_prim(char_general_category, 
                                                "char-general-category", 
                                                1, 1, 1),
                          env);

  scheme_add_global_constant("char-utf-8-length", 
                          scheme_make_folding_prim(char_utf8_length, 
                                                "char-utf-8-length", 
                                                1, 1, 1),
                          env);

  scheme_add_global_constant("make-known-char-range-list", 
                          scheme_make_immed_prim(char_map_list, 
                                              "make-known-char-range-list", 
                                              0, 0),
                          env);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 68 of file char.c.

{
  init_uchar_table();
}

Here is the caller graph for this function:

Definition at line 255 of file char.c.

Definition at line 270 of file char.c.

{
  if ((v >= 0) 
      && (v <= 0x10FFFF)
      && ((v < 0xD800) || (v > 0xDFFF)))
    return scheme_make_char(v);

  return scheme_char_constants[0];
}

Variable Documentation

Scheme_Object* general_category_symbols[NUM_GENERAL_CATEGORIES] [static]

Definition at line 66 of file char.c.

Definition at line 31 of file char.c.