fstrcmp(3)

πŸ“¦
version 0.7.D001 Β· 2 versions
  • 0.7.D001 Β· debian bookworm, debian trixie, fedora 43, fedora 44, opensuse-leap 16.0, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 0.7 Β· alpine 3.24, nixpkgs unstable
, in debian bookworm, debian trixie, fedora 43, fedora 44, opensuse-leap 16.0, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ fstrcmp β€” fuzzy comparison of two strings ✨

okay bestie, pull up a chair, because fstrcmp(3) is literally the moment. this is the <fstrcmp.h> girlie from the Library Functions Manual, and she is here to tell you how similar two strings are β€” not just "same or not same" like some basic function, but an actual ✨vibe score✨. πŸ’…


πŸ¦‹ SYNOPSIS

#include <fstrcmp.h>
#define FSTRCMP_IDENTICAL
#define FSTRCMP_THRESHOLD
#define FSTRCMP_ERROR
double fstrcmp(const char *string1, const char *string2);

like. look at her. four defines and one function. minimalism, but make it iconic. πŸ’–


🌸 DESCRIPTION

The fstrcmp() function compares the two strings, string1 and string2.

that's it. that's the whole description. she's mysterious, she's concise, she contains multitudes. 🧚


πŸ‘‘ RETURN VALUE

okay so this is the part you actually came for, so listen up fr fr.

fstrcmp returns a floating point value between 0.0 and FSTRCMP_IDENTICAL. let's break that down:

  • 0.0 β€” the strings are utterly un-alike. like, not even a little bit. zero chemistry. the vibe check failed. πŸ’€
  • FSTRCMP_IDENTICAL β€” the strings are identical. twin flames. matching energy. slay. πŸ”₯
  • more than FSTRCMP_THRESHOLD β€” this value lies between 0.0 and FSTRCMP_IDENTICAL, and crossing it means most people would consider the strings "similar". bestie-certified close enough. 🫢

and then there's the sad path:

  • FSTRCMP_ERROR β€” always negative, and it indicates a malloc(3) failure. 😭 not the memory allocation ghosting us again.
ngl the threshold thing is the whole personality of this function. it's not a yes/no, it's a how much, and that's highkey gorgeous.

🌈 SEE ALSO

your girl has a whole friend group, and you should meet all of them:

  • fmemcmp(3) β€” fuzzy comparison of two memory areas. same energy, but for raw memory. πŸ“
  • fstrcasecmp(3) β€” fuzzy comparison of two strings ignoring case. because HELLO and hello are obviously the same person. πŸ’œ
  • fstrcmpi(3) β€” fuzzy comparison of two strings. yes, another one. the family is big and we love them all. ⭐
  • strcmp(3) β€” compare two strings. the og. the strict one. no fuzzy feelings, just exact matching. iconic in her own rigid way. πŸ’…

okay so here's the receipts, and we always give credit in this house:

fstrcmp version 0.7 Copyright (C) 2009 Peter Miller Peter Miller <pmiller@opensource.org.au>

The comparison code is derived from the fuzzy comparison functions in GNU Gettext 0.17. The GNU Gettext comparison functions were, in turn, derived from GNU Diff 2.7.

Copyright (C) 1988-2009 Free Software Foundation

like, the lineage? the ancestry? this function has main character energy and a family tree. 🌈✨


and that's the whole fstrcmp(3) page from the Library Functions Manual, bestie β€” fstrcmp version 0.7, Copyright (C) 2009 Peter Miller. now go forth and compare things fuzzily. periodt. πŸ’…πŸŽ€πŸ¦‹