]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/regerror.c
MdeModulePkg RegularExpressionDxe: Update Oniguruma from v6.9.0 to v6.9.3
[mirror_edk2.git] / MdeModulePkg / Universal / RegularExpressionDxe / Oniguruma / regerror.c
index d92b61e229eb37a58368541988236c6720788427..0dca34a8ad293b30f21383a48e9bcd95dfe463c9 100644 (file)
@@ -2,7 +2,7 @@
   regerror.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
 #if 0\r
 #include <stdio.h> /* for vsnprintf() */\r
 \r
-#ifdef HAVE_STDARG_PROTOTYPES\r
 #include <stdarg.h>\r
-#define va_init_list(a,b) va_start(a,b)\r
-#else\r
-#include <varargs.h>\r
-#define va_init_list(a,b) va_start(a)\r
-#endif\r
 #endif\r
 \r
 extern UChar*\r
@@ -213,13 +207,17 @@ static void sprint_byte_with_x(char* s, unsigned int v)
 }\r
 \r
 static int to_ascii(OnigEncoding enc, UChar *s, UChar *end,\r
-                   UChar buf[], int buf_size, int *is_over)\r
+                    UChar buf[], int buf_size, int *is_over)\r
 {\r
   int len;\r
   UChar *p;\r
   OnigCodePoint code;\r
 \r
-  if (ONIGENC_MBC_MINLEN(enc) > 1) {\r
+  if (!s) {\r
+    len = 0;\r
+    *is_over = 0;\r
+  }\r
+  else if (ONIGENC_MBC_MINLEN(enc) > 1) {\r
     p = s;\r
     len = 0;\r
     while (p < end) {\r
@@ -249,7 +247,7 @@ static int to_ascii(OnigEncoding enc, UChar *s, UChar *end,
       if (len >= buf_size) break;\r
     }\r
 \r
-    *is_over = ((p < end) ? 1 : 0);\r
+    *is_over = p < end;\r
   }\r
   else {\r
     len = MIN((int )(end - s), buf_size);\r
@@ -261,19 +259,27 @@ static int to_ascii(OnigEncoding enc, UChar *s, UChar *end,
 }\r
 \r
 \r
+extern int\r
+onig_is_error_code_needs_param(int code)\r
+{\r
+  switch (code) {\r
+  case ONIGERR_UNDEFINED_NAME_REFERENCE:\r
+  case ONIGERR_UNDEFINED_GROUP_REFERENCE:\r
+  case ONIGERR_MULTIPLEX_DEFINED_NAME:\r
+  case ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL:\r
+  case ONIGERR_INVALID_GROUP_NAME:\r
+  case ONIGERR_INVALID_CHAR_IN_GROUP_NAME:\r
+  case ONIGERR_INVALID_CHAR_PROPERTY_NAME:\r
+    return 1;\r
+  default:\r
+    return 0;\r
+  }\r
+}\r
+\r
 /* for ONIG_MAX_ERROR_MESSAGE_LEN */\r
 #define MAX_ERROR_PAR_LEN   30\r
 \r
-extern int\r
-EFIAPI\r
-#ifdef HAVE_STDARG_PROTOTYPES\r
-onig_error_code_to_str(UChar* s, int code, ...)\r
-#else\r
-onig_error_code_to_str(s, code, va_alist)\r
-  UChar* s;\r
-  int code;\r
-  va_dcl \r
-#endif\r
+extern int EFIAPI onig_error_code_to_str(UChar* s, int code, ...)\r
 {\r
   UChar *p, *q;\r
   OnigErrorInfo* einfo;\r
@@ -333,21 +339,8 @@ onig_error_code_to_str(s, code, va_alist)
 }\r
 \r
 \r
-void\r
-EFIAPI\r
-#ifdef HAVE_STDARG_PROTOTYPES\r
-onig_snprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc,\r
-                           UChar* pat, UChar* pat_end, const UChar *fmt, ...)\r
-#else\r
-onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist)\r
-    UChar buf[];\r
-    int bufsize;\r
-    OnigEncoding enc;\r
-    UChar* pat;\r
-    UChar* pat_end;\r
-    const UChar *fmt;\r
-    va_dcl\r
-#endif\r
+void EFIAPI onig_snprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc,\r
+                                UChar* pat, UChar* pat_end, const UChar *fmt, ...)\r
 {\r
   int n, need, len;\r
   UChar *p, *s, *bp;\r