Rename global variable anz_designs to num_designs #78

This commit is contained in:
Thomas Jensen
2021-04-16 20:45:21 +02:00
parent 9d17203f50
commit 4d0dbcd59b
5 changed files with 14 additions and 14 deletions

View File

@@ -44,7 +44,7 @@
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
design_t *designs = NULL; /* available box designs */ design_t *designs = NULL; /* available box designs */
int anz_designs = 0; /* number of designs after parsing TODO rename to num_designs */ int num_designs = 0; /* number of designs after parsing */
opt_t opt; /* command line options */ opt_t opt; /* command line options */
@@ -209,7 +209,7 @@ static int query_by_tag()
if (list == NULL) { if (list == NULL) {
return 1; return 1;
} }
for (int i = 0; i < anz_designs; ++i) { for (int i = 0; i < num_designs; ++i) {
if (filter_by_tag(list[i]->tags)) { if (filter_by_tag(list[i]->tags)) {
fprintf(opt.outfile, "%s%s", list[i]->name, opt.eol); fprintf(opt.outfile, "%s%s", list[i]->name, opt.eol);
for (size_t aidx = 0; list[i]->aliases[aidx] != NULL; ++aidx) { for (size_t aidx = 0; list[i]->aliases[aidx] != NULL; ++aidx) {
@@ -284,14 +284,14 @@ int main(int argc, char *argv[])
if (designs == NULL) { if (designs == NULL) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
anz_designs = (int) r_num_designs; num_designs = (int) r_num_designs;
} }
else { else {
rc = build_design(&designs, opt.cld); rc = build_design(&designs, opt.cld);
if (rc) { if (rc) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
anz_designs = 1; num_designs = 1;
} }
BFREE (opt.design); BFREE (opt.design);
opt.design = designs; opt.design = designs;

View File

@@ -101,7 +101,7 @@ typedef struct {
} design_t; } design_t;
extern design_t *designs; extern design_t *designs;
extern int anz_designs; extern int num_designs;
typedef struct { /* Command line options: */ typedef struct { /* Command line options: */

View File

@@ -110,12 +110,12 @@ static int style_sort(const void *p1, const void *p2)
design_t **sort_designs_by_name() design_t **sort_designs_by_name()
{ {
design_t **result = (design_t **) malloc(anz_designs * sizeof(design_t *)); design_t **result = (design_t **) malloc(num_designs * sizeof(design_t *));
if (result != NULL) { if (result != NULL) {
for (int i = 0; i < anz_designs; ++i) { for (int i = 0; i < num_designs; ++i) {
result[i] = &(designs[i]); result[i] = &(designs[i]);
} }
qsort(result, anz_designs, sizeof(design_t *), style_sort); qsort(result, num_designs, sizeof(design_t *), style_sort);
} }
else { else {
perror(PROJECT); perror(PROJECT);
@@ -360,7 +360,7 @@ int list_designs()
} }
print_design_list_header(); print_design_list_header();
for (int i = 0; i < anz_designs; ++i) { for (int i = 0; i < num_designs; ++i) {
char *all_names = names(list[i]); char *all_names = names(list[i]);
if (list[i]->author && list[i]->designer && strcmp(list[i]->author, list[i]->designer) != 0) { if (list[i]->author && list[i]->designer && strcmp(list[i]->author, list[i]->designer) != 0) {
fprintf(opt.outfile, "%s%s%s, coded by %s:%s%s%s%s%s", all_names, opt.eol, fprintf(opt.outfile, "%s%s%s, coded by %s:%s%s%s%s%s", all_names, opt.eol,

View File

@@ -76,12 +76,12 @@ static int open_yy_config_file(pass_to_bison *bison_args)
void print_design_list_header() void print_design_list_header()
{ {
char buf[42]; char buf[42];
sprintf(buf, "%d", anz_designs); sprintf(buf, "%d", num_designs);
fprintf(opt.outfile, "%d Available Style%s", anz_designs, anz_designs == 1 ? "" : "s"); fprintf(opt.outfile, "%d Available Style%s", num_designs, num_designs == 1 ? "" : "s");
if (num_parent_configs > 0) { if (num_parent_configs > 0) {
fprintf(opt.outfile, ":%s", opt.eol); fprintf(opt.outfile, ":%s", opt.eol);
fprintf(opt.outfile, "-----------------%s", anz_designs == 1 ? "" : "-"); fprintf(opt.outfile, "-----------------%s", num_designs == 1 ? "" : "-");
for (int i = strlen(buf); i > 0; --i) { for (int i = strlen(buf); i > 0; --i) {
fprintf(opt.outfile, "-"); fprintf(opt.outfile, "-");
} }
@@ -94,7 +94,7 @@ void print_design_list_header()
} }
else { else {
fprintf(opt.outfile, " in \"%s\":%s", first_config_file, opt.eol); fprintf(opt.outfile, " in \"%s\":%s", first_config_file, opt.eol);
fprintf(opt.outfile, "-----------------------%s", anz_designs == 1 ? "" : "-"); fprintf(opt.outfile, "-----------------------%s", num_designs == 1 ? "" : "-");
for (int i = strlen(first_config_file) + strlen(buf); i > 0; --i) { for (int i = strlen(first_config_file) + strlen(buf); i > 0; --i) {
fprintf(opt.outfile, "-"); fprintf(opt.outfile, "-");
} }

View File

@@ -531,7 +531,7 @@ static design_t *detect_design()
size_t a; size_t a;
int empty[NUM_SIDES]; int empty[NUM_SIDES];
for (dcnt = 0; dcnt < anz_designs; ++dcnt, ++d) { for (dcnt = 0; dcnt < num_designs; ++dcnt, ++d) {
#ifdef DEBUG #ifdef DEBUG
fprintf (stderr, "CONSIDERING DESIGN ---- \"%s\" ---------------\n", fprintf (stderr, "CONSIDERING DESIGN ---- \"%s\" ---------------\n",
d->name); d->name);