diff options
author | Mattias Andrée <maandree@kth.se> | 2018-11-05 18:29:59 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2018-11-05 18:29:59 +0100 |
commit | 25d1d835d2fdd52144a246a8296460e48d3f3950 (patch) | |
tree | 45b7d412830fb6a6b1b7ab6fdc750fee2037e27c | |
parent | Add man page for the [v]asprintf[a] functions (diff) | |
download | libsimple-25d1d835d2fdd52144a246a8296460e48d3f3950.tar.gz libsimple-25d1d835d2fdd52144a246a8296460e48d3f3950.tar.bz2 libsimple-25d1d835d2fdd52144a246a8296460e48d3f3950.tar.xz |
Add ischrcaseset and man pages for ischrset, ischrcaseset, and [v]{we,en,e}printf
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | libsimple.h | 31 | ||||
-rw-r--r-- | libsimple/str.h | 53 | ||||
-rw-r--r-- | libsimple/strn.h | 4 | ||||
l--------- | man/inchrcaseset.3libsimple | 1 | ||||
l--------- | man/libsimple_inchrcaseset.3 | 1 | ||||
-rw-r--r-- | man/libsimple_inchrset.3 | 96 | ||||
-rw-r--r-- | man/libsimple_strcasechr.3 | 1 | ||||
-rw-r--r-- | man/libsimple_strcasechrnul.3 | 3 | ||||
-rw-r--r-- | man/libsimple_strchrnul.3 | 1 | ||||
-rw-r--r-- | man/libsimple_vasprintf.3 | 2 | ||||
-rw-r--r-- | man/libsimple_vputenvf.3 | 2 | ||||
-rw-r--r-- | man/libsimple_vweprintf.3 | 179 |
12 files changed, 335 insertions, 39 deletions
diff --git a/libsimple.h b/libsimple.h index 0ca873c..b2f9aec 100644 --- a/libsimple.h +++ b/libsimple.h @@ -107,37 +107,6 @@ libsimple_close(int *__fdp) /** - * Check whether a byte is in a string of bytes - * - * @param c The byte to look for, will not be found if it is the NUL byte - * @param s The string to look in - * @return 1 if the byte `c` is not the NUL byte and can be found in `s`, - * 0 otherwise - */ -_LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) -static inline int libsimple_inchrset(int __c, const char *__s) -{ return __c && strchr(__s, __c); } -#ifndef inchrset -# define inchrset libsimple_inchrset -#endif - - -/** - * Check whether a NUL-terminated string is encoded in UTF-8 - * - * @param string The string - * @param allow_modified_nul Whether Modified UTF-8 is allowed, which - * allows a two-byte encoding for NUL - * @return 1 if good, 0 on encoding error - */ -_LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) -int libsimple_isutf8(const char *, int); -#ifndef isutf8 -# define isutf8 libsimple_isutf8 -#endif - - -/** * Remove an item from a list, keeping the list ordered * * `list` must be non-void pointer to a complete type, diff --git a/libsimple/str.h b/libsimple/str.h index 928eb95..3fd1e21 100644 --- a/libsimple/str.h +++ b/libsimple/str.h @@ -98,7 +98,7 @@ int libsimple_strstarts(const char *, const char *); */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline int libsimple_strcasestarts(const char *__s, const char *__t) -{ return !strncasecmp(__s, __t, (strlen)(__t)); } +{ return !strncasecmp(__s, __t, strlen(__t)); } #ifndef strcasestarts # define strcasestarts libsimple_strcasestarts #endif @@ -320,7 +320,7 @@ size_t libsimple_strcaseeqlen(const char *, const char *); */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline size_t libsimple_strreqlen(const char *__a, const char *__b) -{ return memreqlen(__a, (strlen)(__a), __b, (strlen)(__b)); } +{ return memreqlen(__a, strlen(__a), __b, strlen(__b)); } #ifndef strreqlen # define strreqlen libsimple_strreqlen #endif @@ -336,7 +336,54 @@ static inline size_t libsimple_strreqlen(const char *__a, const char *__b) */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline size_t libsimple_strrcaseeqlen(const char *__a, const char *__b) -{ return memrcaseeqlen(__a, (strlen)(__a), __b, (strlen)(__b)); } +{ return memrcaseeqlen(__a, strlen(__a), __b, strlen(__b)); } #ifndef strrcaseeqlen # define strrcaseeqlen libsimple_strrcaseeqlen #endif + + +/** + * Check whether a byte is in a string of bytes, the scan is case-sensitive + * + * @param c The byte to look for, will not be found if it is the NUL byte + * @param s The string to look in + * @return 1 if the byte `c` is not the NUL byte and can be found in `s`, + * 0 otherwise + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) +static inline int libsimple_inchrset(int __c, const char *__s) +{ return __c && strchr(__s, __c); } +#ifndef inchrset +# define inchrset libsimple_inchrset +#endif + + +/** + * Check whether a byte is in a string of bytes, the scan is case-insensitive + * + * @param c The byte to look for, will not be found if it is the NUL byte + * @param s The string to look in + * @return 1 if the byte `c` is not the NUL byte and can be found in `s`, + * 0 otherwise + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) +static inline int libsimple_inchrcaseset(int __c, const char *__s) +{ return __c && strcasechr(__s, __c); } +#ifndef inchrcaseset +# define inchrcaseset libsimple_inchrcaseset +#endif + + +/** + * Check whether a NUL-terminated string is encoded in UTF-8 + * + * @param string The string + * @param allow_modified_nul Whether Modified UTF-8 is allowed, which + * allows a two-byte encoding for NUL + * @return 1 if good, 0 on encoding error + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) +int libsimple_isutf8(const char *, int); +#ifndef isutf8 +# define isutf8 libsimple_isutf8 +#endif diff --git a/libsimple/strn.h b/libsimple/strn.h index b83273c..73947ea 100644 --- a/libsimple/strn.h +++ b/libsimple/strn.h @@ -404,7 +404,7 @@ size_t libsimple_strncaseeqlen(const char *, const char *, size_t); */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline size_t libsimple_strrneqlen(const char *__a, const char *__b, size_t __n) -{ return memreqlen(__a, (strnlen)(__a, __n), __b, (strnlen)(__b, __n)); } +{ return memreqlen(__a, strnlen(__a, __n), __b, strnlen(__b, __n)); } #ifndef strrneqlen # define strrneqlen libsimple_strrneqlen #endif @@ -422,7 +422,7 @@ static inline size_t libsimple_strrneqlen(const char *__a, const char *__b, size */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline size_t libsimple_strrncaseeqlen(const char *__a, const char *__b, size_t __n) -{ return memrcaseeqlen(__a, (strnlen)(__a, __n), __b, (strnlen)(__b, __n)); } +{ return memrcaseeqlen(__a, strnlen(__a, __n), __b, strnlen(__b, __n)); } #ifndef strrncaseeqlen # define strrncaseeqlen libsimple_strrncaseeqlen #endif diff --git a/man/inchrcaseset.3libsimple b/man/inchrcaseset.3libsimple new file mode 120000 index 0000000..b1f18ca --- /dev/null +++ b/man/inchrcaseset.3libsimple @@ -0,0 +1 @@ +libsimple_inchrcaseset.3
\ No newline at end of file diff --git a/man/libsimple_inchrcaseset.3 b/man/libsimple_inchrcaseset.3 new file mode 120000 index 0000000..50838ca --- /dev/null +++ b/man/libsimple_inchrcaseset.3 @@ -0,0 +1 @@ +libsimple_inchrset.3
\ No newline at end of file diff --git a/man/libsimple_inchrset.3 b/man/libsimple_inchrset.3 new file mode 100644 index 0000000..09b1ca1 --- /dev/null +++ b/man/libsimple_inchrset.3 @@ -0,0 +1,96 @@ +.TH LIBSIMPLE_STRCHRNUL 3 2018-11-05 libsimple +.SH NAME +libsimple_inchrset, libsimple_inchrcaseset \- the whether a character belongs to a set +.SH SYNOPSIS +.nf +#include <libsimple.h> + +static inline int libsimple_inchrset(int \fIc\fP, const char *\fIs\fP); +static inline int libsimple_inchrcaseset(int \fIc\fP, const char *\fIs\fP); + +#ifndef inchrset +# define inchrset libsimple_inchrset +#endif +#ifndef inchrcaseset +# define inchrcaseset libsimple_inchrcaseset +#endif +.fi +.PP +Link with +.IR \-lsimple . +.SH DESCRIPTION +The +.BR libsimple_inchrset () +and +.BR libsimple_inchrcaseset () +functions scans the string +.I s +for an occurence of the character +.I c +(it is converted to a +.BR char ), +and returns a value indicating whether it exists in the string, +the scan will always fail if +.I c +is the NUL byte. +.PP +The comparison is case-sensitive for the +.BR libsimple_inchrset () +function, and case-insensitive for the +.BR libsimple_inchrcaseset () +function. +.SH RETURN VALUE +The +.BR libsimple_inchrset () +and +.BR libsimple_inchrcaseset () +functions returns 1 if +.I c +is not the NUL byte but can be found in +.IR s ; +otherwise 0 is returned. +.SH ERRORS +The +.BR libsimple_inchrset () +and +.BR libsimple_inchrcaseset () +functions 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_inchrset (), +.br +.BR libsimple_inchrcaseset () +T} Thread safety MT-Safe +T{ +.BR libsimple_inchrset (), +.br +.BR libsimple_strchrnul () +T} Async-signal safety AS-Safe +T{ +.BR libsimple_inchrset (), +.br +.BR libsimple_strchrnul () +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_strcasechr (3), +.BR strchr (3) diff --git a/man/libsimple_strcasechr.3 b/man/libsimple_strcasechr.3 index 9e60426..8d644a1 100644 --- a/man/libsimple_strcasechr.3 +++ b/man/libsimple_strcasechr.3 @@ -78,4 +78,5 @@ None. .BR libsimple_strrcasechr (3), .BR libsimple_strncasechr (3), .BR libsimple_memcasechr (3), +.BR libsimple_inchrcaseset (3), .BR strchr (3) diff --git a/man/libsimple_strcasechrnul.3 b/man/libsimple_strcasechrnul.3 index b532249..d2098bb 100644 --- a/man/libsimple_strcasechrnul.3 +++ b/man/libsimple_strcasechrnul.3 @@ -74,4 +74,5 @@ None. .SH SEE ALSO .BR libsimple_strcasechr (3), .BR libsimple_strchrnul (3), -.BR libsimple_strncasechrnul (3) +.BR libsimple_strncasechrnul (3), +.BR libsimple_inchrcaseset (3) diff --git a/man/libsimple_strchrnul.3 b/man/libsimple_strchrnul.3 index 73c5f7d..2196933 100644 --- a/man/libsimple_strchrnul.3 +++ b/man/libsimple_strchrnul.3 @@ -75,4 +75,5 @@ None. .BR libsimple_strcasechrnul (3), .BR libsimple_strend (3), .BR libsimple_strnchrnul (3), +.BR libsimple_inchrset (3), .BR strchr (3) diff --git a/man/libsimple_vasprintf.3 b/man/libsimple_vasprintf.3 index 4ad0b4c..e91c404 100644 --- a/man/libsimple_vasprintf.3 +++ b/man/libsimple_vasprintf.3 @@ -56,7 +56,7 @@ The .BR libsimple_asprintf () function is a version of the .BR libsimple_vasprintf () -that uses variadic arguments instead of +function that uses variadic arguments instead of .BR va_list . .PP The diff --git a/man/libsimple_vputenvf.3 b/man/libsimple_vputenvf.3 index cc7f75d..33c5559 100644 --- a/man/libsimple_vputenvf.3 +++ b/man/libsimple_vputenvf.3 @@ -56,7 +56,7 @@ The .BR libsimple_putenvf () function is a version of the .BR libsimple_vputenvf () -that uses variadic arguments instead of +function that uses variadic arguments instead of .BR va_list . .PP The diff --git a/man/libsimple_vweprintf.3 b/man/libsimple_vweprintf.3 new file mode 100644 index 0000000..ef2bedd --- /dev/null +++ b/man/libsimple_vweprintf.3 @@ -0,0 +1,179 @@ +.TH LIBSIMPLE_VWEPRINTF 3 2018-11-05 libsimple +.SH NAME +libsimple_vweprintf \- print an error message +.SH SYNOPSIS +.nf +#include <libsimple.h> + +void libsimple_vweprintf(const char *\fIfmt\fP, va_list \fIap\fP); +static inline void libsimple_weprintf(const char *\fIfmt\fP, ...); +static inline void libsimple_venprintf(int \fIstatus\fP, const char *\fIfmt\fP, va_list \fIap\fP); +static inline void libsimple_enprintf(int \fIstatus\fP, const char *\fIfmt\fP, ...); +static inline void libsimple_veprintf(const char *\fIfmt\fP, va_list \fIap\fP); +static inline void libsimple_eprintf(const char *\fIfmt\fP, ...); + +#ifndef vweprintf +# define vweprintf libsimple_vweprintf +#endif +#ifndef weprintf +# define weprintf libsimple_weprintf +#endif +#ifndef venprintf +# define venprintf libsimple_venprintf +#endif +#ifndef enprintf +# define enprintf libsimple_enprintf +#endif +#ifndef veprintf +# define veprintf libsimple_veprintf +#endif +#ifndef eprintf +# define eprintf libsimple_eprintf +#endif +.fi +.PP +Link with +.IR \-lsimple . +.SH DESCRIPTION +The +.BR libsimple_vweprintf () +function is a version of the +.BR printf (3) +function. It prints the string to the standard error +(rather than the standard output), and attempts to +avoid output mangling in case multiple processes are +writting. Additionally, the output is suffixed with +.nf + + \fB\(dq %s\en\(dq, \fP<\fIerror message\fP> + +.fi +if +.I fmt +ends with a colon +.RB ( : ), +otherwise it is suffixed with a <newline> if +.I fmt +does not end with a <newline>; otherwise, if +.I fmt +is the empty string, the output is suffixed with +.nf + + \fB\(dq%s\en\(dq, \fP<\fIerror message\fP> + +.fi +Furthermore, if +.I argv0 +.RB ( "char *" ) +is non-null and +.I fmt +does not start with +.RB \(dq "usage :" \(dq, +the output is preffixed with +.nf + + \fB\(dq%s: \(dq, \fPIargv0\fP +.fi +.PP +The +.BR libsimple_weprintf () +function is a version of the +.BR libsimple_vweprintf () +function that uses variadic arguments instead of +.BR va_list . +.PP +The +.BR libsimple_venprintf () +and +.BR libsimple_enprintf () +functions are versions of the +.BR libsimple_vweprintf () +and +.BR libsimple_weprintf () +functions that terminate the process by calling +.BR exit (3), +the exit value of the process will be +.IR status . +.PP +The +.BR libsimple_veprintf () +and +.BR libsimple_eprintf () +functions are versions of the +.BR libsimple_vweprintf () +and +.BR libsimple_weprintf () +functions that terminate the process by calling +.BR exit (3), +the exit value of the process will be +.IR libsimple_default_failure_exit (3), +which is 1 by default. +.SH RETURN VALUE +None. +.SH ERRORS +None. +.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_vweprintf (), +.br +.BR libsimple_weprintf (), +.br +.BR libsimple_venprintf (), +.br +.BR libsimple_enprintf (), +.br +.BR libsimple_veprintf (), +.br +.BR libsimple_eprintf () +T} Thread safety MT-Unsafe race:strerror +T{ +.BR libsimple_vweprintf (), +.br +.BR libsimple_weprintf (), +.br +.BR libsimple_venprintf (), +.br +.BR libsimple_enprintf (), +.br +.BR libsimple_veprintf (), +.br +.BR libsimple_eprintf () +T} Async-signal safety AS-Safe +T{ +.BR libsimple_vweprintf (), +.br +.BR libsimple_weprintf (), +.br +.BR libsimple_venprintf (), +.br +.BR libsimple_enprintf (), +.br +.BR libsimple_veprintf (), +.br +.BR libsimple_eprintf () +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_vweprintf (3), +.BR perror (3), +.BR fprintf (3), +.BR exit (3) |