Code

prefixcmp(): fix-up leftover strncmp().
authorJunio C Hamano <junkio@cox.net>
Tue, 20 Feb 2007 09:55:07 +0000 (01:55 -0800)
committerJunio C Hamano <junkio@cox.net>
Wed, 21 Feb 2007 06:03:15 +0000 (22:03 -0800)
There were instances of strncmp() that were formatted improperly
(e.g. whitespace around parameter before closing parenthesis)
that caused the earlier mechanical conversion step to miss
them.  This step cleans them up.

Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-ls-tree.c
builtin-rev-parse.c
builtin-show-branch.c
diff.c
http-fetch.c
http-push.c
imap-send.c
revision.c
wt-status.c

index 201defd9344a25e16066dc7d0a0a8f5707a930cb..6472610ac2fecb8096ecab8fe29331a6fd6c009b 100644 (file)
@@ -118,7 +118,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
                                chomp_prefix = 0;
                                break;
                        }
-                       if (!strncmp(argv[1]+2, "abbrev=",7)) {
+                       if (!prefixcmp(argv[1]+2, "abbrev=")) {
                                abbrev = strtoul(argv[1]+9, NULL, 10);
                                if (abbrev && abbrev < MINIMUM_ABBREV)
                                        abbrev = MINIMUM_ABBREV;
index a1c341112185ec4e53dfd2fc0b6f1868e6c5b754..37addb25fafbedba9bad6e99746ee65bacdee7d3 100644 (file)
@@ -233,7 +233,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                        }
                        continue;
                }
-               if (!strncmp(arg,"-n",2)) {
+               if (!prefixcmp(arg, "-n")) {
                        if ((filter & DO_FLAGS) && (filter & DO_REVS))
                                show(arg);
                        continue;
index 402a8f79300eced54cf4024b8d10f4fd766996a1..67ae6bacda6edda2e36b974c0d36b4611ef1a9a6 100644 (file)
@@ -378,7 +378,7 @@ static int append_head_ref(const char *refname, const unsigned char *sha1, int f
 {
        unsigned char tmp[20];
        int ofs = 11;
-       if (strncmp(refname, "refs/heads/", ofs))
+       if (prefixcmp(refname, "refs/heads/"))
                return 0;
        /* If both heads/foo and tags/foo exists, get_sha1 would
         * get confused.
@@ -392,7 +392,7 @@ static int append_remote_ref(const char *refname, const unsigned char *sha1, int
 {
        unsigned char tmp[20];
        int ofs = 13;
-       if (strncmp(refname, "refs/remotes/", ofs))
+       if (prefixcmp(refname, "refs/remotes/"))
                return 0;
        /* If both heads/foo and tags/foo exists, get_sha1 would
         * get confused.
diff --git a/diff.c b/diff.c
index fad13ab44b5e8e4719ba24e0d059127dbd34ec69..c3afee27434c8dbc71e5df108387552fba16db58 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -77,7 +77,7 @@ int git_diff_ui_config(const char *var, const char *value)
                        diff_detect_rename_default = DIFF_DETECT_RENAME;
                return 0;
        }
-       if (!prefixcmp(var, "diff.color.") || !strncmp(var, "color.diff.", 11)) {
+       if (!prefixcmp(var, "diff.color.") || !prefixcmp(var, "color.diff.")) {
                int slot = parse_diff_color_slot(var, 11);
                color_parse(value, var, diff_colors[slot]);
                return 0;
index d9a4561c8c8e2eff9fe5afcb19dafef3c04962aa..e6cd11db737e1ed79c3b60d33674c6e0ce38af55 100644 (file)
@@ -718,7 +718,7 @@ static int fetch_indices(struct alt_base *repo)
                        i++;
                        if (i + 52 <= buffer.posn &&
                            !prefixcmp(data + i, " pack-") &&
-                           !strncmp(data + i + 46, ".pack\n", 6)) {
+                           !prefixcmp(data + i + 46, ".pack\n")) {
                                get_sha1_hex(data + i + 6, sha1);
                                setup_index(repo, sha1);
                                i += 51;
index eb77c9af45f374e17c9bc91b7c1241e0e0613831..9ad6fd00b0bd96580bcebc5aa9ea1713e2b801cd 100644 (file)
@@ -1061,7 +1061,7 @@ static int fetch_indices(void)
                        i++;
                        if (i + 52 < buffer.posn &&
                            !prefixcmp(data + i, " pack-") &&
-                           !strncmp(data + i + 46, ".pack\n", 6)) {
+                           !prefixcmp(data + i + 46, ".pack\n")) {
                                get_sha1_hex(data + i + 6, sha1);
                                setup_index(sha1);
                                i += 51;
index 3eaf025720c5432065b851ce98f861eee27eadee..84df2fabb7f91d30f7617dd07202ed916c5f8eb1 100644 (file)
@@ -1192,7 +1192,7 @@ count_messages( msg_data_t *msg )
        char *p = msg->data;
 
        while (1) {
-               if (!strncmp( "From ", p, 5 )) {
+               if (!prefixcmp(p, "From ")) {
                        count++;
                        p += 5;
                }
@@ -1216,7 +1216,7 @@ split_msg( msg_data_t *all_msgs, msg_data_t *msg, int *ofs )
        data = &all_msgs->data[ *ofs ];
        msg->len = all_msgs->len - *ofs;
 
-       if (msg->len < 5 || strncmp( data, "From ", 5 ))
+       if (msg->len < 5 || prefixcmp(data, "From "))
                return 0;
 
        p = strchr( data, '\n' );
@@ -1267,12 +1267,12 @@ git_imap_config(const char *key, const char *val)
                imap_folder = xstrdup( val );
        } else if (!strcmp( "host", key )) {
                {
-                       if (!strncmp( "imap:", val, 5 ))
+                       if (!prefixcmp(val, "imap:"))
                                val += 5;
                        if (!server.port)
                                server.port = 143;
                }
-               if (!strncmp( "//", val, 2 ))
+               if (!prefixcmp(val, "//"))
                        val += 2;
                server.host = xstrdup( val );
        }
index abab3b9d01c485bdf6c276011ccaff1c86eeee97..622afe3aa6277220a934a500cbb0f83723f75989 100644 (file)
@@ -832,7 +832,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
                                revs->max_count = atoi(argv[++i]);
                                continue;
                        }
-                       if (!strncmp(arg,"-n",2)) {
+                       if (!prefixcmp(arg, "-n")) {
                                revs->max_count = atoi(arg + 2);
                                continue;
                        }
index d17a6ba5b2e2cb83767230db02025b106fee1cea..035e546ed77248720813e7c42e0e2b25f5e760a3 100644 (file)
@@ -344,7 +344,7 @@ int git_status_config(const char *k, const char *v)
                wt_status_use_color = git_config_colorbool(k, v);
                return 0;
        }
-       if (!prefixcmp(k, "status.color.") || !strncmp(k, "color.status.", 13)) {
+       if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
                int slot = parse_status_slot(k, 13);
                color_parse(v, k, wt_status_colors[slot]);
        }