Back to index

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

Go to the source code of this file.

Defines

#define eucjp_islead(c)   ((UChar )((c) - 0xa1) > 0xfe - 0xa1)

Functions

static int eucjp_mbc_enc_len (const UChar *p)
static OnigCodePoint eucjp_mbc_to_code (const UChar *p, const UChar *end)
static int eucjp_code_to_mbclen (OnigCodePoint code)
static int eucjp_code_to_mbc (OnigCodePoint code, UChar *buf)
static int eucjp_mbc_to_normalize (OnigAmbigType flag, const UChar **pp, const UChar *end, UChar *lower)
static int eucjp_is_mbc_ambiguous (OnigAmbigType flag, const UChar **pp, const UChar *end)
static int eucjp_is_code_ctype (OnigCodePoint code, unsigned int ctype)
static UChareucjp_left_adjust_char_head (const UChar *start, const UChar *s)
static int eucjp_is_allowed_reverse_match (const UChar *s, const UChar *end)

Variables

static const int EncLen_EUCJP []
OnigEncodingType OnigEncodingEUC_JP

Define Documentation

#define eucjp_islead (   c)    ((UChar )((c) - 0xa1) > 0xfe - 0xa1)

Definition at line 32 of file euc_jp.c.


Function Documentation

static int eucjp_code_to_mbc ( OnigCodePoint  code,
UChar buf 
) [static]

Definition at line 106 of file euc_jp.c.

{
  UChar *p = buf;

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

#if 1
  if (enc_len(ONIG_ENCODING_EUC_JP, buf) != (p - buf))
    return ONIGENCERR_INVALID_WIDE_CHAR_VALUE;
#endif  
  return p - buf;
}
static int eucjp_code_to_mbclen ( OnigCodePoint  code) [static]

Definition at line 78 of file euc_jp.c.

{
  if (ONIGENC_IS_CODE_ASCII(code)) return 1;
  else if ((code & 0xff0000) != 0) return 3;
  else if ((code &   0xff00) != 0) return 2;
  else return 0;
}

Here is the caller graph for this function:

static int eucjp_is_allowed_reverse_match ( const UChar s,
const UChar end 
) [static]

Definition at line 193 of file euc_jp.c.

{
  const UChar c = *s;
  if (c <= 0x7e || c == 0x8e || c == 0x8f)
    return TRUE;
  else
    return FALSE;
}
static int eucjp_is_code_ctype ( OnigCodePoint  code,
unsigned int  ctype 
) [static]

Definition at line 159 of file euc_jp.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 (eucjp_code_to_mbclen(code) > 1 ? TRUE : FALSE);
    }
  }

  return FALSE;
}

Here is the call graph for this function:

static int eucjp_is_mbc_ambiguous ( OnigAmbigType  flag,
const UChar **  pp,
const UChar end 
) [static]

Definition at line 153 of file euc_jp.c.

Here is the call graph for this function:

static UChar* eucjp_left_adjust_char_head ( const UChar start,
const UChar s 
) [static]

Definition at line 174 of file euc_jp.c.

{
  /* In this encoding
     mb-trail bytes doesn't mix with single bytes.
  */
  const UChar *p;
  int len;

  if (s <= start) return (UChar* )s;
  p = s;

  while (!eucjp_islead(*p) && p > start) p--;
  len = enc_len(ONIG_ENCODING_EUC_JP, p);
  if (p + len > s) return (UChar* )p;
  p += len;
  return (UChar* )(p + ((s - p) & ~1));
}
static int eucjp_mbc_enc_len ( const UChar p) [static]

Definition at line 54 of file euc_jp.c.

{
  return EncLen_EUCJP[*p];
}
static OnigCodePoint eucjp_mbc_to_code ( const UChar p,
const UChar end 
) [static]

Definition at line 60 of file euc_jp.c.

{
  int c, i, len;
  OnigCodePoint n;

  len = enc_len(ONIG_ENCODING_EUC_JP, 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;
}
static int eucjp_mbc_to_normalize ( OnigAmbigType  flag,
const UChar **  pp,
const UChar end,
UChar lower 
) [static]

Definition at line 122 of file euc_jp.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(ONIG_ENCODING_EUC_JP, p);
    if (lower != p) {
      int i;
      for (i = 0; i < len; i++) {
       *lower++ = *p++;
      }
    }
    (*pp) += len;
    return len; /* return byte length of converted char to lower */
  }
}

Variable Documentation

const int EncLen_EUCJP[] [static]
Initial value:
 {
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1
}

Definition at line 34 of file euc_jp.c.