+2005-04-24 Helge Hess <helge.hess@opengroupware.org>
+
+ * v4.5.152
+
+ * Templates/WODParser.m: rewrote parser to use unichar
+
+ * DynamicElements, WOResponse+private.h: fixed gcc 4.0 warnings
+
2005-04-12 Helge Hess <helge.hess@opengroupware.org>
* v4.5.151
-# $Id$
+# compilation flags
ADDITIONAL_CPPFLAGS += -pipe
# -DHTML_DEBUG=1
# -DPROFILE_CLUSTERS=1
-ADDITIONAL_CPPFLAGS += -pipe -Wall
+ADDITIONAL_CPPFLAGS += -pipe -Wall -funsigned-char
ADDITIONAL_CPPFLAGS += -DCOMPILING_NGOBJWEB=1
DynamicElements_INCLUDE_DIRS += \
}
- (void)dealloc {
- RELEASE(self->template);
- RELEASE(self->queryDictionary);
- RELEASE(self->queryParameters);
- RELEASE(self->fragmentIdentifier);
+ [self->template release];
+ [self->queryDictionary release];
+ [self->queryParameters release];
+ [self->fragmentIdentifier release];
[super dealloc];
}
/* accessors */
-- (WOElement *)template {
+- (id)template {
return self->template;
}
-// ******************** responder ********************
+/* handling requests */
- (void)takeValuesFromRequest:(WORequest *)_req inContext:(WOContext *)_ctx {
/* links can take form values !!!! (for query-parameters) */
return NO;
}
+/* generate response */
+
- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
- if (![[_ctx request] isFromClientComponent]) {
- WOComponent *sComponent = [_ctx component];
- NSString *queryString = nil;
+ WOComponent *sComponent;
+ NSString *queryString = nil;
- if ([self _appendHrefToResponse:_response inContext:_ctx]) {
- queryString = [self queryStringForQueryDictionary:
- [self->queryDictionary valueInComponent:sComponent]
- andQueryParameters:self->queryParameters
- inContext:_ctx];
- }
+ if ([[_ctx request] isFromClientComponent])
+ return;
+
+ sComponent = [_ctx component];
+
+ if ([self _appendHrefToResponse:_response inContext:_ctx]) {
+ queryString = [self queryStringForQueryDictionary:
+ [self->queryDictionary valueInComponent:sComponent]
+ andQueryParameters:self->queryParameters
+ inContext:_ctx];
+ }
- if (self->fragmentIdentifier) {
- [_response appendContentCharacter:'#'];
- WOResponse_AddString(_response,
+ if (self->fragmentIdentifier != nil) {
+ [_response appendContentCharacter:'#'];
+ WOResponse_AddString(_response,
[self->fragmentIdentifier stringValueInComponent:sComponent]);
- }
- if (queryString) {
- [_response appendContentCharacter:'?'];
- WOResponse_AddString(_response, queryString);
- }
-
- /* content */
- [self->template appendToResponse:_response inContext:_ctx];
}
+ if (queryString != nil) {
+ [_response appendContentCharacter:'?'];
+ WOResponse_AddString(_response, queryString);
+ }
+
+ /* content */
+ [self->template appendToResponse:_response inContext:_ctx];
}
/* description */
/* accessors */
-- (WOElement *)template {
+- (id)template {
return self->template;
}
WOResponse_AddCString(_response, "\"");
if ([self->disabled boolValueInComponent:[_ctx component]]) {
- WOResponse_AddCString(_response, _ctx->wcFlags.allowEmptyAttributes
- ? " disabled" : " disabled=\"disabled\"");
+ WOResponse_AddCString(_response,
+ (_ctx->wcFlags.allowEmptyAttributes
+ ? " disabled" : " disabled=\"disabled\""));
}
if (isChecked) {
- WOResponse_AddCString(_response, _ctx->wcFlags.allowEmptyAttributes
- ? " checked" : " checked=\"checked\"");
+ WOResponse_AddCString(_response,
+ (_ctx->wcFlags.allowEmptyAttributes
+ ? " checked" : " checked=\"checked\""));
}
[self appendExtraAttributesToResponse:_response inContext:_ctx];
WOResponse_AddCString(_response, "\"");
if ([self->disabled boolValueInComponent:sComponent]) {
- WOResponse_AddCString(_response, _ctx->wcFlags.allowEmptyAttributes
- ? " disabled" : " disabled=\"disabled\"");
+ WOResponse_AddCString(_response,
+ (_ctx->wcFlags.allowEmptyAttributes
+ ? " disabled" : " disabled=\"disabled\""));
}
if ([selArray containsObject:object]) {
- WOResponse_AddCString(_response, _ctx->wcFlags.allowEmptyAttributes
- ? " checked" : " checked=\"checked\"");
+ WOResponse_AddCString(_response,
+ (_ctx->wcFlags.allowEmptyAttributes
+ ? " checked" : " checked=\"checked\""));
}
[self appendExtraAttributesToResponse:_response inContext:_ctx];
/* accessors */
-- (WOElement *)template {
+- (id)template {
return self->template;
}
/* handle active form elements */
-- (WOElement *)template {
+- (id)template {
return self->template;
}
-// ******************** responder ********************
+/* handling requests */
-- (void)takeValuesFromRequest:(WORequest *)_request
- inContext:(WOContext *)_ctx
-{
+- (void)takeValuesFromRequest:(WORequest *)_rq inContext:(WOContext *)_ctx {
static int alwaysPassIn = -1;
if (alwaysPassIn == -1) {
id value;
assoc = [self->queryParameters objectForKey:key];
- value = [_request formValueForKey:key];
+ value = [_rq formValueForKey:key];
[assoc setValue:value inComponent:sComponent];
}
}
if ([[self->href stringValueInComponent:sComponent]
- isEqualToString:[_request uri]]) {
+ isEqualToString:[_rq uri]]) {
if (debugTakeValues) {
- NSArray *formValues = [_request formValueKeys];
+ NSArray *formValues = [_rq formValueKeys];
NSLog(@"%s: we are uri active (uri=%@): %@ ..", __PRETTY_FUNCTION__,
- [_request uri], formValues);
+ [_rq uri], formValues);
}
doTakeValues = YES;
}
else if ([[_ctx elementID] isEqualToString:[_ctx senderID]]) {
if (debugTakeValues) {
- NSArray *formValues = [_request formValueKeys];
+ NSArray *formValues = [_rq formValueKeys];
NSLog(@"%s: we are elem active (eid=%@): %@ ..", __PRETTY_FUNCTION__,
[_ctx elementID], formValues);
}
}
else {
/* finally, let the component decide */
- doTakeValues = [sComponent shouldTakeValuesFromRequest:_request
+ doTakeValues = [sComponent shouldTakeValuesFromRequest:_rq
inContext:_ctx];
if (debugTakeValues) {
NSLog(@"%s: component should take values: %s ", __PRETTY_FUNCTION__,
if (debugTakeValues)
NSLog(@"%s: taking values ...", __PRETTY_FUNCTION__);
- [self->template takeValuesFromRequest:_request inContext:_ctx];
+ [self->template takeValuesFromRequest:_rq inContext:_ctx];
if (debugTakeValues)
NSLog(@"%s: did take values.", __PRETTY_FUNCTION__);
[_ctx setInForm:NO];
}
-- (id)invokeActionForRequest:(WORequest *)_request
- inContext:(WOContext *)_ctx
-{
+- (id)invokeActionForRequest:(WORequest *)_rq inContext:(WOContext *)_ctx {
id result = nil;
[_ctx setInForm:YES];
if ((element = [_ctx activeFormElement])) {
#if 1
- result = [self->template invokeActionForRequest:_request inContext:_ctx];
+ result = [self->template invokeActionForRequest:_rq inContext:_ctx];
RETAIN(result);
#else
/* wrong - need to setup correct component stack */
- result = [[element invokeActionForRequest:_request
+ result = [[element invokeActionForRequest:_rq
inContext:_ctx]
retain];
#endif
}
}
else
- result = [self->template invokeActionForRequest:_request inContext:_ctx];
+ result = [self->template invokeActionForRequest:_rq inContext:_ctx];
[_ctx setInForm:NO];
return result;
}
+/* generate response */
+
- (NSString *)_addHrefToResponse:(WOResponse *)_r inContext:(WOContext *)_ctx {
/* post to a fixed hyperlink */
WOComponent *sComponent = [_ctx component];
/* accessors */
-- (WOElement *)template {
+- (id)template {
return self->template;
}
-// ******************** responder ********************
+/* handling requests */
- (void)takeValuesFromRequest:(WORequest *)_req inContext:(WOContext *)_ctx {
[self->template takeValuesFromRequest:_req inContext:_ctx];
return [self->template invokeActionForRequest:_req inContext:_ctx];
}
+/* generate response */
+
- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
WOComponent *sComponent;
NSString *tag;
len = [s cStringLength];
cs = malloc(len + 2);
- [s getCString:cs];
+ [s getCString:(char *)cs];
cs[len] = '\0';
self->tagName = cs;
self->tagNameType = TagNameType_ASCII;
/* accessors */
-- (WOElement *)template {
+- (id)template {
return self->template;
}
if (self->checked != nil) {
if ([self->checked boolValueInComponent:sComponent]) {
- WOResponse_AddCString(_response, _ctx->wcFlags.allowEmptyAttributes
- ? " checked" : " checked=\"checked\"");
+ WOResponse_AddCString(_response,
+ (_ctx->wcFlags.allowEmptyAttributes
+ ? " checked" : " checked=\"checked\""));
}
}
else {
v = [self->value valueInComponent:sComponent];
sel = [self->selection valueInComponent:sComponent];
if ((v == sel) || [v isEqual:sel]) {
- WOResponse_AddCString(_response, _ctx->wcFlags.allowEmptyAttributes
- ? " checked" : " checked=\"checked\"");
+ WOResponse_AddCString(_response,
+ (_ctx->wcFlags.allowEmptyAttributes
+ ? " checked" : " checked=\"checked\""));
}
}
if ([self->disabled boolValueInComponent:sComponent]) {
- WOResponse_AddCString(_response, _ctx->wcFlags.allowEmptyAttributes
- ? " disabled" : " disabled=\"disabled\"");
+ WOResponse_AddCString(_response,
+ (_ctx->wcFlags.allowEmptyAttributes
+ ? " disabled" : " disabled=\"disabled\""));
}
[self appendExtraAttributesToResponse:_response inContext:_ctx];
WOResponse_AddCString(_response, "\"");
if (sel == object || [sel isEqual:object]) {
- WOResponse_AddCString(_response, _ctx->wcFlags.allowEmptyAttributes
- ? " checked" : " checked=\"checked\"");
+ WOResponse_AddCString(_response,
+ (_ctx->wcFlags.allowEmptyAttributes
+ ? " checked" : " checked=\"checked\""));
}
if ([self->disabled boolValueInComponent:sComponent]) {
- WOResponse_AddCString(_response, _ctx->wcFlags.allowEmptyAttributes
- ? " disabled" : " disabled=\"disabled\"");
+ WOResponse_AddCString(_response,
+ (_ctx->wcFlags.allowEmptyAttributes
+ ? " disabled" : " disabled=\"disabled\""));
}
[self appendExtraAttributesToResponse:_response inContext:_ctx];
/* accessors */
-- (WOElement *)template {
+- (id)template {
return self->template;
}
return self;
}
- (void)dealloc {
- RELEASE(self->template);
- RELEASE(self->object);
+ [self->template release];
+ [self->object release];
[super dealloc];
}
/* accessors */
-- (WOElement *)template {
+- (id)template {
return self->template;
}
-/* responder */
+/* handling requests */
-- (void)takeValuesFromRequest:(WORequest *)_request
- inContext:(WOContext *)_ctx
-{
+- (void)takeValuesFromRequest:(WORequest *)_rq inContext:(WOContext *)_ctx {
id obj;
obj = [[self->object valueInContext:_ctx] retain];
[_ctx pushCursor:obj];
- [self->template takeValuesFromRequest:_request inContext:_ctx];
+ [self->template takeValuesFromRequest:_rq inContext:_ctx];
[_ctx popCursor];
[obj autorelease];
return [result autorelease];
}
+/* generate response */
+
- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
id obj;
clen = [v cStringLength];
cbuf = malloc(clen + 2);
- [v getCString:cbuf]; cbuf[clen] = '\0';
+ [v getCString:(char *)cbuf]; cbuf[clen] = '\0';
buffer = malloc(clen * 6 + 2); /* longest-encoding: '"' */
if (cbuf) free(cbuf);
clen = (bufPtr - buffer);
self->value = malloc(clen + 2);
- strncpy((char *)self->value, buffer, clen);
+ strncpy((char *)self->value, (const char *)buffer, clen);
((unsigned char *)self->value)[clen] = '\0';
}
else {
/* accessors */
-- (WOElement *)template {
+- (id)template {
return self->template;
}
-// ******************** responder ********************
+/* handle requests */
-- (void)takeValuesFromRequest:(WORequest *)_req inContext:(WOContext *)_ctx {
+- (void)takeValuesFromRequest:(WORequest *)_rq inContext:(WOContext *)_ctx {
/* links can take form values !!!! (for query-parameters) */
if (self->queryParameters) {
assoc = [self->queryParameters objectForKey:key];
if ([assoc isValueSettable]) {
- value = [_req formValueForKey:key];
+ value = [_rq formValueForKey:key];
[assoc setValue:value inComponent:sComponent];
}
}
}
- [self->template takeValuesFromRequest:_req inContext:_ctx];
+ [self->template takeValuesFromRequest:_rq inContext:_ctx];
}
-- (id)invokeActionForRequest:(WORequest *)_request
- inContext:(WOContext *)_ctx
-{
+- (id)invokeActionForRequest:(WORequest *)_rq inContext:(WOContext *)_ctx {
if (self->disabled != nil) {
if ([self->disabled boolValueInComponent:[_ctx component]])
return nil;
if (![[_ctx elementID] isEqualToString:[_ctx senderID]])
/* link is not the active element */
- return [self->template invokeActionForRequest:_request inContext:_ctx];
+ return [self->template invokeActionForRequest:_rq inContext:_ctx];
/* link is active */
[[_ctx session] logWithFormat:@"%@[0x%08X]: no action/page set !",
@end /* _WOHrefHyperlink */
+
@implementation _WOActionHyperlink
- (id)initWithName:(NSString *)_name
/* dynamic invocation */
-- (id)invokeActionForRequest:(WORequest *)_request
+- (id)invokeActionForRequest:(WORequest *)_rq
inContext:(WOContext *)_ctx
{
if (self->disabled) {
if (![[_ctx elementID] isEqualToString:[_ctx senderID]])
/* link is not the active element */
- return [self->template invokeActionForRequest:_request inContext:_ctx];
+ return [self->template invokeActionForRequest:_rq inContext:_ctx];
/* link is active */
return [self executeAction:self->action inContext:_ctx];
@end /* _WOActionHyperlink */
+
@implementation _WOPageHyperlink
- (id)initWithName:(NSString *)_name
[super dealloc];
}
-/* actions */
+/* handle request */
-- (id)invokeActionForRequest:(WORequest *)_request
- inContext:(WOContext *)_ctx
-{
+- (id)invokeActionForRequest:(WORequest *)_rq inContext:(WOContext *)_ctx {
WOComponent *page;
NSString *name;
if (![[_ctx elementID] isEqualToString:[_ctx senderID]])
/* link is not the active element */
- return [self->template invokeActionForRequest:_request inContext:_ctx];
+ return [self->template invokeActionForRequest:_rq inContext:_ctx];
/* link is the active element */
return page;
}
-- (BOOL)_appendHrefToResponse:(WOResponse *)_response
- inContext:(WOContext *)_ctx
-{
+/* generate response */
+
+- (BOOL)_appendHrefToResponse:(WOResponse *)_r inContext:(WOContext *)_ctx {
/*
Profiling:
87% -componentActionURL
13% NSString dataUsingEncoding(appendContentString!)
TODO(prof): use addcstring
*/
- WOResponse_AddString(_response, [_ctx componentActionURL]);
+ WOResponse_AddString(_r, [_ctx componentActionURL]);
return YES;
}
@end /* _WOPageHyperlink */
+
@implementation _WODirectActionHyperlink
- (id)initWithName:(NSString *)_name
[super dealloc];
}
-/* href */
+/* handle requests */
- (void)takeValuesFromRequest:(WORequest *)_req inContext:(WOContext *)_ctx {
/* DA links can *never* take form values !!!! */
[self->template takeValuesFromRequest:_req inContext:_ctx];
}
-- (id)invokeActionForRequest:(WORequest *)_request
- inContext:(WOContext *)_ctx
-{
+- (id)invokeActionForRequest:(WORequest *)_rq inContext:(WOContext *)_ctx {
/* DA links can *never* invoke an action !!!! */
- return [self->template invokeActionForRequest:_request inContext:_ctx];
+ return [self->template invokeActionForRequest:_rq inContext:_ctx];
}
-- (BOOL)_appendHrefToResponse:(WOResponse *)_response
+/* generate response */
+
+- (BOOL)_appendHrefToResponse:(WOResponse *)_r
inContext:(WOContext *)_ctx
{
WOComponent *sComponent;
}
}
- WOResponse_AddString(_response,
+ WOResponse_AddString(_r,
[_ctx directActionURLForActionNamed:daName
queryDictionary:qd]);
return NO;
/* parser */
-static id _parseProperty(NSZone *_zone, const char *_buffer, unsigned *_idx,
+static id _parseProperty(NSZone *_zone, const unichar *_buffer, unsigned *_idx,
unsigned _len, NSException **_exception,
BOOL _allowAssoc, id self);
-static id _parseWodEntry(NSZone *_zone, const char *_buffer, unsigned *_idx,
+static id _parseWodEntry(NSZone *_zone, const unichar *_buffer, unsigned *_idx,
unsigned _len, NSException **_exception,
NSString **_name, NSString **_class,
id self);
-static NSString *_makeStringForBuffer(const unsigned char *_buf, unsigned _l) {
- // TODO: duplicate code with WOHTMLParser, but probably isn't worth a
- // separate file
- NSString *r;
- NSData *data;
-
+static NSString *_makeStringForBuffer(const unichar *_buf, unsigned _l) {
if (_l == 0)
return @"";
-
- if (!useUTF8)
- return [[StrClass alloc] initWithCString:_buf length:_l];
-
- // Note: we cast the pointer because we are not going to modify _buf for the
- // duration and we are never going to write the data - should work
- // with any Foundation, but isn't strictly API compatible
- data = [[NSData alloc] initWithBytesNoCopy:(void *)_buf length:_l
- freeWhenDone:NO];
- r = [[StrClass alloc] initWithData:data encoding:NSUTF8StringEncoding];
- [data release];
- return r;
+
+ return [[StrClass alloc] initWithCharacters:_buf length:_l];
}
-- (NSException *)parseDefinitionsFromBuffer:(const char *)_buffer
+- (NSException *)parseDefinitionsFromBuffer:(const unichar *)_buffer
length:(unsigned)_len
mappings:(NSMutableDictionary *)_mappings
{
while ((entry = _parseWodEntry(NULL, _buffer, &idx, _len, &exception,
&elementName, &componentName,
- self))) {
+ self)) != NULL) {
id def;
if (exception) {
- RELEASE(entry); entry = nil;
- RELEASE(elementName); elementName = nil;
- RELEASE(componentName); componentName = nil;
+ [entry release]; entry = nil;
+ [elementName release]; elementName = nil;
+ [componentName release]; componentName = nil;
break;
}
associations:entry
elementName:elementName];
- RELEASE(componentName); componentName = nil;
- RELEASE(entry); entry = nil;
+ [componentName release]; componentName = nil;
+ [entry release]; entry = nil;
if ((def != nil) && (elementName != nil))
[_mappings setObject:def forKey:elementName];
#if 0
NSLog(@"defined element %@ definition=%@", elementName, def);
#endif
- RELEASE(elementName); elementName = nil;
+ [elementName release]; elementName = nil;
}
return exception;
/* parsing */
+- (NSStringEncoding)stringEncodingForData:(NSData *)_data {
+ // TODO: we could check for UTF-16 marker in front of data
+ return useUTF8 ? NSUTF8StringEncoding : [NSString defaultCStringEncoding];
+}
+
- (NSDictionary *)parseDeclarationData:(NSData *)_decl {
NSMutableDictionary *defs;
- NSException *ex;
+ NSException *ex;
+ NSString *s;
+ unichar *buf;
+ unsigned int bufLen;
if (![self->callback parser:self willParseDeclarationData:_decl])
return nil;
-
+
+ /* recode buffer using NSString */
+
+ s = [[NSString alloc] initWithData:_decl
+ encoding:[self stringEncodingForData:_decl]];
+ bufLen = [s length];
+ buf = calloc(bufLen + 2, sizeof(unichar));
+ [s getCharacters:buf];
+ [s release]; s = nil;
+ buf[bufLen] = 0; /* null-terminate buffer, parser might need that */
+
+ /* start parsing */
+
defs = [NSMutableDictionary dictionaryWithCapacity:100];
- ex = [self parseDefinitionsFromBuffer:[_decl bytes]
- length:[_decl length]
- mappings:defs];
+ ex = [self parseDefinitionsFromBuffer:buf length:bufLen mappings:defs];
- if (ex)
- [self->callback parser:self failedParsingDeclarationData:_decl exception:ex];
+ if (buf != NULL) free(buf); buf = NULL;
+
+ /* report results */
+
+ if (ex != nil) {
+ [self->callback parser:self failedParsingDeclarationData:_decl
+ exception:ex];
+ }
else {
[self->callback parser:self finishedParsingDeclarationData:_decl
declarations:defs];
}
-static int _numberOfLines(const char *_buffer, unsigned _lastIdx) {
+static int _numberOfLines(const unichar *_buffer, unsigned _lastIdx) {
register unsigned pos, lineCount = 1;
-
+
for (pos = 0; (pos < _lastIdx) && (_buffer[pos] != '\0'); pos++) {
if (_buffer[pos] == '\n')
lineCount++;
return lineCount;
}
-static inline BOOL _isBreakChar(unsigned char _c) {
+static inline BOOL _isBreakChar(const unichar _c) {
switch (_c) {
case ' ': case '\t': case '\n': case '\r':
case '=': case ';': case ',':
return NO;
}
}
-static inline BOOL _isIdChar(unsigned char _c) {
+static inline BOOL _isIdChar(const unichar _c) {
return (_isBreakChar(_c) && (_c != '.')) ? NO : YES;
}
-static inline int _valueOfHexChar(unsigned char _c) {
+static inline int _valueOfHexChar(const unichar _c) {
switch (_c) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
return -1;
}
}
-static inline BOOL _isHexDigit(unsigned char _c) {
+static inline BOOL _isHexDigit(const unichar _c) {
switch (_c) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
}
static NSException *_makeException(NSException *_exception,
- const char *_buffer, unsigned _idx,
+ const unichar *_buffer, unsigned _idx,
unsigned _len, NSString *_text)
{
NSMutableDictionary *ui = nil;
if (!atEof && (_idx > 0)) {
register unsigned pos;
- const char *startPos, *endPos;
+ const unichar *startPos, *endPos;
for (pos = _idx; (pos >= 0) && (_buffer[pos] != '\n'); pos--)
;
return exception;
}
-static BOOL _skipComments(const char *_buffer, unsigned *_idx, unsigned _len,
+static BOOL _skipComments(const unichar *_buffer,
+ unsigned *_idx, unsigned _len,
NSException **_exception)
{
register unsigned pos = *_idx;
}
static NSString *_parseIdentifier(NSZone *_zone,
- const char *_buffer, unsigned *_idx,
+ const unichar *_buffer, unsigned *_idx,
unsigned _len, NSException **_exception)
{
register unsigned pos = *_idx;
}
}
static NSString *_parseKeyPath(NSZone *_zone,
- const char *_buffer, unsigned *_idx,
+ const unichar *_buffer, unsigned *_idx,
unsigned _len, NSException **_exception,
id self)
{
*_idx += 1; // skip '.'
[keypath appendString:@"."];
- RELEASE(component); component = nil;
+ [component release]; component = nil;
component = _parseIdentifier(_zone, _buffer, _idx, _len, _exception);
if (component == nil) {
- RELEASE(keypath); keypath = nil;
+ [keypath release]; keypath = nil;
*_exception =
_makeException(*_exception, _buffer, *_idx, _len,
@"expected component after '.' in keypath !");
[keypath appendString:component];
}
- RELEASE(component); component = nil;
+ [component release]; component = nil;
return keypath;
}
static NSString *_parseQString(NSZone *_zone,
- const char *_buffer, unsigned *_idx,
+ const unichar *_buffer, unsigned *_idx,
unsigned _len, NSException **_exception,
id self)
{
}
if (_buffer[*_idx] != '"') { // it's not a quoted string that's follows
- *_exception = _makeException(*_exception, _buffer, *_idx, _len,
- @"did not find quoted string (expected '\"')");
+ *_exception =
+ _makeException(*_exception, _buffer, *_idx, _len,
+ @"did not find quoted string (expected '\"')");
return nil;
}
else { // a quoted string
if (pos == _len) { // syntax error, quote not closed
*_idx = pos;
- *_exception = _makeException(*_exception, _buffer, *_idx, _len,
- @"quoted string not closed (expected '\"')");
+ *_exception =
+ _makeException(*_exception, _buffer, *_idx, _len,
+ @"quoted string not closed (expected '\"')");
return nil;
}
*_idx = pos; // store pointer
pos = 0;
- if (len == 0) { // empty string
+ if (len == 0) /* empty string */
return @"";
- }
- else if (containsEscaped) {
+
+ if (containsEscaped) {
register unsigned pos2;
id ostr = nil;
- unsigned char *str;
+ unichar *str;
NSCAssert(len > 0, @"invalid length ..");
- str = malloc(len + 3);
+ str = calloc(len + 3, sizeof(unichar));
for (pos = startPos, pos2 = 0; _buffer[pos] != '"'; pos++, pos2++) {
//NSLog(@"char=%c pos=%i pos2=%i", _buffer[pos], pos2);
str[pos2] = _buffer[pos];
}
}
- str[pos2] = '\0';
+ str[pos2] = 0;
NSCAssert(pos2 == len, @"invalid unescape ..");
ostr = _makeStringForBuffer(str, pos2);
- if (str) free(str); str = NULL;
+ if (str != NULL) free(str); str = NULL;
return ostr;
}
}
}
-static NSData *_parseData(NSZone *_zone, const char *_buffer,
+static NSData *_parseData(NSZone *_zone, const unichar *_buffer,
unsigned *_idx, unsigned _len,
NSException **_exception,
id self)
}
static NSDictionary *_parseDict(NSZone *_zone,
- const char *_buffer, unsigned *_idx,
+ const unichar *_buffer, unsigned *_idx,
unsigned _len, NSException **_exception,
id self)
{
}
}
-static NSArray *_parseArray(NSZone *_zone, const char *_buffer, unsigned *_idx,
+static NSArray *_parseArray(NSZone *_zone, const unichar *_buffer, unsigned *_idx,
unsigned _len, NSException **_exception,
id self)
{
: [NumberClass numberWithInt:[digitPath intValue]];
}
-static id _parseProperty(NSZone *_zone, const char *_buffer, unsigned *_idx,
+static BOOL _ucIsEqual(const unichar *s, char *tok, unsigned len) {
+ switch (len) {
+ case 0: return NO;
+ case 1: return (s[0] == tok[0]) ? YES : NO;
+ case 2:
+ if (s[0] != tok[0] || s[0] == 0) return NO;
+ if (s[1] != tok[1]) return NO;
+ return YES;
+ case 3:
+ if (s[0] != tok[0] || s[0] == 0) return NO;
+ if (s[1] != tok[1] || s[1] == 0) return NO;
+ if (s[2] != tok[2]) return NO;
+ return YES;
+ default: {
+ register unsigned int i;
+
+ for (i = 0; i < len; i++) {
+ if (s[i] != tok[i] || s[i] == 0) return NO;
+ }
+ return YES;
+ }
+ }
+ return NO;
+}
+
+static id _parseProperty(NSZone *_zone, const unichar *_buffer, unsigned *_idx,
unsigned _len,
NSException **_exception, BOOL _allowAssoc,
id self)
if ((_buffer[*_idx] == 'Y') || (_buffer[*_idx] == 'N')) {
// parse YES and NO
if ((*_idx + 4) < _len) {
- if (strncmp(&(_buffer[*_idx]), "YES", 3) == 0 &&
+ if (_ucIsEqual(&(_buffer[*_idx]), "YES", 3) == 0 &&
_isBreakChar(_buffer[*_idx + 3])) {
result = [yesNum retain];
valueProperty = YES;
}
}
if (((*_idx + 3) < _len) && !valueProperty) {
- if (strncmp(&(_buffer[*_idx]), "NO", 2) == 0 &&
+ if (_ucIsEqual(&(_buffer[*_idx]), "NO", 2) == 0 &&
_isBreakChar(_buffer[*_idx + 2])) {
result = [noNum retain];
valueProperty = YES;
else if ((_buffer[*_idx] == 't') || (_buffer[*_idx] == 'f')) {
// parse true and false
if ((*_idx + 5) < _len) {
- if (strncmp(&(_buffer[*_idx]), "true", 4) == 0 &&
+ if (_ucIsEqual(&(_buffer[*_idx]), "true", 4) == 0 &&
_isBreakChar(_buffer[*_idx + 4])) {
result = [yesNum retain];
valueProperty = YES;
}
}
if (((*_idx + 6) < _len) && !valueProperty) {
- if (strncmp(&(_buffer[*_idx]), "false", 5) == 0 &&
+ if (_ucIsEqual(&(_buffer[*_idx]), "false", 5) == 0 &&
_isBreakChar(_buffer[*_idx + 5])) {
result = [noNum retain];
valueProperty = YES;
return result;
}
-static NSDictionary *_parseWodConfig(NSZone *_zone, const char *_buffer,
+static NSDictionary *_parseWodConfig(NSZone *_zone, const unichar *_buffer,
unsigned *_idx, unsigned _len,
NSException **_exception,
id self)
}
}
-static id _parseWodEntry(NSZone *_zone, const char *_buffer, unsigned *_idx,
+static id _parseWodEntry(NSZone *_zone, const unichar *_buffer, unsigned *_idx,
unsigned _len, NSException **_exception,
NSString **_name, NSString **_class, id self)
{
# version file
-SUBMINOR_VERSION:=151
+SUBMINOR_VERSION:=152
# v4.5.122 requires libNGExtensions v4.5.153
# v4.5.91 requires libNGExtensions v4.5.134
// fast inline functions (non-WO)
#define WOResponse_AddChar(__R__,__C__) \
- if (__R__) {__R__->addChar(__R__, @selector(appendContentCharacter:), __C__);}
+ if (__R__) {__R__->addChar(__R__, @selector(appendContentCharacter:), \
+ __C__);}
#define WOResponse_AddString(__R__,__C__) \
if (__R__) {__R__->addStr(__R__, @selector(appendContentString:), __C__);}
#define WOResponse_AddCString(__R__,__C__) \
- if (__R__) {__R__->addCStr(__R__, @selector(appendContentCString:), __C__);}
+ if (__R__) {__R__->addCStr(__R__, @selector(appendContentCString:), \
+ (const unsigned char *)__C__);}
#define WOResponse_AddHtmlString(__R__,__C__) \
- if (__R__) {__R__->addHStr(__R__, @selector(appendContentHTMLString:), __C__);}
+ if (__R__) {__R__->addHStr(__R__, @selector(appendContentHTMLString:), \
+ __C__);}
// TODO: performance ! - use static buffer and appendContentCString !
#define WOResponse_AddUInt(__R__,__C__) \
if (__R__) {\
switch(__C__) {\
- case 0: __R__->addCStr(__R__, @selector(appendContentCString:),"0");break;\
- case 1: __R__->addCStr(__R__, @selector(appendContentCString:),"1");break;\
- case 2: __R__->addCStr(__R__, @selector(appendContentCString:),"2");break;\
- case 3: __R__->addCStr(__R__, @selector(appendContentCString:),"3");break;\
- case 4: __R__->addCStr(__R__, @selector(appendContentCString:),"4");break;\
+ case 0: __R__->addCStr(__R__, @selector(appendContentCString:),\
+ (const unsigned char *)"0");break; \
+ case 1: __R__->addCStr(__R__, @selector(appendContentCString:),\
+ (const unsigned char *)"1");break; \
+ case 2: __R__->addCStr(__R__, @selector(appendContentCString:),\
+ (const unsigned char *)"2");break; \
+ case 3: __R__->addCStr(__R__, @selector(appendContentCString:),\
+ (const unsigned char *)"3");break; \
+ case 4: __R__->addCStr(__R__, @selector(appendContentCString:),\
+ (const unsigned char *)"4");break; \
default: {\
- char buf[12]; sprintf(buf,"%d", __C__); \
+ unsigned char buf[12]; \
+ sprintf((char *)buf,"%d", __C__); \
__R__->addCStr(__R__, @selector(appendContentCString:), buf);}\
}\
}
#define WOResponse_AddInt(__R__,__C__) \
if (__R__) {\
switch(__C__) {\
- case 0: __R__->addCStr(__R__, @selector(appendContentCString:),"0");break;\
- case 1: __R__->addCStr(__R__, @selector(appendContentCString:),"1");break;\
- case 2: __R__->addCStr(__R__, @selector(appendContentCString:),"2");break;\
- case 3: __R__->addCStr(__R__, @selector(appendContentCString:),"3");break;\
- case 4: __R__->addCStr(__R__, @selector(appendContentCString:),"4");break;\
+ case 0: __R__->addCStr(__R__, @selector(appendContentCString:),\
+ (const unsigned char *)"0");break; \
+ case 1: __R__->addCStr(__R__, @selector(appendContentCString:),\
+ (const unsigned char *)"1");break; \
+ case 2: __R__->addCStr(__R__, @selector(appendContentCString:),\
+ (const unsigned char *)"2");break; \
+ case 3: __R__->addCStr(__R__, @selector(appendContentCString:),\
+ (const unsigned char *)"3");break; \
+ case 4: __R__->addCStr(__R__, @selector(appendContentCString:),\
+ (const unsigned char *)"4");break; \
default: {\
- char buf[12]; sprintf(buf,"%i", __C__); \
+ unsigned char buf[12]; \
+ sprintf((char *)buf,"%d", __C__); \
__R__->addCStr(__R__, @selector(appendContentCString:), buf);}\
}\
}
move-headers-to-fhs :: fhs-header-dirs
@echo "moving headers to $(FHS_INCLUDE_DIR) .."
- mv $(GNUSTEP_HEADERS)$(libNGObjWeb_HEADER_FILES_INSTALL_DIR)/*.h \
+ mv -f $(GNUSTEP_HEADERS)$(libNGObjWeb_HEADER_FILES_INSTALL_DIR)/*.h \
$(FHS_INCLUDE_DIR)$(libNGObjWeb_HEADER_FILES_INSTALL_DIR)/
- mv $(GNUSTEP_HEADERS)/NGHttp/*.h $(FHS_INCLUDE_DIR)/NGHttp/
+ mv -f $(GNUSTEP_HEADERS)/NGHttp/*.h $(FHS_INCLUDE_DIR)/NGHttp/
move-libs-to-fhs ::
@echo "moving libs to $(FHS_LIB_DIR) .."
- mv $(NONFHS_LIBDIR)/$(NONFHS_LIBNAME)* $(FHS_LIB_DIR)/
+ mv -f $(NONFHS_LIBDIR)/$(NONFHS_LIBNAME)* $(FHS_LIB_DIR)/
move-tools-to-fhs :: fhs-bin-dirs
@echo "moving tools from $(NONFHS_BINDIR) to $(FHS_BIN_DIR) .."
for i in $(TOOL_NAME); do \
- mv "$(NONFHS_BINDIR)/$${i}" $(FHS_BIN_DIR); \
+ mv -f "$(NONFHS_BINDIR)/$${i}" $(FHS_BIN_DIR); \
done
move-bundles-to-fhs :: fhs-products-dirs
for i in $(BUNDLE_NAME); do \
j="$(FHS_SO_DIR)/$${i}$(BUNDLE_EXTENSION)"; \
if test -d $$j; then rm -r $$j; fi; \
- mv "$(BUNDLE_INSTALL_DIR)/$${i}$(BUNDLE_EXTENSION)" $$j; \
+ mv -f "$(BUNDLE_INSTALL_DIR)/$${i}$(BUNDLE_EXTENSION)" $$j; \
done
move-to-fhs :: move-headers-to-fhs move-libs-to-fhs move-tools-to-fhs \