]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/regenc.c
MdeModulePkg RegularExpressionDxe: Update Oniguruma from v6.9.0 to v6.9.3
[mirror_edk2.git] / MdeModulePkg / Universal / RegularExpressionDxe / Oniguruma / regenc.c
index 90547d359e77e440891667a547aad2412b3c7b70..079cd01f29f7c383149d4f3588ea8378b5cacdc3 100644 (file)
@@ -2,7 +2,7 @@
   regenc.c -  Oniguruma (regular expression library)\r
 **********************************************************************/\r
 /*-\r
- * Copyright (c) 2002-2018  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>\r
+ * Copyright (c) 2002-2019  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
@@ -77,6 +77,17 @@ enc_is_inited(OnigEncoding enc)
   return 0;\r
 }\r
 \r
+static int OnigEncInited;\r
+\r
+extern int\r
+onigenc_init(void)\r
+{\r
+  if (OnigEncInited != 0) return 0;\r
+\r
+  OnigEncInited = 1;\r
+  return 0;\r
+}\r
+\r
 extern int\r
 onigenc_end(void)\r
 {\r
@@ -86,15 +97,10 @@ onigenc_end(void)
     InitedList[i].enc    = 0;\r
     InitedList[i].inited = 0;\r
   }\r
-\r
   InitedListNum = 0;\r
-  return ONIG_NORMAL;\r
-}\r
 \r
-extern int\r
-onigenc_init(void)\r
-{\r
-  return 0;\r
+  OnigEncInited = 0;\r
+  return ONIG_NORMAL;\r
 }\r
 \r
 extern int\r
@@ -167,7 +173,7 @@ onigenc_get_right_adjust_char_head(OnigEncoding enc, const UChar* start, const U
 \r
 extern UChar*\r
 onigenc_get_right_adjust_char_head_with_prev(OnigEncoding enc,\r
-                                  const UChar* start, const UChar* s, const UChar** prev)\r
+            const UChar* start, const UChar* s, const UChar** prev)\r
 {\r
   UChar* p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s);\r
 \r
@@ -231,7 +237,7 @@ onigenc_strlen(OnigEncoding enc, const UChar* p, const UChar* end)
 {\r
   int n = 0;\r
   UChar* q = (UChar* )p;\r
-  \r
+\r
   while (q < end) {\r
     q += ONIGENC_MBC_ENC_LEN(enc, q);\r
     n++;\r
@@ -244,7 +250,7 @@ onigenc_strlen_null(OnigEncoding enc, const UChar* s)
 {\r
   int n = 0;\r
   UChar* p = (UChar* )s;\r
-  \r
+\r
   while (1) {\r
     if (*p == '\0') {\r
       UChar* q;\r
@@ -511,7 +517,7 @@ const OnigPairCaseFoldCodes OnigAsciiLowerMap[] = {
 \r
 extern int\r
 onigenc_ascii_apply_all_case_fold(OnigCaseFoldType flag ARG_UNUSED,\r
-                                 OnigApplyAllCaseFoldFunc f, void* arg)\r
+                                  OnigApplyAllCaseFoldFunc f, void* arg)\r
 {\r
   OnigCodePoint code;\r
   int i, r;\r
@@ -533,8 +539,8 @@ onigenc_ascii_apply_all_case_fold(OnigCaseFoldType flag ARG_UNUSED,
 \r
 extern int\r
 onigenc_ascii_get_case_fold_codes_by_str(OnigCaseFoldType flag ARG_UNUSED,\r
-        const OnigUChar* p, const OnigUChar* end ARG_UNUSED,\r
-        OnigCaseFoldCodeItem items[])\r
+    const OnigUChar* p, const OnigUChar* end ARG_UNUSED,\r
+    OnigCaseFoldCodeItem items[])\r
 {\r
   if (0x41 <= *p && *p <= 0x5a) {\r
     items[0].byte_len = 1;\r
@@ -554,7 +560,7 @@ onigenc_ascii_get_case_fold_codes_by_str(OnigCaseFoldType flag ARG_UNUSED,
 \r
 static int\r
 ss_apply_all_case_fold(OnigCaseFoldType flag ARG_UNUSED,\r
-                      OnigApplyAllCaseFoldFunc f, void* arg)\r
+                       OnigApplyAllCaseFoldFunc f, void* arg)\r
 {\r
   static OnigCodePoint ss[] = { 0x73, 0x73 };\r
 \r
@@ -600,7 +606,7 @@ onigenc_get_case_fold_codes_by_str_with_map(int map_size,
     items[0].code_len = 1;\r
     items[0].code[0] = (OnigCodePoint )(*p + 0x20);\r
     if (*p == 0x53 && ess_tsett_flag != 0 && end > p + 1\r
-       && (*(p+1) == 0x53 || *(p+1) == 0x73)) {\r
+        && (*(p+1) == 0x53 || *(p+1) == 0x73)) {\r
       /* SS */\r
       items[1].byte_len = 2;\r
       items[1].code_len = 1;\r
@@ -615,7 +621,7 @@ onigenc_get_case_fold_codes_by_str_with_map(int map_size,
     items[0].code_len = 1;\r
     items[0].code[0] = (OnigCodePoint )(*p - 0x20);\r
     if (*p == 0x73 && ess_tsett_flag != 0 && end > p + 1\r
-       && (*(p+1) == 0x73 || *(p+1) == 0x53)) {\r
+        && (*(p+1) == 0x73 || *(p+1) == 0x53)) {\r
       /* ss */\r
       items[1].byte_len = 2;\r
       items[1].code_len = 1;\r
@@ -653,16 +659,16 @@ onigenc_get_case_fold_codes_by_str_with_map(int map_size,
 \r
     for (i = 0; i < map_size; i++) {\r
       if (*p == map[i].from) {\r
-       items[0].byte_len = 1;\r
-       items[0].code_len = 1;\r
-       items[0].code[0] = map[i].to;\r
-       return 1;\r
+        items[0].byte_len = 1;\r
+        items[0].code_len = 1;\r
+        items[0].code[0] = map[i].to;\r
+        return 1;\r
       }\r
       else if (*p == map[i].to) {\r
-       items[0].byte_len = 1;\r
-       items[0].code_len = 1;\r
-       items[0].code[0] = map[i].from;\r
-       return 1;\r
+        items[0].byte_len = 1;\r
+        items[0].code_len = 1;\r
+        items[0].code[0] = map[i].from;\r
+        return 1;\r
       }\r
     }\r
   }\r
@@ -673,8 +679,8 @@ onigenc_get_case_fold_codes_by_str_with_map(int map_size,
 \r
 extern int\r
 onigenc_not_support_get_ctype_code_range(OnigCtype ctype ARG_UNUSED,\r
-        OnigCodePoint* sb_out ARG_UNUSED,\r
-        const OnigCodePoint* ranges[] ARG_UNUSED)\r
+                                         OnigCodePoint* sb_out ARG_UNUSED,\r
+                                         const OnigCodePoint* ranges[] ARG_UNUSED)\r
 {\r
   return ONIG_NO_SUPPORT_CONFIG;\r
 }\r
@@ -691,7 +697,7 @@ onigenc_is_mbc_newline_0x0a(const UChar* p, const UChar* end)
 /* for single byte encodings */\r
 extern int\r
 onigenc_ascii_mbc_case_fold(OnigCaseFoldType flag ARG_UNUSED, const UChar** p,\r
-           const UChar*end ARG_UNUSED, UChar* lower)\r
+                            const UChar*end ARG_UNUSED, UChar* lower)\r
 {\r
   *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(**p);\r
 \r
@@ -702,7 +708,7 @@ onigenc_ascii_mbc_case_fold(OnigCaseFoldType flag ARG_UNUSED, const UChar** p,
 #if 0\r
 extern int\r
 onigenc_ascii_is_mbc_ambiguous(OnigCaseFoldType flag,\r
-                              const UChar** pp, const UChar* end)\r
+                               const UChar** pp, const UChar* end)\r
 {\r
   const UChar* p = *pp;\r
 \r
@@ -738,35 +744,35 @@ onigenc_single_byte_code_to_mbc(OnigCodePoint code, UChar *buf)
 \r
 extern UChar*\r
 onigenc_single_byte_left_adjust_char_head(const UChar* start ARG_UNUSED,\r
-                                         const UChar* s)\r
+                                          const UChar* s)\r
 {\r
   return (UChar* )s;\r
 }\r
 \r
 extern int\r
 onigenc_always_true_is_allowed_reverse_match(const UChar* s   ARG_UNUSED,\r
-                                            const UChar* end ARG_UNUSED)\r
+                                             const UChar* end ARG_UNUSED)\r
 {\r
   return TRUE;\r
 }\r
 \r
 extern int\r
 onigenc_always_false_is_allowed_reverse_match(const UChar* s   ARG_UNUSED,\r
-                                             const UChar* end ARG_UNUSED)\r
+                                              const UChar* end ARG_UNUSED)\r
 {\r
   return FALSE;\r
 }\r
 \r
 extern int\r
 onigenc_always_true_is_valid_mbc_string(const UChar* s   ARG_UNUSED,\r
-                                       const UChar* end ARG_UNUSED)\r
+                                        const UChar* end ARG_UNUSED)\r
 {\r
   return TRUE;\r
 }\r
 \r
 extern int\r
 onigenc_length_check_is_valid_mbc_string(OnigEncoding enc,\r
-                                        const UChar* p, const UChar* end)\r
+                                         const UChar* p, const UChar* end)\r
 {\r
   while (p < end) {\r
     p += enclen(enc, p);\r
@@ -805,7 +811,7 @@ onigenc_mbn_mbc_to_code(OnigEncoding enc, const UChar* p, const UChar* end)
 extern int\r
 onigenc_mbn_mbc_case_fold(OnigEncoding enc, OnigCaseFoldType flag ARG_UNUSED,\r
                           const UChar** pp, const UChar* end ARG_UNUSED,\r
-                         UChar* lower)\r
+                          UChar* lower)\r
 {\r
   int len;\r
   const UChar *p = *pp;\r
@@ -847,6 +853,8 @@ onigenc_mbn_is_mbc_ambiguous(OnigEncoding enc, OnigCaseFoldType flag,
 extern int\r
 onigenc_mb2_code_to_mbclen(OnigCodePoint code)\r
 {\r
+  if ((code & (~0xffff)) != 0) return ONIGERR_INVALID_CODE_POINT_VALUE;\r
+\r
   if ((code & 0xff00) != 0) return 2;\r
   else return 1;\r
 }\r
@@ -946,7 +954,7 @@ onigenc_is_mbc_word_ascii(OnigEncoding enc, UChar* s, const UChar* end)
 \r
 extern int\r
 onigenc_mb2_is_code_ctype(OnigEncoding enc, OnigCodePoint code,\r
-                         unsigned int ctype)\r
+                          unsigned int ctype)\r
 {\r
   if (code < 128)\r
     return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);\r
@@ -961,7 +969,7 @@ onigenc_mb2_is_code_ctype(OnigEncoding enc, OnigCodePoint code,
 \r
 extern int\r
 onigenc_mb4_is_code_ctype(OnigEncoding enc, OnigCodePoint code,\r
-                         unsigned int ctype)\r
+                          unsigned int ctype)\r
 {\r
   if (code < 128)\r
     return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);\r