mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
Upgrade bundled libsqlite to 2.8.9
This commit is contained in:
parent
2cf3cb6407
commit
a4ea8eb44e
37 changed files with 5000 additions and 6182 deletions
|
@ -38,13 +38,13 @@
|
|||
**
|
||||
** If that were all the encoder did, it would work, but in certain cases
|
||||
** it could double the size of the encoded string. For example, to
|
||||
** encode a string of 100 0x27 character would require 100 instances of
|
||||
** encode a string of 100 0x27 characters would require 100 instances of
|
||||
** the 0x01 0x03 escape sequence resulting in a 200-character output.
|
||||
** We would prefer to keep the size of the encoded string smaller than
|
||||
** this.
|
||||
**
|
||||
** To minimize the encoding size, we first add a fixed offset value to each
|
||||
** byte in the sequence. The addition is module 256. (That is to say, if
|
||||
** byte in the sequence. The addition is modulo 256. (That is to say, if
|
||||
** the sum of the original character value and the offset exceeds 256, then
|
||||
** the higher order bits are truncated.) The offset is chosen to minimize
|
||||
** the number of characters in the string that need to be escaped. For
|
||||
|
@ -86,12 +86,12 @@
|
|||
** the encoded buffer from all characters in the output buffer.
|
||||
**
|
||||
** The only tricky part is step (1) - how to compute an offset value to
|
||||
** minimize the size of the output buffer. This is accomplished to testing
|
||||
** minimize the size of the output buffer. This is accomplished by testing
|
||||
** all offset values and picking the one that results in the fewest number
|
||||
** of escapes. To do that, we first scan the entire input and count the
|
||||
** number of occurances of each character value in the input. Suppose
|
||||
** the number of 0x00 characters is N(0), the number of occurances of 0x01
|
||||
** is N(1), and so forth up to the number of occurances of 0xff is N(256).
|
||||
** is N(1), and so forth up to the number of occurances of 0xff is N(255).
|
||||
** An offset of 0 is not allowed so we don't have to test it. The number
|
||||
** of escapes required for an offset of 1 is N(1)+N(2)+N(40). The number
|
||||
** of escapes required for an offset of 2 is N(2)+N(3)+N(41). And so forth.
|
||||
|
@ -107,10 +107,10 @@
|
|||
** string back into its original binary.
|
||||
**
|
||||
** The result is written into a preallocated output buffer "out".
|
||||
** "out" must be able to hold at least (256*n + 1262)/253 bytes.
|
||||
** "out" must be able to hold at least 2 +(257*n)/254 bytes.
|
||||
** In other words, the output will be expanded by as much as 3
|
||||
** bytes for every 253 bytes of input plus 2 bytes of fixed overhead.
|
||||
** (This is approximately 2 + 1.019*n or about a 2% size increase.)
|
||||
** bytes for every 254 bytes of input plus 2 bytes of fixed overhead.
|
||||
** (This is approximately 2 + 1.0118*n or about a 1.2% size increase.)
|
||||
**
|
||||
** The return value is the number of characters in the encoded
|
||||
** string, excluding the "\000" terminator.
|
||||
|
@ -159,7 +159,7 @@ int sqlite_encode_binary(const unsigned char *in, int n, unsigned char *out){
|
|||
|
||||
/*
|
||||
** Decode the string "in" into binary data and write it into "out".
|
||||
** This routine reverses the encoded created by sqlite_encode_binary().
|
||||
** This routine reverses the encoding created by sqlite_encode_binary().
|
||||
** The output will always be a few bytes less than the input. The number
|
||||
** of bytes of output is returned. If the input is not a well-formed
|
||||
** encoding, -1 is returned.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue