Fossil SCM

Add the test-line-hash command for use in debugging and analyzing the match_dline() functions.

drh 2021-09-04 19:45 diff-color-enhancements
Commit 6a2bfba43d58e0188e1849a098af6ab312367369c2c20ec4f8f89ac99d37131d
1 file changed +22
+22
--- src/diff.c
+++ src/diff.c
@@ -899,10 +899,32 @@
899899
#endif
900900
901901
/* Return the result */
902902
return score;
903903
}
904
+
905
+/*
906
+** COMMAND: test-line-match
907
+** Usage: %fossil test-line-match STRING1 STRING2
908
+**
909
+** Return a score from 0 to 100 that is how similar STRING1 is to
910
+** STRING2. Smaller numbers mean more similar. 0 is an exact match.
911
+**
912
+** This command is used to test to match_dline() function in the
913
+** internal Fossil diff logic.
914
+*/
915
+void test_dline_match(void){
916
+ DLine a, b;
917
+ int x;
918
+ if( g.argc!=4 ) usage("STRING1 STRING2");
919
+ a.z = g.argv[2];
920
+ a.n = (int)strlen(a.z);
921
+ b.z = g.argv[3];
922
+ b.n = (int)strlen(b.z);
923
+ x = match_dline(&a, &b);
924
+ fossil_print("%d\n", x);
925
+}
904926
905927
/*
906928
** There is a change block in which nLeft lines of text on the left are
907929
** converted into nRight lines of text on the right. This routine computes
908930
** how the lines on the left line up with the lines on the right.
909931
--- src/diff.c
+++ src/diff.c
@@ -899,10 +899,32 @@
899 #endif
900
901 /* Return the result */
902 return score;
903 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
904
905 /*
906 ** There is a change block in which nLeft lines of text on the left are
907 ** converted into nRight lines of text on the right. This routine computes
908 ** how the lines on the left line up with the lines on the right.
909
--- src/diff.c
+++ src/diff.c
@@ -899,10 +899,32 @@
899 #endif
900
901 /* Return the result */
902 return score;
903 }
904
905 /*
906 ** COMMAND: test-line-match
907 ** Usage: %fossil test-line-match STRING1 STRING2
908 **
909 ** Return a score from 0 to 100 that is how similar STRING1 is to
910 ** STRING2. Smaller numbers mean more similar. 0 is an exact match.
911 **
912 ** This command is used to test to match_dline() function in the
913 ** internal Fossil diff logic.
914 */
915 void test_dline_match(void){
916 DLine a, b;
917 int x;
918 if( g.argc!=4 ) usage("STRING1 STRING2");
919 a.z = g.argv[2];
920 a.n = (int)strlen(a.z);
921 b.z = g.argv[3];
922 b.n = (int)strlen(b.z);
923 x = match_dline(&a, &b);
924 fossil_print("%d\n", x);
925 }
926
927 /*
928 ** There is a change block in which nLeft lines of text on the left are
929 ** converted into nRight lines of text on the right. This routine computes
930 ** how the lines on the left line up with the lines on the right.
931

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button