Changeset 7125cb3 for set.c


Ignore:
Timestamp:
2008-08-24T18:01:05Z (16 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
f3579fd
Parents:
934dddf3
Message:

Added SET_INVALID, which set evaluators should now return instead of NULL
when the given value is not accepted. This to allow certain variables
actually be set to NULL (server, for example). This should fully close
#444.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • set.c

    r934dddf3 r7125cb3  
    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       
     
    187201        for( ; *s; s ++ )
    188202                if( !isdigit( *s ) )
    189                         return NULL;
     203                        return SET_INVALID;
    190204       
    191205        return value;
     
    194208char *set_eval_bool( set_t *set, char *value )
    195209{
    196         return is_bool( value ) ? value : NULL;
     210        return is_bool( value ) ? value : SET_INVALID;
    197211}
    198212
     
    226240                                                              irc->channel, "-oo", irc->nick, irc->mynick );
    227241        else
    228                 return NULL;
     242                return SET_INVALID;
    229243       
    230244        return value;
Note: See TracChangeset for help on using the changeset viewer.