summaryrefslogtreecommitdiff
path: root/src/output
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-01-01 06:09:25 -0500
committermidipix <writeonce@midipix.org>2016-01-01 22:50:26 -0500
commit2f6d9257a577559f5a35ea1269584feb7c952844 (patch)
treebc40f0ee34231cf4bb8e2c41eaccc4b37cea1e0d /src/output
parent5ec0ca7f8db2a0393e602dc9fcb92f437156432e (diff)
downloadapimagic-2f6d9257a577559f5a35ea1269584feb7c952844.tar.bz2
apimagic-2f6d9257a577559f5a35ea1269584feb7c952844.tar.xz
amgc_output_pad_symbol(): initial implementation.
Diffstat (limited to 'src/output')
-rw-r--r--src/output/amgc_output_pad_symbol.c35
1 files changed, 35 insertions, 0 deletions
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 <stdio.h>
+#include <string.h>
+
+#include <apimagic/apimagic.h>
+
+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;
+}