static char *parse_len(char *p,
			int dur_u,
			int *p_len)
{
	int len, fac;
	int err = 0;
	char *q;

	len = dur_u;
	if (isdigit((unsigned char) *p)) {
		len *= strtol(p, &q, 10);
		if (len <= 0 || len > 10000) {
			syntax("Bad length", p);
			len = dur_u;
		}
		p = q;
	}
	if (*p != '/') {
		*p_len = len;
		return p;
	}
	if (isdigit((unsigned char) p[1])) {
		fac = strtol(p + 1, &q, 10);
		p = q;
		if (fac == 0 || (fac & (fac - 1)))
			err = 1;
		else
			len /= fac;
	} else {
		while (*p == '/') {
			if (len & 1)
				err = 1;
			len /= 2;
			p++;
		}
	}
	if (err || !len) {
		syntax("Bad length divisor", p - 1);
		len = dur_u;
	}
	*p_len = len;
	return p;
}
static char *parse_len(char *p,
			int dur_u,
			int *p_len)
{
	int len, fac;
	int err = 0;
	char *q;

	len = dur_u;
	if (isdigit((unsigned char) *p)) {
		len *= strtol(p, &q, 10);
		if (len <= 0 || len > 10000) {
			syntax("Bad length", p);
			len = dur_u;
		}
		p = q;
	}
	if (*p != '/') {
		*p_len = len;
		return p;
	}
	if (isdigit((unsigned char) p[1])) {
		fac = strtol(p + 1, &q, 10);
		p = q;
		if (fac == 0 || (fac & (fac - 1)))
			err = 1;
		else
			len /= fac;
	} else {
		while (*p == '/') {
			if (len & 1)
				err = 1;
			len /= 2;
			p++;
		}
	}
	if (err || !len) {
		syntax("Bad length divisor", p - 1);
		len = dur_u;
	}
	*p_len = len;
	return p;
}