/**********************************************************/
/* apimagic: cparser-based API normalization utility */
/* Copyright (C) 2015--2021 SysDeer Technologies, LLC */
/* Released under GPLv2 and GPLv3; see COPYING.APIMAGIC. */
/**********************************************************/
#include <stdio.h>
#include <string.h>
#include <apimagic/apimagic.h>
#include "apimagic_driver_impl.h"
int amgc_output_pad_symbol(
const struct amgc_driver_ctx * dctx,
const char * symbol,
const struct amgc_layout * layout)
{
int len = (int)(strlen(symbol));
int fdout = amgc_driver_fdout(dctx);
int symwidth = layout->symwidth;
if (layout->symwidth < 1)
return -1;
if (layout->tabwidth == 0)
return amgc_dprintf(
fdout,"%*c",
layout->symwidth-len,' ');
symwidth += layout->tabwidth;
symwidth &= (~(layout->tabwidth-1));
len &= (~(layout->tabwidth-1));
while (len < symwidth) {
if (amgc_dprintf(fdout,"\t") < 0)
return -1;
len += layout->tabwidth;
}
return 0;
}