Back to index

php5  5.3.10
Functions
regext.c File Reference
#include "regint.h"

Go to the source code of this file.

Functions

static void conv_ext0be32 (const UChar *s, const UChar *end, UChar *conv)
static void conv_ext0le32 (const UChar *s, const UChar *end, UChar *conv)
static void conv_ext0be (const UChar *s, const UChar *end, UChar *conv)
static void conv_ext0le (const UChar *s, const UChar *end, UChar *conv)
static void conv_swap4bytes (const UChar *s, const UChar *end, UChar *conv)
static void conv_swap2bytes (const UChar *s, const UChar *end, UChar *conv)
static int conv_encoding (OnigEncoding from, OnigEncoding to, const UChar *s, const UChar *end, UChar **conv, UChar **conv_end)
int onig_new_deluxe (regex_t **reg, const UChar *pattern, const UChar *pattern_end, OnigCompileInfo *ci, OnigErrorInfo *einfo)

Function Documentation

static int conv_encoding ( OnigEncoding  from,
OnigEncoding  to,
const UChar s,
const UChar end,
UChar **  conv,
UChar **  conv_end 
) [static]

Definition at line 95 of file regext.c.

{
  int len = end - s;

  if (to == ONIG_ENCODING_UTF16_BE) {
    if (from == ONIG_ENCODING_ASCII || from == ONIG_ENCODING_ISO_8859_1) {
      *conv = (UChar* )xmalloc(len * 2);
      CHECK_NULL_RETURN_VAL(*conv, ONIGERR_MEMORY);
      *conv_end = *conv + (len * 2);
      conv_ext0be(s, end, *conv);
      return 0;
    }
    else if (from == ONIG_ENCODING_UTF16_LE) {
    swap16:
      *conv = (UChar* )xmalloc(len);
      CHECK_NULL_RETURN_VAL(*conv, ONIGERR_MEMORY);
      *conv_end = *conv + len;
      conv_swap2bytes(s, end, *conv);
      return 0;
    }
  }
  else if (to == ONIG_ENCODING_UTF16_LE) {
    if (from == ONIG_ENCODING_ASCII || from == ONIG_ENCODING_ISO_8859_1) {
      *conv = (UChar* )xmalloc(len * 2);
      CHECK_NULL_RETURN_VAL(*conv, ONIGERR_MEMORY);
      *conv_end = *conv + (len * 2);
      conv_ext0le(s, end, *conv);
      return 0;
    }
    else if (from == ONIG_ENCODING_UTF16_BE) {
      goto swap16;
    }
  }
  if (to == ONIG_ENCODING_UTF32_BE) {
    if (from == ONIG_ENCODING_ASCII || from == ONIG_ENCODING_ISO_8859_1) {
      *conv = (UChar* )xmalloc(len * 4);
      CHECK_NULL_RETURN_VAL(*conv, ONIGERR_MEMORY);
      *conv_end = *conv + (len * 4);
      conv_ext0be32(s, end, *conv);
      return 0;
    }
    else if (from == ONIG_ENCODING_UTF32_LE) {
    swap32:
      *conv = (UChar* )xmalloc(len);
      CHECK_NULL_RETURN_VAL(*conv, ONIGERR_MEMORY);
      *conv_end = *conv + len;
      conv_swap4bytes(s, end, *conv);
      return 0;
    }
  }
  else if (to == ONIG_ENCODING_UTF32_LE) {
    if (from == ONIG_ENCODING_ASCII || from == ONIG_ENCODING_ISO_8859_1) {
      *conv = (UChar* )xmalloc(len * 4);
      CHECK_NULL_RETURN_VAL(*conv, ONIGERR_MEMORY);
      *conv_end = *conv + (len * 4);
      conv_ext0le32(s, end, *conv);
      return 0;
    }
    else if (from == ONIG_ENCODING_UTF32_BE) {
      goto swap32;
    }
  }

  return ONIGERR_NOT_SUPPORTED_ENCODING_COMBINATION;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void conv_ext0be ( const UChar s,
const UChar end,
UChar conv 
) [static]

Definition at line 55 of file regext.c.

{
  while (s < end) {
    *conv++ = '\0';
    *conv++ = *s++;
  }
}

Here is the caller graph for this function:

static void conv_ext0be32 ( const UChar s,
const UChar end,
UChar conv 
) [static]

Definition at line 33 of file regext.c.

{
  while (s < end) {
    *conv++ = '\0';
    *conv++ = '\0';
    *conv++ = '\0';
    *conv++ = *s++;
  }
}

Here is the caller graph for this function:

static void conv_ext0le ( const UChar s,
const UChar end,
UChar conv 
) [static]

Definition at line 64 of file regext.c.

{
  while (s < end) {
    *conv++ = *s++;
    *conv++ = '\0';
  }
}

Here is the caller graph for this function:

static void conv_ext0le32 ( const UChar s,
const UChar end,
UChar conv 
) [static]

Definition at line 44 of file regext.c.

{
  while (s < end) {
    *conv++ = *s++;
    *conv++ = '\0';
    *conv++ = '\0';
    *conv++ = '\0';
  }
}

Here is the caller graph for this function:

static void conv_swap2bytes ( const UChar s,
const UChar end,
UChar conv 
) [static]

Definition at line 85 of file regext.c.

{
  while (s < end) {
    *conv++ = s[1];
    *conv++ = s[0];
    s += 2;
  }
}

Here is the caller graph for this function:

static void conv_swap4bytes ( const UChar s,
const UChar end,
UChar conv 
) [static]

Definition at line 73 of file regext.c.

{
  while (s < end) {
    *conv++ = s[3];
    *conv++ = s[2];
    *conv++ = s[1];
    *conv++ = s[0];
    s += 4;
  }
}

Here is the caller graph for this function:

int onig_new_deluxe ( regex_t **  reg,
const UChar pattern,
const UChar pattern_end,
OnigCompileInfo ci,
OnigErrorInfo einfo 
)

Definition at line 163 of file regext.c.

{
  int r;
  UChar *cpat, *cpat_end;

  if (IS_NOT_NULL(einfo)) einfo->par = (UChar* )NULL;

  if (ci->pattern_enc != ci->target_enc) {
    r = conv_encoding(ci->pattern_enc, ci->target_enc, pattern, pattern_end,
                      &cpat, &cpat_end);
    if (r) return r;
  }
  else {
    cpat     = (UChar* )pattern;
    cpat_end = (UChar* )pattern_end;
  }

  r = onig_alloc_init(reg, ci->option, ci->ambig_flag, ci->target_enc,
                      ci->syntax);
  if (r) goto err;

  r = onig_compile(*reg, cpat, cpat_end, einfo);
  if (r) {
    onig_free(*reg);
    *reg = NULL;
  }

 err:
  if (cpat != pattern) xfree(cpat);

  return r;
}

Here is the call graph for this function: