All pastes #330182 Raw Edit

concat

public text v1 · immutable
#330182 ·published 2007-01-27 16:24 UTC
rendered paste body
stock concat(str[], len, ...)
{
	len--;
	new num = numargs();
	new strindex = 0;
	new arg = 2;
	new argindex;
	new argval;
	while (arg < num)
	{
		argindex = 0;
		do
		{
			argval = getarg(arg, argindex);
			if (argval == 0) break;
			str[strindex] = argval;
			strindex++;
			if (strindex == len) goto concatend;
			argindex++;
		}
		while (argindex != 0); // Impossible (ignores a warning)
		arg++;
	}
	concatend: // Stupid single level breaks!
	str[strindex] = 0; // Null terminate
}