From 5397fd9fdd27857cb4089d3c687b8fa224ab2f59 Mon Sep 17 00:00:00 2001 From: rlar Date: Tue, 13 Jul 2010 18:17:06 +0000 Subject: [PATCH] split the function printstr() into printstr_n() and printstr_m() --- ChangeLog | 8 ++++++++ src/frontend/device.c | 36 ++++++++++++++++++------------------ src/frontend/device.h | 3 ++- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f3cd52df..28c5509e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 : diff --git a/src/frontend/device.c b/src/frontend/device.c index bd2602ad4..c73e2f39c 100644 --- a/src/frontend/device.c +++ b/src/frontend/device.c @@ -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, ""); + 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; } diff --git a/src/frontend/device.h b/src/frontend/device.h index 14d25c623..15d070444 100644 --- a/src/frontend/device.h +++ b/src/frontend/device.h @@ -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);