| ... | ... |
@@ -31,9 +31,21 @@ void mat_print(int *mat, int n, int m){
|
| 31 | 31 |
typedef int score_t; |
| 32 | 32 |
|
| 33 | 33 |
double calculate_score(const char *needle, const char *haystack){
|
| 34 |
+ if(!*haystack || !*needle) |
|
| 35 |
+ return SCORE_MIN; |
|
| 36 |
+ |
|
| 34 | 37 |
int n = strlen(needle); |
| 35 | 38 |
int m = strlen(haystack); |
| 36 | 39 |
|
| 40 |
+ if(m > 1024){
|
|
| 41 |
+ /* |
|
| 42 |
+ * Unreasonably large candidate: return no score |
|
| 43 |
+ * If it is a valid match it will still be returned, it will |
|
| 44 |
+ * just be ranked below any reasonably sized candidates |
|
| 45 |
+ */ |
|
| 46 |
+ return 0; |
|
| 47 |
+ } |
|
| 48 |
+ |
|
| 37 | 49 |
int bow[m]; |
| 38 | 50 |
int D[n][m], M[n][m]; |
| 39 | 51 |
bzero(D, sizeof(D)); |