src/melon/modules/string/format.c
static size_t _out_rev(out_fct_type out, char *buffer, size_t idx, size_t maxlen, const char *buf, size_t len, unsigned int width, unsigned int flags)
{
	const size_t start_idx = idx;

	// pad spaces up to given width
	if (!(flags & FLAGS_LEFT) && !(flags & FLAGS_ZEROPAD))
	{
		for (size_t i = len; i < width; i++)
		{
			out(' ', buffer, idx++, maxlen);
		}
	}

	// reverse string
	while (len)
	{
		out(buf[--len], buffer, idx++, maxlen);
	}

	// append pad spaces up to given width
	if (flags & FLAGS_LEFT)
	{
		while (idx - start_idx < width)
		{
			out(' ', buffer, idx++, maxlen);
		}
	}

	return idx;
}
// output the specified string in reverse, taking care of any zero-padding

output the specified string in reverse, taking care of any zero-padding
output the specified string in reverse taking care of any zero - padding
static size_t _out_rev(out_fct_type out, char *buffer, size_t idx, size_t maxlen, const char *buf, size_t len, unsigned int width, unsigned int flags)
{
	const size_t start_idx = idx;
	if (!(flags & FLAGS_LEFT) && !(flags & FLAGS_ZEROPAD))
	{
		for (size_t i = len; i < width; i++)
		{
			out(' ', buffer, idx++, maxlen);
		}
	}
	while (len)
	{
		out(buf[--len], buffer, idx++, maxlen);
	}
	if (flags & FLAGS_LEFT)
	{
		while (idx - start_idx < width)
		{
			out(' ', buffer, idx++, maxlen);
		}
	}
	return idx;
}
static size_t _out_rev ( out_fct_type out , char * buffer , size_t idx , size_t maxlen , const char * buf , size_t len , unsigned int width , unsigned int flags ) { const size_t start_idx = idx ; if ( ! ( flags & FLAGS_LEFT ) && ! ( flags & FLAGS_ZEROPAD ) ) { for ( size_t i = len ; i < width ; i ++ ) { out ( ' ' , buffer , idx ++ , maxlen ) ; } } while ( len ) { out ( buf [ -- len ] , buffer , idx ++ , maxlen ) ; } if ( flags & FLAGS_LEFT ) { while ( idx - start_idx < width ) { out ( ' ' , buffer , idx ++ , maxlen ) ; } } return idx ; }
output the specified string in reverse, taking care of any zero-padding
output the specified string in reverse taking care of any zero - padding
// pad spaces up to given width
 // reverse string
 // append pad spaces up to given width
