Blame src/output/amgc_output_pad_symbol.c

2f6d92
/**********************************************************/
2f6d92
/*  apimagic: cparser-based API normalization utility     */
2f6d92
/*  Copyright (C) 2015--2016  Z. Gilboa                   */
2f6d92
/*  Released under GPLv2 and GPLv3; see COPYING.APIMAGIC. */
2f6d92
/**********************************************************/
2f6d92
2f6d92
#include <stdio.h>
2f6d92
#include <string.h>
2f6d92
2f6d92
#include <apimagic/apimagic.h>
2f6d92
2f6d92
int  amgc_output_pad_symbol(
2f6d92
	const char *			symbol,
2f6d92
	const struct amgc_layout *	layout,
2f6d92
	FILE *				fout)
2f6d92
{
2f6d92
	int len = (int)(strlen(symbol));
2f6d92
2f6d92
	if (layout->symwidth < 1)
2f6d92
		return -1;
2f6d92
2f6d92
	if (layout->tabwidth == 0)
2f6d92
		return fprintf(fout,"%*c",layout->symwidth-len,' ');
2f6d92
2f6d92
	len &= (~(layout->tabwidth-1));
2f6d92
2f6d92
	while (len < layout->symwidth) {
2f6d92
		if (fputc('\t',fout) < 0)
2f6d92
			return -1;
2f6d92
		else
2f6d92
			len += layout->tabwidth;
2f6d92
	}
2f6d92
2f6d92
	return 0;
2f6d92
}