mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Add error recovery. Make more memory-efficient by avoiding autoreleased objects.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16385 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
83f252e89a
commit
e021f7500a
4 changed files with 385 additions and 328 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2003-04-07 11:56 Alexander Malmberg <alexander@malmberg.org>
|
||||
|
||||
* TextConverters/RTF/rtfGrammer.y: Add error recovery rules.
|
||||
* TextConverters/RTF/rtfGrammer.tab.c: Rebuild.
|
||||
|
||||
* TextConverters/RTF/RTFConsumer.m: Change uses of autoreleased
|
||||
objects to retain/release explicitly instead.
|
||||
|
||||
(GSRTFError): Try to recover from errors instead of raising an
|
||||
exception.
|
||||
|
||||
2003-04-06 19:56 Alexander Malmberg <alexander@malmberg.org>
|
||||
|
||||
* Source/NSWindow.m: Make sure -_handleWindowNeedsDisplay: is run
|
||||
|
|
|
@ -190,7 +190,8 @@ readNSString (StringContext *ctxt)
|
|||
|
||||
- (void) resetParagraphStyle
|
||||
{
|
||||
ASSIGN(paragraph, [NSMutableParagraphStyle defaultParagraphStyle]);
|
||||
DESTROY(paragraph);
|
||||
paragraph = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
||||
real_fi = real_li = 0.0;
|
||||
|
||||
tabChanged = NO;
|
||||
|
@ -221,8 +222,11 @@ readNSString (StringContext *ctxt)
|
|||
|
||||
if (!tabChanged)
|
||||
{
|
||||
NSArray *a;
|
||||
a = [[NSArray alloc] initWithObjects: tab, nil];
|
||||
// remove all tab stops
|
||||
[paragraph setTabStops: [NSArray arrayWithObject: tab]];
|
||||
[paragraph setTabStops: a];
|
||||
DESTROY(a);
|
||||
tabChanged = YES;
|
||||
}
|
||||
else
|
||||
|
@ -456,6 +460,7 @@ static BOOL classInheritsFromNSMutableAttributedString (Class c)
|
|||
|
||||
initStringContext(&stringCtxt, rtfString);
|
||||
lexInitContext(&scanner, &stringCtxt, (int (*)(void*))readNSString);
|
||||
[result beginEditing];
|
||||
NS_DURING
|
||||
GSRTFparse((void *)self, &scanner);
|
||||
NS_HANDLER
|
||||
|
@ -463,6 +468,8 @@ static BOOL classInheritsFromNSMutableAttributedString (Class c)
|
|||
[localException reason]);
|
||||
//[localException raise];
|
||||
NS_ENDHANDLER
|
||||
[result endEditing];
|
||||
|
||||
RELEASE(rtfString);
|
||||
RELEASE(pool);
|
||||
// document attributes
|
||||
|
@ -518,8 +525,9 @@ static BOOL classInheritsFromNSMutableAttributedString (Class c)
|
|||
/* handle errors (this is the yacc error mech) */
|
||||
void GSRTFerror (const char *msg)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Syntax error in RTF: %s", msg];
|
||||
/* [NSException raise:NSInvalidArgumentException
|
||||
format:@"Syntax error in RTF: %s", msg];*/
|
||||
NSDebugLLog(@"RTFParser",@"Syntax error in RTF: %s", msg);
|
||||
}
|
||||
|
||||
void GSRTFgenericRTFcommand (void *ctxt, RTFcmd cmd)
|
||||
|
@ -533,14 +541,12 @@ void GSRTFgenericRTFcommand (void *ctxt, RTFcmd cmd)
|
|||
void GSRTFstart (void *ctxt)
|
||||
{
|
||||
NSDebugLLog(@"RTFParser", @"Start RTF parsing");
|
||||
[RESULT beginEditing];
|
||||
}
|
||||
|
||||
// Finished to parse one piece of RTF.
|
||||
void GSRTFstop (void *ctxt)
|
||||
{
|
||||
//<!> close all open bolds et al.
|
||||
[RESULT endEditing];
|
||||
NSDebugLLog(@"RTFParser", @"End RTF parsing");
|
||||
}
|
||||
|
||||
|
@ -578,15 +584,20 @@ void GSRTFmangleText (void *ctxt, const char *text)
|
|||
|
||||
if (!IGNORE && textlen)
|
||||
{
|
||||
NSString *str = [[NSString alloc] initWithCString: text];
|
||||
[RESULT replaceCharactersInRange: insertionRange
|
||||
withString: [NSString stringWithCString:text]];
|
||||
withString: str];
|
||||
DESTROY(str);
|
||||
|
||||
if (CHANGED)
|
||||
{
|
||||
attributes = [NSMutableDictionary
|
||||
dictionaryWithObjectsAndKeys:
|
||||
NSParagraphStyle *ps = [PARAGRAPH copy];
|
||||
attributes = [[NSMutableDictionary alloc]
|
||||
initWithObjectsAndKeys:
|
||||
[CTXT currentFont], NSFontAttributeName,
|
||||
[[PARAGRAPH copy] autorelease], NSParagraphStyleAttributeName,
|
||||
ps, NSParagraphStyleAttributeName,
|
||||
nil];
|
||||
DESTROY(ps);
|
||||
if (UNDERLINE)
|
||||
{
|
||||
[attributes setObject: [CTXT underline]
|
||||
|
@ -610,6 +621,7 @@ void GSRTFmangleText (void *ctxt, const char *text)
|
|||
|
||||
[RESULT setAttributes: attributes
|
||||
range: NSMakeRange(oldPosition, textlen)];
|
||||
DESTROY(attributes);
|
||||
CHANGED = NO;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -180,6 +180,7 @@ rtfIngredients: /* empty */
|
|||
| rtfIngredients rtfStatement
|
||||
| rtfIngredients RTFtext { GSRTFmangleText(CTXT, $2); free((void *)$2); }
|
||||
| rtfIngredients rtfBlock
|
||||
| rtfIngredients error
|
||||
;
|
||||
|
||||
rtfBlock: '{' { GSRTFopenBlock(CTXT, NO); } rtfIngredients '}' { GSRTFcloseBlock(CTXT, NO); } /* may be empty */
|
||||
|
@ -190,6 +191,7 @@ rtfBlock: '{' { GSRTFopenBlock(CTXT, NO); } rtfIngredients '}' { GSRTFcloseBlock
|
|||
| '{' { GSRTFopenBlock(CTXT, YES); } RTFheader rtfIngredients '}' { GSRTFcloseBlock(CTXT, YES); }
|
||||
| '{' { GSRTFopenBlock(CTXT, YES); } RTFfooter rtfIngredients '}' { GSRTFcloseBlock(CTXT, YES); }
|
||||
| '{' { GSRTFopenBlock(CTXT, YES); } RTFpict rtfIngredients '}' { GSRTFcloseBlock(CTXT, YES); }
|
||||
| '{' error '}'
|
||||
;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue