Compare commits
284
Commits
master
...
RB_20260121
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f272382a9c | ||
|
|
aa8af9d7f8 | ||
|
|
e1f03ae019 | ||
|
|
f316bc6535 | ||
|
|
82e4c66520 | ||
|
|
3c923e0467 | ||
|
|
866985ac88 | ||
|
|
ba772b40ad | ||
|
|
7a86f0e1b7 | ||
|
|
7e9286f2d8 | ||
|
|
b0d1e365ec | ||
|
|
dbd5a2cbf4 | ||
|
|
d60fb1d5c0 | ||
|
|
29c91fcdba | ||
|
|
fe65674f3f | ||
|
|
a3a6b5ed7e | ||
|
|
d2de8658a7 | ||
|
|
be785b4783 | ||
|
|
70e34941c4 | ||
|
|
545d52572d | ||
|
|
dfa0736b49 | ||
|
|
c7bb5664d9 | ||
|
|
6bbc6f3417 | ||
|
|
631169a312 | ||
|
|
427b3312a6 | ||
|
|
2287b0b57a | ||
|
|
56aaba09b1 | ||
|
|
332938fef3 | ||
|
|
13710f7a06 | ||
|
|
530693099b | ||
|
|
f68aa7ea88 | ||
|
|
5bdaee5e40 | ||
|
|
1b465bc2e2 | ||
|
|
e455021bea | ||
|
|
4fe1246bcc | ||
|
|
59b4ac4d5f | ||
|
|
de641fedfe | ||
|
|
cb99fabcc0 | ||
|
|
f996ea12c2 | ||
|
|
4e7fb3e0ea | ||
|
|
e7cbbbef0f | ||
|
|
a181078981 | ||
|
|
987a662b51 | ||
|
|
77e3e14e55 | ||
|
|
98ddf30155 | ||
|
|
83da5c58a2 | ||
|
|
7136ae45a7 | ||
|
|
97d3d61749 | ||
|
|
9c8bf1fe5d | ||
|
|
d1cc6ff3cb | ||
|
|
db76d74820 | ||
|
|
8fdd9d52f9 | ||
|
|
d42797f587 | ||
|
|
6b9c1f6ab8 | ||
|
|
4aedc96db2 | ||
|
|
234830da1e | ||
|
|
244b95968f | ||
|
|
810cd553b5 | ||
|
|
e52eaa961c | ||
|
|
b7827091b8 | ||
|
|
2e344377b5 | ||
|
|
15335ce39d | ||
|
|
14b03e1f8c | ||
|
|
0968b94e5c | ||
|
|
ba6b2258aa | ||
|
|
1e1715ff11 | ||
|
|
c93381fa79 | ||
|
|
65b0a59757 | ||
|
|
c785639043 | ||
|
|
512c259822 | ||
|
|
90fea6f0d4 | ||
|
|
d892468fd0 | ||
|
|
81ab98b329 | ||
|
|
3f1cacd3e6 | ||
|
|
6e41e01a29 | ||
|
|
9ce81488d4 | ||
|
|
25bc2630d9 | ||
|
|
e5b69418a0 | ||
|
|
229a69be5f | ||
|
|
7f2561312a | ||
|
|
93d11a07f9 | ||
|
|
8e5e24c4c6 | ||
|
|
517ee6754c | ||
|
|
47690c287c | ||
|
|
364b95170e | ||
|
|
407006d673 | ||
|
|
2d60605cc6 | ||
|
|
2d1129eb7e | ||
|
|
495b4980e7 | ||
|
|
ad480be112 | ||
|
|
a06001c022 | ||
|
|
6cbda74aeb | ||
|
|
576fbdf490 | ||
|
|
52b00c38ea | ||
|
|
8ec56f459b | ||
|
|
5cbe423461 | ||
|
|
369fbba750 | ||
|
|
8e3c35efc6 | ||
|
|
b3b852b877 | ||
|
|
d5c6e20e9e | ||
|
|
89b36775fb | ||
|
|
df16df5693 | ||
|
|
aa1fd576ac | ||
|
|
2512188ca7 | ||
|
|
89e88ca6a0 | ||
|
|
2697dd162f | ||
|
|
53a4179c4a | ||
|
|
a120731ddd | ||
|
|
bda611a41a | ||
|
|
5a02a4a1a4 | ||
|
|
e59f358b45 | ||
|
|
90c9535b39 | ||
|
|
ad778bbfdb | ||
|
|
8868552b24 | ||
|
|
66826eb487 | ||
|
|
39127b5ee9 | ||
|
|
80cff816a8 | ||
|
|
e9dda8dafa | ||
|
|
11fc818dfb | ||
|
|
84ed844e3f | ||
|
|
50af804f1c | ||
|
|
82ce93bce9 | ||
|
|
228abc8259 | ||
|
|
1692fa5291 | ||
|
|
bb58c6ae38 | ||
|
|
4f58dc27f9 | ||
|
|
fc5324b9f7 | ||
|
|
561f65aabf | ||
|
|
9acfe36b95 | ||
|
|
ce495cbd85 | ||
|
|
c44020f188 | ||
|
|
35e7a695af | ||
|
|
7a55055d22 | ||
|
|
061900b87f | ||
|
|
abe32f7309 | ||
|
|
7bfd4c7fe7 | ||
|
|
859d6a3e2c | ||
|
|
c2f05f99af | ||
|
|
55b33fb02b | ||
|
|
c247e40d41 | ||
|
|
05c58f159d | ||
|
|
67d5fefcf2 | ||
|
|
aad017be9e | ||
|
|
4543dbf3ff | ||
|
|
b1cb7e0a8f | ||
|
|
1c6d21c97d | ||
|
|
fc42fb38c9 | ||
|
|
618068c15b | ||
|
|
808516a0a8 | ||
|
|
7d6b806040 | ||
|
|
6b4e2c9d73 | ||
|
|
787883f6a4 | ||
|
|
7f02753c04 | ||
|
|
8fa38b3445 | ||
|
|
541c5f9f45 | ||
|
|
4b6bd4976a | ||
|
|
a0843d52b4 | ||
|
|
977a8cbed8 | ||
|
|
1e85085305 | ||
|
|
188f61505f | ||
|
|
a514d7f6a4 | ||
|
|
47c2c75ceb | ||
|
|
7082ec8a9a | ||
|
|
2907a84362 | ||
|
|
b8d1ee05c3 | ||
|
|
0b625e624a | ||
|
|
a4da712f91 | ||
|
|
185f124e87 | ||
|
|
8633077691 | ||
|
|
39a1899045 | ||
|
|
4dc011a187 | ||
|
|
ccb12e1dda | ||
|
|
63f0d3e295 | ||
|
|
09d598c496 | ||
|
|
7e60482d80 | ||
|
|
10b3237e52 | ||
|
|
99af7cc028 | ||
|
|
76b360b5d1 | ||
|
|
4001b58a3e | ||
|
|
134a8aac87 | ||
|
|
3e2e48872a | ||
|
|
622b43cbc5 | ||
|
|
75b44ef620 | ||
|
|
00084ea49c | ||
|
|
b6fae24296 | ||
|
|
13c6b7422d | ||
|
|
24f2e663cd | ||
|
|
f96b155988 | ||
|
|
d5cc24e916 | ||
|
|
8eba271c5f | ||
|
|
19955c82b3 | ||
|
|
80ae8aec7c | ||
|
|
d8441d7c81 | ||
|
|
c2446f2478 | ||
|
|
6efb7a1904 | ||
|
|
fa0b03a10f | ||
|
|
3ae2972950 | ||
|
|
2d48de9998 | ||
|
|
3b029cdfe4 | ||
|
|
ea9077a8a5 | ||
|
|
b4af6b6265 | ||
|
|
ae1d53ceb1 | ||
|
|
c3f4709d5e | ||
|
|
a7bb3fc175 | ||
|
|
6a0203f25f | ||
|
|
b0dfcb147f | ||
|
|
06fd4c9357 | ||
|
|
b9ea7fd9ee | ||
|
|
58308a5c7a | ||
|
|
88c7d54975 | ||
|
|
eadb5678b3 | ||
|
|
54e3e60796 | ||
|
|
2a05494abe | ||
|
|
bc89e58def | ||
|
|
3a009b97f6 | ||
|
|
a105f6d5e9 | ||
|
|
5db241c0c0 | ||
|
|
d38dca10e5 | ||
|
|
54fc723126 | ||
|
|
9b8ca17ee4 | ||
|
|
cddc95b39b | ||
|
|
5676529793 | ||
|
|
ce68156cf4 | ||
|
|
5032ad9593 | ||
|
|
b55f765f2e | ||
|
|
856078d435 | ||
|
|
c74c262d2f | ||
|
|
787e29e374 | ||
|
|
e439896c9b | ||
|
|
15b508f1fb | ||
|
|
5651ebfc76 | ||
|
|
593bfc1ce8 | ||
|
|
28953cda7a | ||
|
|
516f3f545d | ||
|
|
83aff65a42 | ||
|
|
5bd97df957 | ||
|
|
8772711181 | ||
|
|
dc9526f4c6 | ||
|
|
9ab36e7ae0 | ||
|
|
e8d30841e7 | ||
|
|
9faf29374e | ||
|
|
75e4818d36 | ||
|
|
a65144e9e0 | ||
|
|
4f29548526 | ||
|
|
528db2cbd8 | ||
|
|
84e6bcc1e6 | ||
|
|
0dc9ff518d | ||
|
|
a2e3bd44aa | ||
|
|
163a0e7caf | ||
|
|
49a86db5f3 | ||
|
|
2640953d8b | ||
|
|
7eb7d67f7a | ||
|
|
e28860ba7f | ||
|
|
49a96b1d91 | ||
|
|
3130812693 | ||
|
|
71ae69aea8 | ||
|
|
9e34d697c7 | ||
|
|
8fa9125d02 | ||
|
|
4b4488c3e4 | ||
|
|
248db7d301 | ||
|
|
e199f2949b | ||
|
|
456b5450a4 | ||
|
|
d8e629c4a3 | ||
|
|
4898c4f297 | ||
|
|
7cd578bbc6 | ||
|
|
1e91df628a | ||
|
|
b110549cbd | ||
|
|
971047835a | ||
|
|
dd4d9eb032 | ||
|
|
8b94f1e480 | ||
|
|
c89610a5c7 | ||
|
|
217963cbed | ||
|
|
c4f4e18340 | ||
|
|
8a7c0e7345 | ||
|
|
52e304d450 | ||
|
|
cfc0eeca53 | ||
|
|
ebd3dd9228 | ||
|
|
cb40e4e7ef | ||
|
|
662dba55fd | ||
|
|
8760ce023c | ||
|
|
b86e148bb7 | ||
|
|
9e83721e5e | ||
|
|
dc2d6c2e60 | ||
|
|
4ada6f6762 |
No files matched your search
@@ -12051,84 +12051,71 @@ CodeGenerator::visitDebugCheckSelfHosted(LDebugCheckSelfHosted* ins)
|
||||
void
|
||||
CodeGenerator::visitRandom(LRandom* ins)
|
||||
{
|
||||
using mozilla::non_crypto::Xoroshiro128PlusPlusRNG;
|
||||
using mozilla::non_crypto::XorShift128PlusRNG;
|
||||
|
||||
FloatRegister output = ToFloatRegister(ins->output());
|
||||
Register tempReg = ToRegister(ins->temp0());
|
||||
|
||||
#ifdef JS_PUNBOX64
|
||||
Register64 s0Reg(ToRegister(ins->temp1()));
|
||||
Register64 s1Reg(ToRegister(ins->temp2()));
|
||||
// Helper registers for intermediate and final results
|
||||
Register64 imr1Reg(ToRegister(ins->temp3()));
|
||||
Register64 imr2Reg(ToRegister(ins->temp4()));
|
||||
Register64 resultReg(ToRegister(ins->temp5()));
|
||||
#else
|
||||
Register64 s0Reg(ToRegister(ins->temp1()), ToRegister(ins->temp2()));
|
||||
Register64 s1Reg(ToRegister(ins->temp3()), ToRegister(ins->temp4()));
|
||||
// Helper registers for intermediate and final results
|
||||
Register64 imr1Reg(ToRegister(ins->temp5()), ToRegister(ins->temp6()));
|
||||
Register64 imr2Reg(ToRegister(ins->temp7()), ToRegister(ins->temp8()));
|
||||
Register64 resultReg(ToRegister(ins->temp9()), ToRegister(ins->temp10()));
|
||||
#endif
|
||||
|
||||
const void* rng = gen->compartment->addressOfRandomNumberGenerator();
|
||||
masm.movePtr(ImmPtr(rng), tempReg);
|
||||
|
||||
static_assert(sizeof(Xoroshiro128PlusPlusRNG) == 2 * sizeof(uint64_t),
|
||||
"Code below assumes Xoroshiro128PlusPlusRNG contains two uint64_t values");
|
||||
static_assert(sizeof(XorShift128PlusRNG) == 2 * sizeof(uint64_t),
|
||||
"Code below assumes XorShift128PlusRNG contains two uint64_t values");
|
||||
|
||||
Address state0Addr(tempReg, Xoroshiro128PlusPlusRNG::offsetOfState0());
|
||||
Address state1Addr(tempReg, Xoroshiro128PlusPlusRNG::offsetOfState1());
|
||||
Address state0Addr(tempReg, XorShift128PlusRNG::offsetOfState0());
|
||||
Address state1Addr(tempReg, XorShift128PlusRNG::offsetOfState1());
|
||||
|
||||
// const uint64_t s0 = mState[0];
|
||||
masm.load64(state0Addr, s0Reg);
|
||||
// uint64_t s1 = mState[1];
|
||||
masm.load64(state1Addr, s1Reg);
|
||||
|
||||
// const uint64_t result = rotl(s0 + s1, 17) + s0;
|
||||
masm.move64(s0Reg, imr1Reg);
|
||||
masm.add64(s1Reg, imr1Reg);
|
||||
#ifdef JS_PUNBOX64
|
||||
masm.rotateLeft64(Imm32(17), imr1Reg, resultReg);
|
||||
#else
|
||||
masm.rotateLeft64(Imm32(17), imr1Reg, resultReg, tempReg);
|
||||
#endif
|
||||
masm.add64(s0Reg, resultReg);
|
||||
|
||||
// s1 ^= s0;
|
||||
// uint64_t s1 = mState[0];
|
||||
masm.load64(state0Addr, s1Reg);
|
||||
|
||||
// s1 ^= s1 << 23;
|
||||
masm.move64(s1Reg, s0Reg);
|
||||
masm.lshift64(Imm32(23), s1Reg);
|
||||
masm.xor64(s0Reg, s1Reg);
|
||||
|
||||
// mState[0] = rotl(s0, 49) ^ s1 ^ (s1 << 21); // a, b
|
||||
#ifdef JS_PUNBOX64
|
||||
masm.rotateLeft64(Imm32(49), s0Reg, imr1Reg); // imr = s0 rotl 49
|
||||
#else
|
||||
masm.rotateLeft64(Imm32(49), s0Reg, imr1Reg, tempReg); // imr = s0 rotl 49
|
||||
#endif
|
||||
masm.xor64(s1Reg, imr1Reg); // imr ^ s1
|
||||
masm.move64(s1Reg, imr2Reg); // imr2 = s1
|
||||
masm.lshift64(Imm32(21), imr2Reg); // imr2 << 21
|
||||
masm.xor64(imr2Reg, imr1Reg); // imr ^ imr2
|
||||
masm.store64(imr1Reg, state0Addr);
|
||||
|
||||
// mState[1] = rotl(s1, 28); // c
|
||||
#ifdef JS_PUNBOX64
|
||||
masm.rotateLeft64(Imm32(28), s1Reg, imr1Reg);
|
||||
#else
|
||||
masm.rotateLeft64(Imm32(28), s1Reg, imr1Reg, tempReg);
|
||||
#endif
|
||||
masm.store64(imr1Reg, state1Addr);
|
||||
// s1 ^= s1 >> 17
|
||||
masm.move64(s1Reg, s0Reg);
|
||||
masm.rshift64(Imm32(17), s1Reg);
|
||||
masm.xor64(s0Reg, s1Reg);
|
||||
|
||||
// See comment in Xoroshiro128PlusPlusRNG::nextDouble().
|
||||
// const uint64_t s0 = mState[1];
|
||||
masm.load64(state1Addr, s0Reg);
|
||||
|
||||
// mState[0] = s0;
|
||||
masm.store64(s0Reg, state0Addr);
|
||||
|
||||
// s1 ^= s0
|
||||
masm.xor64(s0Reg, s1Reg);
|
||||
|
||||
// s1 ^= s0 >> 26
|
||||
masm.rshift64(Imm32(26), s0Reg);
|
||||
masm.xor64(s0Reg, s1Reg);
|
||||
|
||||
// mState[1] = s1
|
||||
masm.store64(s1Reg, state1Addr);
|
||||
|
||||
// s1 += mState[0]
|
||||
masm.load64(state0Addr, s0Reg);
|
||||
masm.add64(s0Reg, s1Reg);
|
||||
|
||||
// See comment in XorShift128PlusRNG::nextDouble().
|
||||
static const int MantissaBits = FloatingPoint<double>::kExponentShift + 1;
|
||||
static const double ScaleInv = double(1) / (1ULL << MantissaBits);
|
||||
|
||||
// Mask the result bits to mantissa size
|
||||
masm.and64(Imm64((1ULL << MantissaBits) - 1), resultReg);
|
||||
masm.and64(Imm64((1ULL << MantissaBits) - 1), s1Reg);
|
||||
|
||||
if (masm.convertUInt64ToDoubleNeedsTemp())
|
||||
masm.convertUInt64ToDouble(resultReg, output, tempReg);
|
||||
masm.convertUInt64ToDouble(s1Reg, output, tempReg);
|
||||
else
|
||||
masm.convertUInt64ToDouble(resultReg, output, Register::Invalid());
|
||||
masm.convertUInt64ToDouble(s1Reg, output, Register::Invalid());
|
||||
|
||||
// output *= ScaleInv
|
||||
masm.mulDoublePtr(ImmPtr(&ScaleInv), tempReg, output);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* Copyright (C) 2008 Apple Inc.
|
||||
* Copyright (C) 2026 Moonchild Productions.
|
||||
* Copyright (C) 2008 Apple Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -12,24 +11,24 @@
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL APPLE INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef jit_ExecutableAllocator_h
|
||||
#define jit_ExecutableAllocator_h
|
||||
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/Xoroshiro128PlusPlusRNG.h"
|
||||
#include "mozilla/XorShift128PlusRNG.h"
|
||||
|
||||
#include <limits>
|
||||
#include <stddef.h> // for ptrdiff_t
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/TaggedAnonymousMemory.h"
|
||||
#include "mozilla/Xoroshiro128PlusPlusRNG.h"
|
||||
#include "mozilla/XorShift128PlusRNG.h"
|
||||
|
||||
#include "jsfriendapi.h"
|
||||
#include "jsmath.h"
|
||||
@@ -441,7 +441,7 @@ class ProcessExecutableMemory
|
||||
// Page where we should try to allocate next.
|
||||
size_t cursor_;
|
||||
|
||||
mozilla::Maybe<mozilla::non_crypto::Xoroshiro128PlusPlusRNG> rng_;
|
||||
mozilla::Maybe<mozilla::non_crypto::XorShift128PlusRNG> rng_;
|
||||
PageBitSet<MaxCodePages> pages_;
|
||||
|
||||
public:
|
||||
@@ -467,7 +467,7 @@ class ProcessExecutableMemory
|
||||
base_ = static_cast<uint8_t*>(p);
|
||||
|
||||
mozilla::Array<uint64_t, 2> seed;
|
||||
GenerateXoroshiro128PlusPlusSeed(seed);
|
||||
GenerateXorShift128PlusSeed(seed);
|
||||
rng_.emplace(seed[0], seed[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -968,12 +968,6 @@ void
|
||||
LIRGeneratorARM::visitRandom(MRandom* ins)
|
||||
{
|
||||
LRandom *lir = new(alloc()) LRandom(temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
|
||||
@@ -326,9 +326,6 @@ void
|
||||
LIRGeneratorARM64::visitRandom(MRandom* ins)
|
||||
{
|
||||
LRandom *lir = new(alloc()) LRandom(temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp());
|
||||
defineFixed(lir, ins, LFloatReg(ReturnDoubleReg));
|
||||
|
||||
@@ -249,12 +249,6 @@ void
|
||||
LIRGeneratorMIPS::visitRandom(MRandom* ins)
|
||||
{
|
||||
LRandom *lir = new(alloc()) LRandom(temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
|
||||
@@ -178,11 +178,6 @@ LIRGeneratorMIPS64::lowerTruncateFToInt32(MTruncateToInt32* ins)
|
||||
void
|
||||
LIRGeneratorMIPS64::visitRandom(MRandom* ins)
|
||||
{
|
||||
LRandom *lir = new(alloc()) LRandom(temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp());
|
||||
LRandom *lir = new(alloc()) LRandom(temp(), temp(), temp());
|
||||
defineFixed(lir, ins, LFloatReg(ReturnDoubleReg));
|
||||
}
|
||||
@@ -8220,9 +8220,9 @@ class LArrowNewTarget : public LInstructionHelper<BOX_PIECES, 1, 0>
|
||||
|
||||
// Math.random().
|
||||
#ifdef JS_PUNBOX64
|
||||
# define LRANDOM_NUM_TEMPS 6
|
||||
# define LRANDOM_NUM_TEMPS 3
|
||||
#else
|
||||
# define LRANDOM_NUM_TEMPS 11
|
||||
# define LRANDOM_NUM_TEMPS 5
|
||||
#endif
|
||||
|
||||
class LRandom : public LInstructionHelper<1, 0, LRANDOM_NUM_TEMPS>
|
||||
@@ -8230,27 +8230,18 @@ class LRandom : public LInstructionHelper<1, 0, LRANDOM_NUM_TEMPS>
|
||||
public:
|
||||
LIR_HEADER(Random)
|
||||
LRandom(const LDefinition &temp0, const LDefinition &temp1,
|
||||
const LDefinition &temp2, const LDefinition &temp3,
|
||||
const LDefinition &temp4, const LDefinition &temp5
|
||||
const LDefinition &temp2
|
||||
#ifndef JS_PUNBOX64
|
||||
, const LDefinition &temp6, const LDefinition &temp7
|
||||
, const LDefinition &temp8, const LDefinition &temp9
|
||||
, const LDefinition &temp10
|
||||
, const LDefinition &temp3, const LDefinition &temp4
|
||||
#endif
|
||||
)
|
||||
{
|
||||
setTemp(0, temp0);
|
||||
setTemp(1, temp1);
|
||||
setTemp(2, temp2);
|
||||
#ifndef JS_PUNBOX64
|
||||
setTemp(3, temp3);
|
||||
setTemp(4, temp4);
|
||||
setTemp(5, temp5);
|
||||
#ifndef JS_PUNBOX64
|
||||
setTemp(6, temp6);
|
||||
setTemp(7, temp7);
|
||||
setTemp(8, temp8);
|
||||
setTemp(9, temp9);
|
||||
setTemp(10, temp10);
|
||||
#endif
|
||||
}
|
||||
const LDefinition* temp0() {
|
||||
@@ -8259,34 +8250,16 @@ class LRandom : public LInstructionHelper<1, 0, LRANDOM_NUM_TEMPS>
|
||||
const LDefinition* temp1() {
|
||||
return getTemp(1);
|
||||
}
|
||||
const LDefinition* temp2() {
|
||||
const LDefinition *temp2() {
|
||||
return getTemp(2);
|
||||
}
|
||||
const LDefinition* temp3() {
|
||||
#ifndef JS_PUNBOX64
|
||||
const LDefinition *temp3() {
|
||||
return getTemp(3);
|
||||
}
|
||||
const LDefinition* temp4() {
|
||||
const LDefinition *temp4() {
|
||||
return getTemp(4);
|
||||
}
|
||||
const LDefinition* temp5() {
|
||||
return getTemp(5);
|
||||
}
|
||||
#ifndef JS_PUNBOX64
|
||||
const LDefinition* temp6() {
|
||||
return getTemp(6);
|
||||
}
|
||||
const LDefinition* temp7() {
|
||||
return getTemp(7);
|
||||
}
|
||||
const LDefinition* temp8() {
|
||||
return getTemp(8);
|
||||
}
|
||||
const LDefinition* temp9() {
|
||||
return getTemp(9);
|
||||
}
|
||||
const LDefinition* temp10() {
|
||||
return getTemp(10);
|
||||
}
|
||||
#endif
|
||||
|
||||
MRandom* mir() const {
|
||||
|
||||
@@ -412,9 +412,6 @@ void
|
||||
LIRGeneratorX64::visitRandom(MRandom* ins)
|
||||
{
|
||||
LRandom *lir = new(alloc()) LRandom(temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp());
|
||||
defineFixed(lir, ins, LFloatReg(ReturnDoubleReg));
|
||||
|
||||
@@ -397,6 +397,7 @@ MacroAssembler::rshift64Arithmetic(Register shift, Register64 srcDest)
|
||||
void
|
||||
MacroAssembler::rotateLeft64(Register count, Register64 src, Register64 dest)
|
||||
{
|
||||
MOZ_ASSERT(src == dest, "defineReuseInput");
|
||||
MOZ_ASSERT(count == ecx, "defineFixed(ecx)");
|
||||
|
||||
rolq_cl(dest.reg);
|
||||
@@ -412,6 +413,7 @@ MacroAssembler::rotateLeft64(Register count, Register64 src, Register64 dest, Re
|
||||
void
|
||||
MacroAssembler::rotateRight64(Register count, Register64 src, Register64 dest)
|
||||
{
|
||||
MOZ_ASSERT(src == dest, "defineReuseInput");
|
||||
MOZ_ASSERT(count == ecx, "defineFixed(ecx)");
|
||||
|
||||
rorq_cl(dest.reg);
|
||||
@@ -427,6 +429,7 @@ MacroAssembler::rotateRight64(Register count, Register64 src, Register64 dest, R
|
||||
void
|
||||
MacroAssembler::rotateLeft64(Imm32 count, Register64 src, Register64 dest)
|
||||
{
|
||||
MOZ_ASSERT(src == dest, "defineReuseInput");
|
||||
rolq(count, dest.reg);
|
||||
}
|
||||
|
||||
@@ -440,6 +443,7 @@ MacroAssembler::rotateLeft64(Imm32 count, Register64 src, Register64 dest, Regis
|
||||
void
|
||||
MacroAssembler::rotateRight64(Imm32 count, Register64 src, Register64 dest)
|
||||
{
|
||||
MOZ_ASSERT(src == dest, "defineReuseInput");
|
||||
rorq(count, dest.reg);
|
||||
}
|
||||
|
||||
|
||||
@@ -607,12 +607,6 @@ void
|
||||
LIRGeneratorX86::visitRandom(MRandom* ins)
|
||||
{
|
||||
LRandom *lir = new(alloc()) LRandom(temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
|
||||
@@ -482,6 +482,7 @@ MacroAssembler::rshift64Arithmetic(Register shift, Register64 srcDest)
|
||||
void
|
||||
MacroAssembler::rotateLeft64(Register count, Register64 src, Register64 dest, Register temp)
|
||||
{
|
||||
MOZ_ASSERT(src == dest, "defineReuseInput");
|
||||
MOZ_ASSERT(count == ecx, "defineFixed(ecx)");
|
||||
|
||||
Label done;
|
||||
@@ -500,6 +501,7 @@ MacroAssembler::rotateLeft64(Register count, Register64 src, Register64 dest, Re
|
||||
void
|
||||
MacroAssembler::rotateRight64(Register count, Register64 src, Register64 dest, Register temp)
|
||||
{
|
||||
MOZ_ASSERT(src == dest, "defineReuseInput");
|
||||
MOZ_ASSERT(count == ecx, "defineFixed(ecx)");
|
||||
|
||||
Label done;
|
||||
@@ -518,6 +520,8 @@ MacroAssembler::rotateRight64(Register count, Register64 src, Register64 dest, R
|
||||
void
|
||||
MacroAssembler::rotateLeft64(Imm32 count, Register64 src, Register64 dest, Register temp)
|
||||
{
|
||||
MOZ_ASSERT(src == dest, "defineReuseInput");
|
||||
|
||||
int32_t amount = count.value & 0x3f;
|
||||
if ((amount & 0x1f) != 0) {
|
||||
movl(dest.high, temp);
|
||||
@@ -532,6 +536,8 @@ MacroAssembler::rotateLeft64(Imm32 count, Register64 src, Register64 dest, Regis
|
||||
void
|
||||
MacroAssembler::rotateRight64(Imm32 count, Register64 src, Register64 dest, Register temp)
|
||||
{
|
||||
MOZ_ASSERT(src == dest, "defineReuseInput");
|
||||
|
||||
int32_t amount = count.value & 0x3f;
|
||||
if ((amount & 0x1f) != 0) {
|
||||
movl(dest.high, temp);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/Tuple.h"
|
||||
#include "mozilla/Variant.h"
|
||||
#include "mozilla/Xoroshiro128PlusPlusRNG.h"
|
||||
#include "mozilla/XorShift128PlusRNG.h"
|
||||
|
||||
#include "builtin/RegExp.h"
|
||||
#include "gc/Barrier.h"
|
||||
@@ -688,13 +688,13 @@ struct JSCompartment
|
||||
js::DtoaCache dtoaCache;
|
||||
|
||||
// Random number generator for Math.random().
|
||||
mozilla::Maybe<mozilla::non_crypto::Xoroshiro128PlusPlusRNG> randomNumberGenerator;
|
||||
mozilla::Maybe<mozilla::non_crypto::XorShift128PlusRNG> randomNumberGenerator;
|
||||
|
||||
// Initialize randomNumberGenerator if needed.
|
||||
void ensureRandomNumberGenerator();
|
||||
|
||||
private:
|
||||
mozilla::non_crypto::Xoroshiro128PlusPlusRNG randomKeyGenerator_;
|
||||
mozilla::non_crypto::XorShift128PlusRNG randomKeyGenerator_;
|
||||
|
||||
public:
|
||||
js::HashNumber randomHashCode();
|
||||
|
||||
+3
-3
@@ -737,9 +737,9 @@ js::GenerateRandomSeed()
|
||||
}
|
||||
|
||||
void
|
||||
js::GenerateXoroshiro128PlusPlusSeed(mozilla::Array<uint64_t, 2>& seed)
|
||||
js::GenerateXorShift128PlusSeed(mozilla::Array<uint64_t, 2>& seed)
|
||||
{
|
||||
// Xoroshiro128PlusPlusRNG must be initialized with a non-zero seed.
|
||||
// XorShift128PlusRNG must be initialized with a non-zero seed.
|
||||
do {
|
||||
seed[0] = GenerateRandomSeed();
|
||||
seed[1] = GenerateRandomSeed();
|
||||
@@ -751,7 +751,7 @@ JSCompartment::ensureRandomNumberGenerator()
|
||||
{
|
||||
if (randomNumberGenerator.isNothing()) {
|
||||
mozilla::Array<uint64_t, 2> seed;
|
||||
GenerateXoroshiro128PlusPlusSeed(seed);
|
||||
GenerateXorShift128PlusSeed(seed);
|
||||
randomNumberGenerator.emplace(seed[0], seed[1]);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -89,9 +89,9 @@ extern uint64_t
|
||||
GenerateRandomSeed();
|
||||
|
||||
// Fill |seed[0]| and |seed[1]| with random bits, suitable for
|
||||
// seeding a Xoroshiro128++ random number generator.
|
||||
// seeding a XorShift128+ random number generator.
|
||||
extern void
|
||||
GenerateXoroshiro128PlusPlusSeed(mozilla::Array<uint64_t, 2>& seed);
|
||||
GenerateXorShift128PlusSeed(mozilla::Array<uint64_t, 2>& seed);
|
||||
|
||||
extern uint64_t
|
||||
random_next(uint64_t* rngState, int bits);
|
||||
|
||||
@@ -765,13 +765,13 @@ JSRuntime::removeUnhandledRejectedPromise(JSContext* cx, js::HandleObject promis
|
||||
PromiseRejectionHandlingState::Handled, data);
|
||||
}
|
||||
|
||||
mozilla::non_crypto::Xoroshiro128PlusPlusRNG&
|
||||
mozilla::non_crypto::XorShift128PlusRNG&
|
||||
JSRuntime::randomKeyGenerator()
|
||||
{
|
||||
MOZ_ASSERT(CurrentThreadCanAccessRuntime(this));
|
||||
if (randomKeyGenerator_.isNothing()) {
|
||||
mozilla::Array<uint64_t, 2> seed;
|
||||
GenerateXoroshiro128PlusPlusSeed(seed);
|
||||
GenerateXorShift128PlusSeed(seed);
|
||||
randomKeyGenerator_.emplace(seed[0], seed[1]);
|
||||
}
|
||||
return randomKeyGenerator_.ref();
|
||||
@@ -784,11 +784,11 @@ JSRuntime::randomHashCodeScrambler()
|
||||
return mozilla::HashCodeScrambler(rng.next(), rng.next());
|
||||
}
|
||||
|
||||
mozilla::non_crypto::Xoroshiro128PlusPlusRNG
|
||||
mozilla::non_crypto::XorShift128PlusRNG
|
||||
JSRuntime::forkRandomKeyGenerator()
|
||||
{
|
||||
auto& rng = randomKeyGenerator();
|
||||
return mozilla::non_crypto::Xoroshiro128PlusPlusRNG(rng.next(), rng.next());
|
||||
return mozilla::non_crypto::XorShift128PlusRNG(rng.next(), rng.next());
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+3
-3
@@ -767,12 +767,12 @@ struct JSRuntime : public JS::shadow::Runtime,
|
||||
|
||||
private:
|
||||
// Used to generate random keys for hash tables.
|
||||
mozilla::Maybe<mozilla::non_crypto::Xoroshiro128PlusPlusRNG> randomKeyGenerator_;
|
||||
mozilla::non_crypto::Xoroshiro128PlusPlusRNG& randomKeyGenerator();
|
||||
mozilla::Maybe<mozilla::non_crypto::XorShift128PlusRNG> randomKeyGenerator_;
|
||||
mozilla::non_crypto::XorShift128PlusRNG& randomKeyGenerator();
|
||||
|
||||
public:
|
||||
mozilla::HashCodeScrambler randomHashCodeScrambler();
|
||||
mozilla::non_crypto::Xoroshiro128PlusPlusRNG forkRandomKeyGenerator();
|
||||
mozilla::non_crypto::XorShift128PlusRNG forkRandomKeyGenerator();
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Self-hosting support
|
||||
|
||||
@@ -1595,7 +1595,7 @@ SavedStacks::chooseSamplingProbability(JSCompartment* compartment)
|
||||
|
||||
if (!bernoulliSeeded) {
|
||||
mozilla::Array<uint64_t, 2> seed;
|
||||
GenerateXoroshiro128PlusPlusSeed(seed);
|
||||
GenerateXorShift128PlusSeed(seed);
|
||||
bernoulli.setRandomState(seed[0], seed[1]);
|
||||
bernoulliSeeded = true;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ class SavedStacks {
|
||||
|
||||
// Set the sampling random number generator's state to |state0| and
|
||||
// |state1|. One or the other must be non-zero. See the comments for
|
||||
// mozilla::non_crypto::Xoroshiro128PlusPlusRNG::setState for details.
|
||||
// mozilla::non_crypto::XorShift128PlusRNG::setState for details.
|
||||
void setRNGState(uint64_t state0, uint64_t state1) { bernoulli.setRandomState(state0, state1); }
|
||||
|
||||
size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf);
|
||||
|
||||
@@ -341,6 +341,7 @@ MOZ_XML_GetCurrentByteIndex
|
||||
MOZ_XML_GetCurrentColumnNumber
|
||||
MOZ_XML_GetCurrentLineNumber
|
||||
MOZ_XML_GetErrorCode
|
||||
MOZ_XML_GetIdAttributeIndex
|
||||
MOZ_XML_GetMismatchedTag
|
||||
MOZ_XML_GetSpecifiedAttributeCount
|
||||
MOZ_XML_Parse
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#define mozilla_FastBernoulliTrial_h
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Xoroshiro128PlusPlusRNG.h"
|
||||
#include "mozilla/XorShift128PlusRNG.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <stdint.h>
|
||||
@@ -303,7 +303,7 @@ class FastBernoulliTrial {
|
||||
double mInvLogNotProbability;
|
||||
|
||||
/* Our random number generator. */
|
||||
non_crypto::Xoroshiro128PlusPlusRNG mGenerator;
|
||||
non_crypto::XorShift128PlusRNG mGenerator;
|
||||
|
||||
/* The number of times |trial| should return false before next returning true. */
|
||||
size_t mSkipCount;
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* The xorshift128+ pseudo-random number generator. */
|
||||
|
||||
#ifndef mozilla_XorShift128Plus_h
|
||||
#define mozilla_XorShift128Plus_h
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
namespace mozilla {
|
||||
namespace non_crypto {
|
||||
|
||||
/*
|
||||
* A stream of pseudo-random numbers generated using the xorshift+ technique
|
||||
* described here:
|
||||
*
|
||||
* Vigna, Sebastiano (2014). "Further scramblings of Marsaglia's xorshift
|
||||
* generators". arXiv:1404.0390 (http://arxiv.org/abs/1404.0390)
|
||||
*
|
||||
* That paper says:
|
||||
*
|
||||
* In particular, we propose a tightly coded xorshift128+ generator that
|
||||
* does not fail systematically any test from the BigCrush suite of TestU01
|
||||
* (even reversed) and generates 64 pseudorandom bits in 1.10 ns on an
|
||||
* Intel(R) Core(TM) i7-4770 CPU @3.40GHz (Haswell). It is the fastest
|
||||
* generator we are aware of with such empirical statistical properties.
|
||||
*
|
||||
* The stream of numbers produced by this method repeats every 2**128 - 1 calls
|
||||
* (i.e. never, for all practical purposes). Zero appears 2**64 - 1 times in
|
||||
* this period; all other numbers appear 2**64 times. Additionally, each *bit*
|
||||
* in the produced numbers repeats every 2**128 - 1 calls.
|
||||
*
|
||||
* This generator is not suitable as a cryptographically secure random number
|
||||
* generator.
|
||||
*/
|
||||
class XorShift128PlusRNG {
|
||||
uint64_t mState[2];
|
||||
|
||||
public:
|
||||
/*
|
||||
* Construct a xorshift128+ pseudo-random number stream using |aInitial0| and
|
||||
* |aInitial1| as the initial state. These MUST NOT both be zero.
|
||||
*
|
||||
* If the initial states contain many zeros, for a few iterations you'll see
|
||||
* many zeroes in the generated numbers. It's suggested to seed a SplitMix64
|
||||
* generator <http://xorshift.di.unimi.it/splitmix64.c> and use its first two
|
||||
* outputs to seed xorshift128+.
|
||||
*/
|
||||
XorShift128PlusRNG(uint64_t aInitial0, uint64_t aInitial1) {
|
||||
setState(aInitial0, aInitial1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a pseudo-random 64-bit number.
|
||||
*/
|
||||
uint64_t next() {
|
||||
/*
|
||||
* The offsetOfState*() methods below are provided so that exceedingly-rare
|
||||
* callers that want to observe or poke at RNG state in C++ type-system-
|
||||
* ignoring means can do so. Don't change the next() or nextDouble()
|
||||
* algorithms without altering code that uses offsetOfState*()!
|
||||
*/
|
||||
uint64_t s1 = mState[0];
|
||||
const uint64_t s0 = mState[1];
|
||||
mState[0] = s0;
|
||||
s1 ^= s1 << 23;
|
||||
mState[1] = s1 ^ s0 ^ (s1 >> 17) ^ (s0 >> 26);
|
||||
return mState[1] + s0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a pseudo-random floating-point value in the range [0, 1). More
|
||||
* precisely, choose an integer in the range [0, 2**53) and divide it by
|
||||
* 2**53. Given the 2**128 - 1 period noted above, the produced doubles are
|
||||
* all but uniformly distributed in this range.
|
||||
*/
|
||||
double nextDouble() {
|
||||
/*
|
||||
* Because the IEEE 64-bit floating point format stores the leading '1' bit
|
||||
* of the mantissa implicitly, it effectively represents a mantissa in the
|
||||
* range [0, 2**53) in only 52 bits. FloatingPoint<double>::kExponentShift
|
||||
* is the width of the bitfield in the in-memory format, so we must add one
|
||||
* to get the mantissa's range.
|
||||
*/
|
||||
static constexpr int kMantissaBits =
|
||||
mozilla::FloatingPoint<double>::kExponentShift + 1;
|
||||
uint64_t mantissa = next() & ((UINT64_C(1) << kMantissaBits) - 1);
|
||||
return double(mantissa) / (UINT64_C(1) << kMantissaBits);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the stream's current state to |aState0| and |aState1|. These must not
|
||||
* both be zero; ideally, they should have an almost even mix of zero and one
|
||||
* bits.
|
||||
*/
|
||||
void setState(uint64_t aState0, uint64_t aState1) {
|
||||
MOZ_ASSERT(aState0 || aState1);
|
||||
mState[0] = aState0;
|
||||
mState[1] = aState1;
|
||||
}
|
||||
|
||||
static size_t offsetOfState0() {
|
||||
return offsetof(XorShift128PlusRNG, mState[0]);
|
||||
}
|
||||
static size_t offsetOfState1() {
|
||||
return offsetof(XorShift128PlusRNG, mState[1]);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace non_crypto
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_XorShift128Plus_h
|
||||
@@ -1,125 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* The xoroshiro128++ pseudo-random number generator. */
|
||||
|
||||
#ifndef mozilla_Xoroshiro128PlusPlus_h
|
||||
#define mozilla_Xoroshiro128PlusPlus_h
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
namespace mozilla {
|
||||
namespace non_crypto {
|
||||
|
||||
/*
|
||||
* A stream of pseudo-random numbers generated using the xoroshiro128++ technique described here:
|
||||
*
|
||||
* Blackman, David and Vigna, Sebastiano (2019). "A PRNG Shootout"
|
||||
* https://prng.di.unimi.it/
|
||||
*
|
||||
* That paper says:
|
||||
*
|
||||
* xoshiro256++/xoshiro256** (XOR/shift/rotate) are our all-purpose generators (not cryptographically secure
|
||||
* generators, though, like all PRNGs in these pages). They have excellent (sub-ns) speed, a state space
|
||||
* (256 bits) that is large enough for any parallel application, and they pass all tests we are aware of.
|
||||
* If you are tight on space, xoroshiro128++/xoroshiro128** (XOR/rotate/shift/rotate) and xoroshiro128+ have
|
||||
* the same speed and use half of the space; the same comments apply.
|
||||
* They are suitable only for low-scale parallel applications.
|
||||
*
|
||||
* The stream of numbers produced by this method repeats every 2**256 - 1 calls (i.e. never, for all practical
|
||||
* purposes).
|
||||
*
|
||||
*/
|
||||
class Xoroshiro128PlusPlusRNG {
|
||||
uint64_t mState[2];
|
||||
|
||||
public:
|
||||
/*
|
||||
* Construct a xoroshiro128++ pseudo-random number stream using |aInitial0| and |aInitial1| as the initial state.
|
||||
* These MUST NOT both be zero.
|
||||
*
|
||||
* If the initial states contain many zeros, for a few iterations you'll see many zeroes in the generated numbers.
|
||||
* It's suggested to seed a SplitMix64 generator <http://xorshift.di.unimi.it/splitmix64.c> and use its first two
|
||||
* outputs to seed xoroshiro128++.
|
||||
*/
|
||||
Xoroshiro128PlusPlusRNG(uint64_t aInitial0, uint64_t aInitial1) {
|
||||
setState(aInitial0, aInitial1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function:
|
||||
* Rotate a 64-bit number left by a specified number of positions
|
||||
*/
|
||||
static inline uint64_t rotl(const uint64_t x, int k) {
|
||||
return (x << k) | (x >> (64 - k));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a pseudo-random 64-bit number.
|
||||
*/
|
||||
uint64_t next() {
|
||||
/*
|
||||
* The offsetOfState*() methods below are provided so that exceedingly-rare callers (like our JIT...) that want to
|
||||
* observe or poke at RNG state in C++ type-system-ignoring means can do so. Don't change the next() or nextDouble()
|
||||
* algorithms without altering code that uses offsetOfState*()!
|
||||
*/
|
||||
const uint64_t s0 = mState[0];
|
||||
uint64_t s1 = mState[1];
|
||||
const uint64_t result = rotl(s0 + s1, 17) + s0;
|
||||
|
||||
s1 ^= s0;
|
||||
mState[0] = rotl(s0, 49) ^ s1 ^ (s1 << 21); // a, b
|
||||
mState[1] = rotl(s1, 28); // c
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a pseudo-random floating-point value in the range [0, 1). More
|
||||
* precisely, choose an integer in the range [0, 2**53) and divide it by
|
||||
* 2**53. Given the 2**256 - 1 period noted above, the produced doubles are
|
||||
* all but uniformly distributed in this range.
|
||||
*/
|
||||
double nextDouble() {
|
||||
/*
|
||||
* Because the IEEE 64-bit floating point format stores the leading '1' bit
|
||||
* of the mantissa implicitly, it effectively represents a mantissa in the
|
||||
* range [0, 2**53) in only 52 bits. FloatingPoint<double>::kExponentShift
|
||||
* is the width of the bitfield in the in-memory format, so we must add one
|
||||
* to get the mantissa's range.
|
||||
*/
|
||||
static constexpr int kMantissaBits =
|
||||
mozilla::FloatingPoint<double>::kExponentShift + 1;
|
||||
uint64_t mantissa = next() & ((UINT64_C(1) << kMantissaBits) - 1);
|
||||
return double(mantissa) / (UINT64_C(1) << kMantissaBits);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the stream's current state to |aState0| and |aState1|. These must not
|
||||
* both be zero; ideally, they should have an almost even mix of zero and one
|
||||
* bits.
|
||||
*/
|
||||
void setState(uint64_t aState0, uint64_t aState1) {
|
||||
MOZ_ASSERT(aState0 || aState1);
|
||||
mState[0] = aState0;
|
||||
mState[1] = aState1;
|
||||
}
|
||||
|
||||
static size_t offsetOfState0() {
|
||||
return offsetof(Xoroshiro128PlusPlusRNG, mState[0]);
|
||||
}
|
||||
static size_t offsetOfState1() {
|
||||
return offsetof(Xoroshiro128PlusPlusRNG, mState[1]);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace non_crypto
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_Xoroshiro128PlusPlus_h
|
||||
+1
-1
@@ -103,7 +103,7 @@ EXPORTS.mozilla = [
|
||||
'Vector.h',
|
||||
'WeakPtr.h',
|
||||
'WrappingOperations.h',
|
||||
'Xoroshiro128PlusPlusRNG.h',
|
||||
'XorShift128PlusRNG.h',
|
||||
]
|
||||
|
||||
if CONFIG['OS_ARCH'] == 'WINNT':
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
diff --git a/lib/expat_external.h b/lib/expat_external.h
|
||||
--- a/lib/expat_external.h
|
||||
+++ b/lib/expat_external.h
|
||||
@@ -138,6 +138,7 @@
|
||||
# endif
|
||||
# endif
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* typedef XML_Char to char16_t */
|
||||
# ifdef XML_UNICODE /* Information is UTF-16 encoded. */
|
||||
# ifdef XML_UNICODE_WCHAR_T
|
||||
typedef wchar_t XML_Char;
|
||||
@@ -150,6 +151,7 @@
|
||||
typedef char XML_Char;
|
||||
typedef char XML_LChar;
|
||||
# endif /* XML_UNICODE */
|
||||
+#endif /* MOZILLA_CLIENT */
|
||||
|
||||
# ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
|
||||
typedef long long XML_Index;
|
||||
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -195,6 +195,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* typedef XML_Char to char16_t */
|
||||
#ifdef XML_UNICODE
|
||||
|
||||
# ifdef XML_UNICODE_WCHAR_T
|
||||
@@ -211,6 +212,7 @@
|
||||
# define XML_L(x) x
|
||||
|
||||
#endif
|
||||
+#endif /* MOZILLA_CLIENT */
|
||||
|
||||
/* Round up n to be a multiple of sz, where sz is a power of 2. */
|
||||
#define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1))
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -267,6 +267,9 @@
|
||||
#define INIT_ATTS_SIZE 16
|
||||
#define INIT_ATTS_VERSION 0xFFFFFFFF
|
||||
#define INIT_BLOCK_SIZE 1024
|
||||
+#ifdef MOZILLA_CLIENT /* Avoid slop in poolGrow() allocations */
|
||||
+#define INIT_BLOCK_SIZE ((int)(1024 - (offsetof(BLOCK, s) / sizeof(XML_Char))))
|
||||
+#endif
|
||||
#define INIT_BUFFER_SIZE 1024
|
||||
|
||||
#define EXPAND_SPARE 24
|
||||
@@ -1,73 +0,0 @@
|
||||
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -787,6 +787,9 @@
|
||||
MALLOC_TRACKER m_alloc_tracker;
|
||||
ENTITY_STATS m_entity_stats;
|
||||
#endif
|
||||
+#ifdef MOZILLA_CLIENT /* Report opening tag of mismatched closing tag */
|
||||
+ const XML_Char* m_mismatch;
|
||||
+#endif
|
||||
XML_Bool m_reenter;
|
||||
};
|
||||
|
||||
@@ -1535,6 +1538,10 @@
|
||||
parser->m_internalEncoding = XmlGetInternalEncoding();
|
||||
}
|
||||
|
||||
+#ifdef MOZILLA_CLIENT /* Report opening tag of mismatched closing tag */
|
||||
+ parser->m_mismatch = NULL;
|
||||
+#endif
|
||||
+
|
||||
return parser;
|
||||
}
|
||||
|
||||
@@ -3110,6 +3117,14 @@
|
||||
}
|
||||
#endif /* XML_GE == 1 */
|
||||
|
||||
+#ifdef MOZILLA_CLIENT /* Report opening tag of mismatched closing tag */
|
||||
+const XML_Char * XMLCALL
|
||||
+MOZ_XML_GetMismatchedTag(XML_Parser parser)
|
||||
+{
|
||||
+ return parser->m_mismatch;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
XML_Bool XMLCALL
|
||||
XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled) {
|
||||
if (parser != NULL && (enabled == XML_TRUE || enabled == XML_FALSE)) {
|
||||
@@ -3590,6 +3605,33 @@
|
||||
len = XmlNameLength(enc, rawName);
|
||||
if (len != tag->rawNameLength
|
||||
|| memcmp(tag->rawName, rawName, len) != 0) {
|
||||
+#ifdef MOZILLA_CLIENT /* Report opening tag of mismatched closing tag */
|
||||
+ /* This code is copied from the |if (parser->m_endElementHandler)|
|
||||
+ block below
|
||||
+ */
|
||||
+ const XML_Char *localPart;
|
||||
+ const XML_Char *prefix;
|
||||
+ XML_Char *uri;
|
||||
+ localPart = tag->name.localPart;
|
||||
+ if (parser->m_ns && localPart) {
|
||||
+ /* localPart and prefix may have been overwritten in
|
||||
+ tag->name.str, since this points to the binding->uri
|
||||
+ buffer which gets reused; so we have to add them again
|
||||
+ */
|
||||
+ uri = (XML_Char *)tag->name.str + tag->name.uriLen;
|
||||
+ /* don't need to check for space - already done in storeAtts() */
|
||||
+ while (*localPart)
|
||||
+ *uri++ = *localPart++;
|
||||
+ prefix = tag->name.prefix;
|
||||
+ if (parser->m_ns_triplets && prefix) {
|
||||
+ *uri++ = parser->m_namespaceSeparator;
|
||||
+ while (*prefix)
|
||||
+ *uri++ = *prefix++;
|
||||
+ }
|
||||
+ *uri = XML_T('\0');
|
||||
+ }
|
||||
+ parser->m_mismatch = tag->name.str;
|
||||
+#endif /* MOZILLA_CLIENT */
|
||||
*eventPP = rawName;
|
||||
return XML_ERROR_TAG_MISMATCH;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -2738,6 +2738,10 @@
|
||||
XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr,
|
||||
parser->m_bufferPtr, &parser->m_position);
|
||||
parser->m_positionPtr = parser->m_bufferPtr;
|
||||
+#ifdef MOZILLA_CLIENT /* always set m_eventPtr/m_eventEndPtr */
|
||||
+ parser->m_eventPtr = parser->m_bufferPtr;
|
||||
+ parser->m_eventEndPtr = parser->m_bufferPtr;
|
||||
+#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -2767,7 +2767,11 @@
|
||||
if (parser->m_eventPtr)
|
||||
return (XML_Index)(parser->m_parseEndByteIndex
|
||||
- (parser->m_parseEndPtr - parser->m_eventPtr));
|
||||
+#ifdef MOZILLA_CLIENT /* fix XML_GetCurrentByteIndex */
|
||||
+ return parser->m_parseEndByteIndex;
|
||||
+#else
|
||||
return -1;
|
||||
+#endif
|
||||
}
|
||||
|
||||
int XMLCALL
|
||||
@@ -1,25 +0,0 @@
|
||||
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -3125,12 +3125,20 @@
|
||||
}
|
||||
#endif /* XML_GE == 1 */
|
||||
|
||||
-#ifdef MOZILLA_CLIENT /* Report opening tag of mismatched closing tag */
|
||||
+#ifdef MOZILLA_CLIENT
|
||||
+/* Report opening tag of mismatched closing tag */
|
||||
const XML_Char * XMLCALL
|
||||
MOZ_XML_GetMismatchedTag(XML_Parser parser)
|
||||
{
|
||||
return parser->m_mismatch;
|
||||
}
|
||||
+
|
||||
+/* Report whether the parser is currently expanding an entity */
|
||||
+XML_Bool XMLCALL
|
||||
+MOZ_XML_ProcessingEntityValue(XML_Parser parser)
|
||||
+{
|
||||
+ return parser->m_openInternalEntities != NULL;
|
||||
+}
|
||||
#endif
|
||||
|
||||
XML_Bool XMLCALL
|
||||
@@ -1,73 +0,0 @@
|
||||
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -508,6 +508,14 @@
|
||||
enum XML_Account account);
|
||||
static enum XML_Error processEntity(XML_Parser parser, ENTITY *entity,
|
||||
XML_Bool betweenDecl, enum EntityType type);
|
||||
+#ifdef MOZILLA_CLIENT
|
||||
+/* Bug 1746996 - Ensure that storeRawNames is always called */
|
||||
+static enum XML_Error doContentInternal(XML_Parser parser, int startTagLevel,
|
||||
+ const ENCODING *enc, const char *start,
|
||||
+ const char *end, const char **endPtr,
|
||||
+ XML_Bool haveMore,
|
||||
+ enum XML_Account account);
|
||||
+#endif
|
||||
static enum XML_Error doContent(XML_Parser parser, int startTagLevel,
|
||||
const ENCODING *enc, const char *start,
|
||||
const char *end, const char **endPtr,
|
||||
@@ -3211,10 +3219,12 @@
|
||||
parser, parser->m_parentParser ? 1 : 0, parser->m_encoding, start, end,
|
||||
endPtr, (XML_Bool)! parser->m_parsingStatus.finalBuffer,
|
||||
XML_ACCOUNT_DIRECT);
|
||||
+#ifndef MOZILLA_CLIENT /* Bug 1746996 - Ensure that storeRawNames is always called */
|
||||
if (result == XML_ERROR_NONE) {
|
||||
if (! storeRawNames(parser))
|
||||
return XML_ERROR_NO_MEMORY;
|
||||
}
|
||||
+#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -3332,6 +3342,23 @@
|
||||
= doContent(parser, 1, parser->m_encoding, start, end, endPtr,
|
||||
(XML_Bool)! parser->m_parsingStatus.finalBuffer,
|
||||
XML_ACCOUNT_ENTITY_EXPANSION);
|
||||
+#ifndef MOZILLA_CLIENT /* Bug 1746996 - Ensure that storeRawNames is always called */
|
||||
+ if (result == XML_ERROR_NONE) {
|
||||
+ if (! storeRawNames(parser))
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ }
|
||||
+#endif
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
+#ifdef MOZILLA_CLIENT
|
||||
+/* Bug 1746996 - Ensure that storeRawNames is always called */
|
||||
+static enum XML_Error
|
||||
+doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
|
||||
+ const char *s, const char *end, const char **nextPtr,
|
||||
+ XML_Bool haveMore, enum XML_Account account) {
|
||||
+ enum XML_Error result = doContentInternal(parser, startTagLevel, enc, s, end,
|
||||
+ nextPtr, haveMore, account);
|
||||
if (result == XML_ERROR_NONE) {
|
||||
if (! storeRawNames(parser))
|
||||
return XML_ERROR_NO_MEMORY;
|
||||
@@ -3339,10 +3366,17 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
+
|
||||
+static enum XML_Error
|
||||
+doContentInternal(XML_Parser parser, int startTagLevel, const ENCODING *enc,
|
||||
+ const char *s, const char *end, const char **nextPtr,
|
||||
+ XML_Bool haveMore, enum XML_Account account) {
|
||||
+#else
|
||||
static enum XML_Error
|
||||
doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
|
||||
const char *s, const char *end, const char **nextPtr,
|
||||
XML_Bool haveMore, enum XML_Account account) {
|
||||
+#endif /* MOZILLA_CLIENT */
|
||||
/* save one level of indirection */
|
||||
DTD *const dtd = parser->m_dtd;
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -3492,9 +3492,14 @@
|
||||
} else if (! entity) {
|
||||
if (parser->m_skippedEntityHandler)
|
||||
parser->m_skippedEntityHandler(parser->m_handlerArg, name, 0);
|
||||
+#ifdef MOZILLA_CLIENT
|
||||
+/* Bug 35984 - Undeclared entities are ignored when external DTD not found */
|
||||
+ return XML_ERROR_UNDEFINED_ENTITY;
|
||||
+#else
|
||||
else if (parser->m_defaultHandler)
|
||||
reportDefault(parser, enc, s, next);
|
||||
break;
|
||||
+#endif
|
||||
}
|
||||
if (entity->open)
|
||||
return XML_ERROR_RECURSIVE_ENTITY_REF;
|
||||
@@ -6790,7 +6795,12 @@
|
||||
if ((pool == &parser->m_tempPool) && parser->m_defaultHandler)
|
||||
reportDefault(parser, enc, ptr, next);
|
||||
*/
|
||||
+#ifdef MOZILLA_CLIENT
|
||||
+/* Bug 35984 - Undeclared entities are ignored when external DTD not found */
|
||||
+ return XML_ERROR_UNDEFINED_ENTITY;
|
||||
+#else
|
||||
break;
|
||||
+#endif
|
||||
}
|
||||
if (entity->open) {
|
||||
if (enc == parser->m_encoding) {
|
||||
@@ -1,134 +0,0 @@
|
||||
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -3933,6 +3933,9 @@
|
||||
int n;
|
||||
XML_Char *uri;
|
||||
int nPrefixes = 0;
|
||||
+#ifdef MOZILLA_CLIENT /* Include xmlns attributes in attributes array */
|
||||
+ int nXMLNSDeclarations = 0;
|
||||
+#endif
|
||||
BINDING *binding;
|
||||
const XML_Char *localPart;
|
||||
|
||||
@@ -4090,7 +4093,13 @@
|
||||
appAtts[attIndex], bindingsPtr);
|
||||
if (result)
|
||||
return result;
|
||||
+#ifdef MOZILLA_CLIENT /* Include xmlns attributes in attributes array */
|
||||
+ attIndex++;
|
||||
+ nXMLNSDeclarations++;
|
||||
+ (attId->name)[-1] = 3;
|
||||
+#else
|
||||
--attIndex;
|
||||
+#endif
|
||||
} else {
|
||||
/* deal with other prefixed names later */
|
||||
attIndex++;
|
||||
@@ -4122,6 +4131,12 @@
|
||||
da->value, bindingsPtr);
|
||||
if (result)
|
||||
return result;
|
||||
+#ifdef MOZILLA_CLIENT /* Include xmlns attributes in attributes array */
|
||||
+ (da->id->name)[-1] = 3;
|
||||
+ nXMLNSDeclarations++;
|
||||
+ appAtts[attIndex++] = da->id->name;
|
||||
+ appAtts[attIndex++] = da->value;
|
||||
+#endif
|
||||
} else {
|
||||
(da->id->name)[-1] = 2;
|
||||
nPrefixes++;
|
||||
@@ -4140,7 +4155,11 @@
|
||||
/* expand prefixed attribute names, check for duplicates,
|
||||
and clear flags that say whether attributes were specified */
|
||||
i = 0;
|
||||
+#ifdef MOZILLA_CLIENT /* Include xmlns attributes in attributes array */
|
||||
+ if (nPrefixes || nXMLNSDeclarations) {
|
||||
+#else
|
||||
if (nPrefixes) {
|
||||
+#endif
|
||||
unsigned int j; /* hash table index */
|
||||
unsigned long version = parser->m_nsAttsVersion;
|
||||
|
||||
@@ -4150,6 +4169,9 @@
|
||||
}
|
||||
|
||||
unsigned int nsAttsSize = 1u << parser->m_nsAttsPower;
|
||||
+#ifdef MOZILLA_CLIENT /* Include xmlns attributes in attributes array */
|
||||
+ if (nPrefixes) {
|
||||
+#endif
|
||||
unsigned char oldNsAttsPower = parser->m_nsAttsPower;
|
||||
/* size of hash table must be at least 2 * (# of prefixed attributes) */
|
||||
if ((nPrefixes << 1)
|
||||
@@ -4198,6 +4220,9 @@
|
||||
parser->m_nsAtts[--j].version = version;
|
||||
}
|
||||
parser->m_nsAttsVersion = --version;
|
||||
+#ifdef MOZILLA_CLIENT /* Include xmlns attributes in attributes array */
|
||||
+ }
|
||||
+#endif
|
||||
|
||||
/* expand prefixed names and check for duplicates */
|
||||
for (; i < attIndex; i += 2) {
|
||||
@@ -4297,10 +4322,61 @@
|
||||
parser->m_nsAtts[j].hash = uriHash;
|
||||
parser->m_nsAtts[j].uriName = s;
|
||||
|
||||
+#ifdef MOZILLA_CLIENT /* Include xmlns attributes in attributes array) */
|
||||
+ if (! --nPrefixes && ! nXMLNSDeclarations) {
|
||||
+#else
|
||||
if (! --nPrefixes) {
|
||||
+#endif
|
||||
i += 2;
|
||||
break;
|
||||
}
|
||||
+#ifdef MOZILLA_CLIENT /* Include xmlns attributes in attributes array */
|
||||
+ } else if (s[-1] == 3) { /* xmlns attribute */
|
||||
+ static const XML_Char xmlnsNamespace[] = {
|
||||
+ ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH,
|
||||
+ ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD,
|
||||
+ ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_2, ASCII_0, ASCII_0, ASCII_0,
|
||||
+ ASCII_SLASH, ASCII_x, ASCII_m, ASCII_l, ASCII_n, ASCII_s, ASCII_SLASH, '\0'
|
||||
+ };
|
||||
+ static const XML_Char xmlnsPrefix[] = {
|
||||
+ ASCII_x, ASCII_m, ASCII_l, ASCII_n, ASCII_s, '\0'
|
||||
+ };
|
||||
+
|
||||
+ ((XML_Char *)s)[-1] = 0; /* clear flag */
|
||||
+ if (! poolAppendString(&parser->m_tempPool, xmlnsNamespace)
|
||||
+ || ! poolAppendChar(&parser->m_tempPool, parser->m_namespaceSeparator))
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ s += sizeof(xmlnsPrefix) / sizeof(xmlnsPrefix[0]) - 1;
|
||||
+ if (*s == XML_T(':')) {
|
||||
+ ++s;
|
||||
+ do { /* copies null terminator */
|
||||
+ if (! poolAppendChar(&parser->m_tempPool, *s))
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ } while (*s++);
|
||||
+ if (parser->m_ns_triplets) { /* append namespace separator and prefix */
|
||||
+ parser->m_tempPool.ptr[-1] = parser->m_namespaceSeparator;
|
||||
+ if (! poolAppendString(&parser->m_tempPool, xmlnsPrefix)
|
||||
+ || ! poolAppendChar(&parser->m_tempPool, '\0'))
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ }
|
||||
+ }
|
||||
+ else {
|
||||
+ /* xlmns attribute without a prefix. */
|
||||
+ if (! poolAppendString(&parser->m_tempPool, xmlnsPrefix)
|
||||
+ || ! poolAppendChar(&parser->m_tempPool, '\0'))
|
||||
+ return XML_ERROR_NO_MEMORY;
|
||||
+ }
|
||||
+
|
||||
+ /* store expanded name in attribute list */
|
||||
+ s = poolStart(&parser->m_tempPool);
|
||||
+ poolFinish(&parser->m_tempPool);
|
||||
+ appAtts[i] = s;
|
||||
+
|
||||
+ if (! --nXMLNSDeclarations && ! nPrefixes) {
|
||||
+ i += 2;
|
||||
+ break;
|
||||
+ }
|
||||
+#endif
|
||||
} else /* not prefixed */
|
||||
((XML_Char *)s)[-1] = 0; /* clear flag */
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -6225,7 +6225,11 @@
|
||||
entity->open = XML_TRUE;
|
||||
entityTrackingOnOpen(parser, entity, __LINE__);
|
||||
if (! parser->m_externalEntityRefHandler(
|
||||
+#ifdef MOZILLA_CLIENT /* Bug 191482 - Add external entity inclusions to internalSubset */
|
||||
+ parser->m_externalEntityRefHandlerArg, entity->name, entity->base,
|
||||
+#else
|
||||
parser->m_externalEntityRefHandlerArg, 0, entity->base,
|
||||
+#endif
|
||||
entity->systemId, entity->publicId)) {
|
||||
entityTrackingOnClose(parser, entity, __LINE__);
|
||||
entity->open = XML_FALSE;
|
||||
@@ -1,33 +0,0 @@
|
||||
diff --git a/lib/xmltok.c b/lib/xmltok.c
|
||||
--- a/lib/xmltok.c
|
||||
+++ b/lib/xmltok.c
|
||||
@@ -1148,6 +1148,12 @@
|
||||
|
||||
static const char KW_no[] = {ASCII_n, ASCII_o, '\0'};
|
||||
|
||||
+#ifdef MOZILLA_CLIENT
|
||||
+/* Bug 62157 - Document content is rendered even though version value is
|
||||
+ not "1.0" */
|
||||
+static const char KW_XML_1_0[] = {ASCII_1, ASCII_PERIOD, ASCII_0, '\0'};
|
||||
+#endif
|
||||
+
|
||||
static int
|
||||
doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *, const char *,
|
||||
const char *),
|
||||
@@ -1175,6 +1181,16 @@
|
||||
*versionPtr = val;
|
||||
if (versionEndPtr)
|
||||
*versionEndPtr = ptr;
|
||||
+#ifdef MOZILLA_CLIENT
|
||||
+/* Bug 62157 - Document content is rendered even though version value is
|
||||
+ not "1.0") */
|
||||
+ /* Anything else but a version="1.0" is invalid for us, until we support
|
||||
+ later versions. */
|
||||
+ if (!XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_XML_1_0)) {
|
||||
+ *badPtr = val;
|
||||
+ return 0;
|
||||
+ }
|
||||
+#endif
|
||||
if (! parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) {
|
||||
*badPtr = ptr;
|
||||
return 0;
|
||||
@@ -1,218 +0,0 @@
|
||||
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -453,7 +453,9 @@
|
||||
typedef struct accounting {
|
||||
XmlBigCount countBytesDirect;
|
||||
XmlBigCount countBytesIndirect;
|
||||
+#ifndef MOZILLA_CLIENT /* don't report debug information */
|
||||
unsigned long debugLevel;
|
||||
+#endif
|
||||
float maximumAmplificationFactor; // >=1.0
|
||||
unsigned long long activationThresholdBytes;
|
||||
} ACCOUNTING;
|
||||
@@ -466,12 +468,14 @@
|
||||
XmlBigCount activationThresholdBytes;
|
||||
} MALLOC_TRACKER;
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* don't report debug information */
|
||||
typedef struct entity_stats {
|
||||
unsigned int countEverOpened;
|
||||
unsigned int currentDepth;
|
||||
unsigned int maximumDepthSeen;
|
||||
unsigned long debugLevel;
|
||||
} ENTITY_STATS;
|
||||
+#endif /* MOZILLA_CLIENT */
|
||||
#endif /* XML_GE == 1 */
|
||||
|
||||
typedef enum XML_Error PTRCALL Processor(XML_Parser parser, const char *start,
|
||||
@@ -630,18 +634,22 @@
|
||||
static float accountingGetCurrentAmplification(XML_Parser rootParser);
|
||||
static void accountingReportStats(XML_Parser originParser, const char *epilog);
|
||||
static void accountingOnAbort(XML_Parser originParser);
|
||||
+#ifndef MOZILLA_CLIENT /* don't report debug information */
|
||||
static void accountingReportDiff(XML_Parser rootParser,
|
||||
unsigned int levelsAwayFromRootParser,
|
||||
const char *before, const char *after,
|
||||
ptrdiff_t bytesMore, int source_line,
|
||||
enum XML_Account account);
|
||||
+#endif
|
||||
static XML_Bool accountingDiffTolerated(XML_Parser originParser, int tok,
|
||||
const char *before, const char *after,
|
||||
int source_line,
|
||||
enum XML_Account account);
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* don't report debug information */
|
||||
static void entityTrackingReportStats(XML_Parser parser, ENTITY *entity,
|
||||
const char *action, int sourceLine);
|
||||
+#endif
|
||||
static void entityTrackingOnOpen(XML_Parser parser, ENTITY *entity,
|
||||
int sourceLine);
|
||||
static void entityTrackingOnClose(XML_Parser parser, ENTITY *entity,
|
||||
@@ -651,8 +659,10 @@
|
||||
static XML_Parser getRootParserOf(XML_Parser parser,
|
||||
unsigned int *outLevelDiff);
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* don't report debug information */
|
||||
static unsigned long getDebugLevel(const char *variableName,
|
||||
unsigned long defaultDebugLevel);
|
||||
+#endif
|
||||
|
||||
#define poolStart(pool) ((pool)->start)
|
||||
#define poolLength(pool) ((pool)->ptr - (pool)->start)
|
||||
@@ -793,8 +803,10 @@
|
||||
#if XML_GE == 1
|
||||
ACCOUNTING m_accounting;
|
||||
MALLOC_TRACKER m_alloc_tracker;
|
||||
+#ifndef MOZILLA_CLIENT /* don't report debug information */
|
||||
ENTITY_STATS m_entity_stats;
|
||||
-#endif
|
||||
+#endif /* MOZILLA_CLIENT */
|
||||
+#endif /* XML_GE == 1 */
|
||||
#ifdef MOZILLA_CLIENT /* Report opening tag of mismatched closing tag */
|
||||
const XML_Char* m_mismatch;
|
||||
#endif
|
||||
@@ -1209,10 +1221,12 @@
|
||||
|
||||
static unsigned long
|
||||
ENTROPY_DEBUG(const char *label, unsigned long entropy) {
|
||||
+#ifndef MOZILLA_CLIENT /* don't report debug information */
|
||||
if (getDebugLevel("EXPAT_ENTROPY_DEBUG", 0) >= 1u) {
|
||||
fprintf(stderr, "expat: Entropy: %s --> 0x%0*lx (%lu bytes)\n", label,
|
||||
(int)sizeof(entropy) * 2, entropy, (unsigned long)sizeof(entropy));
|
||||
}
|
||||
+#endif
|
||||
return entropy;
|
||||
}
|
||||
|
||||
@@ -1632,15 +1646,19 @@
|
||||
|
||||
#if XML_GE == 1
|
||||
memset(&parser->m_accounting, 0, sizeof(ACCOUNTING));
|
||||
+#ifndef MOZILLA_CLIENT /* don't report debug information */
|
||||
parser->m_accounting.debugLevel = getDebugLevel("EXPAT_ACCOUNTING_DEBUG", 0u);
|
||||
+#endif
|
||||
parser->m_accounting.maximumAmplificationFactor
|
||||
= EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT;
|
||||
parser->m_accounting.activationThresholdBytes
|
||||
= EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT;
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* don't report debug information */
|
||||
memset(&parser->m_entity_stats, 0, sizeof(ENTITY_STATS));
|
||||
parser->m_entity_stats.debugLevel = getDebugLevel("EXPAT_ENTITY_DEBUG", 0u);
|
||||
-#endif
|
||||
+#endif /* MOZILLA_CLIENT */
|
||||
+#endif /* XML_GE == 1 */
|
||||
}
|
||||
|
||||
/* moves list of bindings to m_freeBindingList */
|
||||
@@ -8662,6 +8680,7 @@
|
||||
|
||||
static void
|
||||
accountingReportStats(XML_Parser originParser, const char *epilog) {
|
||||
+#ifndef MOZILLA_CLIENT /* don't report debug information */
|
||||
const XML_Parser rootParser = getRootParserOf(originParser, NULL);
|
||||
assert(! rootParser->m_parentParser);
|
||||
|
||||
@@ -8677,6 +8696,7 @@
|
||||
(void *)rootParser, rootParser->m_accounting.countBytesDirect,
|
||||
rootParser->m_accounting.countBytesIndirect,
|
||||
(double)amplificationFactor, epilog);
|
||||
+#endif
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -8684,6 +8704,7 @@
|
||||
accountingReportStats(originParser, " ABORTING\n");
|
||||
}
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* don't report debug information */
|
||||
static void
|
||||
accountingReportDiff(XML_Parser rootParser,
|
||||
unsigned int levelsAwayFromRootParser, const char *before,
|
||||
@@ -8720,6 +8741,7 @@
|
||||
}
|
||||
fprintf(stderr, "\"\n");
|
||||
}
|
||||
+#endif /* MOZILLA_CLIENT */
|
||||
|
||||
static XML_Bool
|
||||
accountingDiffTolerated(XML_Parser originParser, int tok, const char *before,
|
||||
@@ -8767,11 +8789,13 @@
|
||||
|| (amplificationFactor
|
||||
<= rootParser->m_accounting.maximumAmplificationFactor);
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* don't report debug information */
|
||||
if (rootParser->m_accounting.debugLevel >= 2u) {
|
||||
accountingReportStats(rootParser, "");
|
||||
accountingReportDiff(rootParser, levelsAwayFromRootParser, before, after,
|
||||
bytesMore, source_line, account);
|
||||
}
|
||||
+#endif
|
||||
|
||||
return tolerated;
|
||||
}
|
||||
@@ -8790,6 +8814,7 @@
|
||||
return parser->m_accounting.countBytesIndirect;
|
||||
}
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* don't report debug information */
|
||||
static void
|
||||
entityTrackingReportStats(XML_Parser rootParser, ENTITY *entity,
|
||||
const char *action, int sourceLine) {
|
||||
@@ -8813,9 +8838,11 @@
|
||||
entity->is_param ? "%" : "&", entityName, action, entity->textLen,
|
||||
sourceLine);
|
||||
}
|
||||
+#endif /* MOZILLA_CLIENT */
|
||||
|
||||
static void
|
||||
entityTrackingOnOpen(XML_Parser originParser, ENTITY *entity, int sourceLine) {
|
||||
+#ifndef MOZILLA_CLIENT /* don't report debug information */
|
||||
const XML_Parser rootParser = getRootParserOf(originParser, NULL);
|
||||
assert(! rootParser->m_parentParser);
|
||||
|
||||
@@ -8827,15 +8854,18 @@
|
||||
}
|
||||
|
||||
entityTrackingReportStats(rootParser, entity, "OPEN ", sourceLine);
|
||||
+#endif
|
||||
}
|
||||
|
||||
static void
|
||||
entityTrackingOnClose(XML_Parser originParser, ENTITY *entity, int sourceLine) {
|
||||
+#ifndef MOZILLA_CLIENT /* don't report debug information */
|
||||
const XML_Parser rootParser = getRootParserOf(originParser, NULL);
|
||||
assert(! rootParser->m_parentParser);
|
||||
|
||||
entityTrackingReportStats(rootParser, entity, "CLOSE", sourceLine);
|
||||
rootParser->m_entity_stats.currentDepth--;
|
||||
+#endif
|
||||
}
|
||||
|
||||
#endif /* XML_GE == 1 */
|
||||
@@ -8857,6 +8887,7 @@
|
||||
|
||||
#if XML_GE == 1
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* don't report debug information */
|
||||
const char *
|
||||
unsignedCharToPrintable(unsigned char c) {
|
||||
switch (c) {
|
||||
@@ -9380,9 +9411,11 @@
|
||||
assert(0); /* never gets here */
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
+#endif /* MOZILLA_CLIENT */
|
||||
|
||||
#endif /* XML_GE == 1 */
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* don't report debug information */
|
||||
static unsigned long
|
||||
getDebugLevel(const char *variableName, unsigned long defaultDebugLevel) {
|
||||
const char *const valueOrNull = getenv(variableName);
|
||||
@@ -9401,3 +9434,4 @@
|
||||
|
||||
return debugLevel;
|
||||
}
|
||||
+#endif /* MOZILLA_CLIENT */
|
||||
@@ -1,241 +0,0 @@
|
||||
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -582,8 +582,10 @@
|
||||
static void FASTCALL normalizePublicId(XML_Char *s);
|
||||
|
||||
static DTD *dtdCreate(XML_Parser parser);
|
||||
+#ifndef MOZILLA_CLIENT /* unused API */
|
||||
/* do not call if m_parentParser != NULL */
|
||||
static void dtdReset(DTD *p, XML_Parser parser);
|
||||
+#endif
|
||||
static void dtdDestroy(DTD *p, XML_Bool isDocEntity, XML_Parser parser);
|
||||
static int dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd,
|
||||
XML_Parser parser);
|
||||
@@ -592,7 +594,9 @@
|
||||
static NAMED *lookup(XML_Parser parser, HASH_TABLE *table, KEY name,
|
||||
size_t createSize);
|
||||
static void FASTCALL hashTableInit(HASH_TABLE *table, XML_Parser parser);
|
||||
+#ifndef MOZILLA_CLIENT /* unused API */
|
||||
static void FASTCALL hashTableClear(HASH_TABLE *table);
|
||||
+#endif
|
||||
static void FASTCALL hashTableDestroy(HASH_TABLE *table);
|
||||
static void FASTCALL hashTableIterInit(HASH_TABLE_ITER *iter,
|
||||
const HASH_TABLE *table);
|
||||
@@ -1040,6 +1044,7 @@
|
||||
}
|
||||
#endif // XML_GE == 1
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* unused API */
|
||||
XML_Parser XMLCALL
|
||||
XML_ParserCreate(const XML_Char *encodingName) {
|
||||
return XML_ParserCreate_MM(encodingName, NULL, NULL);
|
||||
@@ -1050,6 +1055,7 @@
|
||||
XML_Char tmp[2] = {nsSep, 0};
|
||||
return XML_ParserCreate_MM(encodingName, NULL, tmp);
|
||||
}
|
||||
+#endif
|
||||
|
||||
// "xml=http://www.w3.org/XML/1998/namespace"
|
||||
static const XML_Char implicitContext[]
|
||||
@@ -1661,6 +1667,7 @@
|
||||
#endif /* XML_GE == 1 */
|
||||
}
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* unused API */
|
||||
/* moves list of bindings to m_freeBindingList */
|
||||
static void FASTCALL
|
||||
moveToFreeBindingList(XML_Parser parser, BINDING *bindings) {
|
||||
@@ -1769,6 +1776,7 @@
|
||||
}
|
||||
return XML_STATUS_OK;
|
||||
}
|
||||
+#endif /* MOZILLA_CLIENT */
|
||||
|
||||
XML_Parser XMLCALL
|
||||
XML_ExternalEntityParserCreate(XML_Parser oldParser, const XML_Char *context,
|
||||
@@ -2055,6 +2063,7 @@
|
||||
parser->m_handlerArg = parser;
|
||||
}
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* unused API */
|
||||
enum XML_Error XMLCALL
|
||||
XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD) {
|
||||
if (parser == NULL)
|
||||
@@ -2068,8 +2077,9 @@
|
||||
#else
|
||||
UNUSED_P(useDTD);
|
||||
return XML_ERROR_FEATURE_REQUIRES_XML_DTD;
|
||||
-#endif
|
||||
+#endif /* XML_DTD */
|
||||
}
|
||||
+#endif /* MOZILLA_CLIENT */
|
||||
|
||||
void XMLCALL
|
||||
XML_SetReturnNSTriplet(XML_Parser parser, int do_nst) {
|
||||
@@ -2144,6 +2154,7 @@
|
||||
parser->m_endElementHandler = end;
|
||||
}
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* unused API */
|
||||
void XMLCALL
|
||||
XML_SetStartElementHandler(XML_Parser parser, XML_StartElementHandler start) {
|
||||
if (parser != NULL)
|
||||
@@ -2155,6 +2166,7 @@
|
||||
if (parser != NULL)
|
||||
parser->m_endElementHandler = end;
|
||||
}
|
||||
+#endif
|
||||
|
||||
void XMLCALL
|
||||
XML_SetCharacterDataHandler(XML_Parser parser,
|
||||
@@ -2186,6 +2198,7 @@
|
||||
parser->m_endCdataSectionHandler = end;
|
||||
}
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* unused API */
|
||||
void XMLCALL
|
||||
XML_SetStartCdataSectionHandler(XML_Parser parser,
|
||||
XML_StartCdataSectionHandler start) {
|
||||
@@ -2207,6 +2220,7 @@
|
||||
parser->m_defaultHandler = handler;
|
||||
parser->m_defaultExpandInternalEntities = XML_FALSE;
|
||||
}
|
||||
+#endif /* MOZILLA_CLIENT */
|
||||
|
||||
void XMLCALL
|
||||
XML_SetDefaultHandlerExpand(XML_Parser parser, XML_DefaultHandler handler) {
|
||||
@@ -2225,6 +2239,7 @@
|
||||
parser->m_endDoctypeDeclHandler = end;
|
||||
}
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* unused API */
|
||||
void XMLCALL
|
||||
XML_SetStartDoctypeDeclHandler(XML_Parser parser,
|
||||
XML_StartDoctypeDeclHandler start) {
|
||||
@@ -2237,6 +2252,7 @@
|
||||
if (parser != NULL)
|
||||
parser->m_endDoctypeDeclHandler = end;
|
||||
}
|
||||
+#endif
|
||||
|
||||
void XMLCALL
|
||||
XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
|
||||
@@ -2261,6 +2277,7 @@
|
||||
parser->m_endNamespaceDeclHandler = end;
|
||||
}
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* unused API */
|
||||
void XMLCALL
|
||||
XML_SetStartNamespaceDeclHandler(XML_Parser parser,
|
||||
XML_StartNamespaceDeclHandler start) {
|
||||
@@ -2281,6 +2298,7 @@
|
||||
if (parser != NULL)
|
||||
parser->m_notStandaloneHandler = handler;
|
||||
}
|
||||
+#endif /* MOZILLA_CLIENT */
|
||||
|
||||
void XMLCALL
|
||||
XML_SetExternalEntityRefHandler(XML_Parser parser,
|
||||
@@ -2299,6 +2317,7 @@
|
||||
parser->m_externalEntityRefHandlerArg = parser;
|
||||
}
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* unused API */
|
||||
void XMLCALL
|
||||
XML_SetSkippedEntityHandler(XML_Parser parser,
|
||||
XML_SkippedEntityHandler handler) {
|
||||
@@ -2332,6 +2351,7 @@
|
||||
if (parser != NULL)
|
||||
parser->m_entityDeclHandler = handler;
|
||||
}
|
||||
+#endif /* MOZILLA_CLIENT */
|
||||
|
||||
void XMLCALL
|
||||
XML_SetXmlDeclHandler(XML_Parser parser, XML_XmlDeclHandler handler) {
|
||||
@@ -2800,6 +2820,7 @@
|
||||
#endif
|
||||
}
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* unused API */
|
||||
int XMLCALL
|
||||
XML_GetCurrentByteCount(XML_Parser parser) {
|
||||
if (parser == NULL)
|
||||
@@ -2828,6 +2849,7 @@
|
||||
#endif /* XML_CONTEXT_BYTES > 0 */
|
||||
return (const char *)0;
|
||||
}
|
||||
+#endif /* MOZILLA_CLIENT */
|
||||
|
||||
XML_Size XMLCALL
|
||||
XML_GetCurrentLineNumber(XML_Parser parser) {
|
||||
@@ -2853,6 +2875,7 @@
|
||||
return parser->m_position.columnNumber;
|
||||
}
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* unused API */
|
||||
void XMLCALL
|
||||
XML_FreeContentModel(XML_Parser parser, XML_Content *model) {
|
||||
if (parser == NULL)
|
||||
@@ -3098,11 +3121,12 @@
|
||||
{XML_FEATURE_ALLOC_TRACKER_ACTIVATION_THRESHOLD_DEFAULT,
|
||||
XML_L("XML_AT_ACT_THRES"),
|
||||
(long int)EXPAT_ALLOC_TRACKER_ACTIVATION_THRESHOLD_DEFAULT},
|
||||
-#endif
|
||||
+#endif /* XML_GE == 1 */
|
||||
{XML_FEATURE_END, NULL, 0}};
|
||||
|
||||
return features;
|
||||
}
|
||||
+#endif /* MOZILLA_CLIENT */
|
||||
|
||||
#if XML_GE == 1
|
||||
XML_Bool XMLCALL
|
||||
@@ -7723,6 +7747,7 @@
|
||||
return p;
|
||||
}
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* unused API */
|
||||
static void
|
||||
dtdReset(DTD *p, XML_Parser parser) {
|
||||
HASH_TABLE_ITER iter;
|
||||
@@ -7763,6 +7788,7 @@
|
||||
p->hasParamEntityRefs = XML_FALSE;
|
||||
p->standalone = XML_FALSE;
|
||||
}
|
||||
+#endif /* MOZILLA_CLIENT */
|
||||
|
||||
static void
|
||||
dtdDestroy(DTD *p, XML_Bool isDocEntity, XML_Parser parser) {
|
||||
@@ -8117,6 +8143,7 @@
|
||||
return table->v[i];
|
||||
}
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* unused API */
|
||||
static void FASTCALL
|
||||
hashTableClear(HASH_TABLE *table) {
|
||||
size_t i;
|
||||
@@ -8126,6 +8153,7 @@
|
||||
}
|
||||
table->used = 0;
|
||||
}
|
||||
+#endif
|
||||
|
||||
static void FASTCALL
|
||||
hashTableDestroy(HASH_TABLE *table) {
|
||||
@@ -8800,6 +8828,7 @@
|
||||
return tolerated;
|
||||
}
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* unused API */
|
||||
unsigned long long
|
||||
testingAccountingGetCountBytesDirect(XML_Parser parser) {
|
||||
if (! parser)
|
||||
@@ -8813,6 +8842,7 @@
|
||||
return 0;
|
||||
return parser->m_accounting.countBytesIndirect;
|
||||
}
|
||||
+#endif
|
||||
|
||||
#ifndef MOZILLA_CLIENT /* don't report debug information */
|
||||
static void
|
||||
@@ -1,30 +0,0 @@
|
||||
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
|
||||
--- a/lib/xmlparse.c
|
||||
+++ b/lib/xmlparse.c
|
||||
@@ -1439,8 +1439,10 @@
|
||||
// Initialize .m_alloc_tracker
|
||||
memset(&parser->m_alloc_tracker, 0, sizeof(MALLOC_TRACKER));
|
||||
if (parentParser == NULL) {
|
||||
+#ifndef MOZILLA_CLIENT /* don't report debug information */
|
||||
parser->m_alloc_tracker.debugLevel
|
||||
= getDebugLevel("EXPAT_MALLOC_DEBUG", 0u);
|
||||
+#endif
|
||||
parser->m_alloc_tracker.maximumAmplificationFactor
|
||||
= EXPAT_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION_DEFAULT;
|
||||
parser->m_alloc_tracker.activationThresholdBytes
|
||||
@@ -1737,6 +1739,7 @@
|
||||
dtdReset(parser->m_dtd, parser);
|
||||
return XML_TRUE;
|
||||
}
|
||||
+#endif /* MOZILLA_CLIENT */
|
||||
|
||||
static XML_Bool
|
||||
parserBusy(XML_Parser parser) {
|
||||
@@ -1751,6 +1754,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
+#ifndef MOZILLA_CLIENT /* unused API */
|
||||
enum XML_Status XMLCALL
|
||||
XML_SetEncoding(XML_Parser parser, const XML_Char *encodingName) {
|
||||
if (parser == NULL)
|
||||
@@ -1,5 +1,6 @@
|
||||
Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper
|
||||
Copyright (c) 2001-2022 Expat maintainers
|
||||
Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
|
||||
and Clark Cooper
|
||||
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
This directory contains build files for the Expat XML parser
|
||||
library.
|
||||
|
||||
Any patches or additional configuration to be applied to the
|
||||
upstream source should be kept here in the parser/expat
|
||||
directory.
|
||||
|
||||
The upstream expat git repository is:
|
||||
|
||||
https://github.com/libexpat/libexpat
|
||||
|
||||
The version used was tagged release version 2.7.3.
|
||||
+109
-9
@@ -22,15 +22,9 @@
|
||||
/* Other Mozilla code relies on memmove already, so we assume it's available */
|
||||
#define HAVE_MEMMOVE 1
|
||||
|
||||
/* This doesn't mean we have poor entropy, just that we don't use Expat's. */
|
||||
#define XML_POOR_ENTROPY 1
|
||||
|
||||
#define XMLCALL
|
||||
#define XML_STATIC
|
||||
#ifdef HAVE_VISIBILITY_HIDDEN_ATTRIBUTE
|
||||
# undef XMLIMPORT
|
||||
# define XMLIMPORT __attribute__((visibility("hidden")))
|
||||
#endif
|
||||
#define XMLIMPORT
|
||||
|
||||
#define XML_UNICODE
|
||||
typedef char XML_LChar;
|
||||
@@ -48,8 +42,114 @@ typedef uint16_t XML_Char;
|
||||
#endif
|
||||
|
||||
#define XML_DTD
|
||||
#define XML_GE 1
|
||||
#define XML_NS
|
||||
#define XML_CONTEXT_BYTES 0
|
||||
|
||||
/* avoid conflicts with system version of libexpat */
|
||||
|
||||
/* expat.h */
|
||||
#define XML_SetElementDeclHandler MOZ_XML_SetElementDeclHandler
|
||||
#define XML_SetAttlistDeclHandler MOZ_XML_SetAttlistDeclHandler
|
||||
#define XML_SetXmlDeclHandler MOZ_XML_SetXmlDeclHandler
|
||||
#define XML_ParserCreate MOZ_XML_ParserCreate
|
||||
#define XML_ParserCreateNS MOZ_XML_ParserCreateNS
|
||||
#define XML_ParserCreate_MM MOZ_XML_ParserCreate_MM
|
||||
#define XML_ParserReset MOZ_XML_ParserReset
|
||||
#define XML_SetEntityDeclHandler MOZ_XML_SetEntityDeclHandler
|
||||
#define XML_SetElementHandler MOZ_XML_SetElementHandler
|
||||
#define XML_SetStartElementHandler MOZ_XML_SetStartElementHandler
|
||||
#define XML_SetEndElementHandler MOZ_XML_SetEndElementHandler
|
||||
#define XML_SetCharacterDataHandler MOZ_XML_SetCharacterDataHandler
|
||||
#ifndef __VMS
|
||||
#define XML_SetProcessingInstructionHandler MOZ_XML_SetProcessingInstructionHandler
|
||||
#else
|
||||
#define XML_SetProcessingInstrHandler MOZ_XML_SetProcessingInstrHandler
|
||||
#endif
|
||||
#define XML_SetCommentHandler MOZ_XML_SetCommentHandler
|
||||
#define XML_SetCdataSectionHandler MOZ_XML_SetCdataSectionHandler
|
||||
#define XML_SetStartCdataSectionHandler MOZ_XML_SetStartCdataSectionHandler
|
||||
#define XML_SetEndCdataSectionHandler MOZ_XML_SetEndCdataSectionHandler
|
||||
#define XML_SetDefaultHandler MOZ_XML_SetDefaultHandler
|
||||
#define XML_SetDefaultHandlerExpand MOZ_XML_SetDefaultHandlerExpand
|
||||
#define XML_SetDoctypeDeclHandler MOZ_XML_SetDoctypeDeclHandler
|
||||
#define XML_SetStartDoctypeDeclHandler MOZ_XML_SetStartDoctypeDeclHandler
|
||||
#define XML_SetEndDoctypeDeclHandler MOZ_XML_SetEndDoctypeDeclHandler
|
||||
#ifndef __VMS
|
||||
#define XML_SetUnparsedEntityDeclHandler MOZ_XML_SetUnparsedEntityDeclHandler
|
||||
#else
|
||||
#define XML_SetUnparsedEntDeclHandler MOZ_XML_SetUnparsedEntDeclHandler
|
||||
#endif
|
||||
#define XML_SetNotationDeclHandler MOZ_XML_SetNotationDeclHandler
|
||||
#define XML_SetNamespaceDeclHandler MOZ_XML_SetNamespaceDeclHandler
|
||||
#ifndef __VMS
|
||||
#define XML_SetStartNamespaceDeclHandler MOZ_XML_SetStartNamespaceDeclHandler
|
||||
#else
|
||||
#define XML_SetStartNamespcDeclHandler MOZ_XML_SetStartNamespcDeclHandler
|
||||
#endif
|
||||
#define XML_SetEndNamespaceDeclHandler MOZ_XML_SetEndNamespaceDeclHandler
|
||||
#define XML_SetNotStandaloneHandler MOZ_XML_SetNotStandaloneHandler
|
||||
#define XML_SetExternalEntityRefHandler MOZ_XML_SetExternalEntityRefHandler
|
||||
#ifndef __VMS
|
||||
#define XML_SetExternalEntityRefHandlerArg MOZ_XML_SetExternalEntityRefHandlerArg
|
||||
#else
|
||||
#define XML_SetExternalEntRefHandlerArg MOZ_XML_SetExternalEntRefHandlerArg
|
||||
#endif
|
||||
#define XML_SetSkippedEntityHandler MOZ_XML_SetSkippedEntityHandler
|
||||
#define XML_SetUnknownEncodingHandler MOZ_XML_SetUnknownEncodingHandler
|
||||
#define XML_DefaultCurrent MOZ_XML_DefaultCurrent
|
||||
#define XML_SetReturnNSTriplet MOZ_XML_SetReturnNSTriplet
|
||||
#define XML_SetUserData MOZ_XML_SetUserData
|
||||
#define XML_SetEncoding MOZ_XML_SetEncoding
|
||||
#define XML_UseParserAsHandlerArg MOZ_XML_UseParserAsHandlerArg
|
||||
#define XML_UseForeignDTD MOZ_XML_UseForeignDTD
|
||||
#define XML_SetBase MOZ_XML_SetBase
|
||||
#define XML_GetBase MOZ_XML_GetBase
|
||||
#define XML_GetSpecifiedAttributeCount MOZ_XML_GetSpecifiedAttributeCount
|
||||
#define XML_GetIdAttributeIndex MOZ_XML_GetIdAttributeIndex
|
||||
#define XML_Parse MOZ_XML_Parse
|
||||
#define XML_GetBuffer MOZ_XML_GetBuffer
|
||||
#define XML_ParseBuffer MOZ_XML_ParseBuffer
|
||||
#define XML_StopParser MOZ_XML_StopParser
|
||||
#define XML_ResumeParser MOZ_XML_ResumeParser
|
||||
#define XML_GetParsingStatus MOZ_XML_GetParsingStatus
|
||||
#define XML_ExternalEntityParserCreate MOZ_XML_ExternalEntityParserCreate
|
||||
#define XML_SetParamEntityParsing MOZ_XML_SetParamEntityParsing
|
||||
#define XML_GetErrorCode MOZ_XML_GetErrorCode
|
||||
#define XML_GetCurrentLineNumber MOZ_XML_GetCurrentLineNumber
|
||||
#define XML_GetCurrentColumnNumber MOZ_XML_GetCurrentColumnNumber
|
||||
#define XML_GetCurrentByteIndex MOZ_XML_GetCurrentByteIndex
|
||||
#define XML_GetCurrentByteCount MOZ_XML_GetCurrentByteCount
|
||||
#define XML_GetInputContext MOZ_XML_GetInputContext
|
||||
#define XML_FreeContentModel MOZ_XML_FreeContentModel
|
||||
#define XML_MemMalloc MOZ_XML_MemMalloc
|
||||
#define XML_MemRealloc MOZ_XML_MemRealloc
|
||||
#define XML_MemFree MOZ_XML_MemFree
|
||||
#define XML_ParserFree MOZ_XML_ParserFree
|
||||
#define XML_ErrorString MOZ_XML_ErrorString
|
||||
#define XML_ExpatVersion MOZ_XML_ExpatVersion
|
||||
#define XML_ExpatVersionInfo MOZ_XML_ExpatVersionInfo
|
||||
#define XML_GetFeatureList MOZ_XML_GetFeatureList
|
||||
|
||||
/* xmlrole.h */
|
||||
#define XmlPrologStateInit MOZ_XmlPrologStateInit
|
||||
#ifndef __VMS
|
||||
#define XmlPrologStateInitExternalEntity MOZ_XmlPrologStateInitExternalEntity
|
||||
#else
|
||||
#define XmlPrologStateInitExternalEnt MOZ_XmlPrologStateInitExternalEnt
|
||||
#endif
|
||||
|
||||
/* xmltok.h */
|
||||
#define XmlParseXmlDecl MOZ_XmlParseXmlDecl
|
||||
#define XmlParseXmlDeclNS MOZ_XmlParseXmlDeclNS
|
||||
#define XmlInitEncoding MOZ_XmlInitEncoding
|
||||
#define XmlInitEncodingNS MOZ_XmlInitEncodingNS
|
||||
#define XmlGetUtf8InternalEncoding MOZ_XmlGetUtf8InternalEncoding
|
||||
#define XmlGetUtf16InternalEncoding MOZ_XmlGetUtf16InternalEncoding
|
||||
#define XmlGetUtf8InternalEncodingNS MOZ_XmlGetUtf8InternalEncodingNS
|
||||
#define XmlGetUtf16InternalEncodingNS MOZ_XmlGetUtf16InternalEncodingNS
|
||||
#define XmlUtf8Encode MOZ_XmlUtf8Encode
|
||||
#define XmlUtf16Encode MOZ_XmlUtf16Encode
|
||||
#define XmlSizeOfUnknownEncoding MOZ_XmlSizeOfUnknownEncoding
|
||||
#define XmlInitUnknownEncoding MOZ_XmlInitUnknownEncoding
|
||||
#define XmlInitUnknownEncodingNS MOZ_XmlInitUnknownEncodingNS
|
||||
|
||||
#endif /* __expat_config_h__ */
|
||||
@@ -1,17 +0,0 @@
|
||||
Makefile
|
||||
.libs
|
||||
*.lo
|
||||
Debug
|
||||
Debug-w
|
||||
Release
|
||||
Release-w
|
||||
expat.ncb
|
||||
expat.opt
|
||||
expat.plg
|
||||
Debug_static
|
||||
Debug-w_static
|
||||
Release_static
|
||||
Release-w_static
|
||||
expat_static.plg
|
||||
expatw.plg
|
||||
expatw_static.plg
|
||||
+85
-123
@@ -1,123 +1,85 @@
|
||||
/*
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 1999-2000 Thai Open Source Software Center Ltd
|
||||
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
|
||||
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
|
||||
Copyright (c) 2007 Karl Waclawek <karl@waclawek.net>
|
||||
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#define ASCII_A 0x41
|
||||
#define ASCII_B 0x42
|
||||
#define ASCII_C 0x43
|
||||
#define ASCII_D 0x44
|
||||
#define ASCII_E 0x45
|
||||
#define ASCII_F 0x46
|
||||
#define ASCII_G 0x47
|
||||
#define ASCII_H 0x48
|
||||
#define ASCII_I 0x49
|
||||
#define ASCII_J 0x4A
|
||||
#define ASCII_K 0x4B
|
||||
#define ASCII_L 0x4C
|
||||
#define ASCII_M 0x4D
|
||||
#define ASCII_N 0x4E
|
||||
#define ASCII_O 0x4F
|
||||
#define ASCII_P 0x50
|
||||
#define ASCII_Q 0x51
|
||||
#define ASCII_R 0x52
|
||||
#define ASCII_S 0x53
|
||||
#define ASCII_T 0x54
|
||||
#define ASCII_U 0x55
|
||||
#define ASCII_V 0x56
|
||||
#define ASCII_W 0x57
|
||||
#define ASCII_X 0x58
|
||||
#define ASCII_Y 0x59
|
||||
#define ASCII_Z 0x5A
|
||||
|
||||
#define ASCII_a 0x61
|
||||
#define ASCII_b 0x62
|
||||
#define ASCII_c 0x63
|
||||
#define ASCII_d 0x64
|
||||
#define ASCII_e 0x65
|
||||
#define ASCII_f 0x66
|
||||
#define ASCII_g 0x67
|
||||
#define ASCII_h 0x68
|
||||
#define ASCII_i 0x69
|
||||
#define ASCII_j 0x6A
|
||||
#define ASCII_k 0x6B
|
||||
#define ASCII_l 0x6C
|
||||
#define ASCII_m 0x6D
|
||||
#define ASCII_n 0x6E
|
||||
#define ASCII_o 0x6F
|
||||
#define ASCII_p 0x70
|
||||
#define ASCII_q 0x71
|
||||
#define ASCII_r 0x72
|
||||
#define ASCII_s 0x73
|
||||
#define ASCII_t 0x74
|
||||
#define ASCII_u 0x75
|
||||
#define ASCII_v 0x76
|
||||
#define ASCII_w 0x77
|
||||
#define ASCII_x 0x78
|
||||
#define ASCII_y 0x79
|
||||
#define ASCII_z 0x7A
|
||||
|
||||
#define ASCII_0 0x30
|
||||
#define ASCII_1 0x31
|
||||
#define ASCII_2 0x32
|
||||
#define ASCII_3 0x33
|
||||
#define ASCII_4 0x34
|
||||
#define ASCII_5 0x35
|
||||
#define ASCII_6 0x36
|
||||
#define ASCII_7 0x37
|
||||
#define ASCII_8 0x38
|
||||
#define ASCII_9 0x39
|
||||
|
||||
#define ASCII_TAB 0x09
|
||||
#define ASCII_SPACE 0x20
|
||||
#define ASCII_EXCL 0x21
|
||||
#define ASCII_QUOT 0x22
|
||||
#define ASCII_AMP 0x26
|
||||
#define ASCII_APOS 0x27
|
||||
#define ASCII_MINUS 0x2D
|
||||
#define ASCII_PERIOD 0x2E
|
||||
#define ASCII_COLON 0x3A
|
||||
#define ASCII_SEMI 0x3B
|
||||
#define ASCII_LT 0x3C
|
||||
#define ASCII_EQUALS 0x3D
|
||||
#define ASCII_GT 0x3E
|
||||
#define ASCII_LSQB 0x5B
|
||||
#define ASCII_RSQB 0x5D
|
||||
#define ASCII_UNDERSCORE 0x5F
|
||||
#define ASCII_LPAREN 0x28
|
||||
#define ASCII_RPAREN 0x29
|
||||
#define ASCII_FF 0x0C
|
||||
#define ASCII_SLASH 0x2F
|
||||
#define ASCII_HASH 0x23
|
||||
#define ASCII_PIPE 0x7C
|
||||
#define ASCII_COMMA 0x2C
|
||||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
#define ASCII_A 0x41
|
||||
#define ASCII_B 0x42
|
||||
#define ASCII_C 0x43
|
||||
#define ASCII_D 0x44
|
||||
#define ASCII_E 0x45
|
||||
#define ASCII_F 0x46
|
||||
#define ASCII_G 0x47
|
||||
#define ASCII_H 0x48
|
||||
#define ASCII_I 0x49
|
||||
#define ASCII_J 0x4A
|
||||
#define ASCII_K 0x4B
|
||||
#define ASCII_L 0x4C
|
||||
#define ASCII_M 0x4D
|
||||
#define ASCII_N 0x4E
|
||||
#define ASCII_O 0x4F
|
||||
#define ASCII_P 0x50
|
||||
#define ASCII_Q 0x51
|
||||
#define ASCII_R 0x52
|
||||
#define ASCII_S 0x53
|
||||
#define ASCII_T 0x54
|
||||
#define ASCII_U 0x55
|
||||
#define ASCII_V 0x56
|
||||
#define ASCII_W 0x57
|
||||
#define ASCII_X 0x58
|
||||
#define ASCII_Y 0x59
|
||||
#define ASCII_Z 0x5A
|
||||
|
||||
#define ASCII_a 0x61
|
||||
#define ASCII_b 0x62
|
||||
#define ASCII_c 0x63
|
||||
#define ASCII_d 0x64
|
||||
#define ASCII_e 0x65
|
||||
#define ASCII_f 0x66
|
||||
#define ASCII_g 0x67
|
||||
#define ASCII_h 0x68
|
||||
#define ASCII_i 0x69
|
||||
#define ASCII_j 0x6A
|
||||
#define ASCII_k 0x6B
|
||||
#define ASCII_l 0x6C
|
||||
#define ASCII_m 0x6D
|
||||
#define ASCII_n 0x6E
|
||||
#define ASCII_o 0x6F
|
||||
#define ASCII_p 0x70
|
||||
#define ASCII_q 0x71
|
||||
#define ASCII_r 0x72
|
||||
#define ASCII_s 0x73
|
||||
#define ASCII_t 0x74
|
||||
#define ASCII_u 0x75
|
||||
#define ASCII_v 0x76
|
||||
#define ASCII_w 0x77
|
||||
#define ASCII_x 0x78
|
||||
#define ASCII_y 0x79
|
||||
#define ASCII_z 0x7A
|
||||
|
||||
#define ASCII_0 0x30
|
||||
#define ASCII_1 0x31
|
||||
#define ASCII_2 0x32
|
||||
#define ASCII_3 0x33
|
||||
#define ASCII_4 0x34
|
||||
#define ASCII_5 0x35
|
||||
#define ASCII_6 0x36
|
||||
#define ASCII_7 0x37
|
||||
#define ASCII_8 0x38
|
||||
#define ASCII_9 0x39
|
||||
|
||||
#define ASCII_TAB 0x09
|
||||
#define ASCII_SPACE 0x20
|
||||
#define ASCII_EXCL 0x21
|
||||
#define ASCII_QUOT 0x22
|
||||
#define ASCII_AMP 0x26
|
||||
#define ASCII_APOS 0x27
|
||||
#define ASCII_MINUS 0x2D
|
||||
#define ASCII_PERIOD 0x2E
|
||||
#define ASCII_COLON 0x3A
|
||||
#define ASCII_SEMI 0x3B
|
||||
#define ASCII_LT 0x3C
|
||||
#define ASCII_EQUALS 0x3D
|
||||
#define ASCII_GT 0x3E
|
||||
#define ASCII_LSQB 0x5B
|
||||
#define ASCII_RSQB 0x5D
|
||||
#define ASCII_UNDERSCORE 0x5F
|
||||
+36
-66
@@ -1,66 +1,36 @@
|
||||
/*
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
||||
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
|
||||
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
|
||||
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
|
||||
/* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML,
|
||||
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
|
||||
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
|
||||
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
|
||||
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
|
||||
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
|
||||
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
|
||||
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
|
||||
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
|
||||
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
|
||||
/* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML,
|
||||
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
|
||||
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
|
||||
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
|
||||
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
|
||||
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
|
||||
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
|
||||
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
|
||||
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
|
||||
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
+1018
-1091
File diff suppressed because it is too large.
Load diff
@@ -1,47 +1,16 @@
|
||||
/*
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
||||
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
|
||||
Copyright (c) 2000-2004 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
|
||||
Copyright (c) 2001-2002 Greg Stein <gstein@users.sourceforge.net>
|
||||
Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
|
||||
Copyright (c) 2016 Cristian Rodríguez <crrodriguez@opensuse.org>
|
||||
Copyright (c) 2016-2019 Sebastian Pipping <sebastian@pipping.org>
|
||||
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
|
||||
Copyright (c) 2018 Yury Gribov <tetra2005@gmail.com>
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
#ifndef Expat_External_INCLUDED
|
||||
# define Expat_External_INCLUDED 1
|
||||
#define Expat_External_INCLUDED 1
|
||||
|
||||
/* External API definitions */
|
||||
|
||||
#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
|
||||
#define XML_USE_MSC_EXTENSIONS 1
|
||||
#endif
|
||||
|
||||
/* Expat tries very hard to make the API boundary very specifically
|
||||
defined. There are two macros defined to control this boundary;
|
||||
each of these can be defined before including this header to
|
||||
@@ -64,12 +33,12 @@
|
||||
compiled with the cdecl calling convention as the default since
|
||||
system headers may assume the cdecl convention.
|
||||
*/
|
||||
# ifndef XMLCALL
|
||||
# if defined(_MSC_VER)
|
||||
# define XMLCALL __cdecl
|
||||
# elif defined(__GNUC__) && defined(__i386) && ! defined(__INTEL_COMPILER)
|
||||
# define XMLCALL __attribute__((cdecl))
|
||||
# else
|
||||
#ifndef XMLCALL
|
||||
#if defined(XML_USE_MSC_EXTENSIONS)
|
||||
#define XMLCALL __cdecl
|
||||
#elif defined(__GNUC__) && defined(__i386)
|
||||
#define XMLCALL __attribute__((cdecl))
|
||||
#else
|
||||
/* For any platform which uses this definition and supports more than
|
||||
one calling convention, we need to extend this definition to
|
||||
declare the convention used on that platform, if it's possible to
|
||||
@@ -80,89 +49,68 @@
|
||||
pre-processor and how to specify the same calling convention as the
|
||||
platform's malloc() implementation.
|
||||
*/
|
||||
# define XMLCALL
|
||||
# endif
|
||||
# endif /* not defined XMLCALL */
|
||||
#define XMLCALL
|
||||
#endif
|
||||
#endif /* not defined XMLCALL */
|
||||
|
||||
# if ! defined(XML_STATIC) && ! defined(XMLIMPORT)
|
||||
# ifndef XML_BUILDING_EXPAT
|
||||
|
||||
#if !defined(XML_STATIC) && !defined(XMLIMPORT)
|
||||
#ifndef XML_BUILDING_EXPAT
|
||||
/* using Expat from an application */
|
||||
|
||||
# if defined(_MSC_EXTENSIONS) && ! defined(__BEOS__) \
|
||||
&& ! defined(__CYGWIN__)
|
||||
# define XMLIMPORT __declspec(dllimport)
|
||||
# endif
|
||||
#ifdef XML_USE_MSC_EXTENSIONS
|
||||
#define XMLIMPORT __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
# endif
|
||||
# endif /* not defined XML_STATIC */
|
||||
#endif
|
||||
#endif /* not defined XML_STATIC */
|
||||
|
||||
# ifndef XML_ENABLE_VISIBILITY
|
||||
# define XML_ENABLE_VISIBILITY 0
|
||||
# endif
|
||||
|
||||
# if ! defined(XMLIMPORT) && XML_ENABLE_VISIBILITY
|
||||
# define XMLIMPORT __attribute__((visibility("default")))
|
||||
# endif
|
||||
|
||||
/* If we didn't define it above, define it away: */
|
||||
# ifndef XMLIMPORT
|
||||
# define XMLIMPORT
|
||||
# endif
|
||||
#ifndef XMLIMPORT
|
||||
#define XMLIMPORT
|
||||
#endif
|
||||
|
||||
# if defined(__GNUC__) \
|
||||
&& (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
|
||||
# define XML_ATTR_MALLOC __attribute__((__malloc__))
|
||||
# else
|
||||
# define XML_ATTR_MALLOC
|
||||
# endif
|
||||
|
||||
# if defined(__GNUC__) \
|
||||
&& ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
|
||||
# define XML_ATTR_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
|
||||
# else
|
||||
# define XML_ATTR_ALLOC_SIZE(x)
|
||||
# endif
|
||||
#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
|
||||
|
||||
# define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
|
||||
|
||||
# ifdef __cplusplus
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
#endif
|
||||
|
||||
# ifdef XML_UNICODE_WCHAR_T
|
||||
# ifndef XML_UNICODE
|
||||
# define XML_UNICODE
|
||||
# endif
|
||||
# if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2)
|
||||
# error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc"
|
||||
# endif
|
||||
# endif
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
#define XML_UNICODE
|
||||
#endif
|
||||
|
||||
#ifndef MOZILLA_CLIENT /* typedef XML_Char to char16_t */
|
||||
# ifdef XML_UNICODE /* Information is UTF-16 encoded. */
|
||||
# ifdef XML_UNICODE_WCHAR_T
|
||||
/* BEGIN MOZILLA CHANGE (typedef XML_Char to char16_t) */
|
||||
#if 0
|
||||
|
||||
#ifdef XML_UNICODE /* Information is UTF-16 encoded. */
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
typedef wchar_t XML_Char;
|
||||
typedef wchar_t XML_LChar;
|
||||
# else
|
||||
#else
|
||||
typedef unsigned short XML_Char;
|
||||
typedef char XML_LChar;
|
||||
# endif /* XML_UNICODE_WCHAR_T */
|
||||
# else /* Information is UTF-8 encoded. */
|
||||
#endif /* XML_UNICODE_WCHAR_T */
|
||||
#else /* Information is UTF-8 encoded. */
|
||||
typedef char XML_Char;
|
||||
typedef char XML_LChar;
|
||||
# endif /* XML_UNICODE */
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
#endif /* XML_UNICODE */
|
||||
|
||||
# ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
|
||||
#endif
|
||||
/* END MOZILLA CHANGE */
|
||||
|
||||
#ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
|
||||
typedef long long XML_Index;
|
||||
typedef unsigned long long XML_Size;
|
||||
# else
|
||||
#else
|
||||
typedef long XML_Index;
|
||||
typedef unsigned long XML_Size;
|
||||
# endif /* XML_LARGE_SIZE */
|
||||
#endif /* XML_LARGE_SIZE */
|
||||
|
||||
# ifdef __cplusplus
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* not Expat_External_INCLUDED */
|
||||
@@ -1,67 +1,37 @@
|
||||
/*
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
||||
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
|
||||
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
|
||||
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */
|
||||
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
|
||||
/* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML,
|
||||
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
|
||||
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
|
||||
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
|
||||
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
|
||||
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
|
||||
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
|
||||
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
|
||||
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
|
||||
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */
|
||||
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
|
||||
/* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML,
|
||||
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
|
||||
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
|
||||
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
|
||||
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
|
||||
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
|
||||
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
|
||||
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
|
||||
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
|
||||
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
+73
-193
@@ -1,193 +1,73 @@
|
||||
/* internal.h
|
||||
|
||||
Internal definitions used by Expat. This is not needed to compile
|
||||
client code.
|
||||
|
||||
The following calling convention macros are defined for frequently
|
||||
called functions:
|
||||
|
||||
FASTCALL - Used for those internal functions that have a simple
|
||||
body and a low number of arguments and local variables.
|
||||
|
||||
PTRCALL - Used for functions called though function pointers.
|
||||
|
||||
PTRFASTCALL - Like PTRCALL, but for low number of arguments.
|
||||
|
||||
inline - Used for selected internal functions for which inlining
|
||||
may improve performance on some platforms.
|
||||
|
||||
Note: Use of these macros is based on judgement, not hard rules,
|
||||
and therefore subject to change.
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 2002-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
|
||||
Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
|
||||
Copyright (c) 2003 Greg Stein <gstein@users.sourceforge.net>
|
||||
Copyright (c) 2016-2025 Sebastian Pipping <sebastian@pipping.org>
|
||||
Copyright (c) 2018 Yury Gribov <tetra2005@gmail.com>
|
||||
Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
|
||||
Copyright (c) 2023-2024 Sony Corporation / Snild Dolkow <snild@sony.com>
|
||||
Copyright (c) 2024 Taichi Haradaguchi <20001722@ymail.ne.jp>
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#if defined(__GNUC__) && defined(__i386__) && ! defined(__MINGW32__)
|
||||
/* We'll use this version by default only where we know it helps.
|
||||
|
||||
regparm() generates warnings on Solaris boxes. See SF bug #692878.
|
||||
|
||||
Instability reported with egcs on a RedHat Linux 7.3.
|
||||
Let's comment out:
|
||||
#define FASTCALL __attribute__((stdcall, regparm(3)))
|
||||
and let's try this:
|
||||
*/
|
||||
# define FASTCALL __attribute__((regparm(3)))
|
||||
# define PTRFASTCALL __attribute__((regparm(3)))
|
||||
#endif
|
||||
|
||||
/* Using __fastcall seems to have an unexpected negative effect under
|
||||
MS VC++, especially for function pointers, so we won't use it for
|
||||
now on that platform. It may be reconsidered for a future release
|
||||
if it can be made more effective.
|
||||
Likely reason: __fastcall on Windows is like stdcall, therefore
|
||||
the compiler cannot perform stack optimizations for call clusters.
|
||||
*/
|
||||
|
||||
/* Make sure all of these are defined if they aren't already. */
|
||||
|
||||
#ifndef FASTCALL
|
||||
# define FASTCALL
|
||||
#endif
|
||||
|
||||
#ifndef PTRCALL
|
||||
# define PTRCALL
|
||||
#endif
|
||||
|
||||
#ifndef PTRFASTCALL
|
||||
# define PTRFASTCALL
|
||||
#endif
|
||||
|
||||
#ifndef XML_MIN_SIZE
|
||||
# if ! defined(__cplusplus) && ! defined(inline)
|
||||
# ifdef __GNUC__
|
||||
# define inline __inline
|
||||
# endif /* __GNUC__ */
|
||||
# endif
|
||||
#endif /* XML_MIN_SIZE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define inline inline
|
||||
#else
|
||||
# ifndef inline
|
||||
# define inline
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <limits.h> // ULONG_MAX
|
||||
#include <stddef.h> // size_t
|
||||
|
||||
#if defined(_WIN32) \
|
||||
&& (! defined(__USE_MINGW_ANSI_STDIO) \
|
||||
|| (1 - __USE_MINGW_ANSI_STDIO - 1 == 0))
|
||||
# define EXPAT_FMT_ULL(midpart) "%" midpart "I64u"
|
||||
# if defined(_WIN64) // Note: modifiers "td" and "zu" do not work for MinGW
|
||||
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "I64d"
|
||||
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "I64u"
|
||||
# else
|
||||
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d"
|
||||
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u"
|
||||
# endif
|
||||
#else
|
||||
# define EXPAT_FMT_ULL(midpart) "%" midpart "llu"
|
||||
# if ! defined(ULONG_MAX)
|
||||
# error Compiler did not define ULONG_MAX for us
|
||||
# elif ULONG_MAX == 18446744073709551615u // 2^64-1
|
||||
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld"
|
||||
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "lu"
|
||||
# elif defined(EMSCRIPTEN) // 32bit mode Emscripten
|
||||
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld"
|
||||
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "zu"
|
||||
# else
|
||||
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d"
|
||||
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef UNUSED_P
|
||||
# define UNUSED_P(p) (void)p
|
||||
#endif
|
||||
|
||||
/* NOTE BEGIN If you ever patch these defaults to greater values
|
||||
for non-attack XML payload in your environment,
|
||||
please file a bug report with libexpat. Thank you!
|
||||
*/
|
||||
#define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT \
|
||||
100.0f
|
||||
#define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT \
|
||||
8388608 // 8 MiB, 2^23
|
||||
|
||||
#define EXPAT_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION_DEFAULT 100.0f
|
||||
#define EXPAT_ALLOC_TRACKER_ACTIVATION_THRESHOLD_DEFAULT \
|
||||
67108864 // 64 MiB, 2^26
|
||||
|
||||
// NOTE: If function expat_alloc was user facing, EXPAT_MALLOC_ALIGNMENT would
|
||||
// have to take sizeof(long double) into account
|
||||
#define EXPAT_MALLOC_ALIGNMENT sizeof(long long) // largest parser (sub)member
|
||||
#define EXPAT_MALLOC_PADDING ((EXPAT_MALLOC_ALIGNMENT) - sizeof(size_t))
|
||||
|
||||
/* NOTE END */
|
||||
|
||||
#include "expat.h" // so we can use type XML_Parser below
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void _INTERNAL_trim_to_complete_utf8_characters(const char *from,
|
||||
const char **fromLimRef);
|
||||
|
||||
#if defined(XML_GE) && XML_GE == 1
|
||||
unsigned long long testingAccountingGetCountBytesDirect(XML_Parser parser);
|
||||
unsigned long long testingAccountingGetCountBytesIndirect(XML_Parser parser);
|
||||
const char *unsignedCharToPrintable(unsigned char c);
|
||||
#endif
|
||||
|
||||
extern
|
||||
#if ! defined(XML_TESTING)
|
||||
const
|
||||
#endif
|
||||
XML_Bool g_reparseDeferralEnabledDefault; // written ONLY in runtests.c
|
||||
#if defined(XML_TESTING)
|
||||
void *expat_malloc(XML_Parser parser, size_t size, int sourceLine);
|
||||
void expat_free(XML_Parser parser, void *ptr, int sourceLine);
|
||||
void *expat_realloc(XML_Parser parser, void *ptr, size_t size, int sourceLine);
|
||||
extern unsigned int g_bytesScanned; // used for testing only
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/* internal.h
|
||||
|
||||
Internal definitions used by Expat. This is not needed to compile
|
||||
client code.
|
||||
|
||||
The following calling convention macros are defined for frequently
|
||||
called functions:
|
||||
|
||||
FASTCALL - Used for those internal functions that have a simple
|
||||
body and a low number of arguments and local variables.
|
||||
|
||||
PTRCALL - Used for functions called though function pointers.
|
||||
|
||||
PTRFASTCALL - Like PTRCALL, but for low number of arguments.
|
||||
|
||||
inline - Used for selected internal functions for which inlining
|
||||
may improve performance on some platforms.
|
||||
|
||||
Note: Use of these macros is based on judgment, not hard rules,
|
||||
and therefore subject to change.
|
||||
*/
|
||||
|
||||
#if defined(__GNUC__) && defined(__i386__)
|
||||
/* We'll use this version by default only where we know it helps.
|
||||
|
||||
regparm() generates warnings on Solaris boxes. See SF bug #692878.
|
||||
|
||||
Instability reported with egcs on a RedHat Linux 7.3.
|
||||
Let's comment out:
|
||||
#define FASTCALL __attribute__((stdcall, regparm(3)))
|
||||
and let's try this:
|
||||
*/
|
||||
#define FASTCALL __attribute__((regparm(3)))
|
||||
#define PTRFASTCALL __attribute__((regparm(3)))
|
||||
#endif
|
||||
|
||||
/* Using __fastcall seems to have an unexpected negative effect under
|
||||
MS VC++, especially for function pointers, so we won't use it for
|
||||
now on that platform. It may be reconsidered for a future release
|
||||
if it can be made more effective.
|
||||
Likely reason: __fastcall on Windows is like stdcall, therefore
|
||||
the compiler cannot perform stack optimizations for call clusters.
|
||||
*/
|
||||
|
||||
/* Make sure all of these are defined if they aren't already. */
|
||||
|
||||
#ifndef FASTCALL
|
||||
#define FASTCALL
|
||||
#endif
|
||||
|
||||
#ifndef PTRCALL
|
||||
#define PTRCALL
|
||||
#endif
|
||||
|
||||
#ifndef PTRFASTCALL
|
||||
#define PTRFASTCALL
|
||||
#endif
|
||||
|
||||
#ifndef XML_MIN_SIZE
|
||||
#if !defined(__cplusplus) && !defined(inline)
|
||||
#ifdef __GNUC__
|
||||
#define inline __inline
|
||||
#endif /* __GNUC__ */
|
||||
#endif
|
||||
#endif /* XML_MIN_SIZE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define inline inline
|
||||
#else
|
||||
#ifndef inline
|
||||
#define inline
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,66 +1,36 @@
|
||||
/*
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
||||
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
|
||||
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
|
||||
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME,
|
||||
/* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME,
|
||||
/* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
@@ -0,0 +1,19 @@
|
||||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
EXPORTS += [
|
||||
'expat.h',
|
||||
'expat_external.h',
|
||||
]
|
||||
|
||||
SOURCES += [
|
||||
'xmlparse.c',
|
||||
'xmlrole.c',
|
||||
'xmltok.c',
|
||||
]
|
||||
|
||||
FINAL_LIBRARY = 'gkmedias'
|
||||
|
||||
DEFINES['HAVE_EXPAT_CONFIG_H'] = True
|
||||
@@ -3,23 +3,19 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "lib/xmltok.c"
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
|
||||
#ifdef IS_LITTLE_ENDIAN
|
||||
|
||||
#define PREFIX(ident) little2_ ## ident
|
||||
#define BYTE_TYPE(p) LITTLE2_BYTE_TYPE(XmlGetUtf16InternalEncodingNS(), p)
|
||||
# define IS_NAME_CHAR_MINBPC(p) LITTLE2_IS_NAME_CHAR_MINBPC(p)
|
||||
# define IS_NMSTRT_CHAR_MINBPC(p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(p)
|
||||
#define IS_NAME_CHAR_MINBPC(p) LITTLE2_IS_NAME_CHAR_MINBPC(0, p)
|
||||
#define IS_NMSTRT_CHAR_MINBPC(p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(0, p)
|
||||
|
||||
#else
|
||||
|
||||
#define PREFIX(ident) big2_ ## ident
|
||||
#define BYTE_TYPE(p) BIG2_BYTE_TYPE(XmlGetUtf16InternalEncodingNS(), p)
|
||||
# define IS_NAME_CHAR_MINBPC(p) BIG2_IS_NAME_CHAR_MINBPC(p)
|
||||
# define IS_NMSTRT_CHAR_MINBPC(p) BIG2_IS_NMSTRT_CHAR_MINBPC(p)
|
||||
#define IS_NAME_CHAR_MINBPC(p) BIG2_IS_NAME_CHAR_MINBPC(0, p)
|
||||
#define IS_NMSTRT_CHAR_MINBPC(p) BIG2_IS_NMSTRT_CHAR_MINBPC(0, p)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -162,5 +158,3 @@ int MOZ_XMLTranslateEntity(const char* ptr, const char* end, const char** next,
|
||||
#undef BYTE_TYPE
|
||||
#undef IS_NAME_CHAR_MINBPC
|
||||
#undef IS_NMSTRT_CHAR_MINBPC
|
||||
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
+150
-136
@@ -1,136 +1,150 @@
|
||||
/*
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
|
||||
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
static const unsigned namingBitmap[] = {
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x04000000,
|
||||
0x87FFFFFE, 0x07FFFFFE, 0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF,
|
||||
0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFE00F, 0xFC31FFFF, 0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
|
||||
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF, 0xFFFF0003, 0xFFFFFFFF,
|
||||
0xFFFF199F, 0x033FCFFF, 0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
|
||||
0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF, 0x00000000, 0x07FFFFFE,
|
||||
0x000007FE, 0xFFFE0000, 0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060,
|
||||
0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003, 0xFFF99FE0, 0x03C5FDFF,
|
||||
0xB0000000, 0x00030003, 0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000,
|
||||
0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001, 0xFFF99FE0, 0x23CDFDFF,
|
||||
0xB0000000, 0x00000003, 0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000,
|
||||
0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003, 0xFFFDDFE0, 0x03EFFDFF,
|
||||
0x40000000, 0x00000003, 0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFE, 0x000D7FFF,
|
||||
0x0000003F, 0x00000000, 0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000,
|
||||
0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF, 0x0007DAED, 0x50000000,
|
||||
0x82315001, 0x002C62AB, 0x40000000, 0xF580C900, 0x00000007, 0x02010800,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0FFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0x03FFFFFF, 0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF,
|
||||
0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF, 0x00000000, 0x00004C40,
|
||||
0x00000000, 0x00000000, 0x00000007, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF, 0x001FFFFF, 0xFFFFFFFE,
|
||||
0xFFFFFFFF, 0x07FFFFFF, 0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000000F,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE,
|
||||
0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF, 0x00FFFFFF, 0x00000000,
|
||||
0xFFFF0000, 0xFFFFFFFF, 0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003, 0xFFFFD7C0, 0xFFFFFFFB,
|
||||
0x547F7FFF, 0x000FFFFD, 0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
|
||||
0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF, 0x00000000, 0xFFFE0000,
|
||||
0x027FFFFF, 0xFFFFFFFE, 0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF,
|
||||
0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF, 0xFFFFFFFF, 0x7CFFFFFF,
|
||||
0xFFEF7FFF, 0x03FF3DFF, 0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF,
|
||||
0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF, 0xFFF987E4, 0xD36DFDFF,
|
||||
0x5E003987, 0x001FFFC0, 0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1,
|
||||
0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3, 0xD63DC7EC, 0xC3BFC718,
|
||||
0x00803DC7, 0x0000FF80, 0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3,
|
||||
0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3, 0xFFFDDFEC, 0xC3FFFDFF,
|
||||
0x00803DCF, 0x0000FFC3, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000, 0xFEF02596, 0x3BFF6CAE,
|
||||
0x03FF3F5F, 0x00000000, 0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF,
|
||||
0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1FFF0000, 0x00000002,
|
||||
0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF, 0x661FFFFF, 0xFFFFFFFE,
|
||||
0xFFFFFFFF, 0x77FFFFFF,
|
||||
};
|
||||
static const unsigned char nmstrtPages[] = {
|
||||
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, 0x00, 0x09, 0x0A, 0x0B,
|
||||
0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, 0x00, 0x14, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
static const unsigned char namePages[] = {
|
||||
0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00, 0x00, 0x1F, 0x20, 0x21,
|
||||
0x22, 0x23, 0x24, 0x25, 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, 0x26, 0x14, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
static const unsigned namingBitmap[] = {
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0x00000000, 0x04000000, 0x87FFFFFE, 0x07FFFFFE,
|
||||
0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF,
|
||||
0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFE00F, 0xFC31FFFF,
|
||||
0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
|
||||
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
|
||||
0xFFFF0003, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
|
||||
0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
|
||||
0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF,
|
||||
0x00000000, 0x07FFFFFE, 0x000007FE, 0xFFFE0000,
|
||||
0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060,
|
||||
0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003,
|
||||
0xFFF99FE0, 0x03C5FDFF, 0xB0000000, 0x00030003,
|
||||
0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000,
|
||||
0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001,
|
||||
0xFFF99FE0, 0x23CDFDFF, 0xB0000000, 0x00000003,
|
||||
0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000,
|
||||
0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003,
|
||||
0xFFFDDFE0, 0x03EFFDFF, 0x40000000, 0x00000003,
|
||||
0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFE, 0x000D7FFF, 0x0000003F, 0x00000000,
|
||||
0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000,
|
||||
0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF,
|
||||
0x0007DAED, 0x50000000, 0x82315001, 0x002C62AB,
|
||||
0x40000000, 0xF580C900, 0x00000007, 0x02010800,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0x0FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF,
|
||||
0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF,
|
||||
0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF,
|
||||
0x00000000, 0x00004C40, 0x00000000, 0x00000000,
|
||||
0x00000007, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF,
|
||||
0x001FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x07FFFFFF,
|
||||
0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE,
|
||||
0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF,
|
||||
0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003,
|
||||
0xFFFFD7C0, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
|
||||
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
|
||||
0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
|
||||
0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
|
||||
0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF,
|
||||
0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF,
|
||||
0xFFFFFFFF, 0x7CFFFFFF, 0xFFEF7FFF, 0x03FF3DFF,
|
||||
0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF,
|
||||
0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF,
|
||||
0xFFF987E4, 0xD36DFDFF, 0x5E003987, 0x001FFFC0,
|
||||
0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1,
|
||||
0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3,
|
||||
0xD63DC7EC, 0xC3BFC718, 0x00803DC7, 0x0000FF80,
|
||||
0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3,
|
||||
0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3,
|
||||
0xFFFDDFEC, 0xC3FFFDFF, 0x00803DCF, 0x0000FFC3,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000,
|
||||
0xFEF02596, 0x3BFF6CAE, 0x03FF3F5F, 0x00000000,
|
||||
0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF,
|
||||
0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x1FFF0000, 0x00000002,
|
||||
0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF,
|
||||
0x661FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x77FFFFFF,
|
||||
};
|
||||
static const unsigned char nmstrtPages[] = {
|
||||
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00,
|
||||
0x00, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
|
||||
0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
static const unsigned char namePages[] = {
|
||||
0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00,
|
||||
0x00, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
|
||||
0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
|
||||
0x26, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
@@ -1,392 +0,0 @@
|
||||
/* ==========================================================================
|
||||
* siphash.h - SipHash-2-4 in a single header file
|
||||
* --------------------------------------------------------------------------
|
||||
* Derived by William Ahern from the reference implementation[1] published[2]
|
||||
* by Jean-Philippe Aumasson and Daniel J. Berstein.
|
||||
* Minimal changes by Sebastian Pipping and Victor Stinner on top, see below.
|
||||
* Licensed under the CC0 Public Domain Dedication license.
|
||||
*
|
||||
* 1. https://www.131002.net/siphash/siphash24.c
|
||||
* 2. https://www.131002.net/siphash/
|
||||
* --------------------------------------------------------------------------
|
||||
* HISTORY:
|
||||
*
|
||||
* 2020-10-03 (Sebastian Pipping)
|
||||
* - Drop support for Visual Studio 9.0/2008 and earlier
|
||||
*
|
||||
* 2019-08-03 (Sebastian Pipping)
|
||||
* - Mark part of sip24_valid as to be excluded from clang-format
|
||||
* - Re-format code using clang-format 9
|
||||
*
|
||||
* 2018-07-08 (Anton Maklakov)
|
||||
* - Add "fall through" markers for GCC's -Wimplicit-fallthrough
|
||||
*
|
||||
* 2017-11-03 (Sebastian Pipping)
|
||||
* - Hide sip_tobin and sip_binof unless SIPHASH_TOBIN macro is defined
|
||||
*
|
||||
* 2017-07-25 (Vadim Zeitlin)
|
||||
* - Fix use of SIPHASH_MAIN macro
|
||||
*
|
||||
* 2017-07-05 (Sebastian Pipping)
|
||||
* - Use _SIP_ULL macro to not require a C++11 compiler if compiled as C++
|
||||
* - Add const qualifiers at two places
|
||||
* - Ensure <=80 characters line length (assuming tab width 4)
|
||||
*
|
||||
* 2017-06-23 (Victor Stinner)
|
||||
* - Address Win64 compile warnings
|
||||
*
|
||||
* 2017-06-18 (Sebastian Pipping)
|
||||
* - Clarify license note in the header
|
||||
* - Address C89 issues:
|
||||
* - Stop using inline keyword (and let compiler decide)
|
||||
* - Replace _Bool by int
|
||||
* - Turn macro siphash24 into a function
|
||||
* - Address invalid conversion (void pointer) by explicit cast
|
||||
* - Address lack of stdint.h for Visual Studio 2003 to 2008
|
||||
* - Always expose sip24_valid (for self-tests)
|
||||
*
|
||||
* 2012-11-04 - Born. (William Ahern)
|
||||
* --------------------------------------------------------------------------
|
||||
* USAGE:
|
||||
*
|
||||
* SipHash-2-4 takes as input two 64-bit words as the key, some number of
|
||||
* message bytes, and outputs a 64-bit word as the message digest. This
|
||||
* implementation employs two data structures: a struct sipkey for
|
||||
* representing the key, and a struct siphash for representing the hash
|
||||
* state.
|
||||
*
|
||||
* For converting a 16-byte unsigned char array to a key, use either the
|
||||
* macro sip_keyof or the routine sip_tokey. The former instantiates a
|
||||
* compound literal key, while the latter requires a key object as a
|
||||
* parameter.
|
||||
*
|
||||
* unsigned char secret[16];
|
||||
* arc4random_buf(secret, sizeof secret);
|
||||
* struct sipkey *key = sip_keyof(secret);
|
||||
*
|
||||
* For hashing a message, use either the convenience macro siphash24 or the
|
||||
* routines sip24_init, sip24_update, and sip24_final.
|
||||
*
|
||||
* struct siphash state;
|
||||
* void *msg;
|
||||
* size_t len;
|
||||
* uint64_t hash;
|
||||
*
|
||||
* sip24_init(&state, key);
|
||||
* sip24_update(&state, msg, len);
|
||||
* hash = sip24_final(&state);
|
||||
*
|
||||
* or
|
||||
*
|
||||
* hash = siphash24(msg, len, key);
|
||||
*
|
||||
* To convert the 64-bit hash value to a canonical 8-byte little-endian
|
||||
* binary representation, use either the macro sip_binof or the routine
|
||||
* sip_tobin. The former instantiates and returns a compound literal array,
|
||||
* while the latter requires an array object as a parameter.
|
||||
* --------------------------------------------------------------------------
|
||||
* NOTES:
|
||||
*
|
||||
* o Neither sip_keyof, sip_binof, nor siphash24 will work with compilers
|
||||
* lacking compound literal support. Instead, you must use the lower-level
|
||||
* interfaces which take as parameters the temporary state objects.
|
||||
*
|
||||
* o Uppercase macros may evaluate parameters more than once. Lowercase
|
||||
* macros should not exhibit any such side effects.
|
||||
* ==========================================================================
|
||||
*/
|
||||
#ifndef SIPHASH_H
|
||||
#define SIPHASH_H
|
||||
|
||||
#include <stddef.h> /* size_t */
|
||||
#include <stdint.h> /* uint64_t uint32_t uint8_t */
|
||||
|
||||
/*
|
||||
* Workaround to not require a C++11 compiler for using ULL suffix
|
||||
* if this code is included and compiled as C++; related GCC warning is:
|
||||
* warning: use of C++11 long long integer constant [-Wlong-long]
|
||||
*/
|
||||
#define SIP_ULL(high, low) ((((uint64_t)high) << 32) | (low))
|
||||
|
||||
#define SIP_ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b))))
|
||||
|
||||
#define SIP_U32TO8_LE(p, v) \
|
||||
(p)[0] = (uint8_t)((v) >> 0); \
|
||||
(p)[1] = (uint8_t)((v) >> 8); \
|
||||
(p)[2] = (uint8_t)((v) >> 16); \
|
||||
(p)[3] = (uint8_t)((v) >> 24);
|
||||
|
||||
#define SIP_U64TO8_LE(p, v) \
|
||||
SIP_U32TO8_LE((p) + 0, (uint32_t)((v) >> 0)); \
|
||||
SIP_U32TO8_LE((p) + 4, (uint32_t)((v) >> 32));
|
||||
|
||||
#define SIP_U8TO64_LE(p) \
|
||||
(((uint64_t)((p)[0]) << 0) | ((uint64_t)((p)[1]) << 8) \
|
||||
| ((uint64_t)((p)[2]) << 16) | ((uint64_t)((p)[3]) << 24) \
|
||||
| ((uint64_t)((p)[4]) << 32) | ((uint64_t)((p)[5]) << 40) \
|
||||
| ((uint64_t)((p)[6]) << 48) | ((uint64_t)((p)[7]) << 56))
|
||||
|
||||
#define SIPHASH_INITIALIZER {0, 0, 0, 0, {0}, 0, 0}
|
||||
|
||||
struct siphash {
|
||||
uint64_t v0, v1, v2, v3;
|
||||
|
||||
unsigned char buf[8], *p;
|
||||
uint64_t c;
|
||||
}; /* struct siphash */
|
||||
|
||||
#define SIP_KEYLEN 16
|
||||
|
||||
struct sipkey {
|
||||
uint64_t k[2];
|
||||
}; /* struct sipkey */
|
||||
|
||||
#define sip_keyof(k) sip_tokey(&(struct sipkey){{0}}, (k))
|
||||
|
||||
static struct sipkey *
|
||||
sip_tokey(struct sipkey *key, const void *src) {
|
||||
key->k[0] = SIP_U8TO64_LE((const unsigned char *)src);
|
||||
key->k[1] = SIP_U8TO64_LE((const unsigned char *)src + 8);
|
||||
return key;
|
||||
} /* sip_tokey() */
|
||||
|
||||
#ifdef SIPHASH_TOBIN
|
||||
|
||||
# define sip_binof(v) sip_tobin((unsigned char[8]){0}, (v))
|
||||
|
||||
static void *
|
||||
sip_tobin(void *dst, uint64_t u64) {
|
||||
SIP_U64TO8_LE((unsigned char *)dst, u64);
|
||||
return dst;
|
||||
} /* sip_tobin() */
|
||||
|
||||
#endif /* SIPHASH_TOBIN */
|
||||
|
||||
static void
|
||||
sip_round(struct siphash *H, const int rounds) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < rounds; i++) {
|
||||
H->v0 += H->v1;
|
||||
H->v1 = SIP_ROTL(H->v1, 13);
|
||||
H->v1 ^= H->v0;
|
||||
H->v0 = SIP_ROTL(H->v0, 32);
|
||||
|
||||
H->v2 += H->v3;
|
||||
H->v3 = SIP_ROTL(H->v3, 16);
|
||||
H->v3 ^= H->v2;
|
||||
|
||||
H->v0 += H->v3;
|
||||
H->v3 = SIP_ROTL(H->v3, 21);
|
||||
H->v3 ^= H->v0;
|
||||
|
||||
H->v2 += H->v1;
|
||||
H->v1 = SIP_ROTL(H->v1, 17);
|
||||
H->v1 ^= H->v2;
|
||||
H->v2 = SIP_ROTL(H->v2, 32);
|
||||
}
|
||||
} /* sip_round() */
|
||||
|
||||
static struct siphash *
|
||||
sip24_init(struct siphash *H, const struct sipkey *key) {
|
||||
H->v0 = SIP_ULL(0x736f6d65U, 0x70736575U) ^ key->k[0];
|
||||
H->v1 = SIP_ULL(0x646f7261U, 0x6e646f6dU) ^ key->k[1];
|
||||
H->v2 = SIP_ULL(0x6c796765U, 0x6e657261U) ^ key->k[0];
|
||||
H->v3 = SIP_ULL(0x74656462U, 0x79746573U) ^ key->k[1];
|
||||
|
||||
H->p = H->buf;
|
||||
H->c = 0;
|
||||
|
||||
return H;
|
||||
} /* sip24_init() */
|
||||
|
||||
#define sip_endof(a) (&(a)[sizeof(a) / sizeof *(a)])
|
||||
|
||||
static struct siphash *
|
||||
sip24_update(struct siphash *H, const void *src, size_t len) {
|
||||
const unsigned char *p = (const unsigned char *)src, *pe = p + len;
|
||||
uint64_t m;
|
||||
|
||||
do {
|
||||
while (p < pe && H->p < sip_endof(H->buf))
|
||||
*H->p++ = *p++;
|
||||
|
||||
if (H->p < sip_endof(H->buf))
|
||||
break;
|
||||
|
||||
m = SIP_U8TO64_LE(H->buf);
|
||||
H->v3 ^= m;
|
||||
sip_round(H, 2);
|
||||
H->v0 ^= m;
|
||||
|
||||
H->p = H->buf;
|
||||
H->c += 8;
|
||||
} while (p < pe);
|
||||
|
||||
return H;
|
||||
} /* sip24_update() */
|
||||
|
||||
static uint64_t
|
||||
sip24_final(struct siphash *H) {
|
||||
const char left = (char)(H->p - H->buf);
|
||||
uint64_t b = (H->c + left) << 56;
|
||||
|
||||
switch (left) {
|
||||
case 7:
|
||||
b |= (uint64_t)H->buf[6] << 48;
|
||||
/* fall through */
|
||||
case 6:
|
||||
b |= (uint64_t)H->buf[5] << 40;
|
||||
/* fall through */
|
||||
case 5:
|
||||
b |= (uint64_t)H->buf[4] << 32;
|
||||
/* fall through */
|
||||
case 4:
|
||||
b |= (uint64_t)H->buf[3] << 24;
|
||||
/* fall through */
|
||||
case 3:
|
||||
b |= (uint64_t)H->buf[2] << 16;
|
||||
/* fall through */
|
||||
case 2:
|
||||
b |= (uint64_t)H->buf[1] << 8;
|
||||
/* fall through */
|
||||
case 1:
|
||||
b |= (uint64_t)H->buf[0] << 0;
|
||||
/* fall through */
|
||||
case 0:
|
||||
break;
|
||||
}
|
||||
|
||||
H->v3 ^= b;
|
||||
sip_round(H, 2);
|
||||
H->v0 ^= b;
|
||||
H->v2 ^= 0xff;
|
||||
sip_round(H, 4);
|
||||
|
||||
return H->v0 ^ H->v1 ^ H->v2 ^ H->v3;
|
||||
} /* sip24_final() */
|
||||
|
||||
static uint64_t
|
||||
siphash24(const void *src, size_t len, const struct sipkey *key) {
|
||||
struct siphash state = SIPHASH_INITIALIZER;
|
||||
return sip24_final(sip24_update(sip24_init(&state, key), src, len));
|
||||
} /* siphash24() */
|
||||
|
||||
/*
|
||||
* SipHash-2-4 output with
|
||||
* k = 00 01 02 ...
|
||||
* and
|
||||
* in = (empty string)
|
||||
* in = 00 (1 byte)
|
||||
* in = 00 01 (2 bytes)
|
||||
* in = 00 01 02 (3 bytes)
|
||||
* ...
|
||||
* in = 00 01 02 ... 3e (63 bytes)
|
||||
*/
|
||||
static int
|
||||
sip24_valid(void) {
|
||||
/* clang-format off */
|
||||
static const unsigned char vectors[64][8] = {
|
||||
{ 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, },
|
||||
{ 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, },
|
||||
{ 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, },
|
||||
{ 0x2d, 0x7e, 0xfb, 0xd7, 0x96, 0x66, 0x67, 0x85, },
|
||||
{ 0xb7, 0x87, 0x71, 0x27, 0xe0, 0x94, 0x27, 0xcf, },
|
||||
{ 0x8d, 0xa6, 0x99, 0xcd, 0x64, 0x55, 0x76, 0x18, },
|
||||
{ 0xce, 0xe3, 0xfe, 0x58, 0x6e, 0x46, 0xc9, 0xcb, },
|
||||
{ 0x37, 0xd1, 0x01, 0x8b, 0xf5, 0x00, 0x02, 0xab, },
|
||||
{ 0x62, 0x24, 0x93, 0x9a, 0x79, 0xf5, 0xf5, 0x93, },
|
||||
{ 0xb0, 0xe4, 0xa9, 0x0b, 0xdf, 0x82, 0x00, 0x9e, },
|
||||
{ 0xf3, 0xb9, 0xdd, 0x94, 0xc5, 0xbb, 0x5d, 0x7a, },
|
||||
{ 0xa7, 0xad, 0x6b, 0x22, 0x46, 0x2f, 0xb3, 0xf4, },
|
||||
{ 0xfb, 0xe5, 0x0e, 0x86, 0xbc, 0x8f, 0x1e, 0x75, },
|
||||
{ 0x90, 0x3d, 0x84, 0xc0, 0x27, 0x56, 0xea, 0x14, },
|
||||
{ 0xee, 0xf2, 0x7a, 0x8e, 0x90, 0xca, 0x23, 0xf7, },
|
||||
{ 0xe5, 0x45, 0xbe, 0x49, 0x61, 0xca, 0x29, 0xa1, },
|
||||
{ 0xdb, 0x9b, 0xc2, 0x57, 0x7f, 0xcc, 0x2a, 0x3f, },
|
||||
{ 0x94, 0x47, 0xbe, 0x2c, 0xf5, 0xe9, 0x9a, 0x69, },
|
||||
{ 0x9c, 0xd3, 0x8d, 0x96, 0xf0, 0xb3, 0xc1, 0x4b, },
|
||||
{ 0xbd, 0x61, 0x79, 0xa7, 0x1d, 0xc9, 0x6d, 0xbb, },
|
||||
{ 0x98, 0xee, 0xa2, 0x1a, 0xf2, 0x5c, 0xd6, 0xbe, },
|
||||
{ 0xc7, 0x67, 0x3b, 0x2e, 0xb0, 0xcb, 0xf2, 0xd0, },
|
||||
{ 0x88, 0x3e, 0xa3, 0xe3, 0x95, 0x67, 0x53, 0x93, },
|
||||
{ 0xc8, 0xce, 0x5c, 0xcd, 0x8c, 0x03, 0x0c, 0xa8, },
|
||||
{ 0x94, 0xaf, 0x49, 0xf6, 0xc6, 0x50, 0xad, 0xb8, },
|
||||
{ 0xea, 0xb8, 0x85, 0x8a, 0xde, 0x92, 0xe1, 0xbc, },
|
||||
{ 0xf3, 0x15, 0xbb, 0x5b, 0xb8, 0x35, 0xd8, 0x17, },
|
||||
{ 0xad, 0xcf, 0x6b, 0x07, 0x63, 0x61, 0x2e, 0x2f, },
|
||||
{ 0xa5, 0xc9, 0x1d, 0xa7, 0xac, 0xaa, 0x4d, 0xde, },
|
||||
{ 0x71, 0x65, 0x95, 0x87, 0x66, 0x50, 0xa2, 0xa6, },
|
||||
{ 0x28, 0xef, 0x49, 0x5c, 0x53, 0xa3, 0x87, 0xad, },
|
||||
{ 0x42, 0xc3, 0x41, 0xd8, 0xfa, 0x92, 0xd8, 0x32, },
|
||||
{ 0xce, 0x7c, 0xf2, 0x72, 0x2f, 0x51, 0x27, 0x71, },
|
||||
{ 0xe3, 0x78, 0x59, 0xf9, 0x46, 0x23, 0xf3, 0xa7, },
|
||||
{ 0x38, 0x12, 0x05, 0xbb, 0x1a, 0xb0, 0xe0, 0x12, },
|
||||
{ 0xae, 0x97, 0xa1, 0x0f, 0xd4, 0x34, 0xe0, 0x15, },
|
||||
{ 0xb4, 0xa3, 0x15, 0x08, 0xbe, 0xff, 0x4d, 0x31, },
|
||||
{ 0x81, 0x39, 0x62, 0x29, 0xf0, 0x90, 0x79, 0x02, },
|
||||
{ 0x4d, 0x0c, 0xf4, 0x9e, 0xe5, 0xd4, 0xdc, 0xca, },
|
||||
{ 0x5c, 0x73, 0x33, 0x6a, 0x76, 0xd8, 0xbf, 0x9a, },
|
||||
{ 0xd0, 0xa7, 0x04, 0x53, 0x6b, 0xa9, 0x3e, 0x0e, },
|
||||
{ 0x92, 0x59, 0x58, 0xfc, 0xd6, 0x42, 0x0c, 0xad, },
|
||||
{ 0xa9, 0x15, 0xc2, 0x9b, 0xc8, 0x06, 0x73, 0x18, },
|
||||
{ 0x95, 0x2b, 0x79, 0xf3, 0xbc, 0x0a, 0xa6, 0xd4, },
|
||||
{ 0xf2, 0x1d, 0xf2, 0xe4, 0x1d, 0x45, 0x35, 0xf9, },
|
||||
{ 0x87, 0x57, 0x75, 0x19, 0x04, 0x8f, 0x53, 0xa9, },
|
||||
{ 0x10, 0xa5, 0x6c, 0xf5, 0xdf, 0xcd, 0x9a, 0xdb, },
|
||||
{ 0xeb, 0x75, 0x09, 0x5c, 0xcd, 0x98, 0x6c, 0xd0, },
|
||||
{ 0x51, 0xa9, 0xcb, 0x9e, 0xcb, 0xa3, 0x12, 0xe6, },
|
||||
{ 0x96, 0xaf, 0xad, 0xfc, 0x2c, 0xe6, 0x66, 0xc7, },
|
||||
{ 0x72, 0xfe, 0x52, 0x97, 0x5a, 0x43, 0x64, 0xee, },
|
||||
{ 0x5a, 0x16, 0x45, 0xb2, 0x76, 0xd5, 0x92, 0xa1, },
|
||||
{ 0xb2, 0x74, 0xcb, 0x8e, 0xbf, 0x87, 0x87, 0x0a, },
|
||||
{ 0x6f, 0x9b, 0xb4, 0x20, 0x3d, 0xe7, 0xb3, 0x81, },
|
||||
{ 0xea, 0xec, 0xb2, 0xa3, 0x0b, 0x22, 0xa8, 0x7f, },
|
||||
{ 0x99, 0x24, 0xa4, 0x3c, 0xc1, 0x31, 0x57, 0x24, },
|
||||
{ 0xbd, 0x83, 0x8d, 0x3a, 0xaf, 0xbf, 0x8d, 0xb7, },
|
||||
{ 0x0b, 0x1a, 0x2a, 0x32, 0x65, 0xd5, 0x1a, 0xea, },
|
||||
{ 0x13, 0x50, 0x79, 0xa3, 0x23, 0x1c, 0xe6, 0x60, },
|
||||
{ 0x93, 0x2b, 0x28, 0x46, 0xe4, 0xd7, 0x06, 0x66, },
|
||||
{ 0xe1, 0x91, 0x5f, 0x5c, 0xb1, 0xec, 0xa4, 0x6c, },
|
||||
{ 0xf3, 0x25, 0x96, 0x5c, 0xa1, 0x6d, 0x62, 0x9f, },
|
||||
{ 0x57, 0x5f, 0xf2, 0x8e, 0x60, 0x38, 0x1b, 0xe5, },
|
||||
{ 0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95, }
|
||||
};
|
||||
/* clang-format on */
|
||||
|
||||
unsigned char in[64];
|
||||
struct sipkey k;
|
||||
size_t i;
|
||||
|
||||
sip_tokey(&k, "\000\001\002\003\004\005\006\007\010\011"
|
||||
"\012\013\014\015\016\017");
|
||||
|
||||
for (i = 0; i < sizeof in; ++i) {
|
||||
in[i] = (unsigned char)i;
|
||||
|
||||
if (siphash24(in, i, &k) != SIP_U8TO64_LE(vectors[i]))
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
} /* sip24_valid() */
|
||||
|
||||
#ifdef SIPHASH_MAIN
|
||||
|
||||
# include <stdio.h>
|
||||
|
||||
int
|
||||
main(void) {
|
||||
const int ok = sip24_valid();
|
||||
|
||||
if (ok)
|
||||
puts("OK");
|
||||
else
|
||||
puts("FAIL");
|
||||
|
||||
return ! ok;
|
||||
} /* main() */
|
||||
|
||||
#endif /* SIPHASH_MAIN */
|
||||
|
||||
#endif /* SIPHASH_H */
|
||||
+37
-66
@@ -1,66 +1,37 @@
|
||||
/*
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
||||
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
|
||||
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
|
||||
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4,
|
||||
/* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM,
|
||||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
|
||||
/* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4,
|
||||
/* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM,
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
|
||||
Copyright (c) 2002 Greg Stein <gstein@users.sourceforge.net>
|
||||
Copyright (c) 2005 Karl Waclawek <karl@waclawek.net>
|
||||
Copyright (c) 2017-2023 Sebastian Pipping <sebastian@pipping.org>
|
||||
Copyright (c) 2023 Orgad Shaneh <orgad.shaneh@audiocodes.com>
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef WINCONFIG_H
|
||||
#define WINCONFIG_H
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
|
||||
#endif /* ndef WINCONFIG_H */
|
||||
+3221
-6164
File diff suppressed because it is too large.
Load diff
+1330
-1255
File diff suppressed because it is too large.
Load diff
+114
-136
@@ -1,136 +1,114 @@
|
||||
/*
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
||||
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
|
||||
Copyright (c) 2002 Karl Waclawek <karl@waclawek.net>
|
||||
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
|
||||
Copyright (c) 2017-2025 Sebastian Pipping <sebastian@pipping.org>
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef XmlRole_INCLUDED
|
||||
# define XmlRole_INCLUDED 1
|
||||
|
||||
# include "xmltok.h"
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
enum {
|
||||
XML_ROLE_ERROR = -1,
|
||||
XML_ROLE_NONE = 0,
|
||||
XML_ROLE_XML_DECL,
|
||||
XML_ROLE_INSTANCE_START,
|
||||
XML_ROLE_DOCTYPE_NONE,
|
||||
XML_ROLE_DOCTYPE_NAME,
|
||||
XML_ROLE_DOCTYPE_SYSTEM_ID,
|
||||
XML_ROLE_DOCTYPE_PUBLIC_ID,
|
||||
XML_ROLE_DOCTYPE_INTERNAL_SUBSET,
|
||||
XML_ROLE_DOCTYPE_CLOSE,
|
||||
XML_ROLE_GENERAL_ENTITY_NAME,
|
||||
XML_ROLE_PARAM_ENTITY_NAME,
|
||||
XML_ROLE_ENTITY_NONE,
|
||||
XML_ROLE_ENTITY_VALUE,
|
||||
XML_ROLE_ENTITY_SYSTEM_ID,
|
||||
XML_ROLE_ENTITY_PUBLIC_ID,
|
||||
XML_ROLE_ENTITY_COMPLETE,
|
||||
XML_ROLE_ENTITY_NOTATION_NAME,
|
||||
XML_ROLE_NOTATION_NONE,
|
||||
XML_ROLE_NOTATION_NAME,
|
||||
XML_ROLE_NOTATION_SYSTEM_ID,
|
||||
XML_ROLE_NOTATION_NO_SYSTEM_ID,
|
||||
XML_ROLE_NOTATION_PUBLIC_ID,
|
||||
XML_ROLE_ATTRIBUTE_NAME,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_CDATA,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ID,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_IDREF,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_IDREFS,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ENTITY,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ENTITIES,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS,
|
||||
XML_ROLE_ATTRIBUTE_ENUM_VALUE,
|
||||
XML_ROLE_ATTRIBUTE_NOTATION_VALUE,
|
||||
XML_ROLE_ATTLIST_NONE,
|
||||
XML_ROLE_ATTLIST_ELEMENT_NAME,
|
||||
XML_ROLE_IMPLIED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_REQUIRED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_DEFAULT_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_FIXED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_ELEMENT_NONE,
|
||||
XML_ROLE_ELEMENT_NAME,
|
||||
XML_ROLE_CONTENT_ANY,
|
||||
XML_ROLE_CONTENT_EMPTY,
|
||||
XML_ROLE_CONTENT_PCDATA,
|
||||
XML_ROLE_GROUP_OPEN,
|
||||
XML_ROLE_GROUP_CLOSE,
|
||||
XML_ROLE_GROUP_CLOSE_REP,
|
||||
XML_ROLE_GROUP_CLOSE_OPT,
|
||||
XML_ROLE_GROUP_CLOSE_PLUS,
|
||||
XML_ROLE_GROUP_CHOICE,
|
||||
XML_ROLE_GROUP_SEQUENCE,
|
||||
XML_ROLE_CONTENT_ELEMENT,
|
||||
XML_ROLE_CONTENT_ELEMENT_REP,
|
||||
XML_ROLE_CONTENT_ELEMENT_OPT,
|
||||
XML_ROLE_CONTENT_ELEMENT_PLUS,
|
||||
XML_ROLE_PI,
|
||||
XML_ROLE_COMMENT,
|
||||
# ifdef XML_DTD
|
||||
XML_ROLE_TEXT_DECL,
|
||||
XML_ROLE_IGNORE_SECT,
|
||||
XML_ROLE_INNER_PARAM_ENTITY_REF,
|
||||
# endif /* XML_DTD */
|
||||
XML_ROLE_PARAM_ENTITY_REF
|
||||
};
|
||||
|
||||
typedef struct prolog_state {
|
||||
int(PTRCALL *handler)(struct prolog_state *state, int tok, const char *ptr,
|
||||
const char *end, const ENCODING *enc);
|
||||
unsigned level;
|
||||
int role_none;
|
||||
# ifdef XML_DTD
|
||||
unsigned includeLevel;
|
||||
int documentEntity;
|
||||
int inEntityValue;
|
||||
# endif /* XML_DTD */
|
||||
} PROLOG_STATE;
|
||||
|
||||
void XmlPrologStateInit(PROLOG_STATE *state);
|
||||
# ifdef XML_DTD
|
||||
void XmlPrologStateInitExternalEntity(PROLOG_STATE *state);
|
||||
# endif /* XML_DTD */
|
||||
|
||||
# define XmlTokenRole(state, tok, ptr, end, enc) \
|
||||
(((state)->handler)(state, tok, ptr, end, enc))
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif /* not XmlRole_INCLUDED */
|
||||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
#ifndef XmlRole_INCLUDED
|
||||
#define XmlRole_INCLUDED 1
|
||||
|
||||
#ifdef __VMS
|
||||
/* 0 1 2 3 0 1 2 3
|
||||
1234567890123456789012345678901 1234567890123456789012345678901 */
|
||||
#define XmlPrologStateInitExternalEntity XmlPrologStateInitExternalEnt
|
||||
#endif
|
||||
|
||||
#include "xmltok.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
XML_ROLE_ERROR = -1,
|
||||
XML_ROLE_NONE = 0,
|
||||
XML_ROLE_XML_DECL,
|
||||
XML_ROLE_INSTANCE_START,
|
||||
XML_ROLE_DOCTYPE_NONE,
|
||||
XML_ROLE_DOCTYPE_NAME,
|
||||
XML_ROLE_DOCTYPE_SYSTEM_ID,
|
||||
XML_ROLE_DOCTYPE_PUBLIC_ID,
|
||||
XML_ROLE_DOCTYPE_INTERNAL_SUBSET,
|
||||
XML_ROLE_DOCTYPE_CLOSE,
|
||||
XML_ROLE_GENERAL_ENTITY_NAME,
|
||||
XML_ROLE_PARAM_ENTITY_NAME,
|
||||
XML_ROLE_ENTITY_NONE,
|
||||
XML_ROLE_ENTITY_VALUE,
|
||||
XML_ROLE_ENTITY_SYSTEM_ID,
|
||||
XML_ROLE_ENTITY_PUBLIC_ID,
|
||||
XML_ROLE_ENTITY_COMPLETE,
|
||||
XML_ROLE_ENTITY_NOTATION_NAME,
|
||||
XML_ROLE_NOTATION_NONE,
|
||||
XML_ROLE_NOTATION_NAME,
|
||||
XML_ROLE_NOTATION_SYSTEM_ID,
|
||||
XML_ROLE_NOTATION_NO_SYSTEM_ID,
|
||||
XML_ROLE_NOTATION_PUBLIC_ID,
|
||||
XML_ROLE_ATTRIBUTE_NAME,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_CDATA,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ID,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_IDREF,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_IDREFS,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ENTITY,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ENTITIES,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS,
|
||||
XML_ROLE_ATTRIBUTE_ENUM_VALUE,
|
||||
XML_ROLE_ATTRIBUTE_NOTATION_VALUE,
|
||||
XML_ROLE_ATTLIST_NONE,
|
||||
XML_ROLE_ATTLIST_ELEMENT_NAME,
|
||||
XML_ROLE_IMPLIED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_REQUIRED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_DEFAULT_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_FIXED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_ELEMENT_NONE,
|
||||
XML_ROLE_ELEMENT_NAME,
|
||||
XML_ROLE_CONTENT_ANY,
|
||||
XML_ROLE_CONTENT_EMPTY,
|
||||
XML_ROLE_CONTENT_PCDATA,
|
||||
XML_ROLE_GROUP_OPEN,
|
||||
XML_ROLE_GROUP_CLOSE,
|
||||
XML_ROLE_GROUP_CLOSE_REP,
|
||||
XML_ROLE_GROUP_CLOSE_OPT,
|
||||
XML_ROLE_GROUP_CLOSE_PLUS,
|
||||
XML_ROLE_GROUP_CHOICE,
|
||||
XML_ROLE_GROUP_SEQUENCE,
|
||||
XML_ROLE_CONTENT_ELEMENT,
|
||||
XML_ROLE_CONTENT_ELEMENT_REP,
|
||||
XML_ROLE_CONTENT_ELEMENT_OPT,
|
||||
XML_ROLE_CONTENT_ELEMENT_PLUS,
|
||||
XML_ROLE_PI,
|
||||
XML_ROLE_COMMENT,
|
||||
#ifdef XML_DTD
|
||||
XML_ROLE_TEXT_DECL,
|
||||
XML_ROLE_IGNORE_SECT,
|
||||
XML_ROLE_INNER_PARAM_ENTITY_REF,
|
||||
#endif /* XML_DTD */
|
||||
XML_ROLE_PARAM_ENTITY_REF
|
||||
};
|
||||
|
||||
typedef struct prolog_state {
|
||||
int (PTRCALL *handler) (struct prolog_state *state,
|
||||
int tok,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
const ENCODING *enc);
|
||||
unsigned level;
|
||||
int role_none;
|
||||
#ifdef XML_DTD
|
||||
unsigned includeLevel;
|
||||
int documentEntity;
|
||||
int inEntityValue;
|
||||
#endif /* XML_DTD */
|
||||
} PROLOG_STATE;
|
||||
|
||||
void XmlPrologStateInit(PROLOG_STATE *);
|
||||
#ifdef XML_DTD
|
||||
void XmlPrologStateInitExternalEntity(PROLOG_STATE *);
|
||||
#endif /* XML_DTD */
|
||||
|
||||
#define XmlTokenRole(state, tok, ptr, end, enc) \
|
||||
(((state)->handler)(state, tok, ptr, end, enc))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* not XmlRole_INCLUDED */
|
||||
+763
-793
File diff suppressed because it is too large.
Load diff
+316
-321
@@ -1,321 +1,316 @@
|
||||
/*
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
||||
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
|
||||
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
|
||||
Copyright (c) 2002-2005 Karl Waclawek <karl@waclawek.net>
|
||||
Copyright (c) 2016-2024 Sebastian Pipping <sebastian@pipping.org>
|
||||
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef XmlTok_INCLUDED
|
||||
# define XmlTok_INCLUDED 1
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
/* The following token may be returned by XmlContentTok */
|
||||
# define XML_TOK_TRAILING_RSQB \
|
||||
-5 /* ] or ]] at the end of the scan; might be \
|
||||
start of illegal ]]> sequence */
|
||||
/* The following tokens may be returned by both XmlPrologTok and
|
||||
XmlContentTok.
|
||||
*/
|
||||
# define XML_TOK_NONE -4 /* The string to be scanned is empty */
|
||||
# define XML_TOK_TRAILING_CR \
|
||||
-3 /* A CR at the end of the scan; \
|
||||
might be part of CRLF sequence */
|
||||
# define XML_TOK_PARTIAL_CHAR -2 /* only part of a multibyte sequence */
|
||||
# define XML_TOK_PARTIAL -1 /* only part of a token */
|
||||
# define XML_TOK_INVALID 0
|
||||
|
||||
/* The following tokens are returned by XmlContentTok; some are also
|
||||
returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok.
|
||||
*/
|
||||
# define XML_TOK_START_TAG_WITH_ATTS 1
|
||||
# define XML_TOK_START_TAG_NO_ATTS 2
|
||||
# define XML_TOK_EMPTY_ELEMENT_WITH_ATTS 3 /* empty element tag <e/> */
|
||||
# define XML_TOK_EMPTY_ELEMENT_NO_ATTS 4
|
||||
# define XML_TOK_END_TAG 5
|
||||
# define XML_TOK_DATA_CHARS 6
|
||||
# define XML_TOK_DATA_NEWLINE 7
|
||||
# define XML_TOK_CDATA_SECT_OPEN 8
|
||||
# define XML_TOK_ENTITY_REF 9
|
||||
# define XML_TOK_CHAR_REF 10 /* numeric character reference */
|
||||
|
||||
/* The following tokens may be returned by both XmlPrologTok and
|
||||
XmlContentTok.
|
||||
*/
|
||||
# define XML_TOK_PI 11 /* processing instruction */
|
||||
# define XML_TOK_XML_DECL 12 /* XML decl or text decl */
|
||||
# define XML_TOK_COMMENT 13
|
||||
# define XML_TOK_BOM 14 /* Byte order mark */
|
||||
|
||||
/* The following tokens are returned only by XmlPrologTok */
|
||||
# define XML_TOK_PROLOG_S 15
|
||||
# define XML_TOK_DECL_OPEN 16 /* <!foo */
|
||||
# define XML_TOK_DECL_CLOSE 17 /* > */
|
||||
# define XML_TOK_NAME 18
|
||||
# define XML_TOK_NMTOKEN 19
|
||||
# define XML_TOK_POUND_NAME 20 /* #name */
|
||||
# define XML_TOK_OR 21 /* | */
|
||||
# define XML_TOK_PERCENT 22
|
||||
# define XML_TOK_OPEN_PAREN 23
|
||||
# define XML_TOK_CLOSE_PAREN 24
|
||||
# define XML_TOK_OPEN_BRACKET 25
|
||||
# define XML_TOK_CLOSE_BRACKET 26
|
||||
# define XML_TOK_LITERAL 27
|
||||
# define XML_TOK_PARAM_ENTITY_REF 28
|
||||
# define XML_TOK_INSTANCE_START 29
|
||||
|
||||
/* The following occur only in element type declarations */
|
||||
# define XML_TOK_NAME_QUESTION 30 /* name? */
|
||||
# define XML_TOK_NAME_ASTERISK 31 /* name* */
|
||||
# define XML_TOK_NAME_PLUS 32 /* name+ */
|
||||
# define XML_TOK_COND_SECT_OPEN 33 /* <![ */
|
||||
# define XML_TOK_COND_SECT_CLOSE 34 /* ]]> */
|
||||
# define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */
|
||||
# define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */
|
||||
# define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */
|
||||
# define XML_TOK_COMMA 38
|
||||
|
||||
/* The following token is returned only by XmlAttributeValueTok */
|
||||
# define XML_TOK_ATTRIBUTE_VALUE_S 39
|
||||
|
||||
/* The following token is returned only by XmlCdataSectionTok */
|
||||
# define XML_TOK_CDATA_SECT_CLOSE 40
|
||||
|
||||
/* With namespace processing this is returned by XmlPrologTok for a
|
||||
name with a colon.
|
||||
*/
|
||||
# define XML_TOK_PREFIXED_NAME 41
|
||||
|
||||
# ifdef XML_DTD
|
||||
# define XML_TOK_IGNORE_SECT 42
|
||||
# endif /* XML_DTD */
|
||||
|
||||
# ifdef XML_DTD
|
||||
# define XML_N_STATES 4
|
||||
# else /* not XML_DTD */
|
||||
# define XML_N_STATES 3
|
||||
# endif /* not XML_DTD */
|
||||
|
||||
# define XML_PROLOG_STATE 0
|
||||
# define XML_CONTENT_STATE 1
|
||||
# define XML_CDATA_SECTION_STATE 2
|
||||
# ifdef XML_DTD
|
||||
# define XML_IGNORE_SECTION_STATE 3
|
||||
# endif /* XML_DTD */
|
||||
|
||||
# define XML_N_LITERAL_TYPES 2
|
||||
# define XML_ATTRIBUTE_VALUE_LITERAL 0
|
||||
# define XML_ENTITY_VALUE_LITERAL 1
|
||||
|
||||
/* The size of the buffer passed to XmlUtf8Encode must be at least this. */
|
||||
# define XML_UTF8_ENCODE_MAX 4
|
||||
/* The size of the buffer passed to XmlUtf16Encode must be at least this. */
|
||||
# define XML_UTF16_ENCODE_MAX 2
|
||||
|
||||
typedef struct position {
|
||||
/* first line and first column are 0 not 1 */
|
||||
XML_Size lineNumber;
|
||||
XML_Size columnNumber;
|
||||
} POSITION;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *valuePtr;
|
||||
const char *valueEnd;
|
||||
char normalized;
|
||||
} ATTRIBUTE;
|
||||
|
||||
struct encoding;
|
||||
typedef struct encoding ENCODING;
|
||||
|
||||
typedef int(PTRCALL *SCANNER)(const ENCODING *, const char *, const char *,
|
||||
const char **);
|
||||
|
||||
enum XML_Convert_Result {
|
||||
XML_CONVERT_COMPLETED = 0,
|
||||
XML_CONVERT_INPUT_INCOMPLETE = 1,
|
||||
XML_CONVERT_OUTPUT_EXHAUSTED
|
||||
= 2 /* and therefore potentially input remaining as well */
|
||||
};
|
||||
|
||||
struct encoding {
|
||||
SCANNER scanners[XML_N_STATES];
|
||||
SCANNER literalScanners[XML_N_LITERAL_TYPES];
|
||||
int(PTRCALL *nameMatchesAscii)(const ENCODING *, const char *, const char *,
|
||||
const char *);
|
||||
int(PTRFASTCALL *nameLength)(const ENCODING *, const char *);
|
||||
const char *(PTRFASTCALL *skipS)(const ENCODING *, const char *);
|
||||
int(PTRCALL *getAtts)(const ENCODING *enc, const char *ptr, int attsMax,
|
||||
ATTRIBUTE *atts);
|
||||
int(PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr);
|
||||
int(PTRCALL *predefinedEntityName)(const ENCODING *, const char *,
|
||||
const char *);
|
||||
void(PTRCALL *updatePosition)(const ENCODING *, const char *ptr,
|
||||
const char *end, POSITION *);
|
||||
int(PTRCALL *isPublicId)(const ENCODING *enc, const char *ptr,
|
||||
const char *end, const char **badPtr);
|
||||
enum XML_Convert_Result(PTRCALL *utf8Convert)(const ENCODING *enc,
|
||||
const char **fromP,
|
||||
const char *fromLim, char **toP,
|
||||
const char *toLim);
|
||||
enum XML_Convert_Result(PTRCALL *utf16Convert)(const ENCODING *enc,
|
||||
const char **fromP,
|
||||
const char *fromLim,
|
||||
unsigned short **toP,
|
||||
const unsigned short *toLim);
|
||||
int minBytesPerChar;
|
||||
char isUtf8;
|
||||
char isUtf16;
|
||||
};
|
||||
|
||||
/* Scan the string starting at ptr until the end of the next complete
|
||||
token, but do not scan past eptr. Return an integer giving the
|
||||
type of token.
|
||||
|
||||
Return XML_TOK_NONE when ptr == eptr; nextTokPtr will not be set.
|
||||
|
||||
Return XML_TOK_PARTIAL when the string does not contain a complete
|
||||
token; nextTokPtr will not be set.
|
||||
|
||||
Return XML_TOK_INVALID when the string does not start a valid
|
||||
token; nextTokPtr will be set to point to the character which made
|
||||
the token invalid.
|
||||
|
||||
Otherwise the string starts with a valid token; nextTokPtr will be
|
||||
set to point to the character following the end of that token.
|
||||
|
||||
Each data character counts as a single token, but adjacent data
|
||||
characters may be returned together. Similarly for characters in
|
||||
the prolog outside literals, comments and processing instructions.
|
||||
*/
|
||||
|
||||
# define XmlTok(enc, state, ptr, end, nextTokPtr) \
|
||||
(((enc)->scanners[state])(enc, ptr, end, nextTokPtr))
|
||||
|
||||
# define XmlPrologTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
# define XmlContentTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
# define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
# ifdef XML_DTD
|
||||
|
||||
# define XmlIgnoreSectionTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_IGNORE_SECTION_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
# endif /* XML_DTD */
|
||||
|
||||
/* This is used for performing a 2nd-level tokenization on the content
|
||||
of a literal that has already been returned by XmlTok.
|
||||
*/
|
||||
# define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \
|
||||
(((enc)->literalScanners[literalType])(enc, ptr, end, nextTokPtr))
|
||||
|
||||
# define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr)
|
||||
|
||||
# define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr)
|
||||
|
||||
# define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \
|
||||
(((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2))
|
||||
|
||||
# define XmlNameLength(enc, ptr) (((enc)->nameLength)(enc, ptr))
|
||||
|
||||
# define XmlSkipS(enc, ptr) (((enc)->skipS)(enc, ptr))
|
||||
|
||||
# define XmlGetAttributes(enc, ptr, attsMax, atts) \
|
||||
(((enc)->getAtts)(enc, ptr, attsMax, atts))
|
||||
|
||||
# define XmlCharRefNumber(enc, ptr) (((enc)->charRefNumber)(enc, ptr))
|
||||
|
||||
# define XmlPredefinedEntityName(enc, ptr, end) \
|
||||
(((enc)->predefinedEntityName)(enc, ptr, end))
|
||||
|
||||
# define XmlUpdatePosition(enc, ptr, end, pos) \
|
||||
(((enc)->updatePosition)(enc, ptr, end, pos))
|
||||
|
||||
# define XmlIsPublicId(enc, ptr, end, badPtr) \
|
||||
(((enc)->isPublicId)(enc, ptr, end, badPtr))
|
||||
|
||||
# define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \
|
||||
(((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim))
|
||||
|
||||
# define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \
|
||||
(((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim))
|
||||
|
||||
typedef struct {
|
||||
ENCODING initEnc;
|
||||
const ENCODING **encPtr;
|
||||
} INIT_ENCODING;
|
||||
|
||||
int XmlParseXmlDecl(int isGeneralTextEntity, const ENCODING *enc,
|
||||
const char *ptr, const char *end, const char **badPtr,
|
||||
const char **versionPtr, const char **versionEndPtr,
|
||||
const char **encodingNamePtr,
|
||||
const ENCODING **namedEncodingPtr, int *standalonePtr);
|
||||
|
||||
int XmlInitEncoding(INIT_ENCODING *p, const ENCODING **encPtr,
|
||||
const char *name);
|
||||
const ENCODING *XmlGetUtf8InternalEncoding(void);
|
||||
const ENCODING *XmlGetUtf16InternalEncoding(void);
|
||||
int FASTCALL XmlUtf8Encode(int charNumber, char *buf);
|
||||
int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf);
|
||||
int XmlSizeOfUnknownEncoding(void);
|
||||
|
||||
typedef int(XMLCALL *CONVERTER)(void *userData, const char *p);
|
||||
|
||||
ENCODING *XmlInitUnknownEncoding(void *mem, const int *table, CONVERTER convert,
|
||||
void *userData);
|
||||
|
||||
int XmlParseXmlDeclNS(int isGeneralTextEntity, const ENCODING *enc,
|
||||
const char *ptr, const char *end, const char **badPtr,
|
||||
const char **versionPtr, const char **versionEndPtr,
|
||||
const char **encodingNamePtr,
|
||||
const ENCODING **namedEncodingPtr, int *standalonePtr);
|
||||
|
||||
int XmlInitEncodingNS(INIT_ENCODING *p, const ENCODING **encPtr,
|
||||
const char *name);
|
||||
const ENCODING *XmlGetUtf8InternalEncodingNS(void);
|
||||
const ENCODING *XmlGetUtf16InternalEncodingNS(void);
|
||||
ENCODING *XmlInitUnknownEncodingNS(void *mem, const int *table,
|
||||
CONVERTER convert, void *userData);
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif /* not XmlTok_INCLUDED */
|
||||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
#ifndef XmlTok_INCLUDED
|
||||
#define XmlTok_INCLUDED 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* The following token may be returned by XmlContentTok */
|
||||
#define XML_TOK_TRAILING_RSQB -5 /* ] or ]] at the end of the scan; might be
|
||||
start of illegal ]]> sequence */
|
||||
/* The following tokens may be returned by both XmlPrologTok and
|
||||
XmlContentTok.
|
||||
*/
|
||||
#define XML_TOK_NONE -4 /* The string to be scanned is empty */
|
||||
#define XML_TOK_TRAILING_CR -3 /* A CR at the end of the scan;
|
||||
might be part of CRLF sequence */
|
||||
#define XML_TOK_PARTIAL_CHAR -2 /* only part of a multibyte sequence */
|
||||
#define XML_TOK_PARTIAL -1 /* only part of a token */
|
||||
#define XML_TOK_INVALID 0
|
||||
|
||||
/* The following tokens are returned by XmlContentTok; some are also
|
||||
returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok.
|
||||
*/
|
||||
#define XML_TOK_START_TAG_WITH_ATTS 1
|
||||
#define XML_TOK_START_TAG_NO_ATTS 2
|
||||
#define XML_TOK_EMPTY_ELEMENT_WITH_ATTS 3 /* empty element tag <e/> */
|
||||
#define XML_TOK_EMPTY_ELEMENT_NO_ATTS 4
|
||||
#define XML_TOK_END_TAG 5
|
||||
#define XML_TOK_DATA_CHARS 6
|
||||
#define XML_TOK_DATA_NEWLINE 7
|
||||
#define XML_TOK_CDATA_SECT_OPEN 8
|
||||
#define XML_TOK_ENTITY_REF 9
|
||||
#define XML_TOK_CHAR_REF 10 /* numeric character reference */
|
||||
|
||||
/* The following tokens may be returned by both XmlPrologTok and
|
||||
XmlContentTok.
|
||||
*/
|
||||
#define XML_TOK_PI 11 /* processing instruction */
|
||||
#define XML_TOK_XML_DECL 12 /* XML decl or text decl */
|
||||
#define XML_TOK_COMMENT 13
|
||||
#define XML_TOK_BOM 14 /* Byte order mark */
|
||||
|
||||
/* The following tokens are returned only by XmlPrologTok */
|
||||
#define XML_TOK_PROLOG_S 15
|
||||
#define XML_TOK_DECL_OPEN 16 /* <!foo */
|
||||
#define XML_TOK_DECL_CLOSE 17 /* > */
|
||||
#define XML_TOK_NAME 18
|
||||
#define XML_TOK_NMTOKEN 19
|
||||
#define XML_TOK_POUND_NAME 20 /* #name */
|
||||
#define XML_TOK_OR 21 /* | */
|
||||
#define XML_TOK_PERCENT 22
|
||||
#define XML_TOK_OPEN_PAREN 23
|
||||
#define XML_TOK_CLOSE_PAREN 24
|
||||
#define XML_TOK_OPEN_BRACKET 25
|
||||
#define XML_TOK_CLOSE_BRACKET 26
|
||||
#define XML_TOK_LITERAL 27
|
||||
#define XML_TOK_PARAM_ENTITY_REF 28
|
||||
#define XML_TOK_INSTANCE_START 29
|
||||
|
||||
/* The following occur only in element type declarations */
|
||||
#define XML_TOK_NAME_QUESTION 30 /* name? */
|
||||
#define XML_TOK_NAME_ASTERISK 31 /* name* */
|
||||
#define XML_TOK_NAME_PLUS 32 /* name+ */
|
||||
#define XML_TOK_COND_SECT_OPEN 33 /* <![ */
|
||||
#define XML_TOK_COND_SECT_CLOSE 34 /* ]]> */
|
||||
#define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */
|
||||
#define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */
|
||||
#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */
|
||||
#define XML_TOK_COMMA 38
|
||||
|
||||
/* The following token is returned only by XmlAttributeValueTok */
|
||||
#define XML_TOK_ATTRIBUTE_VALUE_S 39
|
||||
|
||||
/* The following token is returned only by XmlCdataSectionTok */
|
||||
#define XML_TOK_CDATA_SECT_CLOSE 40
|
||||
|
||||
/* With namespace processing this is returned by XmlPrologTok for a
|
||||
name with a colon.
|
||||
*/
|
||||
#define XML_TOK_PREFIXED_NAME 41
|
||||
|
||||
#ifdef XML_DTD
|
||||
#define XML_TOK_IGNORE_SECT 42
|
||||
#endif /* XML_DTD */
|
||||
|
||||
#ifdef XML_DTD
|
||||
#define XML_N_STATES 4
|
||||
#else /* not XML_DTD */
|
||||
#define XML_N_STATES 3
|
||||
#endif /* not XML_DTD */
|
||||
|
||||
#define XML_PROLOG_STATE 0
|
||||
#define XML_CONTENT_STATE 1
|
||||
#define XML_CDATA_SECTION_STATE 2
|
||||
#ifdef XML_DTD
|
||||
#define XML_IGNORE_SECTION_STATE 3
|
||||
#endif /* XML_DTD */
|
||||
|
||||
#define XML_N_LITERAL_TYPES 2
|
||||
#define XML_ATTRIBUTE_VALUE_LITERAL 0
|
||||
#define XML_ENTITY_VALUE_LITERAL 1
|
||||
|
||||
/* The size of the buffer passed to XmlUtf8Encode must be at least this. */
|
||||
#define XML_UTF8_ENCODE_MAX 4
|
||||
/* The size of the buffer passed to XmlUtf16Encode must be at least this. */
|
||||
#define XML_UTF16_ENCODE_MAX 2
|
||||
|
||||
typedef struct position {
|
||||
/* first line and first column are 0 not 1 */
|
||||
XML_Size lineNumber;
|
||||
XML_Size columnNumber;
|
||||
} POSITION;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *valuePtr;
|
||||
const char *valueEnd;
|
||||
char normalized;
|
||||
} ATTRIBUTE;
|
||||
|
||||
struct encoding;
|
||||
typedef struct encoding ENCODING;
|
||||
|
||||
typedef int (PTRCALL *SCANNER)(const ENCODING *,
|
||||
const char *,
|
||||
const char *,
|
||||
const char **);
|
||||
|
||||
struct encoding {
|
||||
SCANNER scanners[XML_N_STATES];
|
||||
SCANNER literalScanners[XML_N_LITERAL_TYPES];
|
||||
int (PTRCALL *sameName)(const ENCODING *,
|
||||
const char *,
|
||||
const char *);
|
||||
int (PTRCALL *nameMatchesAscii)(const ENCODING *,
|
||||
const char *,
|
||||
const char *,
|
||||
const char *);
|
||||
int (PTRFASTCALL *nameLength)(const ENCODING *, const char *);
|
||||
const char *(PTRFASTCALL *skipS)(const ENCODING *, const char *);
|
||||
int (PTRCALL *getAtts)(const ENCODING *enc,
|
||||
const char *ptr,
|
||||
int attsMax,
|
||||
ATTRIBUTE *atts);
|
||||
int (PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr);
|
||||
int (PTRCALL *predefinedEntityName)(const ENCODING *,
|
||||
const char *,
|
||||
const char *);
|
||||
void (PTRCALL *updatePosition)(const ENCODING *,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
POSITION *);
|
||||
int (PTRCALL *isPublicId)(const ENCODING *enc,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
const char **badPtr);
|
||||
void (PTRCALL *utf8Convert)(const ENCODING *enc,
|
||||
const char **fromP,
|
||||
const char *fromLim,
|
||||
char **toP,
|
||||
const char *toLim);
|
||||
void (PTRCALL *utf16Convert)(const ENCODING *enc,
|
||||
const char **fromP,
|
||||
const char *fromLim,
|
||||
unsigned short **toP,
|
||||
const unsigned short *toLim);
|
||||
int minBytesPerChar;
|
||||
char isUtf8;
|
||||
char isUtf16;
|
||||
};
|
||||
|
||||
/* Scan the string starting at ptr until the end of the next complete
|
||||
token, but do not scan past eptr. Return an integer giving the
|
||||
type of token.
|
||||
|
||||
Return XML_TOK_NONE when ptr == eptr; nextTokPtr will not be set.
|
||||
|
||||
Return XML_TOK_PARTIAL when the string does not contain a complete
|
||||
token; nextTokPtr will not be set.
|
||||
|
||||
Return XML_TOK_INVALID when the string does not start a valid
|
||||
token; nextTokPtr will be set to point to the character which made
|
||||
the token invalid.
|
||||
|
||||
Otherwise the string starts with a valid token; nextTokPtr will be
|
||||
set to point to the character following the end of that token.
|
||||
|
||||
Each data character counts as a single token, but adjacent data
|
||||
characters may be returned together. Similarly for characters in
|
||||
the prolog outside literals, comments and processing instructions.
|
||||
*/
|
||||
|
||||
|
||||
#define XmlTok(enc, state, ptr, end, nextTokPtr) \
|
||||
(((enc)->scanners[state])(enc, ptr, end, nextTokPtr))
|
||||
|
||||
#define XmlPrologTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
#define XmlContentTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
#define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
#ifdef XML_DTD
|
||||
|
||||
#define XmlIgnoreSectionTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_IGNORE_SECTION_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
#endif /* XML_DTD */
|
||||
|
||||
/* This is used for performing a 2nd-level tokenization on the content
|
||||
of a literal that has already been returned by XmlTok.
|
||||
*/
|
||||
#define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \
|
||||
(((enc)->literalScanners[literalType])(enc, ptr, end, nextTokPtr))
|
||||
|
||||
#define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr)
|
||||
|
||||
#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr)
|
||||
|
||||
#define XmlSameName(enc, ptr1, ptr2) (((enc)->sameName)(enc, ptr1, ptr2))
|
||||
|
||||
#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \
|
||||
(((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2))
|
||||
|
||||
#define XmlNameLength(enc, ptr) \
|
||||
(((enc)->nameLength)(enc, ptr))
|
||||
|
||||
#define XmlSkipS(enc, ptr) \
|
||||
(((enc)->skipS)(enc, ptr))
|
||||
|
||||
#define XmlGetAttributes(enc, ptr, attsMax, atts) \
|
||||
(((enc)->getAtts)(enc, ptr, attsMax, atts))
|
||||
|
||||
#define XmlCharRefNumber(enc, ptr) \
|
||||
(((enc)->charRefNumber)(enc, ptr))
|
||||
|
||||
#define XmlPredefinedEntityName(enc, ptr, end) \
|
||||
(((enc)->predefinedEntityName)(enc, ptr, end))
|
||||
|
||||
#define XmlUpdatePosition(enc, ptr, end, pos) \
|
||||
(((enc)->updatePosition)(enc, ptr, end, pos))
|
||||
|
||||
#define XmlIsPublicId(enc, ptr, end, badPtr) \
|
||||
(((enc)->isPublicId)(enc, ptr, end, badPtr))
|
||||
|
||||
#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \
|
||||
(((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim))
|
||||
|
||||
#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \
|
||||
(((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim))
|
||||
|
||||
typedef struct {
|
||||
ENCODING initEnc;
|
||||
const ENCODING **encPtr;
|
||||
} INIT_ENCODING;
|
||||
|
||||
int XmlParseXmlDecl(int isGeneralTextEntity,
|
||||
const ENCODING *enc,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
const char **badPtr,
|
||||
const char **versionPtr,
|
||||
const char **versionEndPtr,
|
||||
const char **encodingNamePtr,
|
||||
const ENCODING **namedEncodingPtr,
|
||||
int *standalonePtr);
|
||||
|
||||
int XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name);
|
||||
const ENCODING *XmlGetUtf8InternalEncoding(void);
|
||||
const ENCODING *XmlGetUtf16InternalEncoding(void);
|
||||
int FASTCALL XmlUtf8Encode(int charNumber, char *buf);
|
||||
int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf);
|
||||
int XmlSizeOfUnknownEncoding(void);
|
||||
|
||||
|
||||
typedef int (XMLCALL *CONVERTER) (void *userData, const char *p);
|
||||
|
||||
ENCODING *
|
||||
XmlInitUnknownEncoding(void *mem,
|
||||
int *table,
|
||||
CONVERTER convert,
|
||||
void *userData);
|
||||
|
||||
int XmlParseXmlDeclNS(int isGeneralTextEntity,
|
||||
const ENCODING *enc,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
const char **badPtr,
|
||||
const char **versionPtr,
|
||||
const char **versionEndPtr,
|
||||
const char **encodingNamePtr,
|
||||
const ENCODING **namedEncodingPtr,
|
||||
int *standalonePtr);
|
||||
|
||||
int XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name);
|
||||
const ENCODING *XmlGetUtf8InternalEncodingNS(void);
|
||||
const ENCODING *XmlGetUtf16InternalEncodingNS(void);
|
||||
ENCODING *
|
||||
XmlInitUnknownEncodingNS(void *mem,
|
||||
int *table,
|
||||
CONVERTER convert,
|
||||
void *userData);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* not XmlTok_INCLUDED */
|
||||
+1779
-1819
File diff suppressed because it is too large.
Load diff
@@ -1,74 +1,46 @@
|
||||
/*
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
||||
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
|
||||
Copyright (c) 2017-2019 Sebastian Pipping <sebastian@pipping.org>
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
enum {
|
||||
BT_NONXML, /* e.g. noncharacter-FFFF */
|
||||
BT_MALFORM, /* illegal, with regard to encoding */
|
||||
BT_LT, /* less than = "<" */
|
||||
BT_AMP, /* ampersand = "&" */
|
||||
BT_RSQB, /* right square bracket = "[" */
|
||||
BT_LEAD2, /* lead byte of a 2-byte UTF-8 character */
|
||||
BT_LEAD3, /* lead byte of a 3-byte UTF-8 character */
|
||||
BT_LEAD4, /* lead byte of a 4-byte UTF-8 character */
|
||||
BT_TRAIL, /* trailing unit, e.g. second 16-bit unit of a 4-byte char. */
|
||||
BT_CR, /* carriage return = "\r" */
|
||||
BT_LF, /* line feed = "\n" */
|
||||
BT_GT, /* greater than = ">" */
|
||||
BT_QUOT, /* quotation character = "\"" */
|
||||
BT_APOS, /* apostrophe = "'" */
|
||||
BT_EQUALS, /* equal sign = "=" */
|
||||
BT_QUEST, /* question mark = "?" */
|
||||
BT_EXCL, /* exclamation mark = "!" */
|
||||
BT_SOL, /* solidus, slash = "/" */
|
||||
BT_SEMI, /* semicolon = ";" */
|
||||
BT_NUM, /* number sign = "#" */
|
||||
BT_LSQB, /* left square bracket = "[" */
|
||||
BT_S, /* white space, e.g. "\t", " "[, "\r"] */
|
||||
BT_NMSTRT, /* non-hex name start letter = "G".."Z" + "g".."z" + "_" */
|
||||
BT_COLON, /* colon = ":" */
|
||||
BT_HEX, /* hex letter = "A".."F" + "a".."f" */
|
||||
BT_DIGIT, /* digit = "0".."9" */
|
||||
BT_NAME, /* dot and middle dot = "." + chr(0xb7) */
|
||||
BT_MINUS, /* minus = "-" */
|
||||
BT_OTHER, /* known not to be a name or name start character */
|
||||
BT_NONASCII, /* might be a name or name start character */
|
||||
BT_PERCNT, /* percent sign = "%" */
|
||||
BT_LPAR, /* left parenthesis = "(" */
|
||||
BT_RPAR, /* right parenthesis = "(" */
|
||||
BT_AST, /* asterisk = "*" */
|
||||
BT_PLUS, /* plus sign = "+" */
|
||||
BT_COMMA, /* comma = "," */
|
||||
BT_VERBAR /* vertical bar = "|" */
|
||||
};
|
||||
|
||||
#include <stddef.h>
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
enum {
|
||||
BT_NONXML,
|
||||
BT_MALFORM,
|
||||
BT_LT,
|
||||
BT_AMP,
|
||||
BT_RSQB,
|
||||
BT_LEAD2,
|
||||
BT_LEAD3,
|
||||
BT_LEAD4,
|
||||
BT_TRAIL,
|
||||
BT_CR,
|
||||
BT_LF,
|
||||
BT_GT,
|
||||
BT_QUOT,
|
||||
BT_APOS,
|
||||
BT_EQUALS,
|
||||
BT_QUEST,
|
||||
BT_EXCL,
|
||||
BT_SOL,
|
||||
BT_SEMI,
|
||||
BT_NUM,
|
||||
BT_LSQB,
|
||||
BT_S,
|
||||
BT_NMSTRT,
|
||||
BT_COLON,
|
||||
BT_HEX,
|
||||
BT_DIGIT,
|
||||
BT_NAME,
|
||||
BT_MINUS,
|
||||
BT_OTHER, /* known not to be a name or name start character */
|
||||
BT_NONASCII, /* might be a name or name start character */
|
||||
BT_PERCNT,
|
||||
BT_LPAR,
|
||||
BT_RPAR,
|
||||
BT_AST,
|
||||
BT_PLUS,
|
||||
BT_COMMA,
|
||||
BT_VERBAR
|
||||
};
|
||||
|
||||
#include <stddef.h>
|
||||
+106
-122
@@ -1,122 +1,106 @@
|
||||
/* This file is included!
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
||||
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
|
||||
Copyright (c) 2002 Greg Stein <gstein@users.sourceforge.net>
|
||||
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
|
||||
Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
|
||||
Copyright (c) 2017-2021 Sebastian Pipping <sebastian@pipping.org>
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef XML_TOK_NS_C
|
||||
|
||||
const ENCODING *
|
||||
NS(XmlGetUtf8InternalEncoding)(void) {
|
||||
return &ns(internal_utf8_encoding).enc;
|
||||
}
|
||||
|
||||
const ENCODING *
|
||||
NS(XmlGetUtf16InternalEncoding)(void) {
|
||||
# if BYTEORDER == 1234
|
||||
return &ns(internal_little2_encoding).enc;
|
||||
# elif BYTEORDER == 4321
|
||||
return &ns(internal_big2_encoding).enc;
|
||||
# else
|
||||
const short n = 1;
|
||||
return (*(const char *)&n ? &ns(internal_little2_encoding).enc
|
||||
: &ns(internal_big2_encoding).enc);
|
||||
# endif
|
||||
}
|
||||
|
||||
static const ENCODING *const NS(encodings)[] = {
|
||||
&ns(latin1_encoding).enc, &ns(ascii_encoding).enc,
|
||||
&ns(utf8_encoding).enc, &ns(big2_encoding).enc,
|
||||
&ns(big2_encoding).enc, &ns(little2_encoding).enc,
|
||||
&ns(utf8_encoding).enc /* NO_ENC */
|
||||
};
|
||||
|
||||
static int PTRCALL
|
||||
NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
const char **nextTokPtr) {
|
||||
return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_PROLOG_STATE,
|
||||
ptr, end, nextTokPtr);
|
||||
}
|
||||
|
||||
static int PTRCALL
|
||||
NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
const char **nextTokPtr) {
|
||||
return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_CONTENT_STATE,
|
||||
ptr, end, nextTokPtr);
|
||||
}
|
||||
|
||||
int
|
||||
NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr,
|
||||
const char *name) {
|
||||
int i = getEncodingIndex(name);
|
||||
if (i == UNKNOWN_ENC)
|
||||
return 0;
|
||||
SET_INIT_ENC_INDEX(p, i);
|
||||
p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog);
|
||||
p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent);
|
||||
p->initEnc.updatePosition = initUpdatePosition;
|
||||
p->encPtr = encPtr;
|
||||
*encPtr = &(p->initEnc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const ENCODING *
|
||||
NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end) {
|
||||
# define ENCODING_MAX 128
|
||||
char buf[ENCODING_MAX] = "";
|
||||
char *p = buf;
|
||||
int i;
|
||||
XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);
|
||||
if (ptr != end)
|
||||
return 0;
|
||||
*p = 0;
|
||||
if (streqci(buf, KW_UTF_16) && enc->minBytesPerChar == 2)
|
||||
return enc;
|
||||
i = getEncodingIndex(buf);
|
||||
if (i == UNKNOWN_ENC)
|
||||
return 0;
|
||||
return NS(encodings)[i];
|
||||
}
|
||||
|
||||
int
|
||||
NS(XmlParseXmlDecl)(int isGeneralTextEntity, const ENCODING *enc,
|
||||
const char *ptr, const char *end, const char **badPtr,
|
||||
const char **versionPtr, const char **versionEndPtr,
|
||||
const char **encodingName, const ENCODING **encoding,
|
||||
int *standalone) {
|
||||
return doParseXmlDecl(NS(findEncoding), isGeneralTextEntity, enc, ptr, end,
|
||||
badPtr, versionPtr, versionEndPtr, encodingName,
|
||||
encoding, standalone);
|
||||
}
|
||||
|
||||
#endif /* XML_TOK_NS_C */
|
||||
const ENCODING *
|
||||
NS(XmlGetUtf8InternalEncoding)(void)
|
||||
{
|
||||
return &ns(internal_utf8_encoding).enc;
|
||||
}
|
||||
|
||||
const ENCODING *
|
||||
NS(XmlGetUtf16InternalEncoding)(void)
|
||||
{
|
||||
#if BYTEORDER == 1234
|
||||
return &ns(internal_little2_encoding).enc;
|
||||
#elif BYTEORDER == 4321
|
||||
return &ns(internal_big2_encoding).enc;
|
||||
#else
|
||||
const short n = 1;
|
||||
return (*(const char *)&n
|
||||
? &ns(internal_little2_encoding).enc
|
||||
: &ns(internal_big2_encoding).enc);
|
||||
#endif
|
||||
}
|
||||
|
||||
static const ENCODING * const NS(encodings)[] = {
|
||||
&ns(latin1_encoding).enc,
|
||||
&ns(ascii_encoding).enc,
|
||||
&ns(utf8_encoding).enc,
|
||||
&ns(big2_encoding).enc,
|
||||
&ns(big2_encoding).enc,
|
||||
&ns(little2_encoding).enc,
|
||||
&ns(utf8_encoding).enc /* NO_ENC */
|
||||
};
|
||||
|
||||
static int PTRCALL
|
||||
NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
const char **nextTokPtr)
|
||||
{
|
||||
return initScan(NS(encodings), (const INIT_ENCODING *)enc,
|
||||
XML_PROLOG_STATE, ptr, end, nextTokPtr);
|
||||
}
|
||||
|
||||
static int PTRCALL
|
||||
NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
const char **nextTokPtr)
|
||||
{
|
||||
return initScan(NS(encodings), (const INIT_ENCODING *)enc,
|
||||
XML_CONTENT_STATE, ptr, end, nextTokPtr);
|
||||
}
|
||||
|
||||
int
|
||||
NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr,
|
||||
const char *name)
|
||||
{
|
||||
int i = getEncodingIndex(name);
|
||||
if (i == UNKNOWN_ENC)
|
||||
return 0;
|
||||
SET_INIT_ENC_INDEX(p, i);
|
||||
p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog);
|
||||
p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent);
|
||||
p->initEnc.updatePosition = initUpdatePosition;
|
||||
p->encPtr = encPtr;
|
||||
*encPtr = &(p->initEnc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const ENCODING *
|
||||
NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end)
|
||||
{
|
||||
#define ENCODING_MAX 128
|
||||
char buf[ENCODING_MAX];
|
||||
char *p = buf;
|
||||
int i;
|
||||
XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);
|
||||
if (ptr != end)
|
||||
return 0;
|
||||
*p = 0;
|
||||
if (streqci(buf, KW_UTF_16) && enc->minBytesPerChar == 2)
|
||||
return enc;
|
||||
i = getEncodingIndex(buf);
|
||||
if (i == UNKNOWN_ENC)
|
||||
return 0;
|
||||
return NS(encodings)[i];
|
||||
}
|
||||
|
||||
int
|
||||
NS(XmlParseXmlDecl)(int isGeneralTextEntity,
|
||||
const ENCODING *enc,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
const char **badPtr,
|
||||
const char **versionPtr,
|
||||
const char **versionEndPtr,
|
||||
const char **encodingName,
|
||||
const ENCODING **encoding,
|
||||
int *standalone)
|
||||
{
|
||||
return doParseXmlDecl(NS(findEncoding),
|
||||
isGeneralTextEntity,
|
||||
enc,
|
||||
ptr,
|
||||
end,
|
||||
badPtr,
|
||||
versionPtr,
|
||||
versionEndPtr,
|
||||
encodingName,
|
||||
encoding,
|
||||
standalone);
|
||||
}
|
||||
+2
-12
@@ -3,19 +3,9 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DIRS += ['lib']
|
||||
|
||||
EXPORTS += [
|
||||
'expat_config.h',
|
||||
'lib/expat.h',
|
||||
'lib/expat_external.h',
|
||||
'moz_expat.h',
|
||||
]
|
||||
|
||||
SOURCES += [
|
||||
'lib/xmlrole.c',
|
||||
'moz_xmlparse.c',
|
||||
'moz_xmltok.c',
|
||||
]
|
||||
|
||||
FINAL_LIBRARY = 'gkmedias'
|
||||
|
||||
DEFINES['HAVE_EXPAT_CONFIG_H'] = True
|
||||
@@ -1,134 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef MOZ_EXPAT_H_
|
||||
#define MOZ_EXPAT_H_
|
||||
|
||||
#include "expat_config.h"
|
||||
#include "expat.h"
|
||||
#include "mozilla/Types.h"
|
||||
|
||||
MOZ_BEGIN_EXTERN_C
|
||||
|
||||
void
|
||||
MOZ_XML_SetXmlDeclHandler(XML_Parser parser,
|
||||
XML_XmlDeclHandler xmldecl);
|
||||
|
||||
XML_Parser
|
||||
MOZ_XML_ParserCreate_MM(const XML_Char *encoding,
|
||||
const XML_Memory_Handling_Suite *memsuite,
|
||||
const XML_Char *namespaceSeparator);
|
||||
|
||||
void
|
||||
MOZ_XML_SetElementHandler(XML_Parser parser,
|
||||
XML_StartElementHandler start,
|
||||
XML_EndElementHandler end);
|
||||
|
||||
void
|
||||
MOZ_XML_SetCharacterDataHandler(XML_Parser parser,
|
||||
XML_CharacterDataHandler handler);
|
||||
|
||||
void
|
||||
MOZ_XML_SetProcessingInstructionHandler(XML_Parser parser,
|
||||
XML_ProcessingInstructionHandler handler);
|
||||
|
||||
void
|
||||
MOZ_XML_SetCommentHandler(XML_Parser parser,
|
||||
XML_CommentHandler handler);
|
||||
|
||||
void
|
||||
MOZ_XML_SetCdataSectionHandler(XML_Parser parser,
|
||||
XML_StartCdataSectionHandler start,
|
||||
XML_EndCdataSectionHandler end);
|
||||
|
||||
void
|
||||
MOZ_XML_SetDefaultHandlerExpand(XML_Parser parser,
|
||||
XML_DefaultHandler handler);
|
||||
|
||||
void
|
||||
MOZ_XML_SetDoctypeDeclHandler(XML_Parser parser,
|
||||
XML_StartDoctypeDeclHandler start,
|
||||
XML_EndDoctypeDeclHandler end);
|
||||
void
|
||||
MOZ_XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
|
||||
XML_UnparsedEntityDeclHandler handler);
|
||||
|
||||
void
|
||||
MOZ_XML_SetNotationDeclHandler(XML_Parser parser,
|
||||
XML_NotationDeclHandler handler);
|
||||
|
||||
void
|
||||
MOZ_XML_SetNamespaceDeclHandler(XML_Parser parser,
|
||||
XML_StartNamespaceDeclHandler start,
|
||||
XML_EndNamespaceDeclHandler end);
|
||||
|
||||
void
|
||||
MOZ_XML_SetExternalEntityRefHandler(XML_Parser parser,
|
||||
XML_ExternalEntityRefHandler handler);
|
||||
|
||||
void
|
||||
MOZ_XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg);
|
||||
|
||||
void
|
||||
MOZ_XML_SetReturnNSTriplet(XML_Parser parser, int do_nst);
|
||||
|
||||
void
|
||||
MOZ_XML_SetUserData(XML_Parser parser, void *p);
|
||||
|
||||
enum XML_Status
|
||||
MOZ_XML_SetBase(XML_Parser parser, const XML_Char *base);
|
||||
|
||||
const XML_Char *
|
||||
MOZ_XML_GetBase(XML_Parser parser);
|
||||
|
||||
int
|
||||
MOZ_XML_GetSpecifiedAttributeCount(XML_Parser parser);
|
||||
|
||||
enum XML_Status
|
||||
MOZ_XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
|
||||
|
||||
enum XML_Status
|
||||
MOZ_XML_StopParser(XML_Parser parser, int resumable);
|
||||
|
||||
enum XML_Status
|
||||
MOZ_XML_ResumeParser(XML_Parser parser);
|
||||
|
||||
XML_Parser
|
||||
MOZ_XML_ExternalEntityParserCreate(XML_Parser parser,
|
||||
const XML_Char *context,
|
||||
const XML_Char *encoding);
|
||||
|
||||
int
|
||||
MOZ_XML_SetParamEntityParsing(XML_Parser parser,
|
||||
enum XML_ParamEntityParsing parsing);
|
||||
|
||||
int
|
||||
MOZ_XML_SetHashSalt(XML_Parser parser, unsigned long hash_salt);
|
||||
|
||||
enum XML_Error
|
||||
MOZ_XML_GetErrorCode(XML_Parser parser);
|
||||
|
||||
XML_Size MOZ_XML_GetCurrentLineNumber(XML_Parser parser);
|
||||
|
||||
XML_Size MOZ_XML_GetCurrentColumnNumber(XML_Parser parser);
|
||||
|
||||
XML_Index MOZ_XML_GetCurrentByteIndex(XML_Parser parser);
|
||||
|
||||
void
|
||||
MOZ_XML_ParserFree(XML_Parser parser);
|
||||
|
||||
XML_Bool MOZ_XML_SetReparseDeferralEnabled(XML_Parser parser, int enabled);
|
||||
|
||||
// Mozilla-only API: Report opening tag of mismatched closing tag.
|
||||
const XML_Char*
|
||||
MOZ_XML_GetMismatchedTag(XML_Parser parser);
|
||||
|
||||
// Mozilla-only API: Report whether the parser is currently expanding an entity.
|
||||
XML_Bool
|
||||
MOZ_XML_ProcessingEntityValue(XML_Parser parser);
|
||||
|
||||
MOZ_END_EXTERN_C
|
||||
|
||||
#endif /* MOZ_EXPAT_H_ */
|
||||
@@ -1,180 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "moz_expat.h"
|
||||
#include "lib/xmlparse.c"
|
||||
|
||||
void
|
||||
MOZ_XML_SetXmlDeclHandler(XML_Parser parser,
|
||||
XML_XmlDeclHandler xmldecl) {
|
||||
XML_SetXmlDeclHandler(parser, xmldecl);
|
||||
}
|
||||
|
||||
XML_Parser
|
||||
MOZ_XML_ParserCreate_MM(const XML_Char *encoding,
|
||||
const XML_Memory_Handling_Suite *memsuite,
|
||||
const XML_Char *namespaceSeparator) {
|
||||
return XML_ParserCreate_MM(encoding, memsuite, namespaceSeparator);
|
||||
}
|
||||
|
||||
void
|
||||
MOZ_XML_SetElementHandler(XML_Parser parser,
|
||||
XML_StartElementHandler start,
|
||||
XML_EndElementHandler end) {
|
||||
XML_SetElementHandler(parser, start, end);
|
||||
}
|
||||
|
||||
void
|
||||
MOZ_XML_SetCharacterDataHandler(XML_Parser parser,
|
||||
XML_CharacterDataHandler handler) {
|
||||
XML_SetCharacterDataHandler(parser, handler);
|
||||
}
|
||||
|
||||
void
|
||||
MOZ_XML_SetProcessingInstructionHandler(XML_Parser parser,
|
||||
XML_ProcessingInstructionHandler handler) {
|
||||
XML_SetProcessingInstructionHandler(parser, handler);
|
||||
}
|
||||
|
||||
void
|
||||
MOZ_XML_SetCommentHandler(XML_Parser parser,
|
||||
XML_CommentHandler handler) {
|
||||
XML_SetCommentHandler(parser, handler);
|
||||
}
|
||||
|
||||
void
|
||||
MOZ_XML_SetCdataSectionHandler(XML_Parser parser,
|
||||
XML_StartCdataSectionHandler start,
|
||||
XML_EndCdataSectionHandler end) {
|
||||
XML_SetCdataSectionHandler(parser, start, end);
|
||||
}
|
||||
|
||||
void
|
||||
MOZ_XML_SetDefaultHandlerExpand(XML_Parser parser,
|
||||
XML_DefaultHandler handler) {
|
||||
XML_SetDefaultHandlerExpand(parser, handler);
|
||||
}
|
||||
|
||||
void
|
||||
MOZ_XML_SetDoctypeDeclHandler(XML_Parser parser,
|
||||
XML_StartDoctypeDeclHandler start,
|
||||
XML_EndDoctypeDeclHandler end) {
|
||||
XML_SetDoctypeDeclHandler(parser, start, end);
|
||||
}
|
||||
|
||||
void
|
||||
MOZ_XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
|
||||
XML_UnparsedEntityDeclHandler handler) {
|
||||
XML_SetUnparsedEntityDeclHandler(parser, handler);
|
||||
}
|
||||
|
||||
void
|
||||
MOZ_XML_SetNotationDeclHandler(XML_Parser parser,
|
||||
XML_NotationDeclHandler handler) {
|
||||
XML_SetNotationDeclHandler(parser, handler);
|
||||
}
|
||||
|
||||
void
|
||||
MOZ_XML_SetNamespaceDeclHandler(XML_Parser parser,
|
||||
XML_StartNamespaceDeclHandler start,
|
||||
XML_EndNamespaceDeclHandler end) {
|
||||
XML_SetNamespaceDeclHandler(parser, start, end);
|
||||
}
|
||||
|
||||
void
|
||||
MOZ_XML_SetExternalEntityRefHandler(XML_Parser parser,
|
||||
XML_ExternalEntityRefHandler handler) {
|
||||
XML_SetExternalEntityRefHandler(parser, handler);
|
||||
}
|
||||
|
||||
void
|
||||
MOZ_XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg) {
|
||||
XML_SetExternalEntityRefHandlerArg(parser, arg);
|
||||
}
|
||||
|
||||
void
|
||||
MOZ_XML_SetReturnNSTriplet(XML_Parser parser, int do_nst) {
|
||||
XML_SetReturnNSTriplet(parser, do_nst);
|
||||
}
|
||||
|
||||
void
|
||||
MOZ_XML_SetUserData(XML_Parser parser, void *p) {
|
||||
XML_SetUserData(parser, p);
|
||||
}
|
||||
|
||||
enum XML_Status
|
||||
MOZ_XML_SetBase(XML_Parser parser, const XML_Char *base) {
|
||||
return XML_SetBase(parser, base);
|
||||
}
|
||||
|
||||
const XML_Char *
|
||||
MOZ_XML_GetBase(XML_Parser parser) {
|
||||
return XML_GetBase(parser);
|
||||
}
|
||||
|
||||
int
|
||||
MOZ_XML_GetSpecifiedAttributeCount(XML_Parser parser) {
|
||||
return XML_GetSpecifiedAttributeCount(parser);
|
||||
}
|
||||
|
||||
enum XML_Status
|
||||
MOZ_XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) {
|
||||
return XML_Parse(parser, s, len, isFinal);
|
||||
}
|
||||
|
||||
enum XML_Status
|
||||
MOZ_XML_StopParser(XML_Parser parser, int resumable) {
|
||||
return XML_StopParser(parser, resumable);
|
||||
}
|
||||
|
||||
enum XML_Status
|
||||
MOZ_XML_ResumeParser(XML_Parser parser) {
|
||||
return XML_ResumeParser(parser);
|
||||
}
|
||||
|
||||
XML_Parser
|
||||
MOZ_XML_ExternalEntityParserCreate(XML_Parser parser,
|
||||
const XML_Char *context,
|
||||
const XML_Char *encoding) {
|
||||
return XML_ExternalEntityParserCreate(parser, context, encoding);
|
||||
}
|
||||
|
||||
int
|
||||
MOZ_XML_SetParamEntityParsing(XML_Parser parser,
|
||||
enum XML_ParamEntityParsing parsing) {
|
||||
return XML_SetParamEntityParsing(parser, parsing);
|
||||
}
|
||||
|
||||
int
|
||||
MOZ_XML_SetHashSalt(XML_Parser parser, unsigned long hash_salt) {
|
||||
return XML_SetHashSalt(parser, hash_salt);
|
||||
}
|
||||
|
||||
enum XML_Error
|
||||
MOZ_XML_GetErrorCode(XML_Parser parser)
|
||||
{
|
||||
return XML_GetErrorCode(parser);
|
||||
}
|
||||
|
||||
XML_Size MOZ_XML_GetCurrentLineNumber(XML_Parser parser) {
|
||||
return XML_GetCurrentLineNumber(parser);
|
||||
}
|
||||
|
||||
XML_Size MOZ_XML_GetCurrentColumnNumber(XML_Parser parser) {
|
||||
return XML_GetCurrentColumnNumber(parser);
|
||||
}
|
||||
|
||||
XML_Index MOZ_XML_GetCurrentByteIndex(XML_Parser parser) {
|
||||
return XML_GetCurrentByteIndex(parser);
|
||||
}
|
||||
|
||||
void
|
||||
MOZ_XML_ParserFree(XML_Parser parser) {
|
||||
XML_ParserFree(parser);
|
||||
}
|
||||
|
||||
XML_Bool MOZ_XML_SetReparseDeferralEnabled(XML_Parser parser, int enabled) {
|
||||
return XML_SetReparseDeferralEnabled(parser, enabled);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/bin/sh
|
||||
# This script should apply all relevant patches to the expat source if
|
||||
# deviating from upstream.
|
||||
for patchfile in $(ls *.patch)
|
||||
do
|
||||
patch -p1 < $patchfile
|
||||
done
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "mozilla/UniquePtrExtensions.h"
|
||||
#include "nsHtml5Highlighter.h"
|
||||
#include "expat_config.h"
|
||||
#include "moz_expat.h"
|
||||
#include "expat.h"
|
||||
#include "nsINestedURI.h"
|
||||
#include "nsCharsetSource.h"
|
||||
#include "nsIWyciwygChannel.h"
|
||||
@@ -432,7 +432,7 @@ HandleXMLDeclaration(void* aUserData,
|
||||
UserData* ud = static_cast<UserData*>(aUserData);
|
||||
ud->mStreamParser->SetEncodingFromExpat(
|
||||
reinterpret_cast<const char16_t*>(aEncoding));
|
||||
MOZ_XML_StopParser(ud->mExpat, false);
|
||||
XML_StopParser(ud->mExpat, false);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -441,7 +441,7 @@ HandleStartElement(void* aUserData,
|
||||
const XML_Char **aAtts)
|
||||
{
|
||||
UserData* ud = static_cast<UserData*>(aUserData);
|
||||
MOZ_XML_StopParser(ud->mExpat, false);
|
||||
XML_StopParser(ud->mExpat, false);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -449,7 +449,7 @@ HandleEndElement(void* aUserData,
|
||||
const XML_Char* aName)
|
||||
{
|
||||
UserData* ud = static_cast<UserData*>(aUserData);
|
||||
MOZ_XML_StopParser(ud->mExpat, false);
|
||||
XML_StopParser(ud->mExpat, false);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -457,7 +457,7 @@ HandleComment(void* aUserData,
|
||||
const XML_Char* aName)
|
||||
{
|
||||
UserData* ud = static_cast<UserData*>(aUserData);
|
||||
MOZ_XML_StopParser(ud->mExpat, false);
|
||||
XML_StopParser(ud->mExpat, false);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -466,7 +466,7 @@ HandleProcessingInstruction(void* aUserData,
|
||||
const XML_Char* aData)
|
||||
{
|
||||
UserData* ud = static_cast<UserData*>(aUserData);
|
||||
MOZ_XML_StopParser(ud->mExpat, false);
|
||||
XML_StopParser(ud->mExpat, false);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@@ -502,12 +502,12 @@ nsHtml5StreamParser::FinalizeSniffing(const uint8_t* aFromSegment, // can be nul
|
||||
// and without triggering expat's unknown encoding code paths. This is
|
||||
// enough to be able to use expat to parse the XML declaration in order
|
||||
// to extract the encoding name from it.
|
||||
ud.mExpat = MOZ_XML_ParserCreate_MM(kISO88591, &memsuite, kExpatSeparator);
|
||||
MOZ_XML_SetXmlDeclHandler(ud.mExpat, HandleXMLDeclaration);
|
||||
MOZ_XML_SetElementHandler(ud.mExpat, HandleStartElement, HandleEndElement);
|
||||
MOZ_XML_SetCommentHandler(ud.mExpat, HandleComment);
|
||||
MOZ_XML_SetProcessingInstructionHandler(ud.mExpat, HandleProcessingInstruction);
|
||||
MOZ_XML_SetUserData(ud.mExpat, static_cast<void*>(&ud));
|
||||
ud.mExpat = XML_ParserCreate_MM(kISO88591, &memsuite, kExpatSeparator);
|
||||
XML_SetXmlDeclHandler(ud.mExpat, HandleXMLDeclaration);
|
||||
XML_SetElementHandler(ud.mExpat, HandleStartElement, HandleEndElement);
|
||||
XML_SetCommentHandler(ud.mExpat, HandleComment);
|
||||
XML_SetProcessingInstructionHandler(ud.mExpat, HandleProcessingInstruction);
|
||||
XML_SetUserData(ud.mExpat, static_cast<void*>(&ud));
|
||||
|
||||
XML_Status status = XML_STATUS_OK;
|
||||
|
||||
@@ -519,20 +519,20 @@ nsHtml5StreamParser::FinalizeSniffing(const uint8_t* aFromSegment, // can be nul
|
||||
// 1024 bytes long or shorter). Thus, we parse both buffers, but if the
|
||||
// first call succeeds already, we skip parsing the second buffer.
|
||||
if (mSniffingBuffer) {
|
||||
status = MOZ_XML_Parse(ud.mExpat,
|
||||
reinterpret_cast<const char*>(mSniffingBuffer.get()),
|
||||
mSniffingLength,
|
||||
false);
|
||||
status = XML_Parse(ud.mExpat,
|
||||
reinterpret_cast<const char*>(mSniffingBuffer.get()),
|
||||
mSniffingLength,
|
||||
false);
|
||||
}
|
||||
if (status == XML_STATUS_OK &&
|
||||
mCharsetSource < kCharsetFromMetaTag &&
|
||||
aFromSegment) {
|
||||
status = MOZ_XML_Parse(ud.mExpat,
|
||||
reinterpret_cast<const char*>(aFromSegment),
|
||||
aCountToSniffingLimit,
|
||||
false);
|
||||
status = XML_Parse(ud.mExpat,
|
||||
reinterpret_cast<const char*>(aFromSegment),
|
||||
aCountToSniffingLimit,
|
||||
false);
|
||||
}
|
||||
MOZ_XML_ParserFree(ud.mExpat);
|
||||
XML_ParserFree(ud.mExpat);
|
||||
|
||||
if (mCharsetSource < kCharsetFromMetaTag) {
|
||||
// Failed to get an encoding from the XML declaration. XML defaults
|
||||
|
||||
@@ -360,7 +360,7 @@ nsExpatDriver::nsExpatDriver()
|
||||
nsExpatDriver::~nsExpatDriver()
|
||||
{
|
||||
if (mExpatParser) {
|
||||
MOZ_XML_ParserFree(mExpatParser);
|
||||
XML_ParserFree(mExpatParser);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ nsExpatDriver::HandleStartElement(const char16_t *aValue,
|
||||
// attrs (twice that number, actually), so we have to check for default attrs
|
||||
// ourselves.
|
||||
uint32_t attrArrayLength;
|
||||
for (attrArrayLength = MOZ_XML_GetSpecifiedAttributeCount(mExpatParser);
|
||||
for (attrArrayLength = XML_GetSpecifiedAttributeCount(mExpatParser);
|
||||
aAtts[attrArrayLength];
|
||||
attrArrayLength += 2) {
|
||||
// Just looping till we find out what the length is
|
||||
@@ -394,8 +394,8 @@ nsExpatDriver::HandleStartElement(const char16_t *aValue,
|
||||
|
||||
nsresult rv = mSink->
|
||||
HandleStartElement(aValue, aAtts, attrArrayLength,
|
||||
MOZ_XML_GetCurrentLineNumber(mExpatParser),
|
||||
MOZ_XML_GetCurrentColumnNumber(mExpatParser));
|
||||
XML_GetCurrentLineNumber(mExpatParser),
|
||||
XML_GetCurrentColumnNumber(mExpatParser));
|
||||
MaybeStopParser(rv);
|
||||
}
|
||||
}
|
||||
@@ -674,7 +674,7 @@ ExternalDTDStreamReaderFunc(nsIUnicharInputStream* aIn,
|
||||
uint32_t *aWriteCount)
|
||||
{
|
||||
// Pass the buffer to expat for parsing.
|
||||
if (MOZ_XML_Parse((XML_Parser)aClosure, (const char *)aFromSegment,
|
||||
if (XML_Parse((XML_Parser)aClosure, (const char *)aFromSegment,
|
||||
aCount * sizeof(char16_t), 0) == XML_STATUS_OK) {
|
||||
*aWriteCount = aCount;
|
||||
|
||||
@@ -725,10 +725,10 @@ nsExpatDriver::HandleExternalEntityRef(const char16_t *openEntityNames,
|
||||
|
||||
int result = 1;
|
||||
if (uniIn) {
|
||||
XML_Parser entParser = MOZ_XML_ExternalEntityParserCreate(mExpatParser, 0,
|
||||
kUTF16);
|
||||
XML_Parser entParser = XML_ExternalEntityParserCreate(mExpatParser, 0,
|
||||
kUTF16);
|
||||
if (entParser) {
|
||||
MOZ_XML_SetBase(entParser, absURL.get());
|
||||
XML_SetBase(entParser, absURL.get());
|
||||
|
||||
mInExternalDTD = true;
|
||||
|
||||
@@ -738,11 +738,11 @@ nsExpatDriver::HandleExternalEntityRef(const char16_t *openEntityNames,
|
||||
uint32_t(-1), &totalRead);
|
||||
} while (NS_SUCCEEDED(rv) && totalRead > 0);
|
||||
|
||||
result = MOZ_XML_Parse(entParser, nullptr, 0, 1);
|
||||
result = XML_Parse(entParser, nullptr, 0, 1);
|
||||
|
||||
mInExternalDTD = false;
|
||||
|
||||
MOZ_XML_ParserFree(entParser);
|
||||
XML_ParserFree(entParser);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -888,7 +888,7 @@ AppendErrorPointer(const int32_t aColNumber,
|
||||
nsresult
|
||||
nsExpatDriver::HandleError()
|
||||
{
|
||||
int32_t code = MOZ_XML_GetErrorCode(mExpatParser);
|
||||
int32_t code = XML_GetErrorCode(mExpatParser);
|
||||
NS_ASSERTION(code > XML_ERROR_NONE, "unexpected XML error code");
|
||||
|
||||
// Map Expat error code to an error string
|
||||
@@ -947,11 +947,11 @@ nsExpatDriver::HandleError()
|
||||
}
|
||||
|
||||
// Adjust the column number so that it is one based rather than zero based.
|
||||
uint32_t colNumber = MOZ_XML_GetCurrentColumnNumber(mExpatParser) + 1;
|
||||
uint32_t lineNumber = MOZ_XML_GetCurrentLineNumber(mExpatParser);
|
||||
uint32_t colNumber = XML_GetCurrentColumnNumber(mExpatParser) + 1;
|
||||
uint32_t lineNumber = XML_GetCurrentLineNumber(mExpatParser);
|
||||
|
||||
nsAutoString errorText;
|
||||
CreateErrorText(description.get(), MOZ_XML_GetBase(mExpatParser), lineNumber,
|
||||
CreateErrorText(description.get(), XML_GetBase(mExpatParser), lineNumber,
|
||||
colNumber, errorText);
|
||||
|
||||
NS_ASSERTION(mSink, "no sink?");
|
||||
@@ -1013,25 +1013,25 @@ nsExpatDriver::ParseBuffer(const char16_t *aBuffer,
|
||||
"Useless call, we won't call Expat");
|
||||
NS_PRECONDITION(!BlockedOrInterrupted() || !aBuffer,
|
||||
"Non-null buffer when resuming");
|
||||
NS_PRECONDITION(MOZ_XML_GetCurrentByteIndex(mExpatParser) % sizeof(char16_t) == 0,
|
||||
NS_PRECONDITION(XML_GetCurrentByteIndex(mExpatParser) % sizeof(char16_t) == 0,
|
||||
"Consumed part of a char16_t?");
|
||||
|
||||
if (mExpatParser && (mInternalState == NS_OK || BlockedOrInterrupted())) {
|
||||
int32_t parserBytesBefore = MOZ_XML_GetCurrentByteIndex(mExpatParser);
|
||||
int32_t parserBytesBefore = XML_GetCurrentByteIndex(mExpatParser);
|
||||
NS_ASSERTION(parserBytesBefore >= 0, "Unexpected value");
|
||||
|
||||
XML_Status status;
|
||||
if (BlockedOrInterrupted()) {
|
||||
mInternalState = NS_OK; // Resume in case we're blocked.
|
||||
status = MOZ_XML_ResumeParser(mExpatParser);
|
||||
status = XML_ResumeParser(mExpatParser);
|
||||
}
|
||||
else {
|
||||
status = MOZ_XML_Parse(mExpatParser,
|
||||
reinterpret_cast<const char*>(aBuffer),
|
||||
aLength * sizeof(char16_t), aIsFinal);
|
||||
status = XML_Parse(mExpatParser,
|
||||
reinterpret_cast<const char*>(aBuffer),
|
||||
aLength * sizeof(char16_t), aIsFinal);
|
||||
}
|
||||
|
||||
int32_t parserBytesConsumed = MOZ_XML_GetCurrentByteIndex(mExpatParser);
|
||||
int32_t parserBytesConsumed = XML_GetCurrentByteIndex(mExpatParser);
|
||||
|
||||
NS_ASSERTION(parserBytesConsumed >= 0, "Unexpected value");
|
||||
NS_ASSERTION(parserBytesConsumed >= parserBytesBefore,
|
||||
@@ -1134,7 +1134,7 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner, bool& aFlushTokens)
|
||||
// the error occurred).
|
||||
|
||||
// The length of the last line that Expat has parsed.
|
||||
XML_Size lastLineLength = MOZ_XML_GetCurrentColumnNumber(mExpatParser);
|
||||
XML_Size lastLineLength = XML_GetCurrentColumnNumber(mExpatParser);
|
||||
|
||||
if (lastLineLength <= consumed) {
|
||||
// The length of the last line was less than what expat consumed, so
|
||||
@@ -1175,7 +1175,7 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner, bool& aFlushTokens)
|
||||
}
|
||||
|
||||
if (NS_FAILED(mInternalState)) {
|
||||
if (MOZ_XML_GetErrorCode(mExpatParser) != XML_ERROR_NONE) {
|
||||
if (XML_GetErrorCode(mExpatParser) != XML_ERROR_NONE) {
|
||||
NS_ASSERTION(mInternalState == NS_ERROR_HTMLPARSER_STOPPARSING,
|
||||
"Unexpected error");
|
||||
|
||||
@@ -1252,18 +1252,18 @@ nsExpatDriver::WillBuildModel(const CParserContext& aParserContext,
|
||||
|
||||
static const char16_t kExpatSeparator[] = { kExpatSeparatorChar, '\0' };
|
||||
|
||||
mExpatParser = MOZ_XML_ParserCreate_MM(kUTF16, &memsuite, kExpatSeparator);
|
||||
mExpatParser = XML_ParserCreate_MM(kUTF16, &memsuite, kExpatSeparator);
|
||||
NS_ENSURE_TRUE(mExpatParser, NS_ERROR_FAILURE);
|
||||
|
||||
MOZ_XML_SetReturnNSTriplet(mExpatParser, XML_TRUE);
|
||||
XML_SetReturnNSTriplet(mExpatParser, XML_TRUE);
|
||||
|
||||
#ifdef XML_DTD
|
||||
MOZ_XML_SetParamEntityParsing(mExpatParser, XML_PARAM_ENTITY_PARSING_ALWAYS);
|
||||
XML_SetParamEntityParsing(mExpatParser, XML_PARAM_ENTITY_PARSING_ALWAYS);
|
||||
#endif
|
||||
|
||||
mURISpec = aParserContext.mScanner->GetFilename();
|
||||
|
||||
MOZ_XML_SetBase(mExpatParser, mURISpec.get());
|
||||
XML_SetBase(mExpatParser, mURISpec.get());
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mOriginalSink->GetTarget());
|
||||
if (doc) {
|
||||
@@ -1285,41 +1285,41 @@ nsExpatDriver::WillBuildModel(const CParserContext& aParserContext,
|
||||
}
|
||||
|
||||
// Set up the callbacks
|
||||
MOZ_XML_SetXmlDeclHandler(mExpatParser, Driver_HandleXMLDeclaration);
|
||||
MOZ_XML_SetElementHandler(mExpatParser, Driver_HandleStartElement,
|
||||
Driver_HandleEndElement);
|
||||
MOZ_XML_SetCharacterDataHandler(mExpatParser, Driver_HandleCharacterData);
|
||||
MOZ_XML_SetProcessingInstructionHandler(mExpatParser,
|
||||
Driver_HandleProcessingInstruction);
|
||||
MOZ_XML_SetDefaultHandlerExpand(mExpatParser, Driver_HandleDefault);
|
||||
MOZ_XML_SetExternalEntityRefHandler(mExpatParser,
|
||||
(XML_ExternalEntityRefHandler)
|
||||
Driver_HandleExternalEntityRef);
|
||||
MOZ_XML_SetExternalEntityRefHandlerArg(mExpatParser, this);
|
||||
MOZ_XML_SetCommentHandler(mExpatParser, Driver_HandleComment);
|
||||
MOZ_XML_SetCdataSectionHandler(mExpatParser, Driver_HandleStartCdataSection,
|
||||
Driver_HandleEndCdataSection);
|
||||
XML_SetXmlDeclHandler(mExpatParser, Driver_HandleXMLDeclaration);
|
||||
XML_SetElementHandler(mExpatParser, Driver_HandleStartElement,
|
||||
Driver_HandleEndElement);
|
||||
XML_SetCharacterDataHandler(mExpatParser, Driver_HandleCharacterData);
|
||||
XML_SetProcessingInstructionHandler(mExpatParser,
|
||||
Driver_HandleProcessingInstruction);
|
||||
XML_SetDefaultHandlerExpand(mExpatParser, Driver_HandleDefault);
|
||||
XML_SetExternalEntityRefHandler(mExpatParser,
|
||||
(XML_ExternalEntityRefHandler)
|
||||
Driver_HandleExternalEntityRef);
|
||||
XML_SetExternalEntityRefHandlerArg(mExpatParser, this);
|
||||
XML_SetCommentHandler(mExpatParser, Driver_HandleComment);
|
||||
XML_SetCdataSectionHandler(mExpatParser, Driver_HandleStartCdataSection,
|
||||
Driver_HandleEndCdataSection);
|
||||
|
||||
MOZ_XML_SetParamEntityParsing(mExpatParser,
|
||||
XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE);
|
||||
MOZ_XML_SetDoctypeDeclHandler(mExpatParser, Driver_HandleStartDoctypeDecl,
|
||||
Driver_HandleEndDoctypeDecl);
|
||||
XML_SetParamEntityParsing(mExpatParser,
|
||||
XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE);
|
||||
XML_SetDoctypeDeclHandler(mExpatParser, Driver_HandleStartDoctypeDecl,
|
||||
Driver_HandleEndDoctypeDecl);
|
||||
|
||||
// If the sink is an nsIExtendedExpatSink,
|
||||
// register some addtional handlers.
|
||||
mExtendedSink = do_QueryInterface(mSink);
|
||||
if (mExtendedSink) {
|
||||
MOZ_XML_SetNamespaceDeclHandler(mExpatParser,
|
||||
Driver_HandleStartNamespaceDecl,
|
||||
Driver_HandleEndNamespaceDecl);
|
||||
MOZ_XML_SetUnparsedEntityDeclHandler(mExpatParser,
|
||||
Driver_HandleUnparsedEntityDecl);
|
||||
MOZ_XML_SetNotationDeclHandler(mExpatParser,
|
||||
Driver_HandleNotationDecl);
|
||||
XML_SetNamespaceDeclHandler(mExpatParser,
|
||||
Driver_HandleStartNamespaceDecl,
|
||||
Driver_HandleEndNamespaceDecl);
|
||||
XML_SetUnparsedEntityDeclHandler(mExpatParser,
|
||||
Driver_HandleUnparsedEntityDecl);
|
||||
XML_SetNotationDeclHandler(mExpatParser,
|
||||
Driver_HandleNotationDecl);
|
||||
}
|
||||
|
||||
// Set up the user data.
|
||||
MOZ_XML_SetUserData(mExpatParser, this);
|
||||
XML_SetUserData(mExpatParser, this);
|
||||
|
||||
return mInternalState;
|
||||
}
|
||||
@@ -1351,7 +1351,7 @@ nsExpatDriver::Terminate()
|
||||
{
|
||||
// XXX - not sure what happens to the unparsed data.
|
||||
if (mExpatParser) {
|
||||
MOZ_XML_StopParser(mExpatParser, XML_FALSE);
|
||||
XML_StopParser(mExpatParser, XML_FALSE);
|
||||
}
|
||||
mInternalState = NS_ERROR_HTMLPARSER_STOPPARSING;
|
||||
}
|
||||
@@ -1403,7 +1403,7 @@ nsExpatDriver::MaybeStopParser(nsresult aState)
|
||||
// with false as the last argument). If the parser should be blocked or
|
||||
// interrupted we need to pause Expat (by calling XML_StopParser with
|
||||
// true as the last argument).
|
||||
MOZ_XML_StopParser(mExpatParser, BlockedOrInterrupted());
|
||||
XML_StopParser(mExpatParser, BlockedOrInterrupted());
|
||||
}
|
||||
else if (NS_SUCCEEDED(mInternalState)) {
|
||||
// Only clobber mInternalState with the success code if we didn't block or
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#define NS_EXPAT_DRIVER__
|
||||
|
||||
#include "expat_config.h"
|
||||
#include "moz_expat.h"
|
||||
#include "expat.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDTD.h"
|
||||
|
||||
Reference in new issue
Block a user