rem: if(strcmp(str,"BEGIN") == 0){
add: if(strcasecmp(str,"BEGIN") == 0){
context: icalcomponent* icalparser_add_line(icalparser* parser,                                       char* line){     char *str;    char *end;    int vcount = 0;    icalproperty *prop;    icalproperty_kind prop_kind;    icalvalue *value;    icalvalue_kind value_kind = ICAL_NO_VALUE;    icalerror_check_arg_rz((parser != 0),"parser");    if (line == 0)    {	parser->state = ICALPARSER_ERROR;	return 0;    }    if(line_is_blank(line) == 1){	return 0;    }    /* Begin by getting the property name at the start of the line. The       property name may end up being "BEGIN" or "END" in which case it       is not really a property, but the marker for the start or end of       a component */    end = 0;    str = icalparser_get_prop_name(line, &end);    if (str == 0 || strlen(str) == 0 ){	/* Could not get a property name */	icalcomponent *tail = pvl_data(pvl_tail(parser->components));	if (tail){	    insert_error(tail,line,			 "Got a data line, but could not find a property name or component begin tag",			 ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);	}	tail = 0;	parser->state = ICALPARSER_ERROR;	return 0;     }    /**********************************************************************     * Handle begin and end of components     **********************************************************************/								           /* If the property name is BEGIN or END, we are actually       starting or ending a new component */    if(strcmp(str,"BEGIN") == 0){	icalcomponent *c;        icalcomponent_kind comp_kind;	parser->level++;	str = icalparser_get_next_value(end,&end, value_kind);	            comp_kind = icalenum_string_to_component_kind(str);        if (comp_kind == ICAL_NO_COMPONENT){	    c = icalcomponent_new(ICAL_XLICINVALID_COMPONENT);	    insert_error(c,str,"Parse error in component name",			 ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);        }	c  =  icalcomponent_new(comp_kind);	if (c == 0){	    c = icalcomponent_new(ICAL_XLICINVALID_COMPONENT);	    insert_error(c,str,"Parse error in component name",			 ICAL_XLICERRORTYPE_COMPONENTPARSEERROR);	}	    	pvl_push(parser->components,c);	parser->state = ICALPARSER_BEGIN_COMP;	return 0;    } else if (strcmp(str,"END") == 0 ) {	icalcomponent* tail;	parser->level--;	str = icalparser_get_next_value(end,&end, value_kind);	/* Pop last component off of list and add it to the second-to-last*/	parser->root_component = pvl_pop(parser->components);	tail = pvl_data(pvl_tail(parser->components));	if(tail != 0){	    icalcomponent_add_component(tail,parser->root_component);	} 	tail = 0;	/* Return the component if we are back to the 0th level */	if (parser->level == 0){	    icalcomponent *rtrn; 	    if(pvl_count(parser->components) != 0){	    /* There are still components on the stack -- this means               that one of them did not have a proper "END" */		pvl_push(parser->components,parser->root_component);		icalparser_clean(parser); /* may reset parser->root_component*/	    }	    assert(pvl_count(parser->components) == 0);	    parser->state = ICALPARSER_SUCCESS;	    rtrn = parser->root_component;	    parser->root_component = 0;	    return rtrn;	} else {	    parser->state = ICALPARSER_END_COMP;	    return 0;	}    }    /* There is no point in continuing if we have not seen a       component yet */    if(pvl_data(pvl_tail(parser->components)) == 0){	parser->state = ICALPARSER_ERROR;	return 0;    }    /**********************************************************************     * Handle property names     **********************************************************************/								           /* At this point, the property name really is a property name,       (Not a component name) so make a new property and add it to       the component */        prop_kind = icalproperty_string_to_kind(str);    prop = icalproperty_new(prop_kind);    if (prop != 0){	icalcomponent *tail = pvl_data(pvl_tail(parser->components));        if(prop_kind==ICAL_X_PROPERTY){            icalproperty_set_x_name(prop,str);        }	icalcomponent_add_property(tail, prop);	/* Set the value kind for the default for this type of	   property. This may be re-set by a VALUE parameter */	value_kind = icalproperty_kind_to_value_kind(icalproperty_isa(prop));    } else {	icalcomponent* tail = pvl_data(pvl_tail(parser->components));	insert_error(tail,str,"Parse error in property name",		     ICAL_XLICERRORTYPE_PROPERTYPARSEERROR);	    	tail = 0;	parser->state = ICALPARSER_ERROR;	return 0;    }    /**********************************************************************     * Handle parameter values     **********************************************************************/								           /* Now, add any parameters to the last property */    while(1) {	if (*(end-1) == ':'){	    /* if the last seperator was a ":" and the value is a	       URL, icalparser_get_next_parameter will find the	       ':' in the URL, so better break now. */	    break;	}	str = icalparser_get_next_parameter(end,&end);	if (str != 0){	    char* name;	    char* pvalue;        	    icalparameter *param = 0;	    icalparameter_kind kind;	    icalcomponent *tail = pvl_data(pvl_tail(parser->components));	    name = icalparser_get_param_name(str,&pvalue);	    if (name == 0){		/* 'tail' defined above */		insert_error(tail, str, "Cant parse parameter name",			     ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR);		tail = 0;		break;	    }	    kind = icalparameter_string_to_kind(name);	    if(kind == ICAL_X_PARAMETER){		param = icalparameter_new(ICAL_X_PARAMETER);				if(param != 0){		    icalparameter_set_xname(param,name);		    icalparameter_set_xvalue(param,pvalue);		}	    } else if (kind != ICAL_NO_PARAMETER){		param = icalparameter_new_from_value_string(kind,pvalue);	    } else {		/* Error. Failed to parse the parameter*/		/* 'tail' defined above */		insert_error(tail, str, "Cant parse parameter name",			     ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR);		tail = 0;		parser->state = ICALPARSER_ERROR;		return 0;	    }	    if (param == 0){		/* 'tail' defined above */		insert_error(tail,str,"Cant parse parameter value",			     ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR);		    		tail = 0;		parser->state = ICALPARSER_ERROR;		continue;	    }	    /* If it is a VALUE parameter, set the kind of value*/	    if (icalparameter_isa(param)==ICAL_VALUE_PARAMETER){		value_kind = (icalvalue_kind)                    icalparameter_value_to_value_kind(                                icalparameter_get_value(param)                                );		if (value_kind == ICAL_NO_VALUE){		    /* Ooops, could not parse the value of the		       parameter ( it was not one of the defined		       values ), so reset the value_kind */					    insert_error(			tail, str, 			"Got a VALUE parameter with an unknown type",			ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR);		    icalparameter_free(param);					    value_kind = 			icalproperty_kind_to_value_kind(			    icalproperty_isa(prop));					    icalparameter_free(param);		    tail = 0;		    parser->state = ICALPARSER_ERROR;		    return 0;		} 	    }	    /* Everything is OK, so add the parameter */	    icalproperty_add_parameter(prop,param);	    tail = 0;	} else { /* if ( str != 0)  */	    /* If we did not get a param string, go on to looking	       for a value */	    break;	} /* if ( str != 0)  */    } /* while(1) */	    	    /**********************************************************************     * Handle values     **********************************************************************/								           /* Look for values. If there are ',' characters in the values,       then there are multiple values, so clone the current       parameter and add one part of the value to each clone */    vcount=0;    while(1) {	str = icalparser_get_next_value(end,&end, value_kind);	if (str != 0){			    if (vcount > 0){		/* Actually, only clone after the second value */		icalproperty* clone = icalproperty_new_clone(prop);		icalcomponent* tail = pvl_data(pvl_tail(parser->components));		    		icalcomponent_add_property(tail, clone);		prop = clone;		    		tail = 0;	    }			    value = icalvalue_new_from_string(value_kind, str);			    /* Don't add properties without value */	    if (value == 0){		char temp[200]; /* HACK */		icalproperty_kind prop_kind = icalproperty_isa(prop);		icalcomponent* tail = pvl_data(pvl_tail(parser->components));		snprintf(temp,sizeof(temp),"Can't parse as %s value in %s property. Removing entire property",			icalvalue_kind_to_string(value_kind),			icalproperty_kind_to_string(prop_kind));		insert_error(tail, str, temp,			     ICAL_XLICERRORTYPE_VALUEPARSEERROR);		/* Remove the troublesome property */		icalcomponent_remove_property(tail,prop);		icalproperty_free(prop);		prop = 0;		tail = 0;		parser->state = ICALPARSER_ERROR;		return 0;		    	    } else {		vcount++;		icalproperty_set_value(prop, value);	    }	} else {	    if (vcount == 0){		char temp[200]; /* HACK */				icalproperty_kind prop_kind = icalproperty_isa(prop);		icalcomponent *tail = pvl_data(pvl_tail(parser->components));				snprintf(temp,sizeof(temp),"No value for %s property. Removing entire property",			icalproperty_kind_to_string(prop_kind));		insert_error(tail, str, temp,			     ICAL_XLICERRORTYPE_VALUEPARSEERROR);		/* Remove the troublesome property */		icalcomponent_remove_property(tail,prop);		icalproperty_free(prop);		prop = 0;		tail = 0;		parser->state = ICALPARSER_ERROR;		return 0;	    } else {		break;	    }	}    }	    /****************************************************************     * End of component parsing.      *****************************************************************/    if (pvl_data(pvl_tail(parser->components)) == 0 &&	parser->level == 0){	/* HACK. Does this clause ever get executed? */	parser->state = ICALPARSER_SUCCESS;	assert(0);	return parser->root_component;    } else {	parser->state = ICALPARSER_IN_PROGRESS;	return 0;    }}