On Thu, Jul 09, 2015 at 02:20:08PM +0200, Michael Matz wrote:
> +/* Like fprintf, but print INDENT spaces at the beginning. */
> +
> +static void
> +#if GCC_VERSION >= 4001
> +__attribute__((format (printf, 3, 4)))
> +#endif
> +fprintf_indent (FILE *f, unsigned int indent, const char *format, ...)
> +{
> + va_list ap;
> + va_start (ap, format);
> + fprintf (f, "%*s", indent, "");
That violates the coding style by not using tabs ;)
You could just emit indent / 8 tabs first and then indent % 8 spaces.
const char tabs[] = "\t\t\t\t\t\t\t\t";
while (indent >= 8 * 8)
{
fwrite (tabs, 1, 8, f);
indent -= 8 * 8;
}
if (indent >= 8)
fwrite (tabs, 1, indent / 8, f);
fprintf (f, "%*s", indent % 8, "");
Jakub