/*
- Copyright (C) 2000-2004 SKYRIX Software AG
+ Copyright (C) 2000-2007 SKYRIX Software AG
+ Copyright (C) 2007 Helge Hess
- This file is part of OpenGroupware.org.
+ This file is part of SOPE.
- OGo is free software; you can redistribute it and/or modify it under
+ SOPE is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
- OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+ SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with OGo; see the file COPYING. If not, write to the
+ License along with SOPE; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#include <stdio.h>
#include "EOQualifier.h"
} EOQPTokEntry;
static EOQPTokEntry toks[] = {
- { "NULL", nil, 0 },
- { "nil", nil, 1 },
- { "YES", nil, 0 },
- { "NO", nil, 0 },
- { "TRUE", nil, 0 },
- { "FALSE", nil, 0 },
- { NULL, nil, 0 }
+ { (const unsigned char *)"NULL", nil, 0 },
+ { (const unsigned char *)"nil", nil, 1 },
+ { (const unsigned char *)"YES", nil, 0 },
+ { (const unsigned char *)"NO", nil, 0 },
+ { (const unsigned char *)"TRUE", nil, 0 },
+ { (const unsigned char *)"FALSE", nil, 0 },
+ { (const unsigned char *)NULL, nil, 0 }
};
static inline void _setupLiterals(void) {
unsigned pos = 0;
BOOL valueIsKey = NO;
- dict = [_ctx resultForFunction:@"parseKeyCompQualifier" atPos:(unsigned)_buf];
+ dict = [_ctx resultForFunction:@"parseKeyCompQualifier"
+ atPos:(unsigned long)_buf];
if (dict != nil) {
if (qDebug)
NSLog(@"_parseKeyCompQual return <%@> [cached] for <%s> ", dict, _buf);
[_ctx setResult:
[NSDictionary dictionaryWithObjects:values forKeys:keys count:2]
forFunction:@"parseKeyCompQualifier"
- atPos:(unsigned)_buf];
+ atPos:(unsigned long)_buf];
*_qualLen = pos;
}
return qual;
if (qDebug) NSLog(@"%s: _bufLen == 0 --> return nil", __PRETTY_FUNCTION__);
return nil;
}
- dict = [_ctx resultForFunction:@"parseKey" atPos:(unsigned)_buf];
+ dict = [_ctx resultForFunction:@"parseKey" atPos:(unsigned long)_buf];
if (dict != nil) {
if (qDebug) {
NSLog(@"%s: return <%@> [cached] for <%s> ", __PRETTY_FUNCTION__,
[_ctx setResult:
[NSDictionary dictionaryWithObjects:values forKeys:keys count:2]
forFunction:@"parseKey"
- atPos:(unsigned)_buf];
+ atPos:(unsigned long)_buf];
*_keyLen = pos;
}
return result;
return nil;
}
- dict = [_ctx resultForFunction:@"parseValue" atPos:(unsigned)_buf];
+ dict = [_ctx resultForFunction:@"parseValue" atPos:(unsigned long)_buf];
if (dict != nil) {
if (qDebug) {
NSLog(@"_parseKeyCompQualifier return <%@> [cached] for <%s> ",
int rc;
tok = toks[i].token;
- toklen = strlen(tok);
+ toklen = strlen((const char *)tok);
if ((_bufLen - pos) < toklen)
/* remaining string not long enough */
continue;
rc = toks[i].scase
- ? strncmp(&(_buf[pos]), tok, toklen)
- : strncasecmp(&(_buf[pos]), tok, toklen);
+ ? strncmp(&(_buf[pos]), (const char *)tok, toklen)
+ : strncasecmp(&(_buf[pos]), (const char *)tok, toklen);
if (rc != 0)
/* does not match */
continue;
- if (!(_buf[pos + toklen] == '\0' || isspace(_buf[pos + toklen])))
- /* not at the string end or folloed by a space */
+
+ if (!(_buf[pos + toklen] == '\0' || isspace(_buf[pos + toklen]) ||
+ _buf[pos + toklen] == ')')) {
+ /*
+ Not at the string end or followed by a space or a right
+ parenthesis. The latter is required to correctly parse this:
+ (not (attribute = nil) and
+ attribute.className = 'com.webobjects.foundation.NSTimestamp')
+ */
continue;
+ }
/* wow, found the token */
pos += toklen; /* skip it */
//printf("POS: '%s'\n", &(_buf[pos]));
pos++;
- cs = &(_buf[pos]);
- ce = index(cs, '\'');
- cast = [NSString stringWithCString:cs length:(ce - cs)];
+ cs = (const unsigned char *)&(_buf[pos]);
+ ce = (const unsigned char *)index((const char *)cs, '\'');
+ cast = [NSString stringWithCString:(const char*)cs length:(ce - cs)];
if (qDebug) {
- NSLog(@"%s: parsed complex cast: '%@' to '%@'", __PRETTY_FUNCTION__,
- obj, cast);
+ NSLog(@"%s: parsed complex cast: '%@' to '%@'",
+ __PRETTY_FUNCTION__, obj, cast);
}
pos += (ce - cs);
pos++; // skip '
if (qDebug) {
NSLog(@"%s: return <%@> for <%s> ", __PRETTY_FUNCTION__,
- obj?obj:@"<nil>", _buf);
+ obj != nil ? obj : (id)@"<nil>", _buf);
}
if (obj != nil) {
+ NSDictionary *d;
id keys[2], values[2];
keys[0] = @"length"; values[0] = [NSNumber numberWithUnsignedInt:pos];
keys[1] = @"object"; values[1] = obj;
- [_ctx setResult:
- [NSDictionary dictionaryWithObjects:values forKeys:keys count:2]
- forFunction:@"parseValue" atPos:(unsigned)_buf];
+ d = [[NSDictionary alloc] initWithObjects:values forKeys:keys count:2];
+ [_ctx setResult:d forFunction:@"parseValue" atPos:(unsigned long)_buf];
+ [d release];
*_keyLen = pos;
}
return obj;