* 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
*/
if (msgs->size + argp >= msgs->max) {
- msgs->max += MAXMSGS > argp ? MAXMSGS : argp;
- msgs->msgs = mh_xrealloc(msgs->msgs, msgs->max * sizeof(*msgs->msgs));
+ msgs->max += max(MAXMSGS, argp);
+ msgs->msgs = mh_xrealloc(msgs->msgs, msgs->max * sizeof(*msgs->msgs));
}
for (i = msgs->size - 1; i >= 0; i--)
len = mbtowc (&wide_char, sp, (size_t) MB_CUR_MAX < remaining
? (size_t) MB_CUR_MAX
: remaining);
- sp += len > 0 ? len : 1;
- remaining -= len > 0 ? len : 1;
+ sp += max(len, 1);
+ remaining -= max(len, 1);
}
#else /* ! MULTIBYTE_SUPPORT */
if (charstring_bytes (s) > 0) { len = 1; }
* complete copyright information.
*/
-#include <h/nmh.h>
+#include <h/mh.h>
#include <h/utils.h>
static void
if (strcmp (tmp, "\"")) {
size_t len = destp - tmp;
assert ((ssize_t) strlen(tmp) + 1 == destp - tmp);
- strncpy (name, tmp, len <= namesize ? len : namesize);
+ strncpy (name, tmp, min(len, namesize));
} else {
/* Handle just " as special case here instead of above. */
strncpy (name, "\"\\\"\"", namesize);
int i, errpos, errctx;
errpos = cp - format_string;
- errctx = errpos > 20 ? 20 : errpos;
+ errctx = min(errpos, 20);
usr_fstring[errpos] = '\0';
for (i = errpos-errctx; i < errpos; i++) {
while (len >= cline->input_line_size) {
cline->input_line_size = cline->input_line_size == 0
- ? (BUFSIZ>=8192 ? BUFSIZ : 8192)
+ ? max(BUFSIZ, 8192)
: 2 * cline->input_line_size;
cline->input_line =
mh_xrealloc (cline->input_line, cline->input_line_size);
* limits simply reallocate the folder so it's within range.
*/
if (first < mp->lowoff || first > mp->hghoff)
- mp = folder_realloc(mp, first < mp->lowoff ? first : mp->lowoff,
- first > mp->hghoff ? first : mp->hghoff);
+ mp = folder_realloc(mp, min(first, mp->lowoff),
+ max(first, mp->hghoff));
set_select_empty (mp, first);
} else {
max = *bufsz-1;
/* Back up and store the current position. */
bp = --s->readpos;
- c = s->end - s->readpos < max ? s->end - s->readpos : max;
+ c = min(s->end - s->readpos, max);
if (s->msg_style != MS_DEFAULT && c > 1) {
/*
* packed maildrop - only take up to the (possible)
FILE *fp;
if ((fp = popen(cmd, "r")) != NULL) {
- char buf[BUFSIZ >= 2048 ? BUFSIZ : 2048];
+ char buf[max(BUFSIZ, 2048)];
buf[0] = '\0';
if (fgets(buf, sizeof buf, fp)) {
* assume here that this has something in it.
*/
- retlen = size > nsc->ns_inbuflen ? nsc->ns_inbuflen : size;
+ retlen = min(size, nsc->ns_inbuflen);
memcpy(buffer, nsc->ns_inptr, retlen);
#endif
charstring_push_back_chars (folded_line, cp, char_len, 1);
- remaining -= char_len > 0 ? char_len : 1;
+ remaining -= max(char_len, 1);
/* remaining must be > 0 to pass the loop condition above, so
if it's not > 1, it is == 1. */
}
}
- cp += char_len > 0 ? char_len : 1;
+ cp += max(char_len, 1);
}
free (line);
* someday.
*/
- destlen = len < ((size_t) (n - 1)) ? len : (size_t) (n - 1);
+ destlen = min(len, (size_t)(n - 1));
memcpy(s, p, destlen);
s[destlen] = '\0';
width = INT_MAX;
}
dat[3] = slwidth = width;
- *scanl = charstring_create (width < NMH_BUFSIZ ? width : NMH_BUFSIZ);
+ *scanl = charstring_create (min(width, NMH_BUFSIZ));
if (outnum)
umask(~m_gmprot());