rem: elements[index].type = TYPE_COLON;
add: elements[index].type = TYPE_COMMA;
context: preparseDate(const char *dateString, parsed_element *elements){	int32 index = 0;	char c;	if (dateString == NULL)		return B_ERROR;	for (; (c = dateString[0]) != '\0'; dateString++) {		// we don't care about spaces		if (isspace(c))			continue;		// if we're reached our maximum number of elements, bail out		if (index >= MAX_ELEMENTS)			return B_ERROR;		memset(&elements[index], 0, sizeof(parsed_element));		if (c == ',') {			elements[index].type = TYPE_COLON;			elements[index].value_type = VALUE_CHAR;		} else if (c == '.') {			elements[index].type = TYPE_DOT;			elements[index].value_type = VALUE_CHAR;		} else if (c == '/' || c == '-') {			// ToDo: "-" can also be the minus modifier... - how to distinguish?			elements[index].type = TYPE_DASH;			elements[index].value_type = VALUE_CHAR;		} else if (c == ':') {			elements[index].type = TYPE_SEMICOLON;			elements[index].value_type = VALUE_CHAR;		} else if (c == '+') {			elements[index].type = TYPE_RELATIVE;			elements[index].value_type = VALUE_CHAR;			elements[index].modifier = MODIFY_PLUS;			// this counts for the next element			continue;		} else if (c == '-') {			// ToDo: this never happens, due to TYPE_DASH			elements[index].type = TYPE_MODIFIER;			elements[index].value_type = VALUE_CHAR;			elements[index].modifier = MODIFY_MINUS;			// this counts for the next element			continue;		} else if (isdigit(c)) {			// fetch whole number			elements[index].type = TYPE_UNKNOWN;			elements[index].value_type = VALUE_NUMERICAL;			elements[index].value = atoll(dateString);			// skip number			while (isdigit(dateString[1]))				dateString++;		} else if (isalpha(c)) {			// fetch whole string			const char *string = dateString;			while (isalpha(dateString[1]))				dateString++;			int32 length = dateString + 1 - string;			// compare with known strings			// ToDo: should understand other languages as well...			const known_identifier *identifier = kIdentifiers;			for (; identifier->string; identifier++) {				if (!strncasecmp(identifier->string, string, length)					&& !identifier->string[length])					break;			}			if (identifier->string == NULL) {				// unknown string, we don't have to parse any further				return B_ERROR;			}			if (index > 0 && (identifier->type & TYPE_UNIT) != 0) {				// this is just a unit, so it will give the last value a meaning				if (elements[--index].value_type != VALUE_NUMERICAL					&& elements[index].type != TYPE_NEXT_LAST_THIS)					return B_ERROR;				elements[index].value *= identifier->value;			} else if (index > 0 && elements[index - 1].type == TYPE_NEXT_LAST_THIS) {				if (isType(identifier->type, TYPE_MONTH)					|| isType(identifier->type, TYPE_WEEKDAY)) {					index--;					switch (elements[index].value) {						case -1:							elements[index].modifier = MODIFY_LAST;							break;						case 0:							elements[index].modifier = MODIFY_THIS;							break;						case 1:							elements[index].modifier = MODIFY_NEXT;							break;					}					elements[index].value = identifier->value;				} else					return B_ERROR;			} else {				elements[index].value_type = VALUE_STRING;				elements[index].value = identifier->value;			}			elements[index].type = identifier->type;		}		// see if we can join any preceding modifiers		if (index > 0			&& (elements[index - 1].type & TYPE_MODIFIER) != 0			&& (elements[index].type & TYPE_NOT_MODIFIABLE) == 0) {			// copy the current one to the last and go on			elements[index].modifier = elements[index - 1].modifier;			elements[index].value *= elements[index - 1].value;			elements[index - 1] = elements[index];		} else {			// we filled out one parsed_element			index++;		}	}	// were there any elements?	if (index == 0)		return B_ERROR;	elements[index].type = TYPE_END;	return B_OK;}