ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/String-Similarity/fstrcmp.c
(Generate patch)

Comparing String-Similarity/fstrcmp.c (file contents):
Revision 1.1 by root, Sat Jun 25 09:55:53 2005 UTC vs.
Revision 1.2 by root, Tue Nov 4 15:31:38 2008 UTC

43#include <stdlib.h> 43#include <stdlib.h>
44#include <limits.h> 44#include <limits.h>
45 45
46#include "fstrcmp.h" 46#include "fstrcmp.h"
47 47
48/* moved here from fstrcmp.h to avoid problems on lose32 machines */
49#define PARAMS(proto) proto 48#define PARAMS(proto) proto
50typedef UV CHAR;
51 49
52/* 50/*
53 * Data on one input string being compared. 51 * Data on one input string being compared.
54 */ 52 */
55struct string_data 53struct string_data
56{ 54{
57 /* The string to be compared. */ 55 /* The string to be compared. */
58 const CHAR *data; 56 const UV *data;
59 57
60 /* The length of the string to be compared. */ 58 /* The length of the string to be compared. */
61 int data_length; 59 int data_length;
62 60
63 /* The number of characters inserted or deleted. */ 61 /* The number of characters inserted or deleted. */
164 int minimal; 162 int minimal;
165 struct partition *part; 163 struct partition *part;
166{ 164{
167 int *const fd = fdiag; /* Give the compiler a chance. */ 165 int *const fd = fdiag; /* Give the compiler a chance. */
168 int *const bd = bdiag; /* Additional help for the compiler. */ 166 int *const bd = bdiag; /* Additional help for the compiler. */
169 const CHAR *const xv = string[0].data; /* Still more help for the compiler. */ 167 const UV *const xv = string[0].data; /* Still more help for the compiler. */
170 const CHAR *const yv = string[1].data; /* And more and more . . . */ 168 const UV *const yv = string[1].data; /* And more and more . . . */
171 const int dmin = xoff - ylim; /* Minimum valid diagonal. */ 169 const int dmin = xoff - ylim; /* Minimum valid diagonal. */
172 const int dmax = xlim - yoff; /* Maximum valid diagonal. */ 170 const int dmax = xlim - yoff; /* Maximum valid diagonal. */
173 const int fmid = xoff - yoff; /* Center diagonal of top-down search. */ 171 const int fmid = xoff - yoff; /* Center diagonal of top-down search. */
174 const int bmid = xlim - ylim; /* Center diagonal of bottom-up search. */ 172 const int bmid = xlim - ylim; /* Center diagonal of bottom-up search. */
175 int fmin = fmid; 173 int fmin = fmid;
488 int xlim; 486 int xlim;
489 int yoff; 487 int yoff;
490 int ylim; 488 int ylim;
491 int minimal; 489 int minimal;
492{ 490{
493 const CHAR *const xv = string[0].data; /* Help the compiler. */ 491 const UV *const xv = string[0].data; /* Help the compiler. */
494 const CHAR *const yv = string[1].data; 492 const UV *const yv = string[1].data;
495 493
496 if (string[1].edit_count + string[0].edit_count > max_edits) 494 if (string[1].edit_count + string[0].edit_count > max_edits)
497 return; 495 return;
498 496
499 /* Slide down the bottom initial diagonal. */ 497 /* Slide down the bottom initial diagonal. */
563 561
564/* NAME 562/* NAME
565 fstrcmp - fuzzy string compare 563 fstrcmp - fuzzy string compare
566 564
567 SYNOPSIS 565 SYNOPSIS
568 double fstrcmp(const CHAR *s1, int l1, const CHAR *s2, int l2, double); 566 double fstrcmp(const ChaR *s1, int l1, const UV *s2, int l2, double);
569 567
570 DESCRIPTION 568 DESCRIPTION
571 The fstrcmp function may be used to compare two string for 569 The fstrcmp function may be used to compare two string for
572 similarity. It is very useful in reducing "cascade" or 570 similarity. It is very useful in reducing "cascade" or
573 "secondary" errors in compilers or other situations where 571 "secondary" errors in compilers or other situations where
577 double; 0 if the strings are entirly dissimilar, 1 if the 575 double; 0 if the strings are entirly dissimilar, 1 if the
578 strings are identical, and a number in between if they are 576 strings are identical, and a number in between if they are
579 similar. */ 577 similar. */
580 578
581double 579double
582fstrcmp (const CHAR *string1, int length1, 580fstrcmp (const UV *string1, int length1,
583 const CHAR *string2, int length2, 581 const UV *string2, int length2,
584 double minimum) 582 double minimum)
585{ 583{
586 int i; 584 int i;
587 585
588 size_t fdiag_len; 586 size_t fdiag_len;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines