diff options
author | Mattias Andrée <maandree@kth.se> | 2018-10-21 11:28:52 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2018-10-21 11:28:52 +0200 |
commit | fa7443b88cd25b08e18f8367b3e4a8c9a18d5c7f (patch) | |
tree | 416953f847ce77dfa1c576a41e98b9245eca60e0 | |
parent | Add man pages some str-functions (diff) | |
download | libsimple-fa7443b88cd25b08e18f8367b3e4a8c9a18d5c7f.tar.gz libsimple-fa7443b88cd25b08e18f8367b3e4a8c9a18d5c7f.tar.bz2 libsimple-fa7443b88cd25b08e18f8367b3e4a8c9a18d5c7f.tar.xz |
Add man pages for more str-functions
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r-- | libsimple/str.h | 60 | ||||
-rw-r--r-- | libsimple/strn.h | 8 | ||||
-rw-r--r-- | man/libsimple_strcasecmpnul.3 | 84 | ||||
-rw-r--r-- | man/libsimple_strcaseends.3 | 4 | ||||
-rw-r--r-- | man/libsimple_strcaseeq.3 | 72 | ||||
-rw-r--r-- | man/libsimple_strcaseeqnul.3 | 73 | ||||
-rw-r--r-- | man/libsimple_strcasestarts.3 | 4 | ||||
-rw-r--r-- | man/libsimple_strcasestr.3 | 4 | ||||
-rw-r--r-- | man/libsimple_strcmpnul.3 | 84 | ||||
-rw-r--r-- | man/libsimple_strends.3 | 4 | ||||
-rw-r--r-- | man/libsimple_streq.3 | 71 | ||||
-rw-r--r-- | man/libsimple_streqnul.3 | 72 | ||||
-rw-r--r-- | man/libsimple_strrcasestr.3 | 4 | ||||
-rw-r--r-- | man/libsimple_strrstr.3 | 4 | ||||
-rw-r--r-- | man/libsimple_strstarts.3 | 4 |
15 files changed, 530 insertions, 22 deletions
diff --git a/libsimple/str.h b/libsimple/str.h index 5eaee4e..8fdaf19 100644 --- a/libsimple/str.h +++ b/libsimple/str.h @@ -4,10 +4,10 @@ /* TODO strcasechr */ /* TODO strcasechrnul */ /* TODO strrcasechr */ -/* TODO stpcmp */ -/* TODO stpcmpnul */ -/* TODO stpcasecmp */ -/* TODO stpcasecmpnul */ +/* TODO streqlen */ +/* TODO strcaseeqlen */ +/* TODO strreqlen */ +/* TODO strrcaseeqlen */ /** @@ -144,6 +144,16 @@ char *libsimple_strrcasestr(const char *, const char *); #endif +/** + * Compare two strings, and support `NULL` as less than + * the empty string, the comparison is case-sensitive + * + * @param a One of the strings, may be `NULL` + * @param b The other string, may be `NULL` + * @return A negative value if `a` is less than `b`, + * a positive value if `a` is greater than `b`, + * 0 otherwise + */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) static inline int libsimple_strcmpnul(const char *__a, const char *__b) { return (!__a || !__b) ? !__b - !__a : strcmp(__a, __b); } @@ -152,6 +162,16 @@ static inline int libsimple_strcmpnul(const char *__a, const char *__b) #endif +/** + * Compare two strings, and support `NULL` as less than + * the empty string, the comparison is case-insensitive + * + * @param a One of the strings, may be `NULL` + * @param b The other string, may be `NULL` + * @return A negative value if `a` is less than `b`, + * a positive value if `a` is greater than `b`, + * 0 otherwise + */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) static inline int libsimple_strcasecmpnul(const char *__a, const char *__b) { return (!__a || !__b) ? !__b - !__a : strcasecmp(__a, __b); } @@ -160,6 +180,14 @@ static inline int libsimple_strcasecmpnul(const char *__a, const char *__b) #endif +/** + * Compare two strings, without support for `NULL`, + * the comparison is case-sensitive + * + * @param a One of the strings, may not be `NULL` + * @param b The other string, may not be `NULL` + * @return 1 if the strings are equal, 0 otherwise + */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline int libsimple_streq(const char *__a, const char *__b) { return !strcmp(__a, __b); } @@ -168,6 +196,14 @@ static inline int libsimple_streq(const char *__a, const char *__b) #endif +/** + * Compare two strings, with support for `NULL`, + * the comparison is case-sensitive + * + * @param a One of the strings, may be `NULL` + * @param b The other string, may be `NULL` + * @return 1 if the strings are equal, 0 otherwise + */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) static inline int libsimple_streqnul(const char *__a, const char *__b) { return !strcmpnul(__a, __b); } @@ -176,6 +212,14 @@ static inline int libsimple_streqnul(const char *__a, const char *__b) #endif +/** + * Compare two strings, without support for `NULL`, + * the comparison is case-insensitive + * + * @param a One of the strings, may not be `NULL` + * @param b The other string, may not be `NULL` + * @return 1 if the strings are equal, 0 otherwise + */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline int libsimple_strcaseeq(const char *__a, const char *__b) { return !strcasecmp(__a, __b); } @@ -184,6 +228,14 @@ static inline int libsimple_strcaseeq(const char *__a, const char *__b) #endif +/** + * Compare two strings, with support for `NULL`, + * the comparison is case-insensitive + * + * @param a One of the strings, may be `NULL` + * @param b The other string, may be `NULL` + * @return 1 if the strings are equal, 0 otherwise + */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) static inline int libsimple_strcaseeqnul(const char *__a, const char *__b) { return !strcasecmpnul(__a, __b); } diff --git a/libsimple/strn.h b/libsimple/strn.h index 81d3797..90b2118 100644 --- a/libsimple/strn.h +++ b/libsimple/strn.h @@ -9,10 +9,10 @@ /* TODO strncasestarts */ /* TODO strnends */ /* TODO strncaseends */ -/* TODO stpncmp */ -/* TODO stpncmpnul */ -/* TODO stpncasecmp */ -/* TODO stpncasecmpnul */ +/* TODO strneqlen */ +/* TODO strncaseeqlen */ +/* TODO strrneqlen */ +/* TODO strrncaseeqlen */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strnstr(const char *, const char *, size_t); diff --git a/man/libsimple_strcasecmpnul.3 b/man/libsimple_strcasecmpnul.3 new file mode 100644 index 0000000..ffd0f8d --- /dev/null +++ b/man/libsimple_strcasecmpnul.3 @@ -0,0 +1,84 @@ +.TH LIBSIMPLE_STRCASECMPNUL 3 2018-10-21 libsimple +.SH NAME +libsimple_strcasecmpnul \- compare two strings +.SH SYNOPSIS +.nf +#include <libsimple.h> + +static inline int libsimple_strcasecmpnul(const char *\fIa\fP, const char *\fIb\fP); + +#ifndef strcasecmpnul +# define strcasecmpnul libsimple_strcasecmpnul +#endif +.fi + +Link with +.IR \-lsimple . +.SH DESCRIPTION +The +.BR libsimple_strcasecmpnul () +function compares the strings +.I a +and +.IR b , +both of which may be +.BR NULL , +which is treated as less than the empty string. +.PP +If one of the strings begins with the other string +but is longer, the longer string is treated as +greater than the shorter string. +.PP +The comparison is case-insensitive and made as if the +strings were converted to lowercase and as +.IR "unsigned char *" s. +.SH RETURN VALUE +The +.BR libsimple_strcasecmpnul () +function returns a negative value if +.I a +is less than +.IR b , +a positive value if +.I a +is greater than +.IR b , +and 0 otherwise. +.SH ERRORS +The +.BR libsimple_strcasecmpnul () +function cannot fail. +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_strcasecmpnul () +T} Thread safety MT-Safe +T{ +.BR libsimple_strcasecmpnul () +T} Async-signal safety AS-Safe +T{ +.BR libsimple_strcasecmpnul () +T} Async-cancel safety AC-Safe +.TE +.SH EXAMPLES +None. +.SH APPLICATION USAGE +None. +.SH RATIONALE +None. +.SH FUTURE DIRECTIONS +None. +.SH NOTES +None. +.SH BUGS +None. +.SH SEE ALSO +.BR libsimple_strcmpnul (3), +.BR libsimple_strcaseeqnul (3), +.BR strcasecmp (3) diff --git a/man/libsimple_strcaseends.3 b/man/libsimple_strcaseends.3 index 2d26307..4a792a3 100644 --- a/man/libsimple_strcaseends.3 +++ b/man/libsimple_strcaseends.3 @@ -21,6 +21,8 @@ function checks whether the string .I s ends with the string .IR t . +.PP +The comparison is case-insensitive. .SH RETURN VALUE The .BR libsimple_strcaseends () @@ -29,8 +31,6 @@ function returns 1 if the string ends with the string .IR t , otherwise it returns 0. -.PP -The comparison is case-insensitive. .SH ERRORS The .BR libsimple_strcaseends () diff --git a/man/libsimple_strcaseeq.3 b/man/libsimple_strcaseeq.3 new file mode 100644 index 0000000..41fb3c1 --- /dev/null +++ b/man/libsimple_strcaseeq.3 @@ -0,0 +1,72 @@ +.TH LIBSIMPLE_STRCASEEQ 3 2018-10-21 libsimple +.SH NAME +libsimple_strcaseeq \- compare two strings +.SH SYNOPSIS +.nf +#include <libsimple.h> + +static inline int libsimple_strcaseeq(const char *\fIa\fP, const char *\fIb\fP); + +#ifndef strcaseeq +# define strcaseeq libsimple_strcaseeq +#endif +.fi + +Link with +.IR \-lsimple . +.SH DESCRIPTION +The +.BR libsimple_strcaseeq () +function compares the strings +.I a +and +.IR b , +neither of which may be +.BR NULL . +.PP +The comparison is case-insensitive. +.IR "unsigned char *" s. +.SH RETURN VALUE +The +.BR libsimple_strcaseeq () +function returns 1 if the strings are equals, +with the possible exception of the case, +otherwise it returns 0. +.SH ERRORS +The +.BR libsimple_strcaseeq () +function cannot fail. +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_strcaseeq () +T} Thread safety MT-Safe +T{ +.BR libsimple_strcaseeq () +T} Async-signal safety AS-Safe +T{ +.BR libsimple_strcaseeq () +T} Async-cancel safety AC-Safe +.TE +.SH EXAMPLES +None. +.SH APPLICATION USAGE +None. +.SH RATIONALE +None. +.SH FUTURE DIRECTIONS +None. +.SH NOTES +None. +.SH BUGS +None. +.SH SEE ALSO +.BR libsimple_strcaseeqnul (3), +.BR libsimple_streq (3), +.BR strcasecmp (3) diff --git a/man/libsimple_strcaseeqnul.3 b/man/libsimple_strcaseeqnul.3 new file mode 100644 index 0000000..ab06c67 --- /dev/null +++ b/man/libsimple_strcaseeqnul.3 @@ -0,0 +1,73 @@ +.TH LIBSIMPLE_STRCASEEQNUL 3 2018-10-21 libsimple +.SH NAME +libsimple_strcaseeqnul \- compare two strings +.SH SYNOPSIS +.nf +#include <libsimple.h> + +static inline int libsimple_strcaseeqnul(const char *\fIa\fP, const char *\fIb\fP); + +#ifndef strcaseeqnul +# define strcaseeqnul libsimple_strcaseeqnul +#endif +.fi + +Link with +.IR \-lsimple . +.SH DESCRIPTION +The +.BR libsimple_strcaseeqnul () +function compares the strings +.I a +and +.IR b , +both of which may be +.BR NULL . +.PP +The comparison is case-insensitive. +.IR "unsigned char *" s. +.SH RETURN VALUE +The +.BR libsimple_strcaseeqnul () +function returns 1 if the strings are equals, +with the possible exception of the case, +otherwise it returns 0. +.SH ERRORS +The +.BR libsimple_strcaseeqnul () +function cannot fail. +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_strcaseeqnul () +T} Thread safety MT-Safe +T{ +.BR libsimple_strcaseeqnul () +T} Async-signal safety AS-Safe +T{ +.BR libsimple_strcaseeqnul () +T} Async-cancel safety AC-Safe +.TE +.SH EXAMPLES +None. +.SH APPLICATION USAGE +None. +.SH RATIONALE +None. +.SH FUTURE DIRECTIONS +None. +.SH NOTES +None. +.SH BUGS +None. +.SH SEE ALSO +.BR libsimple_strcaseeq (3), +.BR libsimple_streqnul (3), +.BR libsimple_strcasecmpnul (3), +.BR strcasecmp (3) diff --git a/man/libsimple_strcasestarts.3 b/man/libsimple_strcasestarts.3 index 625edcb..9b7081f 100644 --- a/man/libsimple_strcasestarts.3 +++ b/man/libsimple_strcasestarts.3 @@ -21,6 +21,8 @@ function checks whether the string .I s starts with the string .IR t . +.PP +The comparison is case-insensitive. .SH RETURN VALUE The .BR libsimple_strcasestarts () @@ -29,8 +31,6 @@ function returns 1 if the string begins with the string .IR t , otherwise it returns 0. -.PP -The comparison is case-insensitive. .SH ERRORS The .BR libsimple_strcasestarts () diff --git a/man/libsimple_strcasestr.3 b/man/libsimple_strcasestr.3 index c4d7aab..346a17b 100644 --- a/man/libsimple_strcasestr.3 +++ b/man/libsimple_strcasestr.3 @@ -21,6 +21,8 @@ function scans the string .I haystack the first occurrence of the substring .IR needle . +.PP +The comparison is case-insensitive. .SH RETURN VALUE The .BR libsimple_strcasestr () @@ -33,8 +35,6 @@ begins with where .I r is the returned pointer. -.PP -The comparison is case-insensitive. .SH ERRORS The .BR libsimple_strcasestr () diff --git a/man/libsimple_strcmpnul.3 b/man/libsimple_strcmpnul.3 new file mode 100644 index 0000000..79c53bf --- /dev/null +++ b/man/libsimple_strcmpnul.3 @@ -0,0 +1,84 @@ +.TH LIBSIMPLE_STRCMPNUL 3 2018-10-21 libsimple +.SH NAME +libsimple_strcmpnul \- compare two strings +.SH SYNOPSIS +.nf +#include <libsimple.h> + +static inline int libsimple_strcmpnul(const char *\fIa\fP, const char *\fIb\fP); + +#ifndef strcmpnul +# define strcmpnul libsimple_strcmpnul +#endif +.fi + +Link with +.IR \-lsimple . +.SH DESCRIPTION +The +.BR libsimple_strcmpnul () +function compares the strings +.I a +and +.IR b , +both of which may be +.BR NULL , +which is treated as less than the empty string. +.PP +If one of the strings begins with the other string +but is longer, the longer string is treated as +greater than the shorter string. +.PP +The comparison is case-sensitive and made as if +the strings were +.IR "unsigned char *" s. +.SH RETURN VALUE +The +.BR libsimple_strcmpnul () +function returns a negative value if +.I a +is less than +.IR b , +a positive value if +.I a +is greater than +.IR b , +and 0 otherwise. +.SH ERRORS +The +.BR libsimple_strcmpnul () +function cannot fail. +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_strcmpnul () +T} Thread safety MT-Safe +T{ +.BR libsimple_strcmpnul () +T} Async-signal safety AS-Safe +T{ +.BR libsimple_strcmpnul () +T} Async-cancel safety AC-Safe +.TE +.SH EXAMPLES +None. +.SH APPLICATION USAGE +None. +.SH RATIONALE +None. +.SH FUTURE DIRECTIONS +None. +.SH NOTES +None. +.SH BUGS +None. +.SH SEE ALSO +.BR libsimple_strcasecmpnul (3), +.BR libsimple_streqnul (3), +.BR strcmp (3) diff --git a/man/libsimple_strends.3 b/man/libsimple_strends.3 index 63085ec..abc7e5a 100644 --- a/man/libsimple_strends.3 +++ b/man/libsimple_strends.3 @@ -21,6 +21,8 @@ function checks whether the string .I s ends with the string .IR t . +.PP +The comparison is case-sensitive. .SH RETURN VALUE The .BR libsimple_strends () @@ -29,8 +31,6 @@ function returns 1 if the string ends with the string .IR t , otherwise it returns 0. -.PP -The comparison is case-sensitive. .SH ERRORS The .BR libsimple_strends () diff --git a/man/libsimple_streq.3 b/man/libsimple_streq.3 new file mode 100644 index 0000000..f8d28fb --- /dev/null +++ b/man/libsimple_streq.3 @@ -0,0 +1,71 @@ +.TH LIBSIMPLE_STREQ 3 2018-10-21 libsimple +.SH NAME +libsimple_streq \- compare two strings +.SH SYNOPSIS +.nf +#include <libsimple.h> + +static inline int libsimple_streq(const char *\fIa\fP, const char *\fIb\fP); + +#ifndef streq +# define streq libsimple_streq +#endif +.fi + +Link with +.IR \-lsimple . +.SH DESCRIPTION +The +.BR libsimple_streq () +function compares the strings +.I a +and +.IR b , +neither of which may be +.BR NULL . +.PP +The comparison is case-sensitive. +.IR "unsigned char *" s. +.SH RETURN VALUE +The +.BR libsimple_streq () +function returns 1 if the strings are equals, +otherwise it returns 0. +.SH ERRORS +The +.BR libsimple_streq () +function cannot fail. +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_streq () +T} Thread safety MT-Safe +T{ +.BR libsimple_streq () +T} Async-signal safety AS-Safe +T{ +.BR libsimple_streq () +T} Async-cancel safety AC-Safe +.TE +.SH EXAMPLES +None. +.SH APPLICATION USAGE +None. +.SH RATIONALE +None. +.SH FUTURE DIRECTIONS +None. +.SH NOTES +None. +.SH BUGS +None. +.SH SEE ALSO +.BR libsimple_streqnul (3), +.BR libsimple_strcaseeq (3), +.BR strcmp (3) diff --git a/man/libsimple_streqnul.3 b/man/libsimple_streqnul.3 new file mode 100644 index 0000000..fa0a35e --- /dev/null +++ b/man/libsimple_streqnul.3 @@ -0,0 +1,72 @@ +.TH LIBSIMPLE_STREQNUL 3 2018-10-21 libsimple +.SH NAME +libsimple_streqnul \- compare two strings +.SH SYNOPSIS +.nf +#include <libsimple.h> + +static inline int libsimple_streqnul(const char *\fIa\fP, const char *\fIb\fP); + +#ifndef streqnul +# define streqnul libsimple_streqnul +#endif +.fi + +Link with +.IR \-lsimple . +.SH DESCRIPTION +The +.BR libsimple_streqnul () +function compares the strings +.I a +and +.IR b , +both of which may be +.BR NULL . +.PP +The comparison is case-sensitive. +.IR "unsigned char *" s. +.SH RETURN VALUE +The +.BR libsimple_streqnul () +function returns 1 if the strings are equals, +otherwise it returns 0. +.SH ERRORS +The +.BR libsimple_streqnul () +function cannot fail. +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_streqnul () +T} Thread safety MT-Safe +T{ +.BR libsimple_streqnul () +T} Async-signal safety AS-Safe +T{ +.BR libsimple_streqnul () +T} Async-cancel safety AC-Safe +.TE +.SH EXAMPLES +None. +.SH APPLICATION USAGE +None. +.SH RATIONALE +None. +.SH FUTURE DIRECTIONS +None. +.SH NOTES +None. +.SH BUGS +None. +.SH SEE ALSO +.BR libsimple_streq (3), +.BR libsimple_strcaseeqnul (3), +.BR libsimple_strcmpnul (3), +.BR strcmp (3) diff --git a/man/libsimple_strrcasestr.3 b/man/libsimple_strrcasestr.3 index 187a784..3b277ae 100644 --- a/man/libsimple_strrcasestr.3 +++ b/man/libsimple_strrcasestr.3 @@ -21,6 +21,8 @@ function scans the string .I haystack the last occurrence of the substring .IR needle . +.PP +The comparison is case-insensitive. .SH RETURN VALUE The .BR libsimple_strrcasestr () @@ -33,8 +35,6 @@ begins with where .I r is the returned pointer. -.PP -The comparison is case-insensitive. .SH ERRORS The .BR libsimple_strrcasestr () diff --git a/man/libsimple_strrstr.3 b/man/libsimple_strrstr.3 index 9806a2c..ad85a54 100644 --- a/man/libsimple_strrstr.3 +++ b/man/libsimple_strrstr.3 @@ -21,6 +21,8 @@ function scans the string .I haystack the last occurrence of the substring .IR needle . +.PP +The comparison is case-sensitive. .SH RETURN VALUE The .BR libsimple_strrstr () @@ -33,8 +35,6 @@ begins with where .I r is the returned pointer. -.PP -The comparison is case-sensitive. .SH ERRORS The .BR libsimple_strrstr () diff --git a/man/libsimple_strstarts.3 b/man/libsimple_strstarts.3 index 128c4af..cf08967 100644 --- a/man/libsimple_strstarts.3 +++ b/man/libsimple_strstarts.3 @@ -21,6 +21,8 @@ function checks whether the string .I s starts with the string .IR t . +.PP +The comparison is case-sensitive. .SH RETURN VALUE The .BR libsimple_strstarts () @@ -29,8 +31,6 @@ function returns 1 if the string begins with the string .IR t , otherwise it returns 0. -.PP -The comparison is case-sensitive. .SH ERRORS The .BR libsimple_strstarts () |