@matheusbsbs / matheus-bagliano / commits / 1968d77dd6
Fork 0

prefixcmp(): fix-up leftover strncmp().

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>

Junio C Hamano committed Feb 20, 2007 at 01:55 UTC 1968d77dd632a9a9e5c6f5681649e5e65ed13088
9 files changed +13 -13
builtin-ls-tree.c
+1 -1
@@ -118,7 +118,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
118 chomp_prefix = 0;
119 break;
120 }
121 - if (!strncmp(argv[1]+2, "abbrev=",7)) {
121 + if (!prefixcmp(argv[1]+2, "abbrev=")) {
122 abbrev = strtoul(argv[1]+9, NULL, 10);
123 if (abbrev && abbrev < MINIMUM_ABBREV)
124 abbrev = MINIMUM_ABBREV;
builtin-rev-parse.c
+1 -1
@@ -233,7 +233,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
233 }
234 continue;
235 }
236 - if (!strncmp(arg,"-n",2)) {
236 + if (!prefixcmp(arg, "-n")) {
237 if ((filter & DO_FLAGS) && (filter & DO_REVS))
238 show(arg);
239 continue;
builtin-show-branch.c
+2 -2
@@ -378,7 +378,7 @@ static int append_head_ref(const char *refname, const unsigned char *sha1, int f
378 {
379 unsigned char tmp[20];
380 int ofs = 11;
381 - if (strncmp(refname, "refs/heads/", ofs))
381 + if (prefixcmp(refname, "refs/heads/"))
382 return 0;
383 /* If both heads/foo and tags/foo exists, get_sha1 would
384 * get confused.
@@ -392,7 +392,7 @@ static int append_remote_ref(const char *refname, const unsigned char *sha1, int
392 {
393 unsigned char tmp[20];
394 int ofs = 13;
395 - if (strncmp(refname, "refs/remotes/", ofs))
395 + if (prefixcmp(refname, "refs/remotes/"))
396 return 0;
397 /* If both heads/foo and tags/foo exists, get_sha1 would
398 * get confused.
diff.c
+1 -1
@@ -77,7 +77,7 @@ int git_diff_ui_config(const char *var, const char *value)
77 diff_detect_rename_default = DIFF_DETECT_RENAME;
78 return 0;
79 }
80 - if (!prefixcmp(var, "diff.color.") || !strncmp(var, "color.diff.", 11)) {
80 + if (!prefixcmp(var, "diff.color.") || !prefixcmp(var, "color.diff.")) {
81 int slot = parse_diff_color_slot(var, 11);
82 color_parse(value, var, diff_colors[slot]);
83 return 0;
http-fetch.c
+1 -1
@@ -718,7 +718,7 @@ static int fetch_indices(struct alt_base *repo)
718 i++;
719 if (i + 52 <= buffer.posn &&
720 !prefixcmp(data + i, " pack-") &&
721 - !strncmp(data + i + 46, ".pack\n", 6)) {
721 + !prefixcmp(data + i + 46, ".pack\n")) {
722 get_sha1_hex(data + i + 6, sha1);
723 setup_index(repo, sha1);
724 i += 51;
http-push.c
+1 -1
@@ -1061,7 +1061,7 @@ static int fetch_indices(void)
1061 i++;
1062 if (i + 52 < buffer.posn &&
1063 !prefixcmp(data + i, " pack-") &&
1064 - !strncmp(data + i + 46, ".pack\n", 6)) {
1064 + !prefixcmp(data + i + 46, ".pack\n")) {
1065 get_sha1_hex(data + i + 6, sha1);
1066 setup_index(sha1);
1067 i += 51;
imap-send.c
+4 -4
@@ -1192,7 +1192,7 @@ count_messages( msg_data_t *msg )
1192 char *p = msg->data;
1193
1194 while (1) {
1195 - if (!strncmp( "From ", p, 5 )) {
1195 + if (!prefixcmp(p, "From ")) {
1196 count++;
1197 p += 5;
1198 }
@@ -1216,7 +1216,7 @@ split_msg( msg_data_t *all_msgs, msg_data_t *msg, int *ofs )
1216 data = &all_msgs->data[ *ofs ];
1217 msg->len = all_msgs->len - *ofs;
1218
1219 - if (msg->len < 5 || strncmp( data, "From ", 5 ))
1219 + if (msg->len < 5 || prefixcmp(data, "From "))
1220 return 0;
1221
1222 p = strchr( data, '\n' );
@@ -1267,12 +1267,12 @@ git_imap_config(const char *key, const char *val)
1267 imap_folder = xstrdup( val );
1268 } else if (!strcmp( "host", key )) {
1269 {
1270 - if (!strncmp( "imap:", val, 5 ))
1270 + if (!prefixcmp(val, "imap:"))
1271 val += 5;
1272 if (!server.port)
1273 server.port = 143;
1274 }
1275 - if (!strncmp( "//", val, 2 ))
1275 + if (!prefixcmp(val, "//"))
1276 val += 2;
1277 server.host = xstrdup( val );
1278 }
revision.c
+1 -1
@@ -832,7 +832,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
832 revs->max_count = atoi(argv[++i]);
833 continue;
834 }
835 - if (!strncmp(arg,"-n",2)) {
835 + if (!prefixcmp(arg, "-n")) {
836 revs->max_count = atoi(arg + 2);
837 continue;
838 }
wt-status.c
+1 -1
@@ -344,7 +344,7 @@ int git_status_config(const char *k, const char *v)
344 wt_status_use_color = git_config_colorbool(k, v);
345 return 0;
346 }
347 - if (!prefixcmp(k, "status.color.") || !strncmp(k, "color.status.", 13)) {
347 + if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
348 int slot = parse_status_slot(k, 13);
349 color_parse(v, k, wt_status_colors[slot]);
350 }