Align = of -p? and -c? output

This commit is contained in:
Stefan Rueger 2022-09-16 19:09:35 +01:00
parent 7a76967851
commit fba2ac0330
1 changed files with 36 additions and 8 deletions

View File

@ -167,9 +167,23 @@ static void list_programmers(FILE *f, const char *prefix, LISTID programmers, in
LNODEID ln1;
LNODEID ln2;
PROGRAMMER *pgm;
int maxlen=0, len;
sort_programmers(programmers);
// Compute max length of programmer names
for(ln1 = lfirst(programmers); ln1; ln1 = lnext(ln1)) {
pgm = ldata(ln1);
for(ln2=lfirst(pgm->id); ln2; ln2=lnext(ln2))
if(!pm || !pgm->prog_modes || (pm & pgm->prog_modes)) {
const char *id = ldata(ln2);
if(*id == 0 || *id == '.')
continue;
if((len = strlen(id)) > maxlen)
maxlen = len;
}
}
for(ln1 = lfirst(programmers); ln1; ln1 = lnext(ln1)) {
pgm = ldata(ln1);
for(ln2=lfirst(pgm->id); ln2; ln2=lnext(ln2)) {
@ -179,9 +193,9 @@ static void list_programmers(FILE *f, const char *prefix, LISTID programmers, in
if(*id == 0 || *id == '.')
continue;
if(verbose)
fprintf(f, "%s%-16s = %-30s [%s:%d]", prefix, id, pgm->desc, pgm->config_file, pgm->lineno);
fprintf(f, "%s%-*s = %-30s [%s:%d]", prefix, maxlen, id, pgm->desc, pgm->config_file, pgm->lineno);
else
fprintf(f, "%s%-16s = %-s", prefix, id, pgm->desc);
fprintf(f, "%s%-*s = %-s", prefix, maxlen, id, pgm->desc);
if(pm != ~0)
fprintf(f, " via %s", via_prog_modes(pm & pgm->prog_modes));
fprintf(f, "\n");
@ -212,9 +226,23 @@ static void list_programmer_types(FILE * f, const char *prefix)
static void list_parts(FILE *f, const char *prefix, LISTID avrparts, int pm) {
LNODEID ln1;
AVRPART *p;
int maxlen=0, len;
sort_avrparts(avrparts);
// Compute max length of part names
for(ln1 = lfirst(avrparts); ln1; ln1 = lnext(ln1)) {
p = ldata(ln1);
// List part if pm or prog_modes uninitialised or if they are compatible otherwise
if(!pm || !p->prog_modes || (pm & p->prog_modes)) {
if((verbose < 2) && (p->id[0] == '.')) // hide ids starting with '.'
continue;
if((len = strlen(p->id)) > maxlen)
maxlen = len;
}
}
for(ln1 = lfirst(avrparts); ln1; ln1 = lnext(ln1)) {
p = ldata(ln1);
// List part if pm or prog_modes uninitialised or if they are compatible otherwise
@ -222,9 +250,9 @@ static void list_parts(FILE *f, const char *prefix, LISTID avrparts, int pm) {
if((verbose < 2) && (p->id[0] == '.')) // hide ids starting with '.'
continue;
if(verbose)
fprintf(f, "%s%-8s = %-18s [%s:%d]", prefix, p->id, p->desc, p->config_file, p->lineno);
fprintf(f, "%s%-*s = %-18s [%s:%d]", prefix, maxlen, p->id, p->desc, p->config_file, p->lineno);
else
fprintf(f, "%s%-8s = %s", prefix, p->id, p->desc);
fprintf(f, "%s%-*s = %s", prefix, maxlen, p->id, p->desc);
if(pm != ~0)
fprintf(f, " via %s", via_prog_modes(pm & p->prog_modes));
fprintf(f, "\n");