On Fri, Dec 20, 2013 at 6:32 AM, René Scharfe <l....@web.de> wrote:
> Seeing that skip_prefix_defval is mostly used in the form
> skip_prefix_defval(foo, prefix, foo) I wonder if it makes sense to
> first change skip_prefix to return the full string instead of NULL
> if the prefix is not matched.  Would the resulting function cover
> most use cases?  And would it still be easily usable?

That was skip_prefix_gently() that I forgot to replace in a commit
message, before I turned it into _defval variant. The reason for
_defval is it could be use to chain expression together without adding
temporary variables, e.g.

-       if (starts_with(line->buf, ">From") && isspace(line->buf[5])) {
+       if (isspace(*skip_prefix_defval(line->buf, ">From", "NOSPACE"))) {

Without _defval, one would need to do if ((p = skip_prefix(..)) &&
isspace(*p)). I'm not entirely sure this is a good thing though as it
could make it a bit harder to read.
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to