]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/regenc.h
MdeModulePkg RegularExpressionDxe: Update Oniguruma to 6.9.0
[mirror_edk2.git] / MdeModulePkg / Universal / RegularExpressionDxe / Oniguruma / regenc.h
index 1d39f9c054e95c09a14bcf2007e6d5bb510b9779..6235520a1ed641f277f1324bec7a7a2b687a239c 100644 (file)
@@ -4,7 +4,7 @@
   regenc.h -  Oniguruma (regular expression library)\r
 **********************************************************************/\r
 /*-\r
- * Copyright (c) 2002-2008  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>\r
+ * Copyright (c) 2002-2018  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>\r
  * All rights reserved.\r
  *\r
  * Redistribution and use in source and binary forms, with or without\r
  * SUCH DAMAGE.\r
  */\r
 \r
-#ifndef PACKAGE\r
-/* PACKAGE is defined in config.h */\r
-//#include "config.h"\r
+#ifndef ONIGURUMA_EXPORT\r
+#define ONIGURUMA_EXPORT\r
 #endif\r
 \r
+//#include "config.h"\r
+//#include <stddef.h>\r
+\r
 #ifdef ONIG_ESCAPE_UCHAR_COLLISION\r
 #undef ONIG_ESCAPE_UCHAR_COLLISION\r
 #endif\r
@@ -71,7 +73,9 @@ typedef struct {
 #define ONIG_CHECK_NULL_RETURN(p)          if (ONIG_IS_NULL(p)) return NULL\r
 #define ONIG_CHECK_NULL_RETURN_VAL(p,val)  if (ONIG_IS_NULL(p)) return (val)\r
 \r
-#define enclen(enc,p)      ONIGENC_MBC_ENC_LEN(enc,p)\r
+#define MAX_CODE_POINT         (~((OnigCodePoint )0))\r
+\r
+#define enclen(enc,p)          ONIGENC_MBC_ENC_LEN(enc,p)\r
 \r
 /* character types bit flag */\r
 #define BIT_CTYPE_NEWLINE  (1<< ONIGENC_CTYPE_NEWLINE)\r
@@ -102,88 +106,157 @@ typedef struct {
   short int len;\r
 } PosixBracketEntryType;\r
 \r
+struct PropertyNameCtype {\r
+  char *name;\r
+  int ctype;\r
+};\r
 \r
 /* #define USE_CRNL_AS_LINE_TERMINATOR */\r
 #define USE_UNICODE_PROPERTIES\r
+#define USE_UNICODE_EXTENDED_GRAPHEME_CLUSTER\r
 /* #define USE_UNICODE_CASE_FOLD_TURKISH_AZERI */\r
-/* #define USE_UNICODE_ALL_LINE_TERMINATORS */  /* see Unicode.org UTF#18 */\r
+/* #define USE_UNICODE_ALL_LINE_TERMINATORS */  /* see Unicode.org UT#18 */\r
 \r
 \r
 #define ONIG_ENCODING_INIT_DEFAULT           ONIG_ENCODING_ASCII\r
 \r
+\r
+#define ENC_FLAG_ASCII_COMPATIBLE      (1<<0)\r
+#define ENC_FLAG_UNICODE               (1<<1)\r
+\r
+\r
 /* for encoding system implementation (internal) */\r
-ONIG_EXTERN int onigenc_ascii_apply_all_case_fold P_((OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg));\r
-ONIG_EXTERN int onigenc_ascii_get_case_fold_codes_by_str P_((OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));\r
-ONIG_EXTERN int onigenc_apply_all_case_fold_with_map P_((int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg));\r
-ONIG_EXTERN int onigenc_get_case_fold_codes_by_str_with_map P_((int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));\r
-ONIG_EXTERN int onigenc_not_support_get_ctype_code_range P_((OnigCtype ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[]));\r
-ONIG_EXTERN int onigenc_is_mbc_newline_0x0a P_((const UChar* p, const UChar* end));\r
+extern int onigenc_end(void);\r
+extern int onigenc_ascii_apply_all_case_fold P_((OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg));\r
+extern int onigenc_ascii_get_case_fold_codes_by_str P_((OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));\r
+extern int onigenc_apply_all_case_fold_with_map P_((int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg));\r
+extern int onigenc_get_case_fold_codes_by_str_with_map P_((int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));\r
+extern int onigenc_not_support_get_ctype_code_range P_((OnigCtype ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[]));\r
+extern int onigenc_is_mbc_newline_0x0a P_((const UChar* p, const UChar* end));\r
 \r
 \r
 /* methods for single byte encoding */\r
-ONIG_EXTERN int onigenc_ascii_mbc_case_fold P_((OnigCaseFoldType flag, const UChar** p, const UChar* end, UChar* lower));\r
-ONIG_EXTERN int onigenc_single_byte_mbc_enc_len P_((const UChar* p));\r
-ONIG_EXTERN OnigCodePoint onigenc_single_byte_mbc_to_code P_((const UChar* p, const UChar* end));\r
-ONIG_EXTERN int onigenc_single_byte_code_to_mbclen P_((OnigCodePoint code));\r
-ONIG_EXTERN int onigenc_single_byte_code_to_mbc P_((OnigCodePoint code, UChar *buf));\r
-ONIG_EXTERN UChar* onigenc_single_byte_left_adjust_char_head P_((const UChar* start, const UChar* s));\r
-ONIG_EXTERN int onigenc_always_true_is_allowed_reverse_match P_((const UChar* s, const UChar* end));\r
-ONIG_EXTERN int onigenc_always_false_is_allowed_reverse_match P_((const UChar* s, const UChar* end));\r
+extern int onigenc_ascii_mbc_case_fold P_((OnigCaseFoldType flag, const UChar** p, const UChar* end, UChar* lower));\r
+extern int onigenc_single_byte_mbc_enc_len P_((const UChar* p));\r
+extern OnigCodePoint onigenc_single_byte_mbc_to_code P_((const UChar* p, const UChar* end));\r
+extern int onigenc_single_byte_code_to_mbclen P_((OnigCodePoint code));\r
+extern int onigenc_single_byte_code_to_mbc P_((OnigCodePoint code, UChar *buf));\r
+extern UChar* onigenc_single_byte_left_adjust_char_head P_((const UChar* start, const UChar* s));\r
+extern int onigenc_always_true_is_allowed_reverse_match P_((const UChar* s, const UChar* end));\r
+extern int onigenc_always_false_is_allowed_reverse_match P_((const UChar* s, const UChar* end));\r
+extern int onigenc_always_true_is_valid_mbc_string P_((const UChar* s, const UChar* end));\r
+extern int onigenc_length_check_is_valid_mbc_string P_((OnigEncoding enc, const UChar* s, const UChar* end));\r
 \r
 /* methods for multi byte encoding */\r
-ONIG_EXTERN OnigCodePoint onigenc_mbn_mbc_to_code P_((OnigEncoding enc, const UChar* p, const UChar* end));\r
-ONIG_EXTERN int onigenc_mbn_mbc_case_fold P_((OnigEncoding enc, OnigCaseFoldType flag, const UChar** p, const UChar* end, UChar* lower));\r
-ONIG_EXTERN int onigenc_mb2_code_to_mbclen P_((OnigCodePoint code));\r
-ONIG_EXTERN int onigenc_mb2_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf));\r
-ONIG_EXTERN int onigenc_minimum_property_name_to_ctype P_((OnigEncoding enc, UChar* p, UChar* end));\r
-ONIG_EXTERN int onigenc_unicode_property_name_to_ctype P_((OnigEncoding enc, UChar* p, UChar* end));\r
-ONIG_EXTERN int onigenc_mb2_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype));\r
-ONIG_EXTERN int onigenc_mb4_code_to_mbclen P_((OnigCodePoint code));\r
-ONIG_EXTERN int onigenc_mb4_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf));\r
-ONIG_EXTERN int onigenc_mb4_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype));\r
-\r
+extern OnigCodePoint onigenc_mbn_mbc_to_code P_((OnigEncoding enc, const UChar* p, const UChar* end));\r
+extern int onigenc_mbn_mbc_case_fold P_((OnigEncoding enc, OnigCaseFoldType flag, const UChar** p, const UChar* end, UChar* lower));\r
+extern int onigenc_mb2_code_to_mbclen P_((OnigCodePoint code));\r
+extern int onigenc_mb2_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf));\r
+extern int onigenc_minimum_property_name_to_ctype P_((OnigEncoding enc, UChar* p, UChar* end));\r
+extern int onigenc_unicode_property_name_to_ctype P_((OnigEncoding enc, UChar* p, UChar* end));\r
+extern int onigenc_is_mbc_word_ascii P_((OnigEncoding enc, UChar* s, const UChar* end));\r
+extern int onigenc_mb2_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype));\r
+extern int onigenc_mb4_code_to_mbclen P_((OnigCodePoint code));\r
+extern int onigenc_mb4_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf));\r
+extern int onigenc_mb4_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype));\r
+extern struct PropertyNameCtype* onigenc_euc_jp_lookup_property_name P_((register const char *str, register size_t len));\r
+extern struct PropertyNameCtype* onigenc_sjis_lookup_property_name P_((register const char *str, register size_t len));\r
 \r
 /* in enc/unicode.c */\r
-ONIG_EXTERN int onigenc_unicode_is_code_ctype P_((OnigCodePoint code, unsigned int ctype));\r
-ONIG_EXTERN int onigenc_utf16_32_get_ctype_code_range P_((OnigCtype ctype, OnigCodePoint *sb_out, const OnigCodePoint* ranges[]));\r
-ONIG_EXTERN int onigenc_unicode_ctype_code_range P_((int ctype, const OnigCodePoint* ranges[]));\r
-ONIG_EXTERN int onigenc_unicode_get_case_fold_codes_by_str P_((OnigEncoding enc, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));\r
-ONIG_EXTERN int onigenc_unicode_mbc_case_fold P_((OnigEncoding enc, OnigCaseFoldType flag, const UChar** pp, const UChar* end, UChar* fold));\r
-ONIG_EXTERN int onigenc_unicode_apply_all_case_fold P_((OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg));\r
+extern int onigenc_unicode_is_code_ctype P_((OnigCodePoint code, unsigned int ctype));\r
+extern int onigenc_utf16_32_get_ctype_code_range P_((OnigCtype ctype, OnigCodePoint *sb_out, const OnigCodePoint* ranges[]));\r
+extern int onigenc_unicode_ctype_code_range P_((OnigCtype ctype, const OnigCodePoint* ranges[]));\r
+extern int onigenc_unicode_get_case_fold_codes_by_str P_((OnigEncoding enc, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));\r
+extern int onigenc_unicode_mbc_case_fold P_((OnigEncoding enc, OnigCaseFoldType flag, const UChar** pp, const UChar* end, UChar* fold));\r
+extern int onigenc_unicode_apply_all_case_fold P_((OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg));\r
+extern int onigenc_egcb_is_break_position P_((OnigEncoding enc, UChar* p, UChar* prev, const UChar* start, const UChar* end));\r
 \r
 \r
 #define UTF16_IS_SURROGATE_FIRST(c)    (((c) & 0xfc) == 0xd8)\r
 #define UTF16_IS_SURROGATE_SECOND(c)   (((c) & 0xfc) == 0xdc)\r
 \r
+/* from unicode generated codes */\r
+#define FOLDS1_FOLD(i)         (OnigUnicodeFolds1 + (i))\r
+#define FOLDS2_FOLD(i)         (OnigUnicodeFolds2 + (i))\r
+#define FOLDS3_FOLD(i)         (OnigUnicodeFolds3 + (i))\r
+#define FOLDS1_UNFOLDS_NUM(i)  (OnigUnicodeFolds1[(i)+1])\r
+#define FOLDS2_UNFOLDS_NUM(i)  (OnigUnicodeFolds2[(i)+2])\r
+#define FOLDS3_UNFOLDS_NUM(i)  (OnigUnicodeFolds3[(i)+3])\r
+#define FOLDS1_UNFOLDS(i)      (OnigUnicodeFolds1 + (i) + 2)\r
+#define FOLDS2_UNFOLDS(i)      (OnigUnicodeFolds2 + (i) + 3)\r
+#define FOLDS3_UNFOLDS(i)      (OnigUnicodeFolds3 + (i) + 4)\r
+#define FOLDS1_NEXT_INDEX(i)   ((i) + 2 + OnigUnicodeFolds1[(i)+1])\r
+#define FOLDS2_NEXT_INDEX(i)   ((i) + 3 + OnigUnicodeFolds2[(i)+2])\r
+#define FOLDS3_NEXT_INDEX(i)   ((i) + 4 + OnigUnicodeFolds3[(i)+3])\r
+\r
+#define FOLDS_FOLD_ADDR_BUK(buk, addr) do {\\r
+  if ((buk)->fold_len == 1)\\r
+    addr = OnigUnicodeFolds1 + (buk)->index;\\r
+  else if ((buk)->fold_len == 2)\\r
+    addr = OnigUnicodeFolds2 + (buk)->index;\\r
+  else if ((buk)->fold_len == 3)\\r
+    addr = OnigUnicodeFolds3 + (buk)->index;\\r
+  else\\r
+    addr = 0;\\r
+} while (0)\r
+\r
+extern OnigCodePoint OnigUnicodeFolds1[];\r
+extern OnigCodePoint OnigUnicodeFolds2[];\r
+extern OnigCodePoint OnigUnicodeFolds3[];\r
+\r
+struct ByUnfoldKey {\r
+  OnigCodePoint code;\r
+  short int     index;\r
+  short int     fold_len;\r
+};\r
+\r
+extern const struct ByUnfoldKey* onigenc_unicode_unfold_key(OnigCodePoint code);\r
+extern int onigenc_unicode_fold1_key(OnigCodePoint code[]);\r
+extern int onigenc_unicode_fold2_key(OnigCodePoint code[]);\r
+extern int onigenc_unicode_fold3_key(OnigCodePoint code[]);\r
+\r
+extern int onig_codes_cmp(OnigCodePoint a[], OnigCodePoint b[], int n);\r
+extern int onig_codes_byte_at(OnigCodePoint code[], int at);\r
+\r
+\r
+\r
 #define ONIGENC_ISO_8859_1_TO_LOWER_CASE(c) \\r
   OnigEncISO_8859_1_ToLowerCaseTable[c]\r
 #define ONIGENC_ISO_8859_1_TO_UPPER_CASE(c) \\r
   OnigEncISO_8859_1_ToUpperCaseTable[c]\r
 \r
-ONIG_EXTERN const UChar OnigEncISO_8859_1_ToLowerCaseTable[];\r
-ONIG_EXTERN const UChar OnigEncISO_8859_1_ToUpperCaseTable[];\r
+extern const UChar OnigEncISO_8859_1_ToLowerCaseTable[];\r
+extern const UChar OnigEncISO_8859_1_ToUpperCaseTable[];\r
 \r
-ONIG_EXTERN int\r
+extern int\r
 onigenc_with_ascii_strncmp P_((OnigEncoding enc, const UChar* p, const UChar* end, const UChar* sascii /* ascii */, int n));\r
-ONIG_EXTERN UChar*\r
+extern UChar*\r
 onigenc_step P_((OnigEncoding enc, const UChar* p, const UChar* end, int n));\r
 \r
 /* defined in regexec.c, but used in enc/xxx.c */\r
 extern int  onig_is_in_code_range P_((const UChar* p, OnigCodePoint code));\r
 \r
-ONIG_EXTERN OnigEncoding  OnigEncDefaultCharEncoding;\r
-ONIG_EXTERN const UChar  OnigEncAsciiToLowerCaseTable[];\r
-ONIG_EXTERN const UChar  OnigEncAsciiToUpperCaseTable[];\r
-ONIG_EXTERN const unsigned short OnigEncAsciiCtypeTable[];\r
+extern OnigEncoding  OnigEncDefaultCharEncoding;\r
+extern const UChar  OnigEncAsciiToLowerCaseTable[];\r
+extern const UChar  OnigEncAsciiToUpperCaseTable[];\r
+extern const unsigned short OnigEncAsciiCtypeTable[];\r
+\r
 \r
 #define ONIGENC_IS_ASCII_CODE(code)  ((code) < 0x80)\r
 #define ONIGENC_ASCII_CODE_TO_LOWER_CASE(c) OnigEncAsciiToLowerCaseTable[c]\r
 #define ONIGENC_ASCII_CODE_TO_UPPER_CASE(c) OnigEncAsciiToUpperCaseTable[c]\r
 #define ONIGENC_IS_ASCII_CODE_CTYPE(code,ctype) \\r
   ((OnigEncAsciiCtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)\r
+#define ONIGENC_IS_ASCII_CODE_WORD(code) \\r
+  ((OnigEncAsciiCtypeTable[code] & CTYPE_TO_BIT(ONIGENC_CTYPE_WORD)) != 0)\r
 #define ONIGENC_IS_ASCII_CODE_CASE_AMBIG(code) \\r
  (ONIGENC_IS_ASCII_CODE_CTYPE(code, ONIGENC_CTYPE_UPPER) ||\\r
   ONIGENC_IS_ASCII_CODE_CTYPE(code, ONIGENC_CTYPE_LOWER))\r
    \r
+#define ONIGENC_IS_UNICODE_ENCODING(enc) \\r
+  (((enc)->flag & ENC_FLAG_UNICODE) != 0)\r
+\r
+#define ONIGENC_IS_ASCII_COMPATIBLE_ENCODING(enc)  \\r
+  (((enc)->flag & ENC_FLAG_ASCII_COMPATIBLE) != 0)\r
 \r
 #endif /* REGENC_H */\r