I don't think it's like cleaning at all.  It's primary purpose is conversion 
when parsing BibTeX, not temporary changing for display (as in 
stringByRemovingTeX).  It ultimately affects what gets saved back out to disk, 
so it's part of a critical data path.
 
On Wednesday, January 16, 2008, at 03:10PM, "Christiaan Hofman" <[EMAIL 
PROTECTED]> wrote:
>Isn't detexification something like cleaning? In particular as we  
>don't check lots of other tex mistakes either without returning nil.  
>Why would this be considered an error?
>
>Christiaan
>
>On 17 Jan 2008, at 12:03 AM, Adam R. Maxwell wrote:
>
>> Is this a good idea?  I think returning nil from a syntax error is  
>> generally a good thing, and that's precisely the reason I added  
>> that.  We check for a nil return in BibTeXParser, and other parts  
>> of the code should check for it as well.
>>
>> On Wednesday, January 16, 2008, at 02:50PM,  
>> <[EMAIL PROTECTED]> wrote:
>>> Revision: 12523
>>>          http://bibdesk.svn.sourceforge.net/bibdesk/? 
>>> rev=12523&view=rev
>>> Author:   hofman
>>> Date:     2008-01-16 14:50:39 -0800 (Wed, 16 Jan 2008)
>>>
>>> Log Message:
>>> -----------
>>> Don't return nil when detexification fails.
>>>
>>> Modified Paths:
>>> --------------
>>>    trunk/bibdesk/BDSKConverter.m
>>>
>>> Modified: trunk/bibdesk/BDSKConverter.m
>>> ===================================================================
>>> --- trunk/bibdesk/BDSKConverter.m   2008-01-16 22:35:31 UTC (rev 12522)
>>> +++ trunk/bibdesk/BDSKConverter.m   2008-01-16 22:50:39 UTC (rev 12523)
>>> @@ -137,33 +137,39 @@
>>>     [self setDetexifyAccents:[wholeDict  
>>> objectForKey:TEX_TO_ROMAN_ACCENTS_KEY]];
>>> }
>>>
>>> +- (NSString *)copyComplexString:(BDSKComplexString *)cs  
>>> byCopyingStringNodesUsingSelector:(SEL)copySelector {
>>> +    NSEnumerator *nodeEnum = [[cs nodes] objectEnumerator];
>>> +    BDSKStringNode *node, *newNode;
>>> +    NSMutableArray *nodes = [[NSMutableArray alloc]  
>>> initWithCapacity:[[cs nodes] count]];
>>> +    NSString *string;
>>> +
>>> +    while(node = [nodeEnum nextObject]){
>>> +        if([node type] == BSN_STRING){
>>> +            string = [self performSelector:copySelector  
>>> withObject:[node value]];
>>> +            newNode = [[BDSKStringNode alloc]  
>>> initWithQuotedString:string];
>>> +            [string release];
>>> +        } else {
>>> +            newNode = [node copy];
>>> +        }
>>> +        [nodes addObject:newNode];
>>> +        [newNode release];
>>> +    }
>>> +
>>> +    string = [[NSString alloc] initWithNodes:nodes macroResolver: 
>>> [cs macroResolver]];
>>> +    [nodes release];
>>> +    return string;
>>> +}
>>> +
>>> - (NSString *)copyStringByTeXifyingString:(NSString *)s{
>>>
>>>     // TeXify only string nodes of complex strings;
>>>     if([s isComplex]){
>>> -           BDSKComplexString *cs = (BDSKComplexString *)s;
>>> -           NSEnumerator *nodeEnum = [[cs nodes] objectEnumerator];
>>> -           BDSKStringNode *node, *newNode;
>>> -           NSMutableArray *nodes = [[NSMutableArray alloc]  
>>> initWithCapacity:[[cs nodes] count]];
>>> -        NSString *string;
>>> -           
>>> -           while(node = [nodeEnum nextObject]){
>>> -                   if([node type] == BSN_STRING){
>>> -                           string = [self 
>>> copyStringByTeXifyingString:[node value]];
>>> -                if(string == nil) break;
>>> -                newNode = [[BDSKStringNode alloc]  
>>> initWithQuotedString:string];
>>> -                [string release];
>>> -                   } else {
>>> -                           newNode = [node copy];
>>> -                   }
>>> -            [nodes addObject:newNode];
>>> -                   [newNode release];
>>> -           }
>>> -
>>> -        string = [[NSString alloc] initWithNodes:nodes  
>>> macroResolver:[cs macroResolver]];
>>> -        [nodes release];
>>> -           return string;
>>> +        return [self copyComplexString:(BDSKComplexString *)s  
>>> byCopyingStringNodesUsingSelector:_cmd];
>>>     }
>>> +
>>> +    if([NSString isEmptyString:s]){
>>> +        return [s retain];
>>> +    }
>>>     
>>>     // we expect to find composed accented characters, as this is  
>>> also what we use in the CharacterConversion plist
>>>     NSMutableString *precomposedString = [s mutableCopy];
>>> @@ -264,31 +270,14 @@
>>>
>>> - (NSString *)copyStringByDeTeXifyingString:(NSString *)s{
>>>
>>> -    if([NSString isEmptyString:s]){
>>> -        return [s retain];
>>> -    }
>>> -
>>>     // deTeXify only string nodes of complex strings;
>>>     if([s isComplex]){
>>> -           BDSKComplexString *cs = (BDSKComplexString *)s;
>>> -           NSEnumerator *nodeEnum = [[cs nodes] objectEnumerator];
>>> -           BDSKStringNode *node, *newNode;
>>> -           NSMutableArray *nodes = [NSMutableArray arrayWithCapacity:[[cs  
>>> nodes] count]];
>>> -           NSString *string;
>>> -
>>> -           while(node = [nodeEnum nextObject]){
>>> -                   if([node type] == BSN_STRING){
>>> -                           string = [self 
>>> copyStringByDeTeXifyingString:[node value]];
>>> -                           newNode = [[BDSKStringNode alloc] 
>>> initWithQuotedString:string];
>>> -                [string release];
>>> -                   } else {
>>> -                           newNode = [node copy];
>>> -                   }
>>> -            [nodes addObject:newNode];
>>> -                   [newNode release];
>>> -           }
>>> -           return [[NSString alloc] initWithNodes:nodes macroResolver:[cs  
>>> macroResolver]];
>>> +        return [self copyComplexString:(BDSKComplexString *)s  
>>> byCopyingStringNodesUsingSelector:_cmd];
>>>     }
>>> +
>>> +    if([NSString isEmptyString:s]){
>>> +        return [s retain];
>>> +    }
>>>     
>>>     NSMutableString *tmpConv = nil;
>>>     NSString *TEXString = nil;
>>> @@ -328,8 +317,7 @@
>>>                 range = [convertedSoFar rangeOfString:@"{\\"  
>>> options:0 range:NSMakeRange(replaceRange.location + 1, length -  
>>> replaceRange.location - 1)];
>>>             } else {
>>>                 NSLog(@"missing brace in string %@", convertedSoFar);
>>> -                [convertedSoFar release];
>>> -                return nil;
>>> +                range = NSMakeRange(NSNotFound, 0);
>>>             }
>>>
>>>         }
>>>
>>>
>>> This was sent by the SourceForge.net collaborative development  
>>> platform, the world's largest Open Source development site.
>>>
>>> --------------------------------------------------------------------- 
>>> ----
>>> This SF.net email is sponsored by: Microsoft
>>> Defy all challenges. Microsoft(R) Visual Studio 2008.
>>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>>> _______________________________________________
>>> Bibdesk-commit mailing list
>>> [EMAIL PROTECTED]
>>> https://lists.sourceforge.net/lists/listinfo/bibdesk-commit
>>>
>>>
>>
>> ---------------------------------------------------------------------- 
>> ---
>> This SF.net email is sponsored by: Microsoft
>> Defy all challenges. Microsoft(R) Visual Studio 2008.
>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>> _______________________________________________
>> Bibdesk-develop mailing list
>> Bibdesk-develop@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/bibdesk-develop
>
>
>-------------------------------------------------------------------------
>This SF.net email is sponsored by: Microsoft
>Defy all challenges. Microsoft(R) Visual Studio 2008.
>http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>_______________________________________________
>Bibdesk-develop mailing list
>Bibdesk-develop@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/bibdesk-develop
>
>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bibdesk-develop mailing list
Bibdesk-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-develop

Reply via email to