Skip to content

Commit 6f6180d

Browse files
committed
Remove asserts, general cleanup
Missed two asserts that should hve been done in #1533 #1508
1 parent f047f30 commit 6f6180d

File tree

1 file changed

+16
-24
lines changed

1 file changed

+16
-24
lines changed

link-grammar/print/print.c

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -295,21 +295,15 @@ static char *
295295
build_linkage_postscript_string(const Linkage linkage,
296296
bool display_walls, ps_ctxt_t *pctx)
297297
{
298-
int link, i,j;
299-
int d;
300298
bool print_word_0 = true, print_word_N = true;
301299
int N_links = linkage->num_links;
302300
Link *ppla = linkage->link_array;
303-
dyn_str * string;
304-
int N_words_to_print;
305-
306-
string = dyn_str_new();
307301

308302
/* Do we want to print the left and right walls? */
309303
if (!display_walls)
310304
{
311305
int N_wall_connectors = 0;
312-
for (j=0; j<N_links; j++)
306+
for (int j=0; j<N_links; j++)
313307
{
314308
if (0 == ppla[j].lw)
315309
{
@@ -326,7 +320,7 @@ build_linkage_postscript_string(const Linkage linkage,
326320
}
327321

328322
N_wall_connectors = 0;
329-
for (j=0; j<N_links; j++)
323+
for (int j=0; j<N_links; j++)
330324
{
331325
if (ppla[j].rw == linkage->num_words-1)
332326
{
@@ -342,38 +336,38 @@ build_linkage_postscript_string(const Linkage linkage,
342336
}
343337
}
344338

345-
if (print_word_0) d=0; else d=1;
346-
347-
i = 0;
348-
N_words_to_print = linkage->num_words;
339+
int N_words_to_print = linkage->num_words;
349340
if (!print_word_N) N_words_to_print--;
350341

342+
/* The postscriipt string */
343+
dyn_str * string = dyn_str_new();
351344
dyn_strcat(string, "[");
352-
for (j=d; j<N_words_to_print; j++) {
353-
if ((i%10 == 0) && (i>0)) dyn_strcat(string, "\n");
354-
i++;
345+
346+
int doff = print_word_0 ? 0 : 1;
347+
for (int j=doff; j<N_words_to_print; j++)
348+
{
349+
if ((j%10 == 0) && (j>doff)) dyn_strcat(string, "\n");
355350
append_string(string, "(%s)", linkage->word[j]);
356351
}
357352
dyn_strcat(string,"]");
358353
dyn_strcat(string,"\n");
359354

360355
dyn_strcat(string,"[");
361-
j = 0;
362-
for (link=0; link<N_links; link++) {
356+
int k = 0;
357+
for (int link=0; link<N_links; link++) {
363358
if (!print_word_0 && (ppla[link].lw == 0)) continue;
364359
if (!print_word_N && (ppla[link].rw == linkage->num_words-1)) continue;
365-
assert (ppla[link].lw != SIZE_MAX, "Missing word in link");
366-
if ((j%7 == 0) && (j>0)) dyn_strcat(string,"\n");
367-
j++;
360+
if ((k%7 == 0) && (k>0)) dyn_strcat(string,"\n");
361+
k++;
368362
append_string(string,"[%d %d %d",
369-
ppla[link].lw - d, ppla[link].rw - d,
363+
ppla[link].lw - doff, ppla[link].rw - doff,
370364
pctx->link_heights[link]);
371365
append_string(string," (%s)]", ppla[link].link_name);
372366
}
373367
dyn_strcat(string,"]");
374368
dyn_strcat(string,"\n");
375369
dyn_strcat(string,"[");
376-
for (j=0; j < pctx->N_rows; j++)
370+
for (int j=0; j < pctx->N_rows; j++)
377371
{
378372
if (j>0) append_string(string, " %d", pctx->row_starts[j]);
379373
else append_string(string,"%d", pctx->row_starts[j]);
@@ -434,8 +428,6 @@ static void sort_link_lengths(Link *ppla, link_by_length *ll,
434428
for (unsigned int j = 0; j < N_links; j++)
435429
{
436430
Link *lnk = &ppla[j];
437-
438-
assert(lnk->lw != SIZE_MAX, "Missing word in link");
439431
assert(lnk->link_name != NULL, "Missing link name");
440432

441433
lla[j] = &ll_tmp[j];

0 commit comments

Comments
 (0)