rem: } else if ( (*(p=s->s)=='+') || (*p=='-') || isdigit(*p) ) {
add: } else if ( (*(p=s->s)=='+') || (*p=='-') || isdigit((int)(unsigned char)*p) ) {
context: static inline int parse_db_value( str *s, db_val_t *val, str **ret_s){	db_type_t type;	db_type_t nr_type;	int cast;	struct tm td;	char *p;	char *end;	int n;	float nr;	cast = 0;	*ret_s = 0;	p = 0;	type = DB_STR;	/* some safety checks */	if (s->len==0 || s->s==0) {		semidouble_log("BUG -> parse_db_value gets a len/s=0 string");		goto error;	}	/* is there some data cast operator? */	if (s->s[0]=='[') {		/* get the end of the cast operator */		for(p=s->s,end=s->s+s->len ; p<end && *p!=']' ; p++);		if (p>=end-1) {			double_log("Bad cast operator format (expected attr=[type]val)");			goto error;		}		n = p - s->s - 1;		p = s->s + 1;		DBG("---><%.*s>\n",n,p);		/*identify the cast type*/		if (n==INT_TYPE_LEN && !strncasecmp(p,INT_TYPE,n)) {			type = DB_INT;		} else if (n==DOUBLE_TYPE_LEN && !strncasecmp(p,DOUBLE_TYPE,n)) {			type = DB_DOUBLE;		} else if (n==STRING_TYPE_LEN && !strncasecmp(p,STRING_TYPE,n)) {			type = DB_STR;		} else if (n==BLOB_TYPE_LEN && !strncasecmp(p,BLOB_TYPE,n)) {			type = DB_BLOB;		} else if (n==DATE_TYPE_LEN && !strncasecmp(p,DATE_TYPE,n)) {			type = DB_DATETIME;		} else if (n==BITMAP_TYPE_LEN && !strncasecmp(p,BITMAP_TYPE,n)) {			type = DB_BITMAP;		} else {			double_log("Unknown cast type");			goto error;		}		cast = 1;		s->s += n+2;		s->len -= n+2;	}	/* string has at least one character */	DBG("DEBUG:parse_db_value: value id <%.*s>\n",s->len,s->s);	if ( s->s[0]=='\"' && s->s[s->len-1]=='\"' && s->len!=1) {		/* can be DB_STR, DB_STRING, DB_BLOB */		/* get rid of the quoting */		s->s++;		s->len -= 2;		/* if casted, check if is valid */		if (cast) {			if (type!=DB_STR && type!=DB_BLOB) {				double_log("Invalid cast for quoted value");				goto error;			}		} else {			type = DB_STR;		}		/* fill in the val struct */		memset( val, 0, sizeof(db_val_t));		val->type = type;		if (type==DB_STR) {			val->val.str_val = *s;			*ret_s = &val->val.str_val;		} else if (type==DB_BLOB) {			val->val.blob_val = *s;			*ret_s = &val->val.blob_val;		} else {			semidouble_log("BUG -> type is not STR or BLOB");			goto error;		}	} else if ( s->s[0]=='<' && s->s[s->len-1]=='>' && s->len!=1) {		/* can be only date+time type DB_DATETIME*/		/* if casted, check if is valid */		if (cast && type!=DB_DATETIME) {			double_log("Invalid cast for quoted value");			goto error;		}		/* get rid of the quoting */		s->s++;		s->len -= 2;		/* start parsing */		p = s->s;		end = s->s + s->len;		td.tm_wday = 0;		td.tm_yday = 0;		/* get year */		get_int( p, end, td.tm_year, n, "Missing year in date format",error);		td.tm_year -= 1900; /* correction */		if (*(p++)!='-') goto date_error;		/* get month */		get_int( p, end, td.tm_mon, n, "Missing month in date format",error);		td.tm_mon --; /* correction */		if (*(p++)!='-') goto date_error;		/* get day */		get_int( p, end, td.tm_mday, n, "Missing day in date format",error);		if (*(p++)!=' ') goto date_error;		/* get hour */		get_int( p, end, td.tm_hour, n, "Missing hour in date format",error);		if (*(p++)!=':') goto date_error;		/* get minutes */		get_int( p, end, td.tm_min, n, "Missing minutes in date format",error);		if (*(p++)!=':') goto date_error;		/* get seconds */		get_int( p, end, td.tm_sec, n,"Missing seconds in date format",error);		if (p!=end) goto date_error;		td.tm_isdst = -1 ; /*daylight*/		/* fill the val struct */		val->type = DB_DATETIME;		val->val.time_val = mktime( &td );		/*DBG("DBG: <%.*s> is %s\n",s->len,s->s,ctime(&val->val.time_val));*/	} else if ( (*(p=s->s)=='+') || (*p=='-') || isdigit(*p) ) {		/* can be a DB_INT / DB_DOUBLE / DB_BITMAP value */		if (sgn_str2float( s, &nr, &nr_type)!=0) {			double_log("Bad int/float value format (expected [+/-]nr[.nr])");			goto error;		}		/* if casted, check if valid */		if (cast) {			switch (type) {				case DB_BITMAP:					if ( nr_type!=DB_INT || nr<0 ) {						double_log("Invalid value for BITMAP type");						goto error;					}					break;				case DB_INT:				case DB_DOUBLE:					if (type==DB_INT && nr_type==DB_DOUBLE ) {						double_log("Invalid cast to INT for a DOUBLE value");						goto error;					}					break;				default:					double_log("Invalid cast for numerical value");					goto error;			}		} else {			type = nr_type;		}		/* fill the val struct */		val->type = type;		switch (type) {			case DB_INT:				val->val.int_val = (int)nr; break;			case DB_DOUBLE:				val->val.double_val = nr; break;			case DB_BITMAP:				val->val.bitmap_val = (int)nr; break;			default:				semidouble_log("BUG -> unknown type when filling num. val");				goto error;		}	} else if (s->len==NULL_VAL_LEN && !strncasecmp(s->s,NULL_VAL,s->len) ) {		/* it's a NULL val */		if (!cast) {			double_log("NULL values requires type casting");			goto error;		}		val->type = type;		val->nul = 1;	} else {		double_log("Unable to recognize value type");		goto error;	}	return 0;date_error:	double_log("Bad <date time> format (expected <YYYY-MM-DD hh:mm:ss>)\n");error:	return -1;}