@@ -30,23 +30,23 @@ int has_match(const char *needle, const char *haystack) {
3030
3131#ifdef DEBUG_VERBOSE
3232/* print one of the internal matrices */
33- void mat_print (score_t * mat , const char * needle , const char * haystack ) {
33+ void mat_print (score_t * mat , char name , const char * needle , const char * haystack ) {
3434 int n = strlen (needle );
3535 int m = strlen (haystack );
3636 int i , j ;
37- fprintf (stderr , " " );
37+ fprintf (stderr , "%c " , name );
3838 for (j = 0 ; j < m ; j ++ ) {
39- fprintf (stderr , " %c" , haystack [j ]);
39+ fprintf (stderr , " %c" , haystack [j ]);
4040 }
4141 fprintf (stderr , "\n" );
4242 for (i = 0 ; i < n ; i ++ ) {
4343 fprintf (stderr , " %c |" , needle [i ]);
4444 for (j = 0 ; j < m ; j ++ ) {
4545 score_t val = mat [i * m + j ];
4646 if (val == SCORE_MIN ) {
47- fprintf (stderr , " -\u221E" );
47+ fprintf (stderr , " -\u221E" );
4848 } else {
49- fprintf (stderr , " % 4g " , val );
49+ fprintf (stderr , " %.3f " , val );
5050 }
5151 }
5252 fprintf (stderr , "\n" );
@@ -111,7 +111,7 @@ score_t calculate_score(const char *needle, const char *haystack, size_t *positi
111111 if (tolower (needle [i ]) == tolower (haystack [j ])) {
112112 if (!i ) {
113113 score = (j * SCORE_GAP_LEADING ) + match_bonus [j ];
114- } else if (j ) {
114+ } else if (j ) { /* i > 0 && j > 0*/
115115 score = max (
116116 M [i - 1 ][j - 1 ] + match_bonus [j ],
117117
@@ -126,8 +126,8 @@ score_t calculate_score(const char *needle, const char *haystack, size_t *positi
126126
127127#ifdef DEBUG_VERBOSE
128128 fprintf (stderr , "\"%s\" =~ \"%s\"\n" , needle , haystack );
129- mat_print (& D [0 ][0 ], needle , haystack );
130- mat_print (& M [0 ][0 ], needle , haystack );
129+ mat_print (& D [0 ][0 ], 'D' , needle , haystack );
130+ mat_print (& M [0 ][0 ], 'M' , needle , haystack );
131131 fprintf (stderr , "\n" );
132132#endif
133133
0 commit comments