| ... | ... |
@@ -30,13 +30,13 @@ int has_match(const char *needle, const char *haystack) {
|
| 30 | 30 |
|
| 31 | 31 |
#ifdef DEBUG_VERBOSE |
| 32 | 32 |
/* 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) {
|
|
| 34 | 34 |
int n = strlen(needle); |
| 35 | 35 |
int m = strlen(haystack); |
| 36 | 36 |
int i, j; |
| 37 |
- fprintf(stderr, " "); |
|
| 37 |
+ fprintf(stderr, "%c ", name); |
|
| 38 | 38 |
for (j = 0; j < m; j++) {
|
| 39 |
- fprintf(stderr, " %c", haystack[j]); |
|
| 39 |
+ fprintf(stderr, " %c", haystack[j]); |
|
| 40 | 40 |
} |
| 41 | 41 |
fprintf(stderr, "\n"); |
| 42 | 42 |
for (i = 0; i < n; i++) {
|
| ... | ... |
@@ -44,9 +44,9 @@ void mat_print(score_t *mat, const char *needle, const char *haystack) {
|
| 44 | 44 |
for (j = 0; j < m; j++) {
|
| 45 | 45 |
score_t val = mat[i * m + j]; |
| 46 | 46 |
if (val == SCORE_MIN) {
|
| 47 |
- fprintf(stderr, " -\u221E"); |
|
| 47 |
+ fprintf(stderr, " -\u221E"); |
|
| 48 | 48 |
} else {
|
| 49 |
- fprintf(stderr, " % 4g", val); |
|
| 49 |
+ fprintf(stderr, " %.3f", val); |
|
| 50 | 50 |
} |
| 51 | 51 |
} |
| 52 | 52 |
fprintf(stderr, "\n"); |
| ... | ... |
@@ -111,7 +111,7 @@ score_t calculate_score(const char *needle, const char *haystack, size_t *positi |
| 111 | 111 |
if (tolower(needle[i]) == tolower(haystack[j])) {
|
| 112 | 112 |
if (!i) {
|
| 113 | 113 |
score = (j * SCORE_GAP_LEADING) + match_bonus[j]; |
| 114 |
- } else if (j) {
|
|
| 114 |
+ } else if (j) { /* i > 0 && j > 0*/
|
|
| 115 | 115 |
score = max( |
| 116 | 116 |
M[i - 1][j - 1] + match_bonus[j], |
| 117 | 117 |
|
| ... | ... |
@@ -126,8 +126,8 @@ score_t calculate_score(const char *needle, const char *haystack, size_t *positi |
| 126 | 126 |
|
| 127 | 127 |
#ifdef DEBUG_VERBOSE |
| 128 | 128 |
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); |
|
| 131 | 131 |
fprintf(stderr, "\n"); |
| 132 | 132 |
#endif |
| 133 | 133 |
|