BINSRCH(3)
π BINSRCH(3) π
okay bestie, welcome to the WordNetβ’ Library Functions corner of the manual, page three of the section, and yes it's giving "binary search but make it a whole friend group" πΈ
β¨ NAME β¨
bin_search, copyfile, replace_line, insert_line β general purpose functions for performing a binary search π¦
π SYNOPSIS π
char *bin_search(char *key, FILE *fp);
void copyfile(FILE *fromfp, FILE *tofp);
char *replace_line(char *new_line, char *key, FILE *fp);
char *insert_line(char *new_line, char *key, FILE *fp);
like. look at them. four little icons. π
π DESCRIPTION π
so the WordNet library is carrying several general purpose functions for performing a binary search and modifying sorted files, because sometimes you just need to find things and sometimes you need to rearrange your whole life, fr fr π«
bin_search() is the primary binary search algorithm, and what it does is search for key as the first item on a line in the file pointed to by fp. the delimiter between the key and the rest of the fields on the line β if there even are any β must be a space. periodt. it returns a pointer to a static variable containing the entire line. and if there's no match? NULL. that's it, that's the whole vibe check π
the remaining functions are not used by WordNet, so we're only briefly describing them here. ngl, they're the background characters in this story π
copyfile() copies the contents of one file to another. slay, simple, iconic β¨
replace_line() replaces a line in a file having searchkey key with the contents of new_line. it returns the original line, or NULL in case of error π
insert_line() finds the proper place to insert the contents of new_line, having searchkey key, in the sorted file pointed to by fp. it returns NULL if a line with this searchkey is already in the file β like, no, we're not doing duplicates today bestie π
π NOTES π
- the maximum length of key is 1024.
- the maximum line length in a file is 25K.
- if there are no additional fields after the search key, the key must be followed by at least one space before the newline character. no space, no service. π
π SEE ALSO π
wnintro(3), morph(3), wnsearch(3), wnutil(3), wnintro(5).
go read those too, they're the extended universe π«Ά
β οΈ WARNINGS β οΈ
binsearch() returns a pointer to a static character buffer. π₯ the returned string should be copied by the caller if the results need to be saved, as a subsequent call will replace the contents of the static buffer. like genuinely, if you don't copy it, your data is gone gone. it's giving one shared notebook that everybody keeps erasing. copy it. protect your peace. π
and that's the page, bestie!! this whole thing came to you courtesy of WordNet 3.0, dated Dec 2006, and yeah we're still obsessed with it. mwah πππ
π¦ where this page comes from
- fedora 43: wordnet-devel 3.0-48.fc42 Β· MIT and GPL-2.0-or-later
- fedora 43: wordnet-devel 3.0-48.fc42 Β· MIT and GPL-2.0-or-later
- fedora 44: wordnet-devel 3.0-48.fc42 Β· MIT and GPL-2.0-or-later
- fedora 44: wordnet-devel 3.0-48.fc42 Β· MIT and GPL-2.0-or-later
- opensuse-leap 16.0: wordnet-devel 3.0-bp160.1.11 Β· MIT
- opensuse-leap 16.0: wordnet-devel 3.0-bp160.1.11 Β· MIT
- opensuse-leap 16.0: wordnet-devel 3.0-bp160.1.11 Β· MIT
- opensuse-leap 16.0: wordnet-devel 3.0-bp160.1.11 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms