On Thu, Jan 15, 2015 at 02:44:14PM -0800, Kevin J. McCarthy wrote:
> Attached is a slightly revised version of this patch.  The main
> difference with this version is a refactoring of the IMAP flag
> generation code.  The previous patch added one flag too many to set
> using ternary operators.
> 
this is certainly not very relevant in this specific case, but
strcat-like functions just aren't a terribly efficient way to join
strings, unless you use built-ins which the compiler understands to a
sufficient degree to replace them with something better.

the explicit approach is an append function which returns the length of
the string it appended.

alternatively, one can use the glibc mempcpy() approach. then length
limiting would be based on an end pointer instead of size comparisons.

but whatever. ^^

> +  imap_flags[0] = imap_flags[1] = 0;
> +  if (msg->flags.read)
> +    safe_strcat (imap_flags, sizeof (imap_flags), " \\Seen");
> +  if (msg->flags.replied)
> +    safe_strcat (imap_flags, sizeof (imap_flags), " \\Answered");
> +  if (msg->flags.flagged)
> +    safe_strcat (imap_flags, sizeof (imap_flags), " \\Flagged");
> +  if (msg->flags.draft)
> +    safe_strcat (imap_flags, sizeof (imap_flags), " \\Draft");
> +
> +  snprintf (buf, sizeof (buf), "APPEND %s (%s) \"%s\" {%lu}", mbox,
> +            imap_flags + 1,

Reply via email to