From: helge Date: Sat, 9 Feb 2008 15:16:22 +0000 (+0000) Subject: fixed a few cString related issues X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d648aa587268d0a0572dc8fd2faf6faceb5e73a;p=sope fixed a few cString related issues git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1600 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-gdl1/PostgreSQL/ChangeLog b/sope-gdl1/PostgreSQL/ChangeLog index d762e00e..6ff193d6 100644 --- a/sope-gdl1/PostgreSQL/ChangeLog +++ b/sope-gdl1/PostgreSQL/ChangeLog @@ -1,3 +1,12 @@ +2008-02-09 Helge Hess + + * v4.7.52 + + * NSString+PostgreSQL72.m: properly use -length, not -cStringLength + + * PostgreSQL72Channel+Model.m, PGResultSet.m: use -UTF8String instead + of -cString + 2007-09-27 Helge Hess * PostgreSQL72Context.m: changed to use -evaluateExpressionX: for diff --git a/sope-gdl1/PostgreSQL/NSString+PostgreSQL72.m b/sope-gdl1/PostgreSQL/NSString+PostgreSQL72.m index f0088b46..11f8abc7 100644 --- a/sope-gdl1/PostgreSQL/NSString+PostgreSQL72.m +++ b/sope-gdl1/PostgreSQL/NSString+PostgreSQL72.m @@ -78,7 +78,7 @@ return @""; // TODO: use UTF-8 here - clen = [self cStringLength]; + clen = [self length]; us = malloc((clen + 10) * sizeof(unichar)); [self getCharacters:us]; diff --git a/sope-gdl1/PostgreSQL/PGResultSet.m b/sope-gdl1/PostgreSQL/PGResultSet.m index 3615302e..ce8db023 100644 --- a/sope-gdl1/PostgreSQL/PGResultSet.m +++ b/sope-gdl1/PostgreSQL/PGResultSet.m @@ -98,7 +98,12 @@ } - (int)indexOfFieldNamed:(NSString *)_name { +#if LIB_FOUNDATION_LIBRARY + // TBD: might be wrong even in this case? return PQfnumber(self->results, [_name cString]); +#else + return PQfnumber(self->results, [_name UTF8String]); +#endif } - (int)fieldSizeAtIndex:(unsigned int)_idx { diff --git a/sope-gdl1/PostgreSQL/PostgreSQL72Channel+Model.m b/sope-gdl1/PostgreSQL/PostgreSQL72Channel+Model.m index 68c15dee..b98286d0 100644 --- a/sope-gdl1/PostgreSQL/PostgreSQL72Channel+Model.m +++ b/sope-gdl1/PostgreSQL/PostgreSQL72Channel+Model.m @@ -2,7 +2,7 @@ PostgreSQL72Channel+Model.m Copyright (C) 1999 MDlink online service center GmbH and Helge Hess - Copyright (C) 2000-2004 SKYRIX Software AG and Helge Hess + Copyright (C) 2000-2008 SKYRIX Software AG and Helge Hess Author: Helge Hess (helge.hess@opengroupware.org) @@ -61,7 +61,7 @@ static BOOL debugOn = NO; if (![self evaluateExpression:sqlExpr]) { fprintf(stderr, "Could not evaluate column-describe '%s' on table '%s'\n", - [sqlExpr cString], [_tableName cString]); + [sqlExpr UTF8String], [_tableName UTF8String]); return nil; } @@ -213,19 +213,15 @@ static BOOL debugOn = NO; relName = [@"to" stringByAppendingString: [[sa _pgModelMakeInstanceVarName] _pgStringWithCapitalizedFirstChar]]; - if ([relName hasSuffix:@"Id"]) { - int cLength = [relName cStringLength]; - - relName = [relName substringToIndex:cLength - 2]; - } + if ([relName hasSuffix:@"Id"]) + relName = [relName substringToIndex:([relName length] - 2)]; } if ([relNamesUsed objectForKey:relName] != nil) { int useCount = [[relNamesUsed objectForKey:relName] intValue]; [relNamesUsed setObject:[NSNumber numberWithInt:(useCount++)] forKey:relName]; - relName = [NSString stringWithFormat:@"%s%d", - [relName cString], useCount]; + relName = [NSString stringWithFormat:@"%@%d", relName, useCount]; } else [relNamesUsed setObject:[NSNumber numberWithInt:0] forKey:relName]; @@ -321,7 +317,13 @@ static BOOL debugOn = NO; NSDictionary *row; if (![self evaluateExpression:_query]) { - fprintf(stderr, "Could not evaluate expression: '%s'\n", [_query cString]); + fprintf(stderr, "Could not evaluate expression: '%s'\n", +#if LIB_FOUNDATION_LIBRARY + [_query cString] +#else + [_query UTF8String] +#endif + ); return nil; } diff --git a/sope-gdl1/PostgreSQL/Version b/sope-gdl1/PostgreSQL/Version index 13f24be8..3638a163 100644 --- a/sope-gdl1/PostgreSQL/Version +++ b/sope-gdl1/PostgreSQL/Version @@ -1,5 +1,5 @@ # version file -SUBMINOR_VERSION:=51 +SUBMINOR_VERSION:=52 # v4.5.41 requires libGDLAccess v4.5.50