mirror of
https://github.com/php/php-src.git
synced 2025-08-20 01:14:28 +02:00
Update bundled library to version 2.8.2.
Make OnUpdateInt compatible with ZE2. Fix the makefile fragment for non-gnu makes
This commit is contained in:
parent
82a1818fde
commit
80e7f7001d
42 changed files with 11143 additions and 7558 deletions
|
|
@ -392,6 +392,134 @@ void sqliteSetNString(char **pz, ...){
|
|||
va_end(ap);
|
||||
}
|
||||
|
||||
/*
|
||||
** Add an error message to pParse->zErrMsg and increment pParse->nErr.
|
||||
** The following formatting characters are allowed:
|
||||
**
|
||||
** %s Insert a string
|
||||
** %z A string that should be freed after use
|
||||
** %d Insert an integer
|
||||
** %T Insert a token
|
||||
** %S Insert the first element of a SrcList
|
||||
*/
|
||||
void sqliteErrorMsg(Parse *pParse, const char *zFormat, ...){
|
||||
va_list ap;
|
||||
int nByte;
|
||||
int i, j;
|
||||
char *z;
|
||||
static char zNull[] = "NULL";
|
||||
|
||||
pParse->nErr++;
|
||||
nByte = 1 + strlen(zFormat);
|
||||
va_start(ap, zFormat);
|
||||
for(i=0; zFormat[i]; i++){
|
||||
if( zFormat[i]!='%' || zFormat[i+1]==0 ) continue;
|
||||
i++;
|
||||
switch( zFormat[i] ){
|
||||
case 'd': {
|
||||
(void)va_arg(ap, int);
|
||||
nByte += 20;
|
||||
break;
|
||||
}
|
||||
case 'z':
|
||||
case 's': {
|
||||
char *z2 = va_arg(ap, char*);
|
||||
if( z2==0 ) z2 = zNull;
|
||||
nByte += strlen(z2);
|
||||
break;
|
||||
}
|
||||
case 'T': {
|
||||
Token *p = va_arg(ap, Token*);
|
||||
nByte += p->n;
|
||||
break;
|
||||
}
|
||||
case 'S': {
|
||||
SrcList *p = va_arg(ap, SrcList*);
|
||||
int k = va_arg(ap, int);
|
||||
assert( p->nSrc>k && k>=0 );
|
||||
nByte += strlen(p->a[k].zName);
|
||||
if( p->a[k].zDatabase && p->a[k].zDatabase[0] ){
|
||||
nByte += strlen(p->a[k].zDatabase)+1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
nByte++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
va_end(ap);
|
||||
z = sqliteMalloc( nByte );
|
||||
if( z==0 ) return;
|
||||
sqliteFree(pParse->zErrMsg);
|
||||
pParse->zErrMsg = z;
|
||||
va_start(ap, zFormat);
|
||||
for(i=j=0; zFormat[i]; i++){
|
||||
if( zFormat[i]!='%' || zFormat[i+1]==0 ) continue;
|
||||
if( i>j ){
|
||||
memcpy(z, &zFormat[j], i-j);
|
||||
z += i-j;
|
||||
}
|
||||
j = i+2;
|
||||
i++;
|
||||
switch( zFormat[i] ){
|
||||
case 'd': {
|
||||
int x = va_arg(ap, int);
|
||||
sprintf(z, "%d", x);
|
||||
z += strlen(z);
|
||||
break;
|
||||
}
|
||||
case 'z':
|
||||
case 's': {
|
||||
int len;
|
||||
char *z2 = va_arg(ap, char*);
|
||||
if( z2==0 ) z2 = zNull;
|
||||
len = strlen(z2);
|
||||
memcpy(z, z2, len);
|
||||
z += len;
|
||||
if( zFormat[i]=='z' && z2!=zNull ){
|
||||
sqliteFree(z2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'T': {
|
||||
Token *p = va_arg(ap, Token*);
|
||||
memcpy(z, p->z, p->n);
|
||||
z += p->n;
|
||||
break;
|
||||
}
|
||||
case 'S': {
|
||||
int len;
|
||||
SrcList *p = va_arg(ap, SrcList*);
|
||||
int k = va_arg(ap, int);
|
||||
assert( p->nSrc>k && k>=0 );
|
||||
if( p->a[k].zDatabase && p->a[k].zDatabase[0] ){
|
||||
len = strlen(p->a[k].zDatabase);
|
||||
memcpy(z, p->a[k].zDatabase, len);
|
||||
z += len;
|
||||
*(z++) = '.';
|
||||
}
|
||||
len = strlen(p->a[k].zName);
|
||||
memcpy(z, p->a[k].zName, len);
|
||||
z += len;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
*(z++) = zFormat[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
va_end(ap);
|
||||
if( i>j ){
|
||||
memcpy(z, &zFormat[j], i-j);
|
||||
z += i-j;
|
||||
}
|
||||
assert( (z - pParse->zErrMsg) < nByte );
|
||||
*z = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Convert an SQL-style quoted string into a normal string by removing
|
||||
** the quote characters. The conversion is done in-place. If the
|
||||
|
|
@ -460,8 +588,7 @@ int sqliteHashNoCase(const char *z, int n){
|
|||
h = (h<<3) ^ h ^ UpperToLower[(unsigned char)*z++];
|
||||
n--;
|
||||
}
|
||||
if( h<0 ) h = -h;
|
||||
return h;
|
||||
return h & 0x7fffffff;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -669,12 +796,12 @@ static int sortStrCmp(const char *atext, const char *btext, int useCase){
|
|||
** Return TRUE if z is a pure numeric string. Return FALSE if the
|
||||
** string contains any character which is not part of a number.
|
||||
**
|
||||
** Am empty string is considered numeric.
|
||||
** Am empty string is considered non-numeric.
|
||||
*/
|
||||
static int sqliteIsNumber(const char *z){
|
||||
int sqliteIsNumber(const char *z){
|
||||
if( *z=='-' || *z=='+' ) z++;
|
||||
if( !isdigit(*z) ){
|
||||
return *z==0;
|
||||
return 0;
|
||||
}
|
||||
z++;
|
||||
while( isdigit(*z) ){ z++; }
|
||||
|
|
@ -682,12 +809,12 @@ static int sqliteIsNumber(const char *z){
|
|||
z++;
|
||||
if( !isdigit(*z) ) return 0;
|
||||
while( isdigit(*z) ){ z++; }
|
||||
if( *z=='e' || *z=='E' ){
|
||||
z++;
|
||||
if( *z=='+' || *z=='-' ) z++;
|
||||
if( !isdigit(*z) ) return 0;
|
||||
while( isdigit(*z) ){ z++; }
|
||||
}
|
||||
}
|
||||
if( *z=='e' || *z=='E' ){
|
||||
z++;
|
||||
if( *z=='+' || *z=='-' ) z++;
|
||||
if( !isdigit(*z) ) return 0;
|
||||
while( isdigit(*z) ){ z++; }
|
||||
}
|
||||
return *z==0;
|
||||
}
|
||||
|
|
@ -780,7 +907,6 @@ int sqliteCompare(const char *atext, const char *btext){
|
|||
** 2.6.3 and earlier.
|
||||
*/
|
||||
int sqliteSortCompare(const char *a, const char *b){
|
||||
int len;
|
||||
int res = 0;
|
||||
int isNumA, isNumB;
|
||||
int dir = 0;
|
||||
|
|
@ -832,9 +958,8 @@ int sqliteSortCompare(const char *a, const char *b){
|
|||
if( res ) break;
|
||||
}
|
||||
}
|
||||
len = strlen(&a[1]) + 2;
|
||||
a += len;
|
||||
b += len;
|
||||
a += strlen(&a[1]) + 2;
|
||||
b += strlen(&b[1]) + 2;
|
||||
}
|
||||
if( dir=='-' || dir=='D' ) res = -res;
|
||||
return res;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue