X-Git-Url: https://git.distorted.org.uk/~mdw/mLib/blobdiff_plain/f50c1365107c09453531f01bcaebc3b197c3627f..2f2cb6647cc52037b361d54e46c7c75ebef1c125:/utils/macros.3 diff --git a/utils/macros.3 b/utils/macros.3 index 98ab238..f5dac97 100644 --- a/utils/macros.3 +++ b/utils/macros.3 @@ -6,6 +6,25 @@ macros \- useful macros .\" @STR .\" @GLUE .\" @STATIC_ASSERT +.\" @ISALNUM +.\" @ISALPHA +.\" @ISASCII +.\" @ISBLANK +.\" @ISCNTRL +.\" @ISDIGIT +.\" @ISGRAPH +.\" @ISLOWER +.\" @ISPRINT +.\" @ISPUNCT +.\" @ISSPACE +.\" @ISUPPER +.\" @ISXDIGIT +.\" @TOASCII +.\" @TOLOWER +.\" @TOUPPER +.\" @MEMCMP +.\" @STRCMP +.\" @STRNCMP .\" @DISCARD .\" @IGNORE .\" @DEPRECATED @@ -18,6 +37,7 @@ macros \- useful macros .\" @MUFFLE_WARNINGS_EXPR .\" @MUFFLE_WARNINGS_STMT .\" @GCC_WARNING +.\" @CLANG_WARNING .SH SYNOPSIS .nf .B "#include " @@ -27,6 +47,27 @@ macros \- useful macros .BI "GLUE(" tokens\fR... ", " tokens\fR... ")" .BI "STATIC_ASSERT(" cond ", " msg ");" +.BI "ISALNUM(int " ch ");" +.BI "ISALPHA(int " ch ");" +.BI "ISASCII(int " ch ");" +.BI "ISBLANK(int " ch ");" +.BI "ISCNTRL(int " ch ");" +.BI "ISDIGIT(int " ch ");" +.BI "ISGRAPH(int " ch ");" +.BI "ISLOWER(int " ch ");" +.BI "ISPRINT(int " ch ");" +.BI "ISPUNCT(int " ch ");" +.BI "ISSPACE(int " ch ");" +.BI "ISUPPER(int " ch ");" +.BI "ISXDIGIT(int " ch ");" +.BI "TOASCII(int " ch ");" +.BI "TOLOWER(int " ch ");" +.BI "TOUPPER(int " ch ");" + +.BI "MEMCMP(const void *" x ", " op ", const void *" y ", size_t " n ");" +.BI "STRCMP(const char *" x ", " op ", const char *" y ");" +.BI "STRNCMP(const char *" x ", " op ", const char *" y ", size_t " n ");" + .BI "void DISCARD(" scalar ");" .BI "void IGNORE(" variable ");" @@ -78,6 +119,40 @@ falls back to a somewhat ugly hack which currently ignores the .IR msg . .PP The +.BR IS ...\& +and +.BR TO ...\& +macros are wrappers around the corresponding standard +.B +macros with the corresponding lowercase names. They take care of +forcing the character argument +.I ch +to +.BR "unsigned char" : +this conversion is necessary on platforms with signed +.B char +to avoid passing negative values into the standard macros. +.PP +The +.BR MEMCMP , +.BR STRCMP , +and +.B STRNCMP +macros are wrappers around the standard +.B +functions with the corresponding lowercase names. They take an +additional argument +.I op +which is a equality or ordering operator (e.g., +.B == +or +.BR > ) +inserted between the two operands. The standard functions return a +false value if and only if the operands are equal, which is +counterintuitive and leads to mistakes; requiring an explicit relational +operator should reduce the number of such mistakes. +.PP +The .B DISCARD macro discards its argument, which must be of some scalar type. This can be useful in muffling warnings about ignoring return codes in cases