split the function printstr() into printstr_n() and printstr_m()

This commit is contained in:
rlar 2010-07-13 18:17:06 +00:00
parent 922d5c69ac
commit 5397fd9fdd
3 changed files with 28 additions and 19 deletions

View File

@ -1,3 +1,11 @@
2010-07-13 Robert Larice
* src/frontend/device.c ,
* src/frontend/device.h :
split the function printstr() into printstr_n() and printstr_m()
printstr() is exclusively used as argument
to the map function dgen_for_n()
and misused a parameter to distinguish two separate functionalities.
2010-07-13 Robert Larice
* src/frontend/gens.c ,
* src/frontend/gens.h :

View File

@ -195,7 +195,7 @@ all_show(wordlist *wl, int mode)
i = 0;
do {
fprintf(cp_out,"%*s", LEFT_WIDTH, "model");
j = dgen_for_n(dg, count, printstr, "m", i);
j = dgen_for_n(dg, count, printstr_m, NULL, i);
i += 1;
fprintf(cp_out,"\n");
} while (j);
@ -341,7 +341,7 @@ all_show_old(wordlist *wl, int mode)
i = 0;
do {
fprintf(cp_out,"%*s", LEFT_WIDTH, "device");
j = dgen_for_n(dg, count, printstr, "n", i);
j = dgen_for_n(dg, count, printstr_n, NULL, i);
i += 1;
fprintf(cp_out,"\n");
} while (j);
@ -350,7 +350,7 @@ all_show_old(wordlist *wl, int mode)
i = 0;
do {
fprintf(cp_out,"%*s", LEFT_WIDTH, "model");
j = dgen_for_n(dg, count, printstr, "m", i);
j = dgen_for_n(dg, count, printstr_m, NULL, i);
i += 1;
fprintf(cp_out,"\n");
} while (j);
@ -373,7 +373,7 @@ all_show_old(wordlist *wl, int mode)
i = 0;
do {
fprintf(cp_out,"%*s", LEFT_WIDTH, "model");
j = dgen_for_n(dg, count, printstr, "m", i);
j = dgen_for_n(dg, count, printstr_m, NULL, i);
i += 1;
fprintf(cp_out,"\n");
} while (j);
@ -404,22 +404,22 @@ all_show_old(wordlist *wl, int mode)
}
int
printstr(dgen *dg, char *name)
printstr_n(dgen *dg)
{
/* va: ' ' is no flag for %s; \? avoids trigraph warning */
if (*name == 'n') {
if (dg->instance)
fprintf(cp_out," %*.*s", DEV_WIDTH, DEV_WIDTH, dg->instance->GENname);
else
fprintf(cp_out," %*s", DEV_WIDTH, "<\?\?\?\?\?\?\?>");
} else if (*name == 'm') {
if (dg->model)
fprintf(cp_out," %*.*s", DEV_WIDTH, DEV_WIDTH, dg->model->GENmodName);
else
fprintf(cp_out," %*s", DEV_WIDTH, "<\?\?\?\?\?\?\?>");
} else
fprintf(cp_out," %*s", DEV_WIDTH, "<error>");
if (dg->instance)
fprintf(cp_out," %*.*s", DEV_WIDTH, DEV_WIDTH, dg->instance->GENname);
else
fprintf(cp_out," %*s", DEV_WIDTH, "<\?\?\?\?\?\?\?>");
return 0;
}
int
printstr_m(dgen *dg)
{
if (dg->model)
fprintf(cp_out," %*.*s", DEV_WIDTH, DEV_WIDTH, dg->model->GENmodName);
else
fprintf(cp_out," %*s", DEV_WIDTH, "<\?\?\?\?\?\?\?>");
return 0;
}

View File

@ -12,7 +12,8 @@
void com_showmod(wordlist *wl);
void com_show(wordlist *wl);
int printstr(dgen *dg, char *name);
int printstr_n(dgen *dg);
int printstr_m(dgen *dg);
void param_forall(dgen *dg, int flags);
void param_forall_old(dgen *dg, int flags);
void listparam(wordlist *p, dgen *dg);