mirror of
https://github.com/gnustep/libs-sqlclient.git
synced 2025-02-19 10:00:59 +00:00
fixup for 'standard_conforming_strings'
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@25413 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
bdbbcdda11
commit
61dcdc8acf
1 changed files with 105 additions and 55 deletions
160
Postgres.m
160
Postgres.m
|
@ -185,11 +185,10 @@ connectQuote(NSString *str)
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef HAVE_PQESCAPESTRINGCONN
|
||||
char buf[8];
|
||||
int err;
|
||||
const char *p;
|
||||
|
||||
if (PQescapeStringConn(connection, buf, "\\", 1, &err) == 1)
|
||||
p = PQparameterStatus(connection, "standard_conforming_strings");
|
||||
if (p != 0 && strcmp(p, "on") == 0)
|
||||
{
|
||||
standardEscaping = YES;
|
||||
}
|
||||
|
@ -197,7 +196,7 @@ connectQuote(NSString *str)
|
|||
{
|
||||
standardEscaping = NO;
|
||||
}
|
||||
#endif
|
||||
|
||||
connected = YES;
|
||||
if ([self debugging] > 0)
|
||||
{
|
||||
|
@ -544,40 +543,72 @@ static unsigned int trim(char *str)
|
|||
unsigned i;
|
||||
|
||||
ptr[length++] = '\'';
|
||||
for (i = 0; i < sLen; i++)
|
||||
if (YES == standardEscaping)
|
||||
{
|
||||
unsigned char c = src[i];
|
||||
for (i = 0; i < sLen; i++)
|
||||
{
|
||||
unsigned char c = src[i];
|
||||
|
||||
if (c < 32 || c > 126)
|
||||
{
|
||||
ptr[length] = '\\';
|
||||
ptr[length+1] = '\\';
|
||||
ptr[length + 4] = (c & 7) + '0';
|
||||
c >>= 3;
|
||||
ptr[length + 3] = (c & 7) + '0';
|
||||
c >>= 3;
|
||||
ptr[length + 2] = (c & 7) + '0';
|
||||
length += 5;
|
||||
}
|
||||
else if (c == '\\')
|
||||
{
|
||||
if (standardEscaping == NO)
|
||||
{
|
||||
ptr[length++] = '\\';
|
||||
ptr[length++] = '\\';
|
||||
}
|
||||
ptr[length++] = '\\';
|
||||
ptr[length++] = '\\';
|
||||
}
|
||||
else if (c == '\'')
|
||||
{
|
||||
ptr[length++] = '\'';
|
||||
ptr[length++] = '\'';
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr[length++] = c;
|
||||
}
|
||||
if (c < 32 || c > 126)
|
||||
{
|
||||
ptr[length] = '\\';
|
||||
ptr[length + 3] = (c & 7) + '0';
|
||||
c >>= 3;
|
||||
ptr[length + 2] = (c & 7) + '0';
|
||||
c >>= 3;
|
||||
ptr[length + 1] = (c & 7) + '0';
|
||||
length += 4;
|
||||
}
|
||||
else if (c == '\\')
|
||||
{
|
||||
ptr[length++] = '\\';
|
||||
ptr[length++] = '\\';
|
||||
}
|
||||
else if (c == '\'')
|
||||
{
|
||||
ptr[length++] = '\'';
|
||||
ptr[length++] = '\'';
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr[length++] = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < sLen; i++)
|
||||
{
|
||||
unsigned char c = src[i];
|
||||
|
||||
if (c < 32 || c > 126)
|
||||
{
|
||||
ptr[length] = '\\';
|
||||
ptr[length+1] = '\\';
|
||||
ptr[length + 4] = (c & 7) + '0';
|
||||
c >>= 3;
|
||||
ptr[length + 3] = (c & 7) + '0';
|
||||
c >>= 3;
|
||||
ptr[length + 2] = (c & 7) + '0';
|
||||
length += 5;
|
||||
}
|
||||
else if (c == '\\')
|
||||
{
|
||||
ptr[length++] = '\\';
|
||||
ptr[length++] = '\\';
|
||||
ptr[length++] = '\\';
|
||||
ptr[length++] = '\\';
|
||||
}
|
||||
else if (c == '\'')
|
||||
{
|
||||
ptr[length++] = '\'';
|
||||
ptr[length++] = '\'';
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr[length++] = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
ptr[length++] = '\'';
|
||||
return length;
|
||||
|
@ -590,26 +621,45 @@ static unsigned int trim(char *str)
|
|||
unsigned int length = sLen + 2;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < sLen; i++)
|
||||
if (YES == standardEscaping)
|
||||
{
|
||||
unsigned char c = src[i];
|
||||
for (i = 0; i < sLen; i++)
|
||||
{
|
||||
unsigned char c = src[i];
|
||||
|
||||
if (c < 32 || c > 126)
|
||||
{
|
||||
length += 4;
|
||||
}
|
||||
else if (c == '\\')
|
||||
{
|
||||
if (standardEscaping == NO)
|
||||
{
|
||||
length += 2;
|
||||
}
|
||||
length += 1;
|
||||
}
|
||||
else if (c == '\'')
|
||||
{
|
||||
length += 1;
|
||||
}
|
||||
if (c < 32 || c > 126)
|
||||
{
|
||||
length += 3;
|
||||
}
|
||||
else if (c == '\\')
|
||||
{
|
||||
length += 1;
|
||||
}
|
||||
else if (c == '\'')
|
||||
{
|
||||
length += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < sLen; i++)
|
||||
{
|
||||
unsigned char c = src[i];
|
||||
|
||||
if (c < 32 || c > 126)
|
||||
{
|
||||
length += 4;
|
||||
}
|
||||
else if (c == '\\')
|
||||
{
|
||||
length += 3;
|
||||
}
|
||||
else if (c == '\'')
|
||||
{
|
||||
length += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue