Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
imap-send: simplify v_issue_imap_cmd() and get_cmd_result() using starts_with()
author
René Scharfe
<l.s.r@web.de>
Sat, 30 Aug 2014 16:14:24 +0000
(18:14 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Tue, 2 Sep 2014 19:26:23 +0000
(12:26 -0700)
Use starts_with() instead of memcmp() to check if NUL-terminated
strings match prefixes. This gets rid of some magic string length
constants.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
imap-send.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
3918057
)
diff --git
a/imap-send.c
b/imap-send.c
index 05a02b51caaca56c11db5cd05c28a970d06ead8d..44fd5249e2afd5c73552c5537101e1fc99158ce4 100644
(file)
--- a/
imap-send.c
+++ b/
imap-send.c
@@
-526,7
+526,7
@@
static struct imap_cmd *v_issue_imap_cmd(struct imap_store *ctx,
if (Verbose) {
if (imap->num_in_progress)
printf("(%d in progress) ", imap->num_in_progress);
if (Verbose) {
if (imap->num_in_progress)
printf("(%d in progress) ", imap->num_in_progress);
- if (
memcmp(cmd->cmd, "LOGIN", 5
))
+ if (
!starts_with(cmd->cmd, "LOGIN"
))
printf(">>> %s", buf);
else
printf(">>> %d LOGIN <user> <pass>\n", cmd->tag);
printf(">>> %s", buf);
else
printf(">>> %d LOGIN <user> <pass>\n", cmd->tag);
@@
-829,7
+829,7
@@
static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd)
} else /*if (!strcmp("BAD", arg))*/
resp = RESP_BAD;
fprintf(stderr, "IMAP command '%s' returned response (%s) - %s\n",
} else /*if (!strcmp("BAD", arg))*/
resp = RESP_BAD;
fprintf(stderr, "IMAP command '%s' returned response (%s) - %s\n",
-
memcmp(cmdp->cmd, "LOGIN", 5
) ?
+
!starts_with(cmdp->cmd, "LOGIN"
) ?
cmdp->cmd : "LOGIN <user> <pass>",
arg, cmd ? cmd : "");
}
cmdp->cmd : "LOGIN <user> <pass>",
arg, cmd ? cmd : "");
}