fstrcmp.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* Fuzzy string comparison.
  2. Copyright (C) 1995, 2000, 2002-2003, 2006, 2008-2020 Free Software
  3. Foundation, Inc.
  4. This file was written by Peter Miller <pmiller@agso.gov.au>
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <https://www.gnu.org/licenses/>. */
  15. #ifndef _FSTRCMP_H
  16. #define _FSTRCMP_H
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /* Fuzzy compare of S1 and S2. Return a measure for the similarity of S1
  21. and S1. The higher the result, the more similar the strings are.
  22. The result is bounded between 0 (meaning very dissimilar strings) and
  23. 1 (meaning identical strings). */
  24. extern double fstrcmp (const char *s1, const char *s2);
  25. /* Like fstrcmp (S1, S2), except that if the result is < LOWER_BOUND, an
  26. arbitrary other value < LOWER_BOUND can be returned. */
  27. extern double fstrcmp_bounded (const char *s1, const char *s2,
  28. double lower_bound);
  29. /* A shortcut for fstrcmp. Avoids a function call. */
  30. #define fstrcmp(s1,s2) fstrcmp_bounded (s1, s2, 0.0)
  31. /* Frees the per-thread resources allocated by this module for the current
  32. thread.
  33. You don't need to call this function in threads other than the main thread,
  34. because per-thread resources are reclaimed automatically when the thread
  35. exits. However, per-thread resources allocated by the main thread are
  36. comparable to static allocations; calling this function can be useful to
  37. avoid an error report from valgrind. */
  38. extern void fstrcmp_free_resources (void);
  39. #ifdef __cplusplus
  40. }
  41. #endif
  42. #endif