mirror of
https://github.com/gnustep/libs-sqlclient.git
synced 2025-02-19 10:00:59 +00:00
Now that we use standard conforming strings, we can use use the superclass
string quoting code. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@40493 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2cd211e29d
commit
a592c91aa3
1 changed files with 0 additions and 54 deletions
54
Postgres.m
54
Postgres.m
|
@ -1650,60 +1650,6 @@ static inline unsigned int trim(char *str, unsigned len)
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString*) quoteString: (NSString *)s
|
|
||||||
{
|
|
||||||
NSData *d = [s dataUsingEncoding: NSUTF8StringEncoding];
|
|
||||||
unsigned l = [d length];
|
|
||||||
unsigned char *to = NSZoneMalloc(NSDefaultMallocZone(), (l * 2) + 3);
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
const char *from = (const char*)[d bytes];
|
|
||||||
unsigned i = 0;
|
|
||||||
unsigned j = 0;
|
|
||||||
|
|
||||||
to[j++] = '\'';
|
|
||||||
while (i < l)
|
|
||||||
{
|
|
||||||
if ('\'' == (to[j++] = from[i++]))
|
|
||||||
{
|
|
||||||
to[j++] = '\'';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
to[j++] = '\'';
|
|
||||||
l = j - 2;
|
|
||||||
#else
|
|
||||||
#ifdef HAVE_PQESCAPESTRINGCONN
|
|
||||||
int err;
|
|
||||||
|
|
||||||
[lock lock];
|
|
||||||
NS_DURING
|
|
||||||
{
|
|
||||||
[self connect];
|
|
||||||
l = PQescapeStringConn(connection,
|
|
||||||
(char*)(to + 1), [d bytes], l, &err);
|
|
||||||
}
|
|
||||||
NS_HANDLER
|
|
||||||
{
|
|
||||||
[lock unlock];
|
|
||||||
NSZoneFree(NSDefaultMallocZone(), to);
|
|
||||||
[localException raise];
|
|
||||||
}
|
|
||||||
NS_ENDHANDLER
|
|
||||||
[lock unlock];
|
|
||||||
#else
|
|
||||||
l = PQescapeString(to + 1, [d bytes], l);
|
|
||||||
#endif
|
|
||||||
to[0] = '\'';
|
|
||||||
to[l + 1] = '\'';
|
|
||||||
#endif
|
|
||||||
|
|
||||||
s = [[NSString alloc] initWithBytesNoCopy: to
|
|
||||||
length: l + 2
|
|
||||||
encoding: NSUTF8StringEncoding
|
|
||||||
freeWhenDone: YES];
|
|
||||||
return [s autorelease];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#if defined(GNUSTEP_BASE_LIBRARY) && !defined(__MINGW__)
|
#if defined(GNUSTEP_BASE_LIBRARY) && !defined(__MINGW__)
|
||||||
|
|
Loading…
Reference in a new issue