]> diplodocus.org Git - nmh/commitdiff
Rename recently added HasPrefix() to has_prefix().
authorRalph Corderoy <ralph@inputplus.co.uk>
Sat, 10 Dec 2016 14:36:43 +0000 (14:36 +0000)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sat, 10 Dec 2016 14:36:43 +0000 (14:36 +0000)
Sticking with local convention, as Ken requested.

18 files changed:
h/utils.h
mts/smtp/smtp.c
sbr/folder_read.c
sbr/m_convert.c
sbr/m_maildir.c
sbr/mf.c
sbr/oauth.c
sbr/path.c
sbr/utils.c
uip/aliasbr.c
uip/dropsbr.c
uip/mhfixmsg.c
uip/mhoutsbr.c
uip/mhstoresbr.c
uip/popsbr.c
uip/replsbr.c
uip/rmf.c
uip/slocal.c

index 939bd80..5e1522c 100644 (file)
--- 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);
index 80bff19..0e6e511 100644 (file)
@@ -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
index 5b9f73f..1e95a92 100644 (file)
@@ -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 */
index 88ea9da..82ab07e 100644 (file)
@@ -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;
     }
index 2947c9b..0e8d3f2 100644 (file)
@@ -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;
     }
index 870a0a5..084643b 100644 (file)
--- 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 ");
 }
 
 
index 0cda2bf..2180be8 100755 (executable)
@@ -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
index 8f6bd55..79d7f38 100644 (file)
@@ -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;
index 78ec2da..80c0cd0 100644 (file)
@@ -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;
 
index 069e454..e9724f7 100644 (file)
@@ -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;
index 937ff82..baf8268 100644 (file)
@@ -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");
                    }
index ff3e383..553b14e 100644 (file)
@@ -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];
 
index d18d888..638cf97 100644 (file)
@@ -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;
index 515699d..5a6f630 100644 (file)
@@ -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);
             }
index fefd495..16eba46 100644 (file)
@@ -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));
index 69fe6a0..7df163b 100644 (file)
@@ -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);
             }
index 493510a..30f9421 100644 (file)
--- 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",
index fd60e23..4c670b9 100644 (file)
@@ -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);