I disabled tonight's build in iCal, too, just in case I screwed  
something up in saving; that gives us a bit of extra time for  
testing.  Test & diff looked OK, but I only checked one file.


On Dec 19, 2007, at 8:15 PM, Adam R. Maxwell wrote:

> Well, I just reverted it after discovering that it was writing data as
> @type{citekey} when doing a copy/paste or save from tugboat.bib, not
> to mention the debugging problem.
>
> -- 
> adam
>
> On Dec 19, 2007, at 5:25 PM, Christiaan Hofman wrote:
>
>> Only using code duplication, as it is about setting up the local
>> variables.
>>
>> Christiaan
>>
>> On 20 Dec 2007, at 2:19 AM, Adam R. Maxwell wrote:
>>
>>> Can we do this without a macro?  Debugging with gdb is impossible
>>> when
>>> you don't have correct line numbers (I hate the macro in the
>>> TextWithIconCell for that reason).  It also makes it harder to see
>>> the
>>> flow, and this code is critical.
>>>
>>>
>>> On Dec 19, 2007, at 9:11 AM, [EMAIL PROTECTED] wrote:
>>>
>>>> Revision: 11977
>>>>        http://bibdesk.svn.sourceforge.net/bibdesk/?
>>>> rev=11977&view=rev
>>>> Author:   hofman
>>>> Date:     2007-12-19 09:11:28 -0800 (Wed, 19 Dec 2007)
>>>>
>>>> Log Message:
>>>> -----------
>>>> Add empty fields that always should be included only when they are
>>>> required or optional, and also if they are nil. Field values can  
>>>> now
>>>> be nil, so make sure we don't append nil strings or data. Define a
>>>> macro for some common setup code.
>>>>
>>>> Modified Paths:
>>>> --------------
>>>>  trunk/bibdesk/BibItem.m
>>>>
>>>> Modified: trunk/bibdesk/BibItem.m
>>>> ===================================================================
>>>> --- trunk/bibdesk/BibItem.m        2007-12-19 17:08:39 UTC (rev 11976)
>>>> +++ trunk/bibdesk/BibItem.m        2007-12-19 17:11:28 UTC (rev 11977)
>>>> @@ -1590,119 +1590,109 @@
>>>>   return string;
>>>> }
>>>>
>>>> +#define PREPARE_KEYS \
>>>> +    NSAssert1(type != nil, @"Tried to use a nil pubtype in [EMAIL 
>>>> PROTECTED]   
>>>> You
>>>> will need to quit and relaunch BibDesk after fixing the error
>>>> manually.", self ); \
>>>> +  if (shouldTeXify) \
>>>> +        urlKeys = [btm allURLFieldsSet]; \
>>>> +  if (drop || keysToWriteIfEmpty) { \
>>>> +        knownKeys = [[NSMutableSet alloc] initWithCapacity:14]; \
>>>> +          [knownKeys addObjectsFromArray:[btm
>>>> requiredFieldsForType:type]]; \
>>>> +          [knownKeys addObjectsFromArray:[btm
>>>> optionalFieldsForType:type]]; \
>>>> +        [keysToWriteIfEmpty intersectSet:knownKeys]; \
>>>> +          [knownKeys addObject:BDSKCrossrefString]; \
>>>> +        if ([keysToWriteIfEmpty count]) { \
>>>> +            e = [keysToWriteIfEmpty objectEnumerator]; \
>>>> +            while (field = [e nextObject]) { \
>>>> +                if ([keys containsObject:field] == NO) \
>>>> +                    [keys addObject:field]; \
>>>> +            } \
>>>> +        } else { \
>>>> +            [keysToWriteIfEmpty release]; \
>>>> +            keysToWriteIfEmpty = nil; \
>>>> +        } \
>>>> +  } \
>>>> +    [keys sortUsingSelector:@selector(caseInsensitiveCompare:)]; \
>>>> +    if ([pw boolForKey:BDSKSaveAnnoteAndAbstractAtEndOfItemKey])
>>>> { \
>>>> +          NSMutableArray *noteKeys = [[[btm noteFieldsSet] allObjects]
>>>> mutableCopy]; \
>>>> +        [noteKeys
>>>> sortUsingSelector:@selector(caseInsensitiveCompare:)]; \
>>>> +        [keys removeObjectsInArray:noteKeys]; \
>>>> +          [keys addObjectsFromArray:noteKeys]; \
>>>> +        [noteKeys release]; \
>>>> +  } \
>>>> +  e = [keys objectEnumerator]; \
>>>> +  [keys release];
>>>> +
>>>> - (NSString *)bibTeXStringDroppingInternal:(BOOL)drop texify:
>>>> (BOOL)shouldTeXify{
>>>>    OFPreferenceWrapper *pw = [OFPreferenceWrapper
>>>> sharedPreferenceWrapper];
>>>> +    BDSKTypeManager *btm = [BDSKTypeManager sharedManager];
>>>> +    NSString *type = [self pubType];
>>>>    NSMutableSet *knownKeys = nil;
>>>> +  NSMutableSet *keysToWriteIfEmpty = [fieldsToWriteIfEmpty
>>>> mutableCopy];
>>>>    NSSet *urlKeys = nil;
>>>> +    NSMutableArray *keys = [[self allFieldNames] mutableCopy];
>>>> +  NSEnumerator *e;
>>>>    NSString *field;
>>>>   NSString *value;
>>>>   NSMutableString *s = [NSMutableString stringWithCapacity:200];
>>>> -    NSMutableArray *keys = [[self allFieldNames] mutableCopy];
>>>> -  NSEnumerator *e;
>>>>
>>>> -    BDSKTypeManager *btm = [BDSKTypeManager sharedManager];
>>>> -    NSString *type = [self pubType];
>>>> -    NSAssert1(type != nil, @"Tried to use a nil pubtype in [EMAIL 
>>>> PROTECTED]   
>>>> You
>>>> will need to quit and relaunch BibDesk after fixing the error
>>>> manually.", self );
>>>> -  [keys sortUsingSelector:@selector(caseInsensitiveCompare:)];
>>>> -  if ([pw boolForKey:BDSKSaveAnnoteAndAbstractAtEndOfItemKey]) {
>>>> -          NSMutableArray *noteKeys = [[[btm noteFieldsSet] allObjects]
>>>> mutableCopy];
>>>> -        [noteKeys
>>>> sortUsingSelector:@selector(caseInsensitiveCompare:)];
>>>> -        [keys removeObjectsInArray:noteKeys]; // make sure these
>>>> fields are at the end, as they can be long
>>>> -          [keys addObjectsFromArray:noteKeys];
>>>> -        [noteKeys release];
>>>> -  }
>>>> -  if (drop) {
>>>> -        knownKeys = [[NSMutableSet alloc] initWithCapacity:14];
>>>> -          [knownKeys addObjectsFromArray:[btm  
>>>> requiredFieldsForType:type]];
>>>> -          [knownKeys addObjectsFromArray:[btm  
>>>> optionalFieldsForType:type]];
>>>> -          [knownKeys addObject:BDSKCrossrefString];
>>>> -  }
>>>> -  if(shouldTeXify)
>>>> -        urlKeys = [[BDSKTypeManager sharedManager]
>>>> allURLFieldsSet];
>>>> -  
>>>> -  e = [keys objectEnumerator];
>>>> -  [keys release];
>>>> -
>>>> -    //build BibTeX entry:
>>>> -    [s appendString:@"@"];
>>>> +  PREPARE_KEYS
>>>>
>>>> +    [s appendString:@"@"];
>>>>   [s appendString:type];
>>>>   [s appendString:@"{"];
>>>>   [s appendString:[self citeKey]];
>>>>
>>>>   NSSet *personFields = [btm personFieldsSet];
>>>>
>>>> -    while(field = [e nextObject]){
>>>> -        if (drop && ![knownKeys containsObject:field])
>>>> -            continue;
>>>> -
>>>> -        value = [pubFields objectForKey:field];
>>>> -
>>>> -        if([personFields containsObject:field] && [pw
>>>> boolForKey:BDSKShouldSaveNormalizedAuthorNamesKey] && ![value
>>>> isComplex]){ // only if it's not complex, use the normalized author
>>>> name
>>>> -            value = [self bibTeXNameStringForField:field
>>>> normalized:YES inherit:NO];
>>>> +    while (field = [e nextObject]) {
>>>> +        if (drop == NO || [knownKeys containsObject:field]) {
>>>> +            value = [pubFields objectForKey:field];
>>>> +
>>>> +            // only if it's not complex, use the normalized author
>>>> name
>>>> +            if ([personFields containsObject:field] && [pw
>>>> boolForKey:BDSKShouldSaveNormalizedAuthorNamesKey] && NO == [value
>>>> isComplex])
>>>> +                value = [self bibTeXNameStringForField:field
>>>> normalized:YES inherit:NO];
>>>> +
>>>> +            if (shouldTeXify && NO == [urlKeys
>>>> containsObject:field])
>>>> +                value = [value stringByTeXifyingString];
>>>> +
>>>> +            if ([NSString isEmptyString:value] ||
>>>> [keysToWriteIfEmpty containsObject:field]) {
>>>> +                [s appendString:@",\n\t"];
>>>> +                [s appendString:field];
>>>> +                [s appendString:@" = "];
>>>> +                [s appendString:[(value ? value : @"")
>>>> stringAsBibTeXString]];
>>>> +            }
>>>>       }
>>>> -
>>>> -        if(shouldTeXify && ![urlKeys containsObject:field]){
>>>> -            value = [value stringByTeXifyingString];
>>>> -        }
>>>> -
>>>> -        if(![value isEqualToString:@""] || [fieldsToWriteIfEmpty
>>>> containsObject:field]){
>>>> -            [s appendString:@",\n\t"];
>>>> -            [s appendString:field];
>>>> -            [s appendString:@" = "];
>>>> -            [s appendString:[value stringAsBibTeXString]];
>>>> -        }
>>>>   }
>>>>
>>>>   // make sure to add these at the end to avoid problems with
>>>> BibTeX's buffers
>>>> -    if (!drop) {
>>>> -        value = [self filesAsBibTeXFragmentRelativeToPath:[self
>>>> basePath]];
>>>> -        if (value) [s appendString:value];
>>>> -    }
>>>> -    [knownKeys release];
>>>> +    if (drop == NO && (value = [self
>>>> filesAsBibTeXFragmentRelativeToPath:[self basePath]]))
>>>> +        [s appendString:value];
>>>>   [s appendString:@"}"];
>>>>
>>>> +    [knownKeys release];
>>>> +    [keysToWriteIfEmpty release];
>>>> +
>>>>   return s;
>>>> }
>>>>
>>>> - (NSData *)bibTeXDataDroppingInternal:(BOOL)drop relativeToPath:
>>>> (NSString *)basePath encoding:(NSStringEncoding)encoding error:
>>>> (NSError **)outError{
>>>>    OFPreferenceWrapper *pw = [OFPreferenceWrapper
>>>> sharedPreferenceWrapper];
>>>>   BOOL shouldTeXify = [pw
>>>> boolForKey:BDSKShouldTeXifyWhenSavingAndCopyingKey];
>>>> +    BDSKTypeManager *btm = [BDSKTypeManager sharedManager];
>>>> +    NSString *type = [self pubType];
>>>>    NSMutableSet *knownKeys = nil;
>>>> +  NSMutableSet *keysToWriteIfEmpty = [fieldsToWriteIfEmpty
>>>> mutableCopy];
>>>>    NSSet *urlKeys = nil;
>>>> +    NSMutableArray *keys = [[self allFieldNames] mutableCopy];
>>>> +  NSEnumerator *e;
>>>>    NSString *field;
>>>>   NSString *value;
>>>>   NSMutableData *data = [NSMutableData dataWithCapacity:200];
>>>> -    NSMutableArray *keys = [[self allFieldNames] mutableCopy];
>>>> -  NSEnumerator *e;
>>>> -    NSError *error= nil;
>>>> +    NSError *error = nil;
>>>>   BOOL isOK = YES;
>>>>
>>>> -
>>>> -    BDSKTypeManager *btm = [BDSKTypeManager sharedManager];
>>>> -    NSString *type = [self pubType];
>>>> -    NSAssert1(type != nil, @"Tried to use a nil pubtype in [EMAIL 
>>>> PROTECTED]   
>>>> You
>>>> will need to quit and relaunch BibDesk after fixing the error
>>>> manually.", self );
>>>> -  [keys sortUsingSelector:@selector(caseInsensitiveCompare:)];
>>>> -  if ([pw boolForKey:BDSKSaveAnnoteAndAbstractAtEndOfItemKey]) {
>>>> -          NSMutableArray *noteKeys = [[[btm noteFieldsSet] allObjects]
>>>> mutableCopy];
>>>> -        [noteKeys
>>>> sortUsingSelector:@selector(caseInsensitiveCompare:)];
>>>> -        [keys removeObjectsInArray:noteKeys]; // make sure these
>>>> fields are at the end, as they can be long
>>>> -          [keys addObjectsFromArray:noteKeys];
>>>> -        [noteKeys release];
>>>> -  }
>>>> -  if (drop) {
>>>> -        knownKeys = [[NSMutableSet alloc] initWithCapacity:14];
>>>> -          [knownKeys addObjectsFromArray:[btm  
>>>> requiredFieldsForType:type]];
>>>> -          [knownKeys addObjectsFromArray:[btm  
>>>> optionalFieldsForType:type]];
>>>> -          [knownKeys addObject:BDSKCrossrefString];
>>>> -  }
>>>> -  if(shouldTeXify)
>>>> -        urlKeys = [[BDSKTypeManager sharedManager]
>>>> allURLFieldsSet];
>>>> -  
>>>> -  e = [keys objectEnumerator];
>>>> -  [keys release];
>>>> +  PREPARE_KEYS
>>>>
>>>> -    //build BibTeX entry:
>>>>   isOK = [data appendDataFromString:@"@" encoding:encoding
>>>> error:&error] &&
>>>>          [data appendDataFromString:type encoding:encoding
>>>> error:&error] &&
>>>>          [data appendDataFromString:@"{" encoding:encoding
>>>> error:&error] &&
>>>> @@ -1717,47 +1707,45 @@
>>>>   NSData *lineSeparator = [@",\n\t" dataUsingEncoding:encoding];
>>>>   NSData *fieldValueSeparator = [@" = "
>>>> dataUsingEncoding:encoding];
>>>>
>>>> -    while(isOK && (field = [e nextObject])){
>>>> -        if (drop && ![knownKeys containsObject:field])
>>>> -            continue;
>>>> -
>>>> -        value = [pubFields objectForKey:field];
>>>> -
>>>> -        if([personFields containsObject:field] && [pw
>>>> boolForKey:BDSKShouldSaveNormalizedAuthorNamesKey] && ![value
>>>> isComplex]){ // only if it's not complex, use the normalized author
>>>> name
>>>> -            value = [self bibTeXNameStringForField:field
>>>> normalized:YES inherit:NO];
>>>> -        }
>>>> -
>>>> -        if(shouldTeXify && ![urlKeys containsObject:field]){
>>>> -            value = [value stringByTeXifyingString];
>>>> -        }
>>>> -
>>>> -        if(NO == [value isEqualToString:@""] ||
>>>> [fieldsToWriteIfEmpty containsObject:field]){
>>>> +    while (isOK && (field = [e nextObject])) {
>>>> +        if (drop == NO || [knownKeys containsObject:field]) {
>>>> +            value = [pubFields objectForKey:field];
>>>>
>>>> -            [data appendData:lineSeparator];
>>>> -            isOK = [data appendDataFromString:field
>>>> encoding:encoding error:&error];
>>>> -            [data appendData:fieldValueSeparator];
>>>> +            // only if it's not complex, use the normalized author
>>>> name
>>>> +            if ([personFields containsObject:field] && [pw
>>>> boolForKey:BDSKShouldSaveNormalizedAuthorNamesKey] && NO == [value
>>>> isComplex])
>>>> +                value = [self bibTeXNameStringForField:field
>>>> normalized:YES inherit:NO];
>>>>
>>>> -            if(isOK)
>>>> -                isOK = [data appendDataFromString:[value
>>>> stringAsBibTeXString] encoding:encoding error:&error];
>>>> -
>>>> -            if(isOK == NO) {
>>>> -                error = [[error mutableCopy] autorelease];
>>>> -                [error setValue:[NSString
>>>> stringWithFormat:NSLocalizedString(@"Unable to convert field \"[EMAIL 
>>>> PROTECTED]"
>>>> of item with cite key \"[EMAIL PROTECTED]".", @"string encoding error 
>>>> context"),
>>>> [field localizedFieldName], [self citeKey]]
>>>> forKey:NSLocalizedRecoverySuggestionErrorKey];
>>>> +            if (shouldTeXify && NO == [urlKeys
>>>> containsObject:field])
>>>> +                value = [value stringByTeXifyingString];
>>>> +
>>>> +            if ([NSString isEmptyString:value] ||
>>>> [keysToWriteIfEmpty containsObject:field]) {
>>>> +
>>>> +                [data appendData:lineSeparator];
>>>> +                isOK = [data appendDataFromString:field
>>>> encoding:encoding error:&error];
>>>> +                [data appendData:fieldValueSeparator];
>>>> +
>>>> +                if (isOK)
>>>> +                    isOK = [data appendDataFromString:[(value ?
>>>> value : @"") stringAsBibTeXString] encoding:encoding error:&error];
>>>> +
>>>> +                if (isOK == NO) {
>>>> +                    error = [[error mutableCopy] autorelease];
>>>> +                    [error setValue:[NSString
>>>> stringWithFormat:NSLocalizedString(@"Unable to convert field \"[EMAIL 
>>>> PROTECTED]"
>>>> of item with cite key \"[EMAIL PROTECTED]".", @"string encoding error 
>>>> context"),
>>>> [field localizedFieldName], [self citeKey]]
>>>> forKey:NSLocalizedRecoverySuggestionErrorKey];
>>>> +                }
>>>>           }
>>>>       }
>>>>   }
>>>> +
>>>>   [knownKeys release];
>>>> +    [keysToWriteIfEmpty release];
>>>>
>>>>   // make sure to add these at the end to avoid problems with
>>>> BibTeX's buffers
>>>> -    if(isOK && !drop) {
>>>> -        value = [self
>>>> filesAsBibTeXFragmentRelativeToPath:basePath];
>>>> +    if (isOK && drop == NO && (value = [self
>>>> filesAsBibTeXFragmentRelativeToPath:basePath]))
>>>>       // assumes encoding is ascii-compatible, but btparse does as
>>>> well
>>>> -        if (value) [data appendDataFromString:value
>>>> encoding:encoding error:&error];
>>>> -    }
>>>> -    if(isOK)
>>>> +        [data appendDataFromString:value encoding:encoding
>>>> error:&error];
>>>> +    if (isOK)
>>>>       isOK = [data appendDataFromString:@"}" encoding:encoding
>>>> error:&error];
>>>>
>>>> -    if(isOK == NO && outError)
>>>> +    if (isOK == NO && outError)
>>>>       *outError = error;
>>>>
>>>>   return isOK ? data : nil;
>>>>
>>>>
>>>> This was sent by the SourceForge.net collaborative development
>>>> platform, the world's largest Open Source development site.
>>>>
>>>> ---------------------------------------------------------------------
>>>> ----
>>>> SF.Net email is sponsored by:
>>>> Check out the new SourceForge.net Marketplace.
>>>> It's the best place to buy or sell services
>>>> for just about anything Open Source.
>>>> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/
>>>> marketplace
>>>> _______________________________________________
>>>> Bibdesk-commit mailing list
>>>> [EMAIL PROTECTED]
>>>> https://lists.sourceforge.net/lists/listinfo/bibdesk-commit
>>>
>>>
>>> ----------------------------------------------------------------------
>>> ---
>>> SF.Net email is sponsored by:
>>> Check out the new SourceForge.net Marketplace.
>>> It's the best place to buy or sell services
>>> for just about anything Open Source.
>>> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/
>>> marketplace
>>> _______________________________________________
>>> Bibdesk-develop mailing list
>>> Bibdesk-develop@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/bibdesk-develop
>>
>>
>> -------------------------------------------------------------------------
>> SF.Net email is sponsored by:
>> Check out the new SourceForge.net Marketplace.
>> It's the best place to buy or sell services
>> for just about anything Open Source.
>> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
>> _______________________________________________
>> Bibdesk-develop mailing list
>> Bibdesk-develop@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/bibdesk-develop
>
>
> -------------------------------------------------------------------------
> SF.Net email is sponsored by:
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services
> for just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> _______________________________________________
> Bibdesk-develop mailing list
> Bibdesk-develop@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bibdesk-develop


-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Bibdesk-develop mailing list
Bibdesk-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-develop

Reply via email to