From: helge Date: Sun, 24 Apr 2005 14:26:34 +0000 (+0000) Subject: rewrote .wod parser to use 'unichar' X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af9ee4c8a882dc556e194dd9ed573c81b2aefd83;p=sope rewrote .wod parser to use 'unichar' fixed some gcc 4.0 warnings git-svn-id: http://svn.opengroupware.org/SOPE/trunk@765 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index 95fd2616..3b361bc5 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,3 +1,11 @@ +2005-04-24 Helge Hess + + * 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 * v4.5.151 diff --git a/sope-appserver/NGObjWeb/DynamicElements/GNUmakefile.preamble b/sope-appserver/NGObjWeb/DynamicElements/GNUmakefile.preamble index b540adce..1721fee9 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/GNUmakefile.preamble +++ b/sope-appserver/NGObjWeb/DynamicElements/GNUmakefile.preamble @@ -1,10 +1,10 @@ -# $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 += \ diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOActionURL.m b/sope-appserver/NGObjWeb/DynamicElements/WOActionURL.m index 5d27367d..d95f69f1 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOActionURL.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOActionURL.m @@ -122,20 +122,20 @@ } - (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) */ @@ -178,31 +178,36 @@ 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 */ diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOBody.m b/sope-appserver/NGObjWeb/DynamicElements/WOBody.m index 8bf43e3b..4fe6a3be 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOBody.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOBody.m @@ -72,7 +72,7 @@ /* accessors */ -- (WOElement *)template { +- (id)template { return self->template; } diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOCheckBox.m b/sope-appserver/NGObjWeb/DynamicElements/WOCheckBox.m index fb265f2b..72c6d131 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOCheckBox.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOCheckBox.m @@ -97,13 +97,15 @@ 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]; diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOCheckBoxList.m b/sope-appserver/NGObjWeb/DynamicElements/WOCheckBoxList.m index a22794fa..4b924d58 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOCheckBoxList.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOCheckBoxList.m @@ -194,13 +194,15 @@ 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]; diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOConditional.m b/sope-appserver/NGObjWeb/DynamicElements/WOConditional.m index 8264dfbf..494ea9c0 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOConditional.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOConditional.m @@ -155,7 +155,7 @@ static int descriptiveIDs = -1; /* accessors */ -- (WOElement *)template { +- (id)template { return self->template; } diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOForm.m b/sope-appserver/NGObjWeb/DynamicElements/WOForm.m index 0665ee3b..bceb3e7e 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOForm.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOForm.m @@ -90,15 +90,13 @@ static int debugTakeValues = -1; /* 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) { @@ -128,24 +126,24 @@ static int debugTakeValues = -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); } @@ -158,7 +156,7 @@ static int debugTakeValues = -1; } 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__, @@ -170,7 +168,7 @@ static int debugTakeValues = -1; 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__); @@ -193,9 +191,7 @@ static int debugTakeValues = -1; [_ctx setInForm:NO]; } -- (id)invokeActionForRequest:(WORequest *)_request - inContext:(WOContext *)_ctx -{ +- (id)invokeActionForRequest:(WORequest *)_rq inContext:(WOContext *)_ctx { id result = nil; [_ctx setInForm:YES]; @@ -205,11 +201,11 @@ static int debugTakeValues = -1; 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 @@ -234,13 +230,15 @@ static int debugTakeValues = -1; } } 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]; diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOGenericContainer.m b/sope-appserver/NGObjWeb/DynamicElements/WOGenericContainer.m index 39d99eef..45c5c4be 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOGenericContainer.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOGenericContainer.m @@ -61,11 +61,11 @@ /* accessors */ -- (WOElement *)template { +- (id)template { return self->template; } -// ******************** responder ******************** +/* handling requests */ - (void)takeValuesFromRequest:(WORequest *)_req inContext:(WOContext *)_ctx { [self->template takeValuesFromRequest:_req inContext:_ctx]; @@ -74,6 +74,8 @@ return [self->template invokeActionForRequest:_req inContext:_ctx]; } +/* generate response */ + - (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx { WOComponent *sComponent; NSString *tag; diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOGenericElement.m b/sope-appserver/NGObjWeb/DynamicElements/WOGenericElement.m index 290b025c..e10d10b2 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOGenericElement.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOGenericElement.m @@ -116,7 +116,7 @@ typedef struct { len = [s cStringLength]; cs = malloc(len + 2); - [s getCString:cs]; + [s getCString:(char *)cs]; cs[len] = '\0'; self->tagName = cs; self->tagNameType = TagNameType_ASCII; diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOHtml.m b/sope-appserver/NGObjWeb/DynamicElements/WOHtml.m index 81a11131..27925b0b 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOHtml.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOHtml.m @@ -56,7 +56,7 @@ /* accessors */ -- (WOElement *)template { +- (id)template { return self->template; } diff --git a/sope-appserver/NGObjWeb/DynamicElements/WORadioButton.m b/sope-appserver/NGObjWeb/DynamicElements/WORadioButton.m index 3b2f3a16..508662bb 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WORadioButton.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WORadioButton.m @@ -102,8 +102,9 @@ 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 { @@ -112,14 +113,16 @@ 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]; diff --git a/sope-appserver/NGObjWeb/DynamicElements/WORadioButtonList.m b/sope-appserver/NGObjWeb/DynamicElements/WORadioButtonList.m index 5ad8d250..ffacf539 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WORadioButtonList.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WORadioButtonList.m @@ -153,13 +153,15 @@ 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]; diff --git a/sope-appserver/NGObjWeb/DynamicElements/WORepetition.m b/sope-appserver/NGObjWeb/DynamicElements/WORepetition.m index 2a9a9e62..5e06bb73 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WORepetition.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WORepetition.m @@ -237,7 +237,7 @@ static inline Class _classForConfig(NSDictionary *_config) { /* accessors */ -- (WOElement *)template { +- (id)template { return self->template; } diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOSetCursor.m b/sope-appserver/NGObjWeb/DynamicElements/WOSetCursor.m index 87dffee4..49867f67 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOSetCursor.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOSetCursor.m @@ -50,28 +50,26 @@ 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]; @@ -91,6 +89,8 @@ return [result autorelease]; } +/* generate response */ + - (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx { id obj; diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOString.m b/sope-appserver/NGObjWeb/DynamicElements/WOString.m index f3ff6259..fc9c9d03 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOString.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOString.m @@ -278,7 +278,7 @@ 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: '"' */ @@ -323,7 +323,7 @@ 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 { diff --git a/sope-appserver/NGObjWeb/DynamicElements/_WOComplexHyperlink.m b/sope-appserver/NGObjWeb/DynamicElements/_WOComplexHyperlink.m index b159c363..61c4ce76 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/_WOComplexHyperlink.m +++ b/sope-appserver/NGObjWeb/DynamicElements/_WOComplexHyperlink.m @@ -148,13 +148,13 @@ static Class NSURLClass = Nil; /* 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) { @@ -170,18 +170,16 @@ static Class NSURLClass = Nil; 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; @@ -189,7 +187,7 @@ static Class NSURLClass = 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 !", @@ -445,6 +443,7 @@ static BOOL debugStaticLinks = NO; @end /* _WOHrefHyperlink */ + @implementation _WOActionHyperlink - (id)initWithName:(NSString *)_name @@ -464,7 +463,7 @@ static BOOL debugStaticLinks = NO; /* dynamic invocation */ -- (id)invokeActionForRequest:(WORequest *)_request +- (id)invokeActionForRequest:(WORequest *)_rq inContext:(WOContext *)_ctx { if (self->disabled) { @@ -474,7 +473,7 @@ static BOOL debugStaticLinks = NO; 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]; @@ -499,6 +498,7 @@ static BOOL debugStaticLinks = NO; @end /* _WOActionHyperlink */ + @implementation _WOPageHyperlink - (id)initWithName:(NSString *)_name @@ -516,11 +516,9 @@ static BOOL debugStaticLinks = NO; [super dealloc]; } -/* actions */ +/* handle request */ -- (id)invokeActionForRequest:(WORequest *)_request - inContext:(WOContext *)_ctx -{ +- (id)invokeActionForRequest:(WORequest *)_rq inContext:(WOContext *)_ctx { WOComponent *page; NSString *name; @@ -531,7 +529,7 @@ static BOOL debugStaticLinks = NO; 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 */ @@ -546,16 +544,16 @@ static BOOL debugStaticLinks = NO; 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; } @@ -571,6 +569,7 @@ static BOOL debugStaticLinks = NO; @end /* _WOPageHyperlink */ + @implementation _WODirectActionHyperlink - (id)initWithName:(NSString *)_name @@ -593,21 +592,21 @@ static BOOL debugStaticLinks = NO; [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; @@ -671,7 +670,7 @@ static BOOL debugStaticLinks = NO; } } - WOResponse_AddString(_response, + WOResponse_AddString(_r, [_ctx directActionURLForActionNamed:daName queryDictionary:qd]); return NO; diff --git a/sope-appserver/NGObjWeb/Templates/WODParser.m b/sope-appserver/NGObjWeb/Templates/WODParser.m index 242e62d0..153300d1 100644 --- a/sope-appserver/NGObjWeb/Templates/WODParser.m +++ b/sope-appserver/NGObjWeb/Templates/WODParser.m @@ -74,37 +74,22 @@ static BOOL useUTF8 = 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 { @@ -118,13 +103,13 @@ static NSString *_makeStringForBuffer(const unsigned char *_buf, unsigned _l) { 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; } @@ -136,15 +121,15 @@ static NSString *_makeStringForBuffer(const unsigned char *_buf, unsigned _l) { 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; @@ -152,21 +137,45 @@ static NSString *_makeStringForBuffer(const unsigned char *_buf, unsigned _l) { /* 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]; @@ -176,9 +185,9 @@ static NSString *_makeStringForBuffer(const unsigned char *_buf, unsigned _l) { } -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++; @@ -186,7 +195,7 @@ static int _numberOfLines(const char *_buffer, unsigned _lastIdx) { 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 ',': @@ -199,11 +208,11 @@ static inline BOOL _isBreakChar(unsigned char _c) { 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': @@ -221,7 +230,7 @@ static inline int _valueOfHexChar(unsigned char _c) { 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': @@ -237,7 +246,7 @@ static inline BOOL _isHexDigit(unsigned char _c) { } static NSException *_makeException(NSException *_exception, - const char *_buffer, unsigned _idx, + const unichar *_buffer, unsigned _idx, unsigned _len, NSString *_text) { NSMutableDictionary *ui = nil; @@ -270,7 +279,7 @@ static NSException *_makeException(NSException *_exception, if (!atEof && (_idx > 0)) { register unsigned pos; - const char *startPos, *endPos; + const unichar *startPos, *endPos; for (pos = _idx; (pos >= 0) && (_buffer[pos] != '\n'); pos--) ; @@ -301,7 +310,8 @@ static NSException *_makeException(NSException *_exception, 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; @@ -374,7 +384,7 @@ static BOOL _skipComments(const char *_buffer, unsigned *_idx, unsigned _len, } static NSString *_parseIdentifier(NSZone *_zone, - const char *_buffer, unsigned *_idx, + const unichar *_buffer, unsigned *_idx, unsigned _len, NSException **_exception) { register unsigned pos = *_idx; @@ -407,7 +417,7 @@ static NSString *_parseIdentifier(NSZone *_zone, } } static NSString *_parseKeyPath(NSZone *_zone, - const char *_buffer, unsigned *_idx, + const unichar *_buffer, unsigned *_idx, unsigned _len, NSException **_exception, id self) { @@ -437,11 +447,11 @@ static NSString *_parseKeyPath(NSZone *_zone, *_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 !"); @@ -450,13 +460,13 @@ static NSString *_parseKeyPath(NSZone *_zone, [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) { @@ -469,8 +479,9 @@ static NSString *_parseQString(NSZone *_zone, } 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 @@ -499,8 +510,9 @@ static NSString *_parseQString(NSZone *_zone, 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; } @@ -508,16 +520,16 @@ static NSString *_parseQString(NSZone *_zone, *_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); @@ -541,11 +553,11 @@ static NSString *_parseQString(NSZone *_zone, 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; } @@ -556,7 +568,7 @@ static NSString *_parseQString(NSZone *_zone, } } -static NSData *_parseData(NSZone *_zone, const char *_buffer, +static NSData *_parseData(NSZone *_zone, const unichar *_buffer, unsigned *_idx, unsigned _len, NSException **_exception, id self) @@ -653,7 +665,7 @@ static NSData *_parseData(NSZone *_zone, const char *_buffer, } static NSDictionary *_parseDict(NSZone *_zone, - const char *_buffer, unsigned *_idx, + const unichar *_buffer, unsigned *_idx, unsigned _len, NSException **_exception, id self) { @@ -807,7 +819,7 @@ static NSDictionary *_parseDict(NSZone *_zone, } } -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) { @@ -905,7 +917,32 @@ static NSNumber *_parseDigitPath(NSString *digitPath) { : [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) @@ -955,7 +992,7 @@ static id _parseProperty(NSZone *_zone, const char *_buffer, unsigned *_idx, 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; @@ -963,7 +1000,7 @@ static id _parseProperty(NSZone *_zone, const char *_buffer, unsigned *_idx, } } 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; @@ -974,7 +1011,7 @@ static id _parseProperty(NSZone *_zone, const char *_buffer, unsigned *_idx, 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; @@ -982,7 +1019,7 @@ static id _parseProperty(NSZone *_zone, const char *_buffer, unsigned *_idx, } } 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; @@ -1034,7 +1071,7 @@ static id _parseProperty(NSZone *_zone, const char *_buffer, unsigned *_idx, 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) @@ -1194,7 +1231,7 @@ static NSDictionary *_parseWodConfig(NSZone *_zone, const char *_buffer, } } -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) { diff --git a/sope-appserver/NGObjWeb/Version b/sope-appserver/NGObjWeb/Version index 74e87125..8cf51b05 100644 --- a/sope-appserver/NGObjWeb/Version +++ b/sope-appserver/NGObjWeb/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=151 +SUBMINOR_VERSION:=152 # v4.5.122 requires libNGExtensions v4.5.153 # v4.5.91 requires libNGExtensions v4.5.134 diff --git a/sope-appserver/NGObjWeb/WOResponse+private.h b/sope-appserver/NGObjWeb/WOResponse+private.h index 540df8b9..789e3bf9 100644 --- a/sope-appserver/NGObjWeb/WOResponse+private.h +++ b/sope-appserver/NGObjWeb/WOResponse+private.h @@ -27,28 +27,37 @@ // 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);}\ }\ } @@ -56,13 +65,19 @@ #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);}\ }\ } diff --git a/sope-appserver/NGObjWeb/fhs.make b/sope-appserver/NGObjWeb/fhs.make index de580e5d..caff5ea0 100644 --- a/sope-appserver/NGObjWeb/fhs.make +++ b/sope-appserver/NGObjWeb/fhs.make @@ -31,18 +31,18 @@ fhs-products-dirs :: 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 @@ -50,7 +50,7 @@ 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 \