From 2f6d9257a577559f5a35ea1269584feb7c952844 Mon Sep 17 00:00:00 2001 From: midipix Date: Fri, 1 Jan 2016 06:09:25 -0500 Subject: amgc_output_pad_symbol(): initial implementation. --- src/output/amgc_output_pad_symbol.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/output/amgc_output_pad_symbol.c (limited to 'src/output') diff --git a/src/output/amgc_output_pad_symbol.c b/src/output/amgc_output_pad_symbol.c new file mode 100644 index 0000000..ea10204 --- /dev/null +++ b/src/output/amgc_output_pad_symbol.c @@ -0,0 +1,35 @@ +/**********************************************************/ +/* apimagic: cparser-based API normalization utility */ +/* Copyright (C) 2015--2016 Z. Gilboa */ +/* Released under GPLv2 and GPLv3; see COPYING.APIMAGIC. */ +/**********************************************************/ + +#include +#include + +#include + +int amgc_output_pad_symbol( + const char * symbol, + const struct amgc_layout * layout, + FILE * fout) +{ + int len = (int)(strlen(symbol)); + + if (layout->symwidth < 1) + return -1; + + if (layout->tabwidth == 0) + return fprintf(fout,"%*c",layout->symwidth-len,' '); + + len &= (~(layout->tabwidth-1)); + + while (len < layout->symwidth) { + if (fputc('\t',fout) < 0) + return -1; + else + len += layout->tabwidth; + } + + return 0; +} -- cgit v1.2.3