diff options
Diffstat (limited to 'regparse.h')
| -rw-r--r-- | regparse.h | 89 |
1 files changed, 55 insertions, 34 deletions
diff --git a/regparse.h b/regparse.h index 7a6314098a..65da835a55 100644 --- a/regparse.h +++ b/regparse.h @@ -1,10 +1,11 @@ -#ifndef REGPARSE_H -#define REGPARSE_H +#ifndef ONIGMO_REGPARSE_H +#define ONIGMO_REGPARSE_H /********************************************************************** - regparse.h - Oniguruma (regular expression library) + regparse.h - Onigmo (Oniguruma-mod) (regular expression library) **********************************************************************/ /*- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp> + * Copyright (c) 2011-2019 K.Takata <kentkt AT csc DOT jp> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,6 +32,8 @@ #include "regint.h" +RUBY_SYMBOL_EXPORT_BEGIN + /* node type */ #define NT_STR 0 #define NT_CCLASS 1 @@ -64,7 +67,11 @@ BIT_NT_CANY | BIT_NT_BREF)) != 0) #define NTYPE(node) ((node)->u.base.type) -#define SET_NTYPE(node, ntype) (node)->u.base.type = (ntype) +#define SET_NTYPE(node, ntype) \ + do { \ + int value = ntype; \ + memcpy(&((node)->u.base.type), &value, sizeof(int)); \ + } while (0) #define NSTR(node) (&((node)->u.str)) #define NCCLASS(node) (&((node)->u.cclass)) @@ -87,6 +94,8 @@ #define ENCLOSE_MEMORY (1<<0) #define ENCLOSE_OPTION (1<<1) #define ENCLOSE_STOP_BACKTRACK (1<<2) +#define ENCLOSE_CONDITION (1<<3) +#define ENCLOSE_ABSENT (1<<4) #define NODE_STR_MARGIN 16 #define NODE_STR_BUF_SIZE 24 /* sizeof(CClassNode) - sizeof(int)*4 */ @@ -96,7 +105,7 @@ #define NSTR_AMBIG (1<<1) #define NSTR_DONT_GET_OPT_INFO (1<<2) -#define NSTRING_LEN(node) ((node)->u.str.end - (node)->u.str.s) +#define NSTRING_LEN(node) (OnigDistance )((node)->u.str.end - (node)->u.str.s) #define NSTRING_SET_RAW(node) (node)->u.str.flag |= NSTR_RAW #define NSTRING_CLEAR_RAW(node) (node)->u.str.flag &= ~NSTR_RAW #define NSTRING_SET_AMBIG(node) (node)->u.str.flag |= NSTR_AMBIG @@ -146,6 +155,7 @@ #define IS_ENCLOSE_STOP_BT_SIMPLE_REPEAT(en) \ (((en)->state & NST_STOP_BT_SIMPLE_REPEAT) != 0) #define IS_ENCLOSE_NAMED_GROUP(en) (((en)->state & NST_NAMED_GROUP) != 0) +#define IS_ENCLOSE_NAME_REF(en) (((en)->state & NST_NAME_REF) != 0) #define SET_CALL_RECURSION(node) (node)->u.call.state |= NST_RECURSION #define IS_CALL_RECURSION(cn) (((cn)->state & NST_RECURSION) != 0) @@ -176,7 +186,7 @@ typedef struct { int target_empty_info; struct _Node* head_exact; struct _Node* next_head_exact; - int is_refered; /* include called node. don't eliminate even if {0} */ + int is_referred; /* include called node. don't eliminate even if {0} */ #ifdef USE_COMBINATION_EXPLOSION_CHECK int comb_exp_check_num; /* 1,2,3...: check, 0: no check */ #endif @@ -188,11 +198,11 @@ typedef struct { int type; int regnum; OnigOptionType option; - struct _Node* target; AbsAddrType call_addr; + struct _Node* target; /* for multiple call reference */ OnigDistance min_len; /* min length (byte) */ - OnigDistance max_len; /* max length (byte) */ + OnigDistance max_len; /* max length (byte) */ int char_len; /* character length */ int opt_count; /* referenced count in optimize_node_left() */ } EncloseNode; @@ -213,7 +223,7 @@ typedef struct { typedef struct { NodeBase base; int state; - int ref_num; + int group_num; UChar* name; UChar* name_end; struct _Node* target; /* EncloseNode : ENCLOSE_MEMORY */ @@ -236,6 +246,7 @@ typedef struct { int type; struct _Node* target; int char_len; + int ascii_range; } AnchorNode; typedef struct { @@ -248,6 +259,7 @@ typedef struct { NodeBase base; int ctype; int not; + int ascii_range; } CtypeNode; typedef struct _Node { @@ -279,7 +291,7 @@ typedef struct { OnigOptionType option; OnigCaseFoldType case_fold_flag; OnigEncoding enc; - OnigSyntaxType* syntax; + const OnigSyntaxType* syntax; BitStatusType capture_history; BitStatusType bt_mem_start; BitStatusType bt_mem_end; @@ -289,10 +301,10 @@ typedef struct { UChar* error; UChar* error_end; regex_t* reg; /* for reg->names only */ - int num_call; #ifdef USE_SUBEXP_CALL UnsetAddrList* unset_addr_list; #endif + int num_call; int num_mem; #ifdef USE_NAMED_GROUP int num_named; @@ -306,6 +318,12 @@ typedef struct { int curr_max_regnum; int has_recursion; #endif + unsigned int parse_depth; + int warnings_flag; +#ifdef RUBY + const char* sourcefile; + int sourceline; +#endif } ScanEnv; @@ -318,33 +336,36 @@ typedef struct { int new_val; } GroupNumRemap; -extern int onig_renumber_name_table P_((regex_t* reg, GroupNumRemap* map)); +extern int onig_renumber_name_table(regex_t* reg, GroupNumRemap* map); #endif -extern int onig_strncmp P_((const UChar* s1, const UChar* s2, int n)); -extern void onig_strcpy P_((UChar* dest, const UChar* src, const UChar* end)); -extern void onig_scan_env_set_error_string P_((ScanEnv* env, int ecode, UChar* arg, UChar* arg_end)); -extern int onig_scan_unsigned_number P_((UChar** src, const UChar* end, OnigEncoding enc)); -extern void onig_reduce_nested_quantifier P_((Node* pnode, Node* cnode)); -extern void onig_node_conv_to_str_node P_((Node* node, int raw)); -extern int onig_node_str_cat P_((Node* node, const UChar* s, const UChar* end)); -extern int onig_node_str_set P_((Node* node, const UChar* s, const UChar* end)); -extern void onig_node_free P_((Node* node)); -extern Node* onig_node_new_enclose P_((int type)); -extern Node* onig_node_new_anchor P_((int type)); -extern Node* onig_node_new_str P_((const UChar* s, const UChar* end)); -extern Node* onig_node_new_list P_((Node* left, Node* right)); -extern Node* onig_node_list_add P_((Node* list, Node* x)); -extern Node* onig_node_new_alt P_((Node* left, Node* right)); -extern void onig_node_str_clear P_((Node* node)); -extern int onig_free_node_list P_((void)); -extern int onig_names_free P_((regex_t* reg)); -extern int onig_parse_make_tree P_((Node** root, const UChar* pattern, const UChar* end, regex_t* reg, ScanEnv* env)); +extern int onig_strncmp(const UChar* s1, const UChar* s2, size_t n); +extern void onig_strcpy(UChar* dest, const UChar* src, const UChar* end); +extern void onig_scan_env_set_error_string(ScanEnv* env, int ecode, UChar* arg, UChar* arg_end); +extern int onig_scan_unsigned_number(UChar** src, const UChar* end, OnigEncoding enc); +extern void onig_reduce_nested_quantifier(Node* pnode, Node* cnode); +extern void onig_node_conv_to_str_node(Node* node, int raw); +extern int onig_node_str_cat(Node* node, const UChar* s, const UChar* end); +extern int onig_node_str_set(Node* node, const UChar* s, const UChar* end); +extern void onig_node_free(Node* node); +extern Node* onig_node_new_enclose(int type); +extern Node* onig_node_new_anchor(int type); +extern Node* onig_node_new_str(const UChar* s, const UChar* end); +extern Node* onig_node_new_list(Node* left, Node* right); +extern Node* onig_node_list_add(Node* list, Node* x); +extern Node* onig_node_new_alt(Node* left, Node* right); +extern void onig_node_str_clear(Node* node); +extern int onig_names_free(regex_t* reg); +extern int onig_names_copy(regex_t* reg, regex_t* oreg); +extern int onig_parse_make_tree(Node** root, const UChar* pattern, const UChar* end, regex_t* reg, ScanEnv* env); +extern int onig_free_shared_cclass_table(void); #ifdef ONIG_DEBUG -#ifdef USE_NAMED_GROUP +# ifdef USE_NAMED_GROUP extern int onig_print_names(FILE*, regex_t*); +# endif #endif -#endif -#endif /* REGPARSE_H */ +RUBY_SYMBOL_EXPORT_END + +#endif /* ONIGMO_REGPARSE_H */ |
