From: Ralph Corderoy Date: Sun, 27 Aug 2017 10:53:26 +0000 (+0100) Subject: Replace strlen("foo") with LEN("foo"). X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/2fc70e8bf64ead869fce76abb74f04bf1af94923?ds=inline Replace strlen("foo") with LEN("foo"). The existing LEN() uses sizeof. --- diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index 7c957b08..a615dcf9 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -243,11 +243,11 @@ build_mime (char *infile, int autobuild, int dist, int directives, attach_head = attach_tail = entry; } } else if (strncasecmp(MHBUILD_FILE_PSEUDOHEADER, np, - strlen (MHBUILD_FILE_PSEUDOHEADER)) == 0) { + LEN(MHBUILD_FILE_PSEUDOHEADER)) == 0) { /* E.g., * Nmh-mhbuild-file-text/calendar: /home/user/Mail/inbox/9 */ - char *type = np + strlen (MHBUILD_FILE_PSEUDOHEADER); + char *type = np + LEN(MHBUILD_FILE_PSEUDOHEADER); char *filename = vp; /* vp should begin with a space because m_getfld2() @@ -283,11 +283,11 @@ build_mime (char *infile, int autobuild, int dist, int directives, free (vp); free (np); } else if (strncasecmp(MHBUILD_ARGS_PSEUDOHEADER, np, - strlen (MHBUILD_ARGS_PSEUDOHEADER)) == 0) { + LEN(MHBUILD_ARGS_PSEUDOHEADER)) == 0) { /* E.g., * Nmh-mhbuild-args-text/calendar: -reply accept */ - char *type = np + strlen (MHBUILD_ARGS_PSEUDOHEADER); + char *type = np + LEN(MHBUILD_ARGS_PSEUDOHEADER); char *argstring = vp; /* vp should begin with a space because m_getfld2() @@ -710,7 +710,7 @@ user_content (FILE *in, char *buf, CT *ctp, const char *infilename) int i; if (headers >= 0 && do_direct() && uprf (buffer, DESCR_FIELD) - && buffer[i = strlen (DESCR_FIELD)] == ':') { + && buffer[i = LEN(DESCR_FIELD)] == ':') { headers = 1; again_descr: @@ -733,7 +733,7 @@ again_descr: } if (headers >= 0 && do_direct() && uprf (buffer, DISPO_FIELD) - && buffer[i = strlen (DISPO_FIELD)] == ':') { + && buffer[i = LEN(DISPO_FIELD)] == ':') { headers = 1; again_dispo: @@ -1670,7 +1670,7 @@ build_headers (CT ct, int header_encoding) vp = concat (" ", ci->ci_type, "/", ci->ci_subtype, NULL); /* keep track of length of line */ - len = strlen (TYPE_FIELD) + strlen (ci->ci_type) + len = LEN(TYPE_FIELD) + strlen (ci->ci_type) + strlen (ci->ci_subtype) + 3; extbody = ct->c_type == CT_MESSAGE && ct->c_subtype == MESSAGE_EXTERNAL; @@ -1745,7 +1745,7 @@ build_headers (CT ct, int header_encoding) add_header (ct, np, vp); } else if (ct->c_dispo_type) { vp = concat (" ", ct->c_dispo_type, NULL); - len = strlen(DISPO_FIELD) + strlen(vp) + 1; + len = LEN(DISPO_FIELD) + strlen(vp) + 1; np = output_params(len, ct->c_dispo_first, NULL, 0); vp = add(np, vp); vp = add("\n", vp); @@ -2365,8 +2365,8 @@ extract_headers (CT ct, char *reply_file, FILE **reply_fp) { buffer[statbuf.st_size] = '\0'; /* Look for a header in the convert reply. */ - if (strncasecmp (buffer, TYPE_FIELD, strlen (TYPE_FIELD)) == 0 && - buffer[strlen (TYPE_FIELD)] == ':') { + if (strncasecmp (buffer, TYPE_FIELD, LEN(TYPE_FIELD)) == 0 && + buffer[LEN(TYPE_FIELD)] == ':') { if ((end_of_header = strstr (buffer, "\r\n\r\n"))) { end_of_header += 2; found_header = 1; diff --git a/uip/mhfixmsg.c b/uip/mhfixmsg.c index 88dfb153..0bf0437c 100644 --- a/uip/mhfixmsg.c +++ b/uip/mhfixmsg.c @@ -866,7 +866,7 @@ replace_boundary (CT ct, char *file, char *boundary) { new_ctline = concat(" ", ct->c_ctinfo.ci_type, "/", ct->c_ctinfo.ci_subtype, NULL); - new_params = output_params(strlen(TYPE_FIELD) + + new_params = output_params(LEN(TYPE_FIELD) + strlen(new_ctline) + 1, ct->c_ctinfo.ci_first_pm, NULL, 0); fprintf (fpout, "%s:%s%s\n", np, new_ctline, @@ -1125,7 +1125,7 @@ fix_composite_cte (CT ct, int *message_mods) { } if (! strncasecmp (name, ENCODING_FIELD, - strlen (ENCODING_FIELD))) { + LEN(ENCODING_FIELD))) { char *prefix = "Nmh-REPLACED-INVALID-"; HF h; @@ -1868,7 +1868,7 @@ transfer_noncontent_headers (CT old, CT new) { while (hp) { HF next = hp->next; - if (strncasecmp (XXX_FIELD_PRF, hp->name, strlen (XXX_FIELD_PRF))) { + if (strncasecmp (XXX_FIELD_PRF, hp->name, LEN(XXX_FIELD_PRF))) { if (hp == old->c_last_hf) { if (hp == old->c_first_hf) { old->c_last_hf = old->c_first_hf = NULL; diff --git a/uip/mhparse.c b/uip/mhparse.c index ca01545f..2842b0c6 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -2214,7 +2214,7 @@ open7Bit (CT ct, char **file) len = 0; fprintf (ce->ce_fp, "%s: %s/%s", TYPE_FIELD, ci->ci_type, ci->ci_subtype); - len += strlen (TYPE_FIELD) + 2 + strlen (ci->ci_type) + len += LEN(TYPE_FIELD) + 2 + strlen (ci->ci_type) + 1 + strlen (ci->ci_subtype); buffer = output_params(len, ci->ci_first_pm, &len, 0); diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c index 6f8a978f..0a40bfc1 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -1220,7 +1220,7 @@ iconv_start: replace_param(&ct->c_ctinfo.ci_first_pm, &ct->c_ctinfo.ci_last_pm, "charset", dest_charset, 0); - outline = output_params(strlen(TYPE_FIELD) + 1 + strlen(ctline), + outline = output_params(LEN(TYPE_FIELD) + 1 + strlen(ctline), ct->c_ctinfo.ci_first_pm, NULL, 0); if (outline) { ctline = add(outline, ctline);