/* 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:
extern char *mhdocdir;
+/* plurals gives the letter ess to indicate a plural noun, or an empty
+ * string as plurals+1 for the singular noun. Used by the PLURALS
+ * macro. */
+const char plurals[] = "s";
+
/*
* We allocate space for messages (msgs array)
* this number of elements at a time.
if ((numburst = find_delim (msgnum, smsgs, &mimesw)) >= 1) {
if (verbosw)
printf ("%d message%s exploded from digest %d\n",
- numburst, numburst > 1 ? "s" : "", msgnum);
+ numburst, PLURALS(numburst), msgnum);
burst (&mp, msgnum, smsgs, numburst, inplace, verbosw,
maildir, mimesw);
} else {
} else {
printf ("has %*d message%1s (%*d-%*d)",
nummsgdigits, fi[i].nummsg,
- (fi[i].nummsg == 1) ? "" : "s",
+ PLURALS(fi[i].nummsg),
lowmsgdigits, fi[i].lowmsg,
hghmsgdigits, fi[i].hghmsg);
if (fi[i].curmsg >= fi[i].lowmsg && fi[i].curmsg <= fi[i].hghmsg) {
if (all)
putchar('\n');
printf ("TOTAL = %d message%s in %d folder%s.\n",
- total_msgs, total_msgs != 1 ? "s" : "",
- total_folders, total_folders != 1 ? "s" : "");
+ total_msgs, PLURALS(total_msgs),
+ total_folders, PLURALS(total_folders));
}
fflush (stdout);
if (msgnum == mp->lowsel) {
snprintf (bp, buflen, " Forwarded Message%s",
- mp->numsel > 1 ? "s" : "");
+ PLURALS(mp->numsel));
} else {
snprintf (bp, buflen, " Message %d", msgcnt);
}
strncpy (buffer, delim4, sizeof(buffer));
} else {
snprintf (buffer, sizeof(buffer), "\n------- End of Forwarded Message%s\n",
- mp->numsel > 1 ? "s" : "");
+ PLURALS(mp->numsel));
}
if (write (out, buffer, strlen (buffer)) < 0) {
advise (drft, "write");
char buffer[BUFSIZ];
snprintf (buffer, sizeof(buffer), "#forw [forwarded message%s] +%s",
- mp->numsel == 1 ? "" : "s", mp->foldpath);
+ PLURALS(mp->numsel), mp->foldpath);
if (write (out, buffer, strlen (buffer)) < 0) {
advise (drft, "write");
}
}
else
printf ("\n------- End of Forwarded Message%s\n",
- vecp > 1 ? "s" : "");
+ PLURALS(vecp));
}
fflush(stdout);
else {
printf ("\n-------");
if (ofilen == 1)
- printf (" Forwarded Message%s", ofilec > 1 ? "s" : "");
+ printf (" Forwarded Message%s", PLURALS(ofilec));
else
printf (" Message %d", ofilen);
printf ("\n\n");
printf ("%s has ", user);
printf ("%d message%s (%d bytes)",
- nmsgs, nmsgs != 1 ? "s" : "", nbytes);
+ nmsgs, PLURALS(nmsgs), nbytes);
}
else
notifysw = 0;
* Print total matched if not printing each matched message number.
*/
if (!listsw) {
- printf ("%d hit%s\n", mp2->numsel, mp2->numsel == 1 ? "" : "s");
+ printf ("%d hit%s\n", mp2->numsel, PLURALS(mp2->numsel));
}
svector_free (seqs);
}
-#define plural(x) (x == 1 ? "" : "s")
-
static void
chkadr (void)
{
if (badadr && unkadr)
die (NULL, "%d address%s unparsable, %d addressee%s undeliverable",
- badadr, plural (badadr), unkadr, plural (badadr));
+ badadr, PLURALS(badadr), unkadr, PLURALS(badadr));
if (badadr)
- die (NULL, "%d address%s unparsable", badadr, plural (badadr));
+ die (NULL, "%d address%s unparsable", badadr, PLURALS(badadr));
if (unkadr)
- die (NULL, "%d addressee%s undeliverable", unkadr, plural (unkadr));
+ die (NULL, "%d addressee%s undeliverable", unkadr, PLURALS(unkadr));
}