Changeset 2288705 for set.c


Ignore:
Timestamp:
2009-12-07T21:54:19Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
1c3008a
Parents:
aac4017 (diff), 36cf9fd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merging head.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • set.c

    raac4017 r2288705  
    2525#define BITLBEE_CORE
    2626#include "bitlbee.h"
     27
     28/* Used to use NULL for this, but NULL is actually a "valid" value. */
     29char *SET_INVALID = "nee";
    2730
    2831set_t *set_add( set_t **head, char *key, char *def, set_eval eval, void *data )
     
    114117       
    115118        if( !s )
     119                /*
     120                Used to do this, but it never really made sense.
    116121                s = set_add( head, key, NULL, NULL, NULL );
    117        
    118         if( s->eval && !( nv = s->eval( s, value ) ) )
     122                */
     123                return 0;
     124       
     125        if( value == NULL && ( s->flags & SET_NULL_OK ) == 0 )
     126                return 0;
     127       
     128        /* Call the evaluator. For invalid values, evaluators should now
     129           return SET_INVALID, but previously this was NULL. Try to handle
     130           that too if NULL is not an allowed value for this setting. */
     131        if( s->eval && ( ( nv = s->eval( s, value ) ) == SET_INVALID ||
     132                         ( ( s->flags & SET_NULL_OK ) == 0 && nv == NULL ) ) )
    119133                return 0;
    120134       
     
    168182}
    169183
    170 void set_reset( set_t **head, char *key )
     184int set_reset( set_t **head, char *key )
    171185{
    172186        set_t *s;
     
    174188        s = set_find( head, key );
    175189        if( s )
    176                 set_setstr( head, key, s->def );
     190                return set_setstr( head, key, s->def );
     191       
     192        return 0;
    177193}
    178194
     
    187203        for( ; *s; s ++ )
    188204                if( !isdigit( *s ) )
    189                         return NULL;
     205                        return SET_INVALID;
    190206       
    191207        return value;
     
    194210char *set_eval_bool( set_t *set, char *value )
    195211{
    196         return is_bool( value ) ? value : NULL;
     212        return is_bool( value ) ? value : SET_INVALID;
    197213}
    198214
     
    226242                                                              irc->channel, "-oo", irc->nick, irc->mynick );
    227243        else
    228                 return NULL;
     244                return SET_INVALID;
    229245       
    230246        return value;
Note: See TracChangeset for help on using the changeset viewer.