IMPROVES-i5 full fix on sequal_full()

This commit is contained in:
2026-05-22 20:28:13 -03:00
parent aabab06352
commit d2e5dfce38
3 changed files with 34 additions and 24 deletions

View File

@@ -9,7 +9,9 @@
#ifndef LIB11SHT_H
#define LIB11SHT_H
#define LEVN_SBUFF 256 /* min size for s1/s2 buffers and bounded input */
#include <stddef.h> /* size_t */
#define LEVN_SBUFF 256 /* recommended size for s1/s2 buffers */
/* Compare similarity between two strings (after asciify + trim + lowercase).
* Symmetric in shape with fequal(a, b, delta).
@@ -31,11 +33,14 @@ int sequal(char *a, char *b, float shold);
* (e.g. cmp11sht CLI's -o / -n flags).
*
* Extra parameters:
* ratio out: Levenshtein similarity 0.0..1.0 (1.0 on exact-after-normalize)
* s1, s2 out: caller-provided buffers (>= LEVN_SBUFF) filled with the
* normalized inputs
* ratio out: Levenshtein similarity 0.0..1.0 (1.0 on exact-after-normalize)
* s1, s2 out: caller-provided buffers filled with the normalized inputs
* s1_size size of s1 in bytes (writes capped at s1_size-1 + final NUL)
* s2_size size of s2 in bytes (writes capped at s2_size-1 + final NUL)
*/
int sequal_full(char *a, char *b, float shold, float *ratio, char *s1, char *s2);
int sequal_full(char *a, char *b, float shold, float *ratio,
char *s1, size_t s1_size,
char *s2, size_t s2_size);
/* Compare two floats within ±delta.
* Returns: