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:
rfm 2017-04-26 13:49:24 +00:00
parent 2cd211e29d
commit a592c91aa3

View file

@ -1650,60 +1650,6 @@ static inline unsigned int trim(char *str, unsigned len)
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
#if defined(GNUSTEP_BASE_LIBRARY) && !defined(__MINGW__)