Back to index

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

Go to the source code of this file.

Defines

#define SJIS_ISMB_FIRST(byte)   (EncLen_SJIS[byte] > 1)
#define SJIS_ISMB_TRAIL(byte)   SJIS_CAN_BE_TRAIL_TABLE[(byte)]

Functions

static int sjis_mbc_enc_len (const UChar *p)
static int sjis_code_to_mbclen (OnigCodePoint code)
static OnigCodePoint sjis_mbc_to_code (const UChar *p, const UChar *end)
static int sjis_code_to_mbc (OnigCodePoint code, UChar *buf)
static int sjis_mbc_to_normalize (OnigAmbigType flag, const UChar **pp, const UChar *end, UChar *lower)
static int sjis_is_mbc_ambiguous (OnigAmbigType flag, const UChar **pp, const UChar *end)
static int sjis_is_code_ctype (OnigCodePoint code, unsigned int ctype)
static UCharsjis_left_adjust_char_head (const UChar *start, const UChar *s)
static int sjis_is_allowed_reverse_match (const UChar *s, const UChar *end)

Variables

static const int EncLen_SJIS []
static const char SJIS_CAN_BE_TRAIL_TABLE [256]
OnigEncodingType OnigEncodingSJIS

Define Documentation

#define SJIS_ISMB_FIRST (   byte)    (EncLen_SJIS[byte] > 1)

Definition at line 70 of file sjis.c.

#define SJIS_ISMB_TRAIL (   byte)    SJIS_CAN_BE_TRAIL_TABLE[(byte)]

Definition at line 71 of file sjis.c.


Function Documentation

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

Definition at line 115 of file sjis.c.

{
  UChar *p = buf;

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

#if 0
  if (enc_len(ONIG_ENCODING_SJIS, buf) != (p - buf))
    return REGERR_INVALID_WIDE_CHAR_VALUE;
#endif
  return p - buf;
}
static int sjis_code_to_mbclen ( OnigCodePoint  code) [static]

Definition at line 80 of file sjis.c.

{
  if (code < 256) {
    if (EncLen_SJIS[(int )code] == 1)
      return 1;
    else
      return 0;
  }
  else if (code <= 0xffff) {
    return 2;
  }
  else
    return 0;
}

Here is the caller graph for this function:

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

Definition at line 206 of file sjis.c.

{
  const UChar c = *s;
  return (SJIS_ISMB_TRAIL(c) ? FALSE : TRUE);
}
static int sjis_is_code_ctype ( OnigCodePoint  code,
unsigned int  ctype 
) [static]

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

  return FALSE;
}

Here is the call graph for this function:

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

Definition at line 161 of file sjis.c.

Here is the call graph for this function:

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

Definition at line 183 of file sjis.c.

{
  const UChar *p;
  int len;

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

  if (SJIS_ISMB_TRAIL(*p)) {
    while (p > start) {
      if (! SJIS_ISMB_FIRST(*--p)) {
       p++;
       break;
      }
    } 
  }
  len = enc_len(ONIG_ENCODING_SJIS, p);
  if (p + len > s) return (UChar* )p;
  p += len;
  return (UChar* )(p + ((s - p) & ~1));
}
static int sjis_mbc_enc_len ( const UChar p) [static]

Definition at line 74 of file sjis.c.

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

Definition at line 96 of file sjis.c.

{
  int c, i, len;
  OnigCodePoint n;

  len = enc_len(ONIG_ENCODING_SJIS, p);
  c = *p++;
  n = c;
  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 sjis_mbc_to_normalize ( OnigAmbigType  flag,
const UChar **  pp,
const UChar end,
UChar lower 
) [static]

Definition at line 130 of file sjis.c.

{
  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 {
    int len = enc_len(ONIG_ENCODING_SJIS, 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_SJIS[] [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, 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, 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, 2, 2, 2, 2, 2, 2, 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