Blame src/ascii.c

Packit b89d10
/**********************************************************************
Packit b89d10
  ascii.c -  Oniguruma (regular expression library)
Packit b89d10
**********************************************************************/
Packit b89d10
/*-
Packit b89d10
 * Copyright (c) 2002-2018  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
Packit b89d10
 * All rights reserved.
Packit b89d10
 *
Packit b89d10
 * Redistribution and use in source and binary forms, with or without
Packit b89d10
 * modification, are permitted provided that the following conditions
Packit b89d10
 * are met:
Packit b89d10
 * 1. Redistributions of source code must retain the above copyright
Packit b89d10
 *    notice, this list of conditions and the following disclaimer.
Packit b89d10
 * 2. Redistributions in binary form must reproduce the above copyright
Packit b89d10
 *    notice, this list of conditions and the following disclaimer in the
Packit b89d10
 *    documentation and/or other materials provided with the distribution.
Packit b89d10
 *
Packit b89d10
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
Packit b89d10
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit b89d10
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit b89d10
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
Packit b89d10
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit b89d10
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
Packit b89d10
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
Packit b89d10
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
Packit b89d10
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
Packit b89d10
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
Packit b89d10
 * SUCH DAMAGE.
Packit b89d10
 */
Packit b89d10
Packit b89d10
#include "regint.h"   /* for USE_CALLOUT */
Packit b89d10
Packit b89d10
static int
Packit b89d10
init(void)
Packit b89d10
{
Packit b89d10
#ifdef USE_CALLOUT
Packit b89d10
Packit b89d10
    int id;
Packit b89d10
    OnigEncoding enc;
Packit b89d10
    char* name;
Packit b89d10
    unsigned int args[4];
Packit b89d10
    OnigValue    opts[4];
Packit b89d10
Packit b89d10
    enc = ONIG_ENCODING_ASCII;
Packit b89d10
Packit b89d10
    name = "FAIL";        BC0_P(name, fail);
Packit b89d10
    name = "MISMATCH";    BC0_P(name, mismatch);
Packit b89d10
Packit b89d10
    name = "MAX";
Packit b89d10
    args[0] = ONIG_TYPE_TAG | ONIG_TYPE_LONG;
Packit b89d10
    args[1] = ONIG_TYPE_CHAR;
Packit b89d10
    opts[0].c = 'X';
Packit b89d10
    BC_B_O(name, max, 2, args, 1, opts);
Packit b89d10
Packit b89d10
    name = "ERROR";
Packit b89d10
    args[0] = ONIG_TYPE_LONG; opts[0].l = ONIG_ABORT;
Packit b89d10
    BC_P_O(name, error, 1, args, 1, opts);
Packit b89d10
Packit b89d10
    name = "COUNT";
Packit b89d10
    args[0] = ONIG_TYPE_CHAR; opts[0].c = '>';
Packit b89d10
    BC_B_O(name, count, 1, args, 1, opts);
Packit b89d10
Packit b89d10
    name = "TOTAL_COUNT";
Packit b89d10
    args[0] = ONIG_TYPE_CHAR; opts[0].c = '>';
Packit b89d10
    BC_B_O(name, total_count, 1, args, 1, opts);
Packit b89d10
Packit b89d10
    name = "CMP";
Packit b89d10
    args[0] = ONIG_TYPE_TAG | ONIG_TYPE_LONG;
Packit b89d10
    args[1] = ONIG_TYPE_STRING;
Packit b89d10
    args[2] = ONIG_TYPE_TAG | ONIG_TYPE_LONG;
Packit b89d10
    BC_P(name, cmp, 3, args);
Packit b89d10
Packit b89d10
#endif /* USE_CALLOUT */
Packit b89d10
Packit b89d10
  return ONIG_NORMAL;
Packit b89d10
}
Packit b89d10
Packit b89d10
#if 0
Packit b89d10
static int
Packit b89d10
is_initialized(void)
Packit b89d10
{
Packit b89d10
  /* Don't use this function */
Packit b89d10
  /* can't answer, because builtin callout entries removed in onig_end() */
Packit b89d10
  return 0;
Packit b89d10
}
Packit b89d10
#endif
Packit b89d10
Packit b89d10
static int
Packit b89d10
ascii_is_code_ctype(OnigCodePoint code, unsigned int ctype)
Packit b89d10
{
Packit b89d10
  if (code < 128)
Packit b89d10
    return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);
Packit b89d10
  else
Packit b89d10
    return FALSE;
Packit b89d10
}
Packit b89d10
Packit b89d10
OnigEncodingType OnigEncodingASCII = {
Packit b89d10
  onigenc_single_byte_mbc_enc_len,
Packit b89d10
  "US-ASCII",  /* name */
Packit b89d10
  1,           /* max enc length */
Packit b89d10
  1,           /* min enc length */
Packit b89d10
  onigenc_is_mbc_newline_0x0a,
Packit b89d10
  onigenc_single_byte_mbc_to_code,
Packit b89d10
  onigenc_single_byte_code_to_mbclen,
Packit b89d10
  onigenc_single_byte_code_to_mbc,
Packit b89d10
  onigenc_ascii_mbc_case_fold,
Packit b89d10
  onigenc_ascii_apply_all_case_fold,
Packit b89d10
  onigenc_ascii_get_case_fold_codes_by_str,
Packit b89d10
  onigenc_minimum_property_name_to_ctype,
Packit b89d10
  ascii_is_code_ctype,
Packit b89d10
  onigenc_not_support_get_ctype_code_range,
Packit b89d10
  onigenc_single_byte_left_adjust_char_head,
Packit b89d10
  onigenc_always_true_is_allowed_reverse_match,
Packit b89d10
  init,
Packit b89d10
  0, /* is_initialized */
Packit b89d10
  onigenc_always_true_is_valid_mbc_string,
Packit b89d10
  ENC_FLAG_ASCII_COMPATIBLE,
Packit b89d10
  0, 0
Packit b89d10
};