src/z-dice.c
static int dice_add_variable(dice_t *dice, const char *name)
{
	int i;

	if (dice->expressions == NULL) {
		dice->expressions = mem_zalloc(DICE_MAX_EXPRESSIONS *
									   sizeof(dice_expression_entry_t));
	}

	for (i = 0; i < DICE_MAX_EXPRESSIONS; i++) {
		if (dice->expressions[i].name == NULL) {
			/* Add the variable to an empty slot. */
			dice->expressions[i].name = string_make(name);
			return i;
		}
		else if (my_stricmp(dice->expressions[i].name, name) == 0) {
			/* We already have the variable and will use this expression. */
			return i;
		}
	}

	/* No space left for variables. */
	return -1;
}
/**
 * Add an entry to the dice object's symbol list.
 *
 * \param dice is the object the variable is being added to.
 * \param name is the name of the variable.
 * \return The index of the variable name (if added or already found), or -1 for error.
 */
Add an entry to the dice object's symbol list.
\param dice is the object the variable is being added to.
\param name is the name of the variable.
\return The index of the variable name (if added or already found), or -1 for error.
Add an entry to the dice object ' s symbol list . \ param dice is the object the variable is being added to . \ param name is the name of the variable . \ return The index of the variable name ( if added or already found ) or - 1 for error .
static int dice_add_variable(dice_t *dice, const char *name)
{
	int i;
	if (dice->expressions == NULL) {
		dice->expressions = mem_zalloc(DICE_MAX_EXPRESSIONS *
									   sizeof(dice_expression_entry_t));
	}
	for (i = 0; i < DICE_MAX_EXPRESSIONS; i++) {
		if (dice->expressions[i].name == NULL) {
			dice->expressions[i].name = string_make(name);
			return i;
		}
		else if (my_stricmp(dice->expressions[i].name, name) == 0) {
			return i;
		}
	}
	return -1;
}
static int dice_add_variable ( dice_t * dice , const char * name ) { int i ; if ( dice -> expressions == NULL ) { dice -> expressions = mem_zalloc ( DICE_MAX_EXPRESSIONS * sizeof ( dice_expression_entry_t ) ) ; } for ( i = 0 ; i < DICE_MAX_EXPRESSIONS ; i ++ ) { if ( dice -> expressions [ i ] . name == NULL ) { dice -> expressions [ i ] . name = string_make ( name ) ; return i ; } else if ( my_stricmp ( dice -> expressions [ i ] . name , name ) == 0 ) { return i ; } } return -1 ; }
Add an entry to the dice object's symbol list.
Add an entry to the dice object ' s symbol list .
/* Add the variable to an empty slot. */ /* We already have the variable and will use this expression. */ /* No space left for variables. */