From bc237bbae1393cacee9d534832a050f1148b0d8b Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Sat, 10 Dec 2016 14:36:43 +0000 Subject: [PATCH] Rename recently added HasPrefix() to has_prefix(). Sticking with local convention, as Ken requested. --- h/utils.h | 2 +- mts/smtp/smtp.c | 8 ++++---- sbr/folder_read.c | 2 +- sbr/m_convert.c | 2 +- sbr/m_maildir.c | 8 ++++---- sbr/mf.c | 8 ++++---- sbr/oauth.c | 8 ++++---- sbr/path.c | 12 ++++++------ sbr/utils.c | 6 +++--- uip/aliasbr.c | 2 +- uip/dropsbr.c | 8 ++++---- uip/mhfixmsg.c | 2 +- uip/mhoutsbr.c | 2 +- uip/mhstoresbr.c | 2 +- uip/popsbr.c | 4 ++-- uip/replsbr.c | 2 +- uip/rmf.c | 2 +- uip/slocal.c | 2 +- 18 files changed, 41 insertions(+), 41 deletions(-) diff --git a/h/utils.h b/h/utils.h index 939bd80e..5e1522c6 100644 --- a/h/utils.h +++ b/h/utils.h @@ -67,7 +67,7 @@ void trunccpy(char *dst, const char *src, size_t size); /* A convenience for the common case of dst being an array. */ #define TRUNCCPY(dst, src) trunccpy(dst, src, sizeof (dst)) -bool HasPrefix(const char *s, const char *prefix); +bool has_prefix(const char *s, const char *prefix); bool HasSuffix(const char *s, const char *suffix); bool HasSuffixC(const char *s, int c); void TrimSuffixC(char *s, int c); diff --git a/mts/smtp/smtp.c b/mts/smtp/smtp.c index 80bff194..0e6e5116 100644 --- a/mts/smtp/smtp.c +++ b/mts/smtp/smtp.c @@ -815,7 +815,7 @@ again: ; &errstr)) != NULL ; ) { if (doingEHLO - && HasPrefix(buffer, "250") + && has_prefix(buffer, "250") && (buffer[3] == '-' || doingEHLO == 2) && buffer[4]) { if (doingEHLO == 2) { @@ -954,7 +954,7 @@ EHLOset (char *s) for (ehlo = EHLOkeys; *ehlo; ehlo++) { ep = *ehlo; - if (HasPrefix(ep, s)) { + if (has_prefix(ep, s)) { for (ep += len; *ep == ' '; ep++) continue; return ep; @@ -1032,7 +1032,7 @@ sm_sasl_callback(enum sasl_message_type mtype, unsigned const char *indata, return NOTOK; } - if (!HasPrefix(line, "334 ")) { + if (!has_prefix(line, "334 ")) { netsec_err(errstr, "Improper SASL protocol response: %s", line); return NOTOK; } @@ -1081,7 +1081,7 @@ sm_sasl_callback(enum sasl_message_type mtype, unsigned const char *indata, if (line == NULL) return NOTOK; - if (!HasPrefix(line, "235 ")) { + if (!has_prefix(line, "235 ")) { if (len > 4) netsec_err(errstr, "Authentication failed: %s", line + 4); else diff --git a/sbr/folder_read.c b/sbr/folder_read.c index 5b9f73f1..1e95a92b 100644 --- a/sbr/folder_read.c +++ b/sbr/folder_read.c @@ -99,7 +99,7 @@ folder_read (char *name, int lockflag) default: /* skip any files beginning with backup prefix */ - if (HasPrefix(dp->d_name, BACKUP_PREFIX)) + if (has_prefix(dp->d_name, BACKUP_PREFIX)) continue; /* skip the LINK file */ diff --git a/sbr/m_convert.c b/sbr/m_convert.c index 88ea9da5..82ab07e3 100644 --- a/sbr/m_convert.c +++ b/sbr/m_convert.c @@ -360,7 +360,7 @@ attr (struct msgs *mp, char *cp) /* hack for "cur-name", "cur-n", etc. */ if (!strcmp (cp, "cur")) return 0; - if (HasPrefix(cp, "cur")) { + if (has_prefix(cp, "cur")) { if (cp[3] == ':' || cp[3] == '=') return 0; } diff --git a/sbr/m_maildir.c b/sbr/m_maildir.c index 2947c9b5..0e8d3f2c 100644 --- a/sbr/m_maildir.c +++ b/sbr/m_maildir.c @@ -44,10 +44,10 @@ m_mailpath (char *folder) char maildir[BUFSIZ]; if (*folder != '/' - && !HasPrefix(folder, CWD) + && !has_prefix(folder, CWD) && strcmp (folder, DOT) && strcmp (folder, DOTDOT) - && !HasPrefix(folder, PWD)) { + && !has_prefix(folder, PWD)) { strncpy (maildir, mailfold, sizeof(maildir)); /* preserve... */ cp = getcpy (m_maildir (folder)); strncpy (mailfold, maildir, sizeof(mailfold)); @@ -69,10 +69,10 @@ exmaildir (char *folder) folder = getfolder(1); if (!(*folder != '/' - && !HasPrefix(folder, CWD) + && !has_prefix(folder, CWD) && strcmp (folder, DOT) && strcmp (folder, DOTDOT) - && !HasPrefix(folder, PWD))) { + && !has_prefix(folder, PWD))) { strncpy (mailfold, folder, sizeof(mailfold)); return mailfold; } diff --git a/sbr/mf.c b/sbr/mf.c index 870a0a52..084643b4 100644 --- a/sbr/mf.c +++ b/sbr/mf.c @@ -26,8 +26,8 @@ static int my_lex (char *); int isfrom(const char *string) { - return (HasPrefix(string, "From ") - || HasPrefix(string, ">From ")); + return (has_prefix(string, "From ") + || has_prefix(string, ">From ")); } @@ -52,8 +52,8 @@ lequal (const char *a, const char *b) static int isat (const char *p) { - return HasPrefix(p, " AT ") || HasPrefix(p, " At ") || - HasPrefix(p, " aT ") || HasPrefix(p, " at "); + return has_prefix(p, " AT ") || has_prefix(p, " At ") || + has_prefix(p, " aT ") || has_prefix(p, " at "); } diff --git a/sbr/oauth.c b/sbr/oauth.c index 0cda2bfa..2180be87 100755 --- a/sbr/oauth.c +++ b/sbr/oauth.c @@ -628,17 +628,17 @@ load_creds(struct user_creds **result, FILE *fp, mh_oauth_ctx *ctx) case FLDPLUS: { char **save, *expire; time_t *expires_at = NULL; - if (HasPrefix(name, "access-")) { + if (has_prefix(name, "access-")) { const char *user = name + 7; mh_oauth_cred *creds = find_or_alloc_user_creds(user_creds, user); save = &creds->access_token; - } else if (HasPrefix(name, "refresh-")) { + } else if (has_prefix(name, "refresh-")) { const char *user = name + 8; mh_oauth_cred *creds = find_or_alloc_user_creds(user_creds, user); save = &creds->refresh_token; - } else if (HasPrefix(name, "expire-")) { + } else if (has_prefix(name, "expire-")) { const char *user = name + 7; mh_oauth_cred *creds = find_or_alloc_user_creds(user_creds, user); @@ -949,7 +949,7 @@ post(struct curl_ctx *ctx, const char *url, const char *req_body) curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, ctx); - if (HasPrefix(url, "http://127.0.0.1:")) { + if (has_prefix(url, "http://127.0.0.1:")) { /* Hack: on Cygwin, curl doesn't fail to connect with ECONNREFUSED. Instead, it waits to timeout. So set a really short timeout, but just on localhost (for convenience of the user, and the test diff --git a/sbr/path.c b/sbr/path.c index 8f6bd55f..79d7f38c 100644 --- a/sbr/path.c +++ b/sbr/path.c @@ -64,10 +64,10 @@ expath (char *name, int flag) if (*name == '/' || (flag == TFOLDER - && (!HasPrefix(name, CWD) + && (!has_prefix(name, CWD) && strcmp (name, DOT) && strcmp (name, DOTDOT) - && !HasPrefix(name, PWD)))) + && !has_prefix(name, PWD)))) return mh_xstrdup(name); if (pwds == NULL) @@ -83,7 +83,7 @@ expath (char *name, int flag) if (cp == pwds) cp++; - if (HasPrefix(name, CWD)) + if (has_prefix(name, CWD)) name += LEN(CWD); if (strcmp (name, DOTDOT) == 0 || strcmp (name, PWD) == 0) { @@ -91,7 +91,7 @@ expath (char *name, int flag) return mh_xstrdup(buffer); } - if (HasPrefix(name, PWD)) + if (has_prefix(name, PWD)) name += LEN(PWD); else cp = ep; @@ -139,7 +139,7 @@ compath (char *f) *cp = '\0'; break; } - if (HasPrefix(cp, PWD)) { + if (has_prefix(cp, PWD)) { for (dp = cp - 2; dp > f; dp--) if (*dp == '/') break; @@ -149,7 +149,7 @@ compath (char *f) cp = dp; continue; } - if (HasPrefix(cp, CWD)) { + if (has_prefix(cp, CWD)) { strcpy (cp - 1, cp + LEN(CWD) - 1); cp--; continue; diff --git a/sbr/utils.c b/sbr/utils.c index 78ec2da9..80c0cd0d 100644 --- a/sbr/utils.c +++ b/sbr/utils.c @@ -371,8 +371,8 @@ void trunccpy(char *dst, const char *src, size_t size) } -/* HasPrefix returns true if non-NULL s starts with non-NULL prefix. */ -bool HasPrefix(const char *s, const char *prefix) +/* has_prefix returns true if non-NULL s starts with non-NULL prefix. */ +bool has_prefix(const char *s, const char *prefix) { while (*s && *s == *prefix) { s++; @@ -527,7 +527,7 @@ nmh_version_changed (int older) { break for versions with multiple decimal points, etc. */ const float current_version = strtof (VERSION, NULL); const float old_version = - context_version && HasPrefix(context_version, "nmh-") + context_version && has_prefix(context_version, "nmh-") ? strtof (context_version + 4, NULL) : 99999999; diff --git a/uip/aliasbr.c b/uip/aliasbr.c index 069e4546..e9724f73 100644 --- a/uip/aliasbr.c +++ b/uip/aliasbr.c @@ -182,7 +182,7 @@ alias (char *file) FILE *fp; if (*file != '/' - && !HasPrefix(file, "./") && !HasPrefix(file, "../")) + && !has_prefix(file, "./") && !has_prefix(file, "../")) file = etcpath (file); if ((fp = fopen (file, "r")) == NULL) { akerrst = file; diff --git a/uip/dropsbr.c b/uip/dropsbr.c index 937ff827..baf8268b 100644 --- a/uip/dropsbr.c +++ b/uip/dropsbr.c @@ -350,7 +350,7 @@ mbx_copy (char *mailbox, int mbx_style, int md, int fd, * Change the "Return-Path:" field (if in first line) * back to "From ". */ - if (HasPrefix(buffer, "Return-Path:")) { + if (has_prefix(buffer, "Return-Path:")) { char tmpbuffer[BUFSIZ]; char *tp, *ep, *fp; @@ -361,7 +361,7 @@ mbx_copy (char *mailbox, int mbx_style, int md, int fd, tp = dctime(dlocaltimenow()); snprintf (buffer, sizeof(buffer), "From %.*s %s", (int)(fp - ep), ep, tp); - } else if (HasPrefix(buffer, "X-Envelope-From:")) { + } else if (has_prefix(buffer, "X-Envelope-From:")) { /* * Change the "X-Envelope-From:" field * (if first line) back to "From ". @@ -372,7 +372,7 @@ mbx_copy (char *mailbox, int mbx_style, int md, int fd, strncpy(tmpbuffer, buffer, sizeof(tmpbuffer)); ep = tmpbuffer + 17; snprintf (buffer, sizeof(buffer), "From %s", ep); - } else if (!HasPrefix(buffer, "From ")) { + } else if (!has_prefix(buffer, "From ")) { /* * If there is already a "From " line, * then leave it alone. Else we add one. @@ -391,7 +391,7 @@ mbx_copy (char *mailbox, int mbx_style, int md, int fd, * If this is not first line, and begins with * "From ", then prepend line with ">". */ - if (j != 0 && HasPrefix(buffer, "From ")) { + if (j != 0 && has_prefix(buffer, "From ")) { if (write (md, ">", 1) < 0) { advise (mailbox, "write"); } diff --git a/uip/mhfixmsg.c b/uip/mhfixmsg.c index ff3e383a..553b14e3 100644 --- a/uip/mhfixmsg.c +++ b/uip/mhfixmsg.c @@ -2589,7 +2589,7 @@ static int fix_filename_param (char *name, char *value, PM *first_pm, PM *last_pm) { int fixed = 0; - if (HasPrefix(value, "=?") && HasSuffix(value, "?=")) { + if (has_prefix(value, "=?") && HasSuffix(value, "?=")) { /* Looks like an RFC 2047 encoded parameter. */ char decoded[PATH_MAX + 1]; diff --git a/uip/mhoutsbr.c b/uip/mhoutsbr.c index d18d8885..638cf979 100644 --- a/uip/mhoutsbr.c +++ b/uip/mhoutsbr.c @@ -348,7 +348,7 @@ writeQuoted (CT ct, FILE *out) * doesn't falsely match an mbox delimiter. */ cp = bufp; - if (gotlen >= 5 && HasPrefix(cp, "From ")) { + if (gotlen >= 5 && has_prefix(cp, "From ")) { fprintf (out, "=%02X", 'F'); cp++; n += 3; diff --git a/uip/mhstoresbr.c b/uip/mhstoresbr.c index 515699d8..5a6f630c 100644 --- a/uip/mhstoresbr.c +++ b/uip/mhstoresbr.c @@ -671,7 +671,7 @@ got_filename: int cwdlen = strlen (info->cwd); fprintf (stderr, " as file %s\n", - !HasPrefix(ct->c_storage, info->cwd) + !has_prefix(ct->c_storage, info->cwd) || ct->c_storage[cwdlen] != '/' ? ct->c_storage : ct->c_storage + cwdlen + 1); } diff --git a/uip/popsbr.c b/uip/popsbr.c index fefd4954..16eba46d 100644 --- a/uip/popsbr.c +++ b/uip/popsbr.c @@ -435,7 +435,7 @@ pop_sasl_callback(enum sasl_message_type mtype, unsigned const char *indata, if (line == NULL) return NOTOK; - if (!HasPrefix(line, "+OK")) { + if (!has_prefix(line, "+OK")) { netsec_err(errstr, "Authentication failed: %s", line); return NOTOK; } @@ -691,7 +691,7 @@ multiline (void) if (pop_getline (buffer, sizeof buffer, nsc) != OK) return NOTOK; - if (HasPrefix(buffer, TRM)) { + if (has_prefix(buffer, TRM)) { if (buffer[LEN(TRM)] == 0) return DONE; strncpy (response, buffer + LEN(TRM), sizeof(response)); diff --git a/uip/replsbr.c b/uip/replsbr.c index 69fe6a02..7df163b9 100644 --- a/uip/replsbr.c +++ b/uip/replsbr.c @@ -532,7 +532,7 @@ fix_addresses (char *str) { const char *no_at_sign = "no at-sign after local-part"; adr_nodep->escape_local_part = - HasPrefix(error, no_at_sign); + has_prefix(error, no_at_sign); } else { mnfree (mp); } diff --git a/uip/rmf.c b/uip/rmf.c index 493510a0..30f94219 100644 --- a/uip/rmf.c +++ b/uip/rmf.c @@ -171,7 +171,7 @@ rmf (char *folder) if (m_atoi (dp->d_name)) break; if (strcmp (dp->d_name, LINK) == 0 - || HasPrefix(dp->d_name, BACKUP_PREFIX)) + || has_prefix(dp->d_name, BACKUP_PREFIX)) break; admonish (NULL, "file \"%s/%s\" not deleted", diff --git a/uip/slocal.c b/uip/slocal.c index fd60e232..4c670b98 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -1253,7 +1253,7 @@ you_lose: while (fgets (buffer, sizeof(buffer), qfp)) { if (first) { first = 0; - if (HasPrefix(buffer, "From ")) { + if (has_prefix(buffer, "From ")) { /* get copy of envelope information ("From " line) */ envelope = mh_xstrdup(buffer); -- 2.56.0