Skip to content

Commit 49b2202

Browse files
committed
merge 25.8.16
2 parents 92e2155 + 7938087 commit 49b2202

120 files changed

Lines changed: 2609 additions & 690 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

base/poco/XML/include/Poco/XML/expat.h

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
Copyright (c) 2023 Hanno Böck <hanno@gentoo.org>
2020
Copyright (c) 2023 Sony Corporation / Snild Dolkow <snild@sony.com>
2121
Copyright (c) 2024 Taichi Haradaguchi <20001722@ymail.ne.jp>
22+
Copyright (c) 2025 Matthew Fernandez <matthew.fernandez@gmail.com>
2223
Licensed under the MIT license:
2324
2425
Permission is hereby granted, free of charge, to any person obtaining
25-
a copy of this software and associated documentation files (the
26+
a copy of this software and associated documentation files (the
2627
"Software"), to deal in the Software without restriction, including
2728
without limitation the rights to use, copy, modify, merge, publish,
2829
distribute, sublicense, and/or sell copies of the Software, and to permit
@@ -42,21 +43,21 @@
4243
*/
4344

4445
#ifndef Expat_INCLUDED
45-
#define Expat_INCLUDED 1
46+
# define Expat_INCLUDED 1
4647

47-
#include <stdlib.h>
48-
#include "expat_external.h"
48+
# include <stdlib.h>
49+
# include "expat_external.h"
4950

50-
#ifdef __cplusplus
51+
# ifdef __cplusplus
5152
extern "C" {
52-
#endif
53+
# endif
5354

5455
struct XML_ParserStruct;
5556
typedef struct XML_ParserStruct *XML_Parser;
5657

5758
typedef unsigned char XML_Bool;
58-
#define XML_TRUE ((XML_Bool)1)
59-
#define XML_FALSE ((XML_Bool)0)
59+
# define XML_TRUE ((XML_Bool)1)
60+
# define XML_FALSE ((XML_Bool)0)
6061

6162
/* The XML_Status enum gives the possible return values for several
6263
API functions. The preprocessor #defines are included so this
@@ -73,11 +74,11 @@ typedef unsigned char XML_Bool;
7374
*/
7475
enum XML_Status {
7576
XML_STATUS_ERROR = 0,
76-
#define XML_STATUS_ERROR XML_STATUS_ERROR
77+
# define XML_STATUS_ERROR XML_STATUS_ERROR
7778
XML_STATUS_OK = 1,
78-
#define XML_STATUS_OK XML_STATUS_OK
79+
# define XML_STATUS_OK XML_STATUS_OK
7980
XML_STATUS_SUSPENDED = 2
80-
#define XML_STATUS_SUSPENDED XML_STATUS_SUSPENDED
81+
# define XML_STATUS_SUSPENDED XML_STATUS_SUSPENDED
8182
};
8283

8384
enum XML_Error {
@@ -276,7 +277,7 @@ XML_ParserCreate_MM(const XML_Char *encoding,
276277

277278
/* Prepare a parser object to be reused. This is particularly
278279
valuable when memory allocation overhead is disproportionately high,
279-
such as when a large number of small documnents need to be parsed.
280+
such as when a large number of small documents need to be parsed.
280281
All handlers are cleared from the parser, except for the
281282
unknownEncodingHandler. The parser's external state is re-initialized
282283
except for the values of ns and ns_triplets.
@@ -680,7 +681,7 @@ XMLPARSEAPI(void)
680681
XML_SetUserData(XML_Parser parser, void *userData);
681682

682683
/* Returns the last value set by XML_SetUserData or NULL. */
683-
#define XML_GetUserData(parser) (*(void **)(parser))
684+
# define XML_GetUserData(parser) (*(void **)(parser))
684685

685686
/* This is equivalent to supplying an encoding argument to
686687
XML_ParserCreate. On success XML_SetEncoding returns non-zero,
@@ -752,7 +753,7 @@ XML_GetSpecifiedAttributeCount(XML_Parser parser);
752753
XMLPARSEAPI(int)
753754
XML_GetIdAttributeIndex(XML_Parser parser);
754755

755-
#ifdef XML_ATTR_INFO
756+
# ifdef XML_ATTR_INFO
756757
/* Source file byte offsets for the start and end of attribute names and values.
757758
The value indices are exclusive of surrounding quotes; thus in a UTF-8 source
758759
file an attribute value of "blah" will yield:
@@ -773,7 +774,7 @@ typedef struct {
773774
*/
774775
XMLPARSEAPI(const XML_AttrInfo *)
775776
XML_GetAttributeInfo(XML_Parser parser);
776-
#endif
777+
# endif
777778

778779
/* Parses some input. Returns XML_STATUS_ERROR if a fatal error is
779780
detected. The last call to XML_Parse must have isFinal true; len
@@ -970,9 +971,9 @@ XMLPARSEAPI(const char *)
970971
XML_GetInputContext(XML_Parser parser, int *offset, int *size);
971972

972973
/* For backwards compatibility with previous versions. */
973-
#define XML_GetErrorLineNumber XML_GetCurrentLineNumber
974-
#define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
975-
#define XML_GetErrorByteIndex XML_GetCurrentByteIndex
974+
# define XML_GetErrorLineNumber XML_GetCurrentLineNumber
975+
# define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
976+
# define XML_GetErrorByteIndex XML_GetCurrentByteIndex
976977

977978
/* Frees the content model passed to the element declaration handler */
978979
XMLPARSEAPI(void)
@@ -1032,7 +1033,10 @@ enum XML_FeatureEnum {
10321033
XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT,
10331034
XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT,
10341035
/* Added in Expat 2.6.0. */
1035-
XML_FEATURE_GE
1036+
XML_FEATURE_GE,
1037+
/* Added in Expat 2.7.2. */
1038+
XML_FEATURE_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION_DEFAULT,
1039+
XML_FEATURE_ALLOC_TRACKER_ACTIVATION_THRESHOLD_DEFAULT,
10361040
/* Additional features must be added to the end of this enum. */
10371041
};
10381042

@@ -1045,7 +1049,7 @@ typedef struct {
10451049
XMLPARSEAPI(const XML_Feature *)
10461050
XML_GetFeatureList(void);
10471051

1048-
#if defined(XML_DTD) || (defined(XML_GE) && XML_GE == 1)
1052+
# if defined(XML_DTD) || (defined(XML_GE) && XML_GE == 1)
10491053
/* Added in Expat 2.4.0 for XML_DTD defined and
10501054
* added in Expat 2.6.0 for XML_GE == 1. */
10511055
XMLPARSEAPI(XML_Bool)
@@ -1057,7 +1061,17 @@ XML_SetBillionLaughsAttackProtectionMaximumAmplification(
10571061
XMLPARSEAPI(XML_Bool)
10581062
XML_SetBillionLaughsAttackProtectionActivationThreshold(
10591063
XML_Parser parser, unsigned long long activationThresholdBytes);
1060-
#endif
1064+
1065+
/* Added in Expat 2.7.2. */
1066+
XMLPARSEAPI(XML_Bool)
1067+
XML_SetAllocTrackerMaximumAmplification(XML_Parser parser,
1068+
float maximumAmplificationFactor);
1069+
1070+
/* Added in Expat 2.7.2. */
1071+
XMLPARSEAPI(XML_Bool)
1072+
XML_SetAllocTrackerActivationThreshold(
1073+
XML_Parser parser, unsigned long long activationThresholdBytes);
1074+
# endif
10611075

10621076
/* Added in Expat 2.6.0. */
10631077
XMLPARSEAPI(XML_Bool)
@@ -1066,12 +1080,12 @@ XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled);
10661080
/* Expat follows the semantic versioning convention.
10671081
See https://semver.org
10681082
*/
1069-
#define XML_MAJOR_VERSION 2
1070-
#define XML_MINOR_VERSION 7
1071-
#define XML_MICRO_VERSION 1
1083+
# define XML_MAJOR_VERSION 2
1084+
# define XML_MINOR_VERSION 7
1085+
# define XML_MICRO_VERSION 3
10721086

1073-
#ifdef __cplusplus
1087+
# ifdef __cplusplus
10741088
}
1075-
#endif
1089+
# endif
10761090

10771091
#endif /* not Expat_INCLUDED */

base/poco/XML/include/Poco/XML/expat_external.h

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*/
3939

4040
#ifndef Expat_External_INCLUDED
41-
#define Expat_External_INCLUDED 1
41+
# define Expat_External_INCLUDED 1
4242

4343
/* External API definitions */
4444

@@ -64,12 +64,12 @@
6464
compiled with the cdecl calling convention as the default since
6565
system headers may assume the cdecl convention.
6666
*/
67-
#ifndef XMLCALL
68-
# if defined(_MSC_VER)
69-
# define XMLCALL __cdecl
70-
# elif defined(__GNUC__) && defined(__i386) && ! defined(__INTEL_COMPILER)
71-
# define XMLCALL __attribute__((cdecl))
72-
# else
67+
# ifndef XMLCALL
68+
# if defined(_MSC_VER)
69+
# define XMLCALL __cdecl
70+
# elif defined(__GNUC__) && defined(__i386) && ! defined(__INTEL_COMPILER)
71+
# define XMLCALL __attribute__((cdecl))
72+
# else
7373
/* For any platform which uses this definition and supports more than
7474
one calling convention, we need to extend this definition to
7575
declare the convention used on that platform, if it's possible to
@@ -80,86 +80,86 @@
8080
pre-processor and how to specify the same calling convention as the
8181
platform's malloc() implementation.
8282
*/
83-
# define XMLCALL
84-
# endif
85-
#endif /* not defined XMLCALL */
83+
# define XMLCALL
84+
# endif
85+
# endif /* not defined XMLCALL */
8686

87-
#if ! defined(XML_STATIC) && ! defined(XMLIMPORT)
88-
# ifndef XML_BUILDING_EXPAT
87+
# if ! defined(XML_STATIC) && ! defined(XMLIMPORT)
88+
# ifndef XML_BUILDING_EXPAT
8989
/* using Expat from an application */
9090

91-
# if defined(_MSC_EXTENSIONS) && ! defined(__BEOS__) && ! defined(__CYGWIN__)
92-
# define XMLIMPORT __declspec(dllimport)
91+
# if defined(_MSC_VER) && ! defined(__BEOS__) && ! defined(__CYGWIN__)
92+
# define XMLIMPORT __declspec(dllimport)
93+
# endif
94+
9395
# endif
96+
# endif /* not defined XML_STATIC */
9497

98+
# ifndef XML_ENABLE_VISIBILITY
99+
# define XML_ENABLE_VISIBILITY 0
95100
# endif
96-
#endif /* not defined XML_STATIC */
97-
98-
#ifndef XML_ENABLE_VISIBILITY
99-
# define XML_ENABLE_VISIBILITY 0
100-
#endif
101101

102-
#if ! defined(XMLIMPORT) && XML_ENABLE_VISIBILITY
103-
# define XMLIMPORT __attribute__((visibility("default")))
104-
#endif
102+
# if ! defined(XMLIMPORT) && XML_ENABLE_VISIBILITY
103+
# define XMLIMPORT __attribute__((visibility("default")))
104+
# endif
105105

106106
/* If we didn't define it above, define it away: */
107-
#ifndef XMLIMPORT
108-
# define XMLIMPORT
109-
#endif
110-
111-
#if defined(__GNUC__) \
112-
&& (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
113-
# define XML_ATTR_MALLOC __attribute__((__malloc__))
114-
#else
115-
# define XML_ATTR_MALLOC
116-
#endif
117-
118-
#if defined(__GNUC__) \
119-
&& ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
120-
# define XML_ATTR_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
121-
#else
122-
# define XML_ATTR_ALLOC_SIZE(x)
123-
#endif
124-
125-
#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
126-
127-
#ifdef __cplusplus
128-
extern "C" {
129-
#endif
107+
# ifndef XMLIMPORT
108+
# define XMLIMPORT
109+
# endif
110+
111+
# if defined(__GNUC__) \
112+
&& (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
113+
# define XML_ATTR_MALLOC __attribute__((__malloc__))
114+
# else
115+
# define XML_ATTR_MALLOC
116+
# endif
130117

131-
#ifdef XML_UNICODE_WCHAR_T
132-
# ifndef XML_UNICODE
133-
# define XML_UNICODE
118+
# if defined(__GNUC__) \
119+
&& ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
120+
# define XML_ATTR_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
121+
# else
122+
# define XML_ATTR_ALLOC_SIZE(x)
134123
# endif
135-
# if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2)
136-
# error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc"
124+
125+
# define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
126+
127+
# ifdef __cplusplus
128+
extern "C" {
137129
# endif
138-
#endif
139130

140-
#ifdef XML_UNICODE /* Information is UTF-16 encoded. */
141131
# ifdef XML_UNICODE_WCHAR_T
132+
# ifndef XML_UNICODE
133+
# define XML_UNICODE
134+
# endif
135+
# if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2)
136+
# error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc"
137+
# endif
138+
# endif
139+
140+
# ifdef XML_UNICODE /* Information is UTF-16 encoded. */
141+
# ifdef XML_UNICODE_WCHAR_T
142142
typedef wchar_t XML_Char;
143143
typedef wchar_t XML_LChar;
144-
# else
144+
# else
145145
typedef unsigned short XML_Char;
146146
typedef char XML_LChar;
147-
# endif /* XML_UNICODE_WCHAR_T */
148-
#else /* Information is UTF-8 encoded. */
147+
# endif /* XML_UNICODE_WCHAR_T */
148+
# else /* Information is UTF-8 encoded. */
149149
typedef char XML_Char;
150150
typedef char XML_LChar;
151-
#endif /* XML_UNICODE */
151+
# endif /* XML_UNICODE */
152152

153-
#ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
153+
# ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
154154
typedef long long XML_Index;
155155
typedef unsigned long long XML_Size;
156-
#else
156+
# else
157157
typedef long XML_Index;
158158
typedef unsigned long XML_Size;
159-
#endif /* XML_LARGE_SIZE */
159+
# endif /* XML_LARGE_SIZE */
160160

161-
#ifdef __cplusplus
161+
# ifdef __cplusplus
162162
}
163-
#endif
163+
# endif
164164

165165
#endif /* not Expat_External_INCLUDED */

base/poco/XML/src/internal.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
#endif
109109

110110
#include <limits.h> // ULONG_MAX
111+
#include <stddef.h> // size_t
111112

112113
#if defined(_WIN32) \
113114
&& (! defined(__USE_MINGW_ANSI_STDIO) \
@@ -127,7 +128,7 @@
127128
# elif ULONG_MAX == 18446744073709551615u // 2^64-1
128129
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld"
129130
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "lu"
130-
# elif defined(EMSCRIPTEN) // 32bit mode Emscripten
131+
# elif defined(__wasm32__) // 32bit mode Emscripten or WASI SDK
131132
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld"
132133
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "zu"
133134
# else
@@ -148,6 +149,16 @@
148149
100.0f
149150
#define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT \
150151
8388608 // 8 MiB, 2^23
152+
153+
#define EXPAT_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION_DEFAULT 100.0f
154+
#define EXPAT_ALLOC_TRACKER_ACTIVATION_THRESHOLD_DEFAULT \
155+
67108864 // 64 MiB, 2^26
156+
157+
// NOTE: If function expat_alloc was user facing, EXPAT_MALLOC_ALIGNMENT would
158+
// have to take sizeof(long double) into account
159+
#define EXPAT_MALLOC_ALIGNMENT sizeof(long long) // largest parser (sub)member
160+
#define EXPAT_MALLOC_PADDING ((EXPAT_MALLOC_ALIGNMENT) - sizeof(size_t))
161+
151162
/* NOTE END */
152163

153164
#include "Poco/XML/expat.h" // so we can use type XML_Parser below
@@ -171,6 +182,9 @@ extern
171182
#endif
172183
XML_Bool g_reparseDeferralEnabledDefault; // written ONLY in runtests.c
173184
#if defined(XML_TESTING)
185+
void *expat_malloc(XML_Parser parser, size_t size, int sourceLine);
186+
void expat_free(XML_Parser parser, void *ptr, int sourceLine);
187+
void *expat_realloc(XML_Parser parser, void *ptr, size_t size, int sourceLine);
174188
extern unsigned int g_bytesScanned; // used for testing only
175189
#endif
176190

0 commit comments

Comments
 (0)