Back to index

php5  5.3.10
Defines | Functions | Variables
regenc.c File Reference
#include "regint.h"

Go to the source code of this file.

Defines

#define USE_APPLICATION_TO_LOWER_CASE_TABLE

Functions

int onigenc_init (void)
OnigEncoding onigenc_get_default_encoding (void)
int onigenc_set_default_encoding (OnigEncoding enc)
UCharonigenc_get_right_adjust_char_head (OnigEncoding enc, const UChar *start, const UChar *s)
UCharonigenc_get_right_adjust_char_head_with_prev (OnigEncoding enc, const UChar *start, const UChar *s, const UChar **prev)
UCharonigenc_get_prev_char_head (OnigEncoding enc, const UChar *start, const UChar *s)
UCharonigenc_step_back (OnigEncoding enc, const UChar *start, const UChar *s, int n)
UCharonigenc_step (OnigEncoding enc, const UChar *p, const UChar *end, int n)
int onigenc_strlen (OnigEncoding enc, const UChar *p, const UChar *end)
int onigenc_strlen_null (OnigEncoding enc, const UChar *s)
int onigenc_str_bytelen_null (OnigEncoding enc, const UChar *s)
void onigenc_set_default_caseconv_table (const UChar *table)
UCharonigenc_get_left_adjust_char_head (OnigEncoding enc, const UChar *start, const UChar *s)
int onigenc_ascii_get_all_pair_ambig_codes (OnigAmbigType flag, const OnigPairAmbigCodes **ccs)
int onigenc_nothing_get_all_comp_ambig_codes (OnigAmbigType flag, const OnigCompAmbigCodes **ccs)
int onigenc_iso_8859_1_get_all_pair_ambig_codes (OnigAmbigType flag, const OnigPairAmbigCodes **ccs)
int onigenc_ess_tsett_get_all_comp_ambig_codes (OnigAmbigType flag, const OnigCompAmbigCodes **ccs)
int onigenc_not_support_get_ctype_code_range (int ctype, const OnigCodePoint *sbr[], const OnigCodePoint *mbr[])
int onigenc_is_mbc_newline_0x0a (const UChar *p, const UChar *end)
int onigenc_ascii_mbc_to_normalize (OnigAmbigType flag, const UChar **p, const UChar *end, UChar *lower)
int onigenc_ascii_is_mbc_ambiguous (OnigAmbigType flag, const UChar **pp, const UChar *end)
int onigenc_single_byte_mbc_enc_len (const UChar *p)
OnigCodePoint onigenc_single_byte_mbc_to_code (const UChar *p, const UChar *end)
int onigenc_single_byte_code_to_mbclen (OnigCodePoint code)
int onigenc_single_byte_code_to_mbc_first (OnigCodePoint code)
int onigenc_single_byte_code_to_mbc (OnigCodePoint code, UChar *buf)
UCharonigenc_single_byte_left_adjust_char_head (const UChar *start, const UChar *s)
int onigenc_always_true_is_allowed_reverse_match (const UChar *s, const UChar *end)
int onigenc_always_false_is_allowed_reverse_match (const UChar *s, const UChar *end)
OnigCodePoint onigenc_mbn_mbc_to_code (OnigEncoding enc, const UChar *p, const UChar *end)
int onigenc_mbn_mbc_to_normalize (OnigEncoding enc, OnigAmbigType flag, const UChar **pp, const UChar *end, UChar *lower)
int onigenc_mbn_is_mbc_ambiguous (OnigEncoding enc, OnigAmbigType flag, const UChar **pp, const UChar *end)
int onigenc_mb2_code_to_mbclen (OnigCodePoint code)
int onigenc_mb4_code_to_mbclen (OnigCodePoint code)
int onigenc_mb2_code_to_mbc_first (OnigCodePoint code)
int onigenc_mb4_code_to_mbc_first (OnigCodePoint code)
int onigenc_mb2_code_to_mbc (OnigEncoding enc, OnigCodePoint code, UChar *buf)
int onigenc_mb4_code_to_mbc (OnigEncoding enc, OnigCodePoint code, UChar *buf)
int onigenc_mb2_is_code_ctype (OnigEncoding enc, OnigCodePoint code, unsigned int ctype)
int onigenc_mb4_is_code_ctype (OnigEncoding enc, OnigCodePoint code, unsigned int ctype)
int onigenc_with_ascii_strncmp (OnigEncoding enc, const UChar *p, const UChar *end, const UChar *sascii, int n)

Variables

OnigEncoding OnigEncDefaultCharEncoding = ONIG_ENCODING_INIT_DEFAULT
const unsigned short OnigEnc_Unicode_ISO_8859_1_CtypeTable [256]
const UCharOnigEncAsciiToLowerCaseTable = (const UChar* )0
const unsigned short OnigEncAsciiCtypeTable [256]
const UChar OnigEncISO_8859_1_ToLowerCaseTable [256]
const OnigPairAmbigCodes OnigAsciiPairAmbigCodes []

Define Documentation

Definition at line 176 of file regenc.c.


Function Documentation

Definition at line 685 of file regenc.c.

{
  return FALSE;
}
int onigenc_always_true_is_allowed_reverse_match ( const UChar s,
const UChar end 
)

Definition at line 679 of file regenc.c.

{
  return TRUE;
}

Definition at line 477 of file regenc.c.

{
  if (flag == ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) {
    *ccs = OnigAsciiPairAmbigCodes;
    return (sizeof(OnigAsciiPairAmbigCodes) / sizeof(OnigPairAmbigCodes));
  }
  else {
    return 0;
  }
}
int onigenc_ascii_is_mbc_ambiguous ( OnigAmbigType  flag,
const UChar **  pp,
const UChar end 
)

Definition at line 627 of file regenc.c.

{
  const UChar* p = *pp;

  (*pp)++;
  if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) {
    return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p);
  }
  else {
    return FALSE;
  }
}
int onigenc_ascii_mbc_to_normalize ( OnigAmbigType  flag,
const UChar **  p,
const UChar end,
UChar lower 
)

Definition at line 612 of file regenc.c.

{
  if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) {
    *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(**p);
  }
  else {
    *lower = **p;
  }

  (*p)++;
  return 1; /* return byte length of converted char to lower */
}

Definition at line 579 of file regenc.c.

{
  static const OnigCompAmbigCodes folds[] = {
    { 2, 0xdf, {{ 2, { 0x53, 0x53 } }, { 2, { 0x73, 0x73} } } }
  };

  if (flag == ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) {
    *ccs = folds;
    return sizeof(folds) / sizeof(OnigCompAmbigCodes);
  }
  else
    return 0;
}

Definition at line 41 of file regenc.c.

UChar* onigenc_get_left_adjust_char_head ( OnigEncoding  enc,
const UChar start,
const UChar s 
)

Definition at line 415 of file regenc.c.

{
  return ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s);
}
UChar* onigenc_get_prev_char_head ( OnigEncoding  enc,
const UChar start,
const UChar s 
)

Definition at line 80 of file regenc.c.

{
  if (s <= start)
    return (UChar* )NULL;

  return ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s - 1);
}

Here is the caller graph for this function:

UChar* onigenc_get_right_adjust_char_head ( OnigEncoding  enc,
const UChar start,
const UChar s 
)

Definition at line 54 of file regenc.c.

{
  UChar* p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s);
  if (p < s) {
    p += enc_len(enc, p);
  }
  return p;
}

Here is the caller graph for this function:

UChar* onigenc_get_right_adjust_char_head_with_prev ( OnigEncoding  enc,
const UChar start,
const UChar s,
const UChar **  prev 
)

Definition at line 64 of file regenc.c.

{
  UChar* p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s);

  if (p < s) {
    if (prev) *prev = (const UChar* )p;
    p += enc_len(enc, p);
  }
  else {
    if (prev) *prev = (const UChar* )NULL; /* Sorry */
  }
  return p;
}

Here is the caller graph for this function:

int onigenc_init ( void  )

Definition at line 35 of file regenc.c.

{
  return 0;
}

Here is the caller graph for this function:

int onigenc_is_mbc_newline_0x0a ( const UChar p,
const UChar end 
)

Definition at line 602 of file regenc.c.

{
  if (p < end) {
    if (*p == 0x0a) return 1;
  }
  return 0;
}

Definition at line 497 of file regenc.c.

{
  static const OnigPairAmbigCodes cc[] = {
    { 0xc0, 0xe0 },
    { 0xc1, 0xe1 },
    { 0xc2, 0xe2 },
    { 0xc3, 0xe3 },
    { 0xc4, 0xe4 },
    { 0xc5, 0xe5 },
    { 0xc6, 0xe6 },
    { 0xc7, 0xe7 },
    { 0xc8, 0xe8 },
    { 0xc9, 0xe9 },
    { 0xca, 0xea },
    { 0xcb, 0xeb },
    { 0xcc, 0xec },
    { 0xcd, 0xed },
    { 0xce, 0xee },
    { 0xcf, 0xef },

    { 0xd0, 0xf0 },
    { 0xd1, 0xf1 },
    { 0xd2, 0xf2 },
    { 0xd3, 0xf3 },
    { 0xd4, 0xf4 },
    { 0xd5, 0xf5 },
    { 0xd6, 0xf6 },
    { 0xd8, 0xf8 },
    { 0xd9, 0xf9 },
    { 0xda, 0xfa },
    { 0xdb, 0xfb },
    { 0xdc, 0xfc },
    { 0xdd, 0xfd },
    { 0xde, 0xfe },

    { 0xe0, 0xc0 },
    { 0xe1, 0xc1 },
    { 0xe2, 0xc2 },
    { 0xe3, 0xc3 },
    { 0xe4, 0xc4 },
    { 0xe5, 0xc5 },
    { 0xe6, 0xc6 },
    { 0xe7, 0xc7 },
    { 0xe8, 0xc8 },
    { 0xe9, 0xc9 },
    { 0xea, 0xca },
    { 0xeb, 0xcb },
    { 0xec, 0xcc },
    { 0xed, 0xcd },
    { 0xee, 0xce },
    { 0xef, 0xcf },

    { 0xf0, 0xd0 },
    { 0xf1, 0xd1 },
    { 0xf2, 0xd2 },
    { 0xf3, 0xd3 },
    { 0xf4, 0xd4 },
    { 0xf5, 0xd5 },
    { 0xf6, 0xd6 },
    { 0xf8, 0xd8 },
    { 0xf9, 0xd9 },
    { 0xfa, 0xda },
    { 0xfb, 0xdb },
    { 0xfc, 0xdc },
    { 0xfd, 0xdd },
    { 0xfe, 0xde }
  };

  if (flag == ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) {
    *ccs = OnigAsciiPairAmbigCodes;
    return (sizeof(OnigAsciiPairAmbigCodes) / sizeof(OnigPairAmbigCodes));
  }
  else if (flag == ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) {
    *ccs = cc;
    return sizeof(cc) / sizeof(OnigPairAmbigCodes);
  }
  else
    return 0;
}

Definition at line 809 of file regenc.c.

{
  UChar *p = buf;

  if ((code & 0xff00) != 0) {
    *p++ = (UChar )((code >>  8) & 0xff);
  }
  *p++ = (UChar )(code & 0xff);

#if 1
  if (enc_len(enc, buf) != (p - buf))
    return ONIGENCERR_INVALID_WIDE_CHAR_VALUE;
#endif
  return p - buf;
}

Here is the caller graph for this function:

Definition at line 775 of file regenc.c.

{
  int first;

  if ((code & 0xff00) != 0) {
    first = (code >> 8) & 0xff;
  }
  else {
    return (int )code;
  }
  return first;
}

Definition at line 759 of file regenc.c.

{
  if ((code & 0xff00) != 0) return 2;
  else return 1;
}
int onigenc_mb2_is_code_ctype ( OnigEncoding  enc,
OnigCodePoint  code,
unsigned int  ctype 
)

Definition at line 849 of file regenc.c.

{
  if (code < 128)
    return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);
  else {
    if ((ctype & (ONIGENC_CTYPE_WORD |
                  ONIGENC_CTYPE_GRAPH | ONIGENC_CTYPE_PRINT)) != 0) {
      return (ONIGENC_CODE_TO_MBCLEN(enc, code) > 1 ? TRUE : FALSE);
    }
  }

  return FALSE;
}

Here is the caller graph for this function:

Definition at line 826 of file regenc.c.

{
  UChar *p = buf;

  if ((code & 0xff000000) != 0) {
    *p++ = (UChar )((code >> 24) & 0xff);
  }
  if ((code & 0xff0000) != 0 || p != buf) {
    *p++ = (UChar )((code >> 16) & 0xff);
  }
  if ((code & 0xff00) != 0 || p != buf) {
    *p++ = (UChar )((code >> 8) & 0xff);
  }
  *p++ = (UChar )(code & 0xff);

#if 1
  if (enc_len(enc, buf) != (p - buf))
    return ONIGENCERR_INVALID_WIDE_CHAR_VALUE;
#endif
  return p - buf;
}

Here is the caller graph for this function:

Definition at line 789 of file regenc.c.

{
  int first;

  if ((code & 0xff000000) != 0) {
    first = (code >> 24) & 0xff;
  }
  else if ((code & 0xff0000) != 0) {
    first = (code >> 16) & 0xff;
  }
  else if ((code & 0xff00) != 0) {
    first = (code >>  8) & 0xff;
  }
  else {
    return (int )code;
  }
  return first;
}

Definition at line 766 of file regenc.c.

{
       if ((code & 0xff000000) != 0) return 4;
  else if ((code & 0xff0000) != 0) return 3;
  else if ((code & 0xff00) != 0) return 2;
  else return 1;
}
int onigenc_mb4_is_code_ctype ( OnigEncoding  enc,
OnigCodePoint  code,
unsigned int  ctype 
)

Definition at line 865 of file regenc.c.

{
  if (code < 128)
    return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);
  else {
    if ((ctype & (ONIGENC_CTYPE_WORD |
                  ONIGENC_CTYPE_GRAPH | ONIGENC_CTYPE_PRINT)) != 0) {
      return (ONIGENC_CODE_TO_MBCLEN(enc, code) > 1 ? TRUE : FALSE);
    }
  }

  return FALSE;
}

Here is the caller graph for this function:

int onigenc_mbn_is_mbc_ambiguous ( OnigEncoding  enc,
OnigAmbigType  flag,
const UChar **  pp,
const UChar end 
)

Definition at line 739 of file regenc.c.

{
  const UChar* p = *pp;

  if (ONIGENC_IS_MBC_ASCII(p)) {
    (*pp)++;
    if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) {
      return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p);
    }
    else {
      return FALSE;
    }
  }

  (*pp) += enc_len(enc, p);
  return FALSE;
}

Here is the caller graph for this function:

OnigCodePoint onigenc_mbn_mbc_to_code ( OnigEncoding  enc,
const UChar p,
const UChar end 
)

Definition at line 691 of file regenc.c.

{
  int c, i, len;
  OnigCodePoint n;

  len = enc_len(enc, p);
  n = (OnigCodePoint )(*p++);
  if (len == 1) return n;

  for (i = 1; i < len; i++) {
    if (p >= end) break;
    c = *p++;
    n <<= 8;  n += c;
  }
  return n;
}

Here is the caller graph for this function:

int onigenc_mbn_mbc_to_normalize ( OnigEncoding  enc,
OnigAmbigType  flag,
const UChar **  pp,
const UChar end,
UChar lower 
)

Definition at line 709 of file regenc.c.

{
  int len;
  const UChar *p = *pp;

  if (ONIGENC_IS_MBC_ASCII(p)) {
    if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) {
      *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);
    }
    else {
      *lower = *p;
    }
    (*pp)++;
    return 1;
  }
  else {
    len = enc_len(enc, p);
    if (lower != p) {
      int i;
      for (i = 0; i < len; i++) {
       *lower++ = *p++;
      }
    }
    (*pp) += len;
    return len; /* return byte length of converted to lower char */
  }
}

Here is the caller graph for this function:

int onigenc_not_support_get_ctype_code_range ( int  ctype,
const OnigCodePoint sbr[],
const OnigCodePoint mbr[] 
)

Definition at line 595 of file regenc.c.

Definition at line 490 of file regenc.c.

{
  return 0;
}
void onigenc_set_default_caseconv_table ( const UChar table)

Definition at line 399 of file regenc.c.

{
  if (table == (const UChar* )0) {
#ifndef USE_APPLICATION_TO_LOWER_CASE_TABLE
    table = BuiltInAsciiToLowerCaseTable;
#else
    return ;
#endif
  }

  if (table != OnigEncAsciiToLowerCaseTable) {
    OnigEncAsciiToLowerCaseTable = table;
  }
}

Here is the caller graph for this function:

Definition at line 47 of file regenc.c.

{
  OnigEncDefaultCharEncoding = enc;
  return 0;
}

Here is the caller graph for this function:

Definition at line 666 of file regenc.c.

{
  *buf = (UChar )(code & 0xff);
  return 1;
}

Definition at line 660 of file regenc.c.

{
  return (code & 0xff);
}

Definition at line 654 of file regenc.c.

{
  return 1;
}
UChar* onigenc_single_byte_left_adjust_char_head ( const UChar start,
const UChar s 
)

Definition at line 673 of file regenc.c.

{
  return (UChar* )s;
}

Definition at line 642 of file regenc.c.

{
  return 1;
}
OnigCodePoint onigenc_single_byte_mbc_to_code ( const UChar p,
const UChar end 
)

Definition at line 648 of file regenc.c.

{
  return (OnigCodePoint )(*p);
}
UChar* onigenc_step ( OnigEncoding  enc,
const UChar p,
const UChar end,
int  n 
)

Definition at line 101 of file regenc.c.

{
  UChar* q = (UChar* )p;
  while (n-- > 0) {
    q += ONIGENC_MBC_ENC_LEN(enc, q);
  }
  return (q <= end ? q : NULL);
}

Here is the caller graph for this function:

UChar* onigenc_step_back ( OnigEncoding  enc,
const UChar start,
const UChar s,
int  n 
)

Definition at line 89 of file regenc.c.

{
  while (ONIG_IS_NOT_NULL(s) && n-- > 0) {
    if (s <= start)
      return (UChar* )NULL;

    s = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s - 1);
  }
  return (UChar* )s;
}
int onigenc_str_bytelen_null ( OnigEncoding  enc,
const UChar s 
)

Definition at line 149 of file regenc.c.

{
  UChar* start = (UChar* )s;
  UChar* p = (UChar* )s;

  while (1) {
    if (*p == '\0') {
      UChar* q;
      int len = ONIGENC_MBC_MINLEN(enc);

      if (len == 1) return (int )(p - start);
      q = p + 1;
      while (len > 1) {
        if (*q != '\0') break;
        q++;
        len--;
      }
      if (len == 1) return (int )(p - start);
    }
    p += ONIGENC_MBC_ENC_LEN(enc, p);
  }
}

Here is the caller graph for this function:

int onigenc_strlen ( OnigEncoding  enc,
const UChar p,
const UChar end 
)

Definition at line 111 of file regenc.c.

{
  int n = 0;
  UChar* q = (UChar* )p;
  
  while (q < end) {
    q += ONIGENC_MBC_ENC_LEN(enc, q);
    n++;
  }
  return n;
}

Here is the caller graph for this function:

int onigenc_strlen_null ( OnigEncoding  enc,
const UChar s 
)

Definition at line 124 of file regenc.c.

{
  int n = 0;
  UChar* p = (UChar* )s;
  
  while (1) {
    if (*p == '\0') {
      UChar* q;
      int len = ONIGENC_MBC_MINLEN(enc);

      if (len == 1) return n;
      q = p + 1;
      while (len > 1) {
        if (*q != '\0') break;
        q++;
        len--;
      }
      if (len == 1) return n;
    }
    p += ONIGENC_MBC_ENC_LEN(enc, p);
    n++;
  }
}
int onigenc_with_ascii_strncmp ( OnigEncoding  enc,
const UChar p,
const UChar end,
const UChar sascii,
int  n 
)

Definition at line 881 of file regenc.c.

{
  int x, c;

  while (n-- > 0) {
    if (p >= end) return (int )(*sascii);

    c = (int )ONIGENC_MBC_TO_CODE(enc, p, end);
    x = *sascii - c;
    if (x) return x;

    sascii++;
    p += enc_len(enc, p);
  }
  return 0;
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 420 of file regenc.c.

const unsigned short OnigEnc_Unicode_ISO_8859_1_CtypeTable[256]

Definition at line 178 of file regenc.c.

const unsigned short OnigEncAsciiCtypeTable[256]

Definition at line 290 of file regenc.c.

Definition at line 214 of file regenc.c.

Definition at line 32 of file regenc.c.

Definition at line 326 of file regenc.c.