summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hawthorn <john.hawthorn@gmail.com>2014-09-18 17:28:21 -0700
committerJohn Hawthorn <john.hawthorn@gmail.com>2014-09-18 17:28:21 -0700
commit00e8069b4e228af1bf3e2ae282f368676efbe0db (patch)
tree25c9a67c9e016cd87bd6ac3bf792a6dd2d1ad450
parent23b369a57c05d863eb5c2f471f52359fe287b17f (diff)
Move scoring constants into config.h
-rw-r--r--config.h9
-rw-r--r--match.c11
2 files changed, 11 insertions, 9 deletions
diff --git a/config.h b/config.h
index 7b56ce9..8fa5284 100644
--- a/config.h
+++ b/config.h
@@ -1 +1,10 @@
#define TTY_COLOR_HIGHLIGHT TTY_COLOR_YELLOW
+
+#define SCORE_GAP_LEADING -0.005
+#define SCORE_GAP_TRAILING -0.005
+#define SCORE_GAP_INNER -0.01
+#define SCORE_MATCH_CONSECUTIVE 1.0
+#define SCORE_MATCH_SLASH 0.9
+#define SCORE_MATCH_WORD 0.8
+#define SCORE_MATCH_CAPITAL 0.7
+#define SCORE_MATCH_DOT 0.6
diff --git a/match.c b/match.c
index 2721179..7e56072 100644
--- a/match.c
+++ b/match.c
@@ -7,6 +7,8 @@
#include "match.h"
+#include "config.h"
+
int has_match(const char *needle, const char *haystack){
while(*needle){
char nch = tolower(*needle++);
@@ -75,15 +77,6 @@ double calculate_score(const char *needle, const char *haystack, size_t *positio
* M[][] Stores the best possible score at this position.
*/
-#define SCORE_GAP_LEADING -0.005
-#define SCORE_GAP_TRAILING -0.005
-#define SCORE_GAP_INNER -0.01
-#define SCORE_MATCH_CONSECUTIVE 1.0
-#define SCORE_MATCH_SLASH 0.9
-#define SCORE_MATCH_WORD 0.8
-#define SCORE_MATCH_CAPITAL 0.7
-#define SCORE_MATCH_DOT 0.6
-
/* Which positions are beginning of words */
char last_ch = '\0';
for(int i = 0; i < m; i++){