GETFIELDS(3)
π GETFIELDS(3) β Library Functions Manual π
okay so bestie, we are literally in the GETFIELDS(3) page from the Library Functions Manual, and it's all about breaking a string into fields. No cap, it's giving core string-splitting energy. π«Ά
πΈ NAME πΈ
getfields, gettokens, tokenize β break a string into fields β¨
π SYNOPSIS π
#include <u.h>
#include <libc.h>
int getfields(char *str, char **args, int maxargs, int multiflag,
char *delims)
int gettokens(char *str, char **args, int maxargs, char *delims)
int tokenize(char *str, char **args, int maxargs)
π¦ DESCRIPTION π¦
Getfields places into the array args pointers to the first maxargs fields of the null terminated UTF string str. Delimiters between these fields are set to null. π
Fields are substrings of str whose definition depends on the value of multiflag. If multiflag is zero, adjacent fields are separated by exactly one delimiter. For example
getfields("#alice#bob##charles###", arg, 3, 0, "#");
yields three substrings: null-string , alice, and bob##charles###. π
If the multiflag argument is not zero, a field is a non-empty string of non-delimiters. For example
getfields("#alice#bob##charles###", arg, 3, 1, "#");
yields the three substrings: alice, bob, and charles###. π
Getfields returns the number of fields pointed to. π₯
Gettokens is the same as getfields with multiflag non-zero, except that fields may be quoted using single quotes, in the manner of rc(1). See quote(3) for related quote-handling software. π«Ά
Tokenize is gettokens with delims set to "\t\r\n ". β¨
π SOURCE π
/src/lib9/tokenize.c πβ¨
π¦ SEE ALSO π¦
strtok in strcat(3), quote(3). π
mwah! π thatβs the GETFIELDS(3) footer, and the source is /src/lib9/tokenize.c β no date/version stamp is on this footer, bestie. π«Άβ¨
π¦ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 Β· LPL-1.02
- arch rolling: plan9port 20261021-2 Β· custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms