summaryrefslogtreecommitdiff
path: root/src/output
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-01-09 16:34:39 -0500
committermidipix <writeonce@midipix.org>2016-01-09 16:34:39 -0500
commit5a349e333087d9901d1a046139ec942c36afcb93 (patch)
tree157e42de84baf8348c6f9bd04968013628efdf0e /src/output
parent58e7b9bc575a315f8bfcc70c1e7b6f6730b0f536 (diff)
downloadapimagic-5a349e333087d9901d1a046139ec942c36afcb93.tar.bz2
apimagic-5a349e333087d9901d1a046139ec942c36afcb93.tar.xz
amgc_output_pad_symbol(): use symwidth, fix unspecified tab-width code path.
of the three compilers in use (gcc 5.3.0, clang 3.6.2, cparser 1.22.1), flaws in the previous version of this function were only spotted by cparser.
Diffstat (limited to 'src/output')
-rw-r--r--src/output/amgc_output_pad_symbol.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/output/amgc_output_pad_symbol.c b/src/output/amgc_output_pad_symbol.c
index 6a475ee..6c1d34a 100644
--- a/src/output/amgc_output_pad_symbol.c
+++ b/src/output/amgc_output_pad_symbol.c
@@ -21,20 +21,15 @@ int amgc_output_pad_symbol(
if (layout->symwidth < 1)
return -1;
- if (layout->tabwidth) {
- symwidth += layout->tabwidth;
- symwidth &= (~(layout->tabwidth-1));
- } else {
- symwidth += AMGC_TAB_WIDTH;
- symwidth &= (~(AMGC_TAB_WIDTH-1));
- }
-
if (layout->tabwidth == 0)
return fprintf(fout,"%*c",layout->symwidth-len,' ');
+ symwidth += layout->tabwidth;
+ symwidth &= (~(layout->tabwidth-1));
+
len &= (~(layout->tabwidth-1));
- while (len < layout->symwidth) {
+ while (len < symwidth) {
if (fputc('\t',fout) < 0)
return -1;
else