Jeff King <peff@xxxxxxxx> writes: > On Tue, Jun 30, 2015 at 09:22:18AM -0700, Junio C Hamano wrote: > >> Jeff King <peff@xxxxxxxx> writes: >> >> >> strbuf_addf(&f, "%s ", fmt); >> > >> > Basically I was trying to avoid making any assumptions about exactly how >> > strftime works. But presumably "stick a space in the format" is a >> > universally reasonable thing to do. It's a hack, but it's contained to >> > the function. >> >> Why can't I shake this feeling that (" %s", fmt), i.e. prepend not >> append, is the safer thing to do than to append? > > Because then removing the extra space involves `memmove` of the buffer, > rather than just shortening the length by one. That does not explain why I feel the other way is safer, though ;-) In any case, responding myself to my other question, strftime(3) does not define any useful error information even for a case where you feed nonsense format to it, so it is even not possible to protect ourselves by checking errno or doing something similar X-<. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html