示例#1
0
void EvalLTrim(const void *data, qCtx *ctx, qStr *out, qArgAry *args) {
	VALID_ARGC("ltrim", 1, 2);
	if (args->Count() > 1) {
		CStr str = (*args)[0];
		if (str.IsEmpty()) 
			return;
		CStr toks = (*args)[1];
		if (toks.Length() == 0)
			out->PutS(str);
		else if (toks.Length() == 1)
			out->PutS(str.LTrim(*toks));
		else {
			const char *p = str;
			size_t i = strspn(p,toks); 
			out->PutS(p+i, str.Length() - i); 
		}
	} else
		out->PutS((*args)[0].LTrim());
}