X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/159b2a1ede7bd581508e8704112d83efd44e0dfa..3deb45e64aab151581891a10a1650915dff2e4b8:/h/mh.h diff --git a/h/mh.h b/h/mh.h index 8829eb4c..22e3a0b5 100644 --- a/h/mh.h +++ b/h/mh.h @@ -8,7 +8,7 @@ */ #define NOTOK (-1) /* syscall()s return this on error */ #define OK 0 /* ditto on success */ -#define DONE 1 /* trinary logic */ +#define DONE 1 /* ternary logic */ #define ALL "" #define MAXARGS 1000 /* max arguments to exec */ @@ -20,7 +20,7 @@ * This macro is for use by scan, for example, so that platforms with * a small BUFSIZ can easily allocate larger buffers. */ -#define NMH_BUFSIZ (BUFSIZ>=8192 ? BUFSIZ : 8192) +#define NMH_BUFSIZ max(BUFSIZ, 8192) #ifndef FALSE #define FALSE false @@ -48,6 +48,18 @@ typedef unsigned char boolean; /* not int so we can pack in a structure */ * terminating NUL. */ #define LEN(s) (sizeof (s) - 1) +/* FENDNULL fends off NULL by giving an empty string instead. */ +#define FENDNULL(s) ((s) ? (s) : "") + +/* PLURALS gives a pointer to the string "s" when n isn't 1, and to the + * empty string "" when it is. Suitable for obtaining the plural `s' + * used for English nouns. It treats -1 as plural, as does GNU gettext. + * Having output vary for plurals is annoying for those writing parsers; + * better to phrase the output such that no test is needed, e.g. + * "messages found: 42". */ +extern const char plurals[]; +#define PLURALS(n) (plurals + ((n) == 1)) + /* * char array that keeps track of size in both bytes and characters * Usage note: