strbuf: introduce starts_with() and ends_with()
commit956623157f828b2b4fd91a9bc5e78ba8e42437d9
authorChristian Couder <chriscool@tuxfamily.org>
Sun, 1 Dec 2013 07:49:16 +0000 (1 08:49 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Dec 2013 22:12:52 +0000 (5 14:12 -0800)
treeb081b8ea3eb225110374f985ca322bbb3a078156
parent3fb5aead2971c6181dbf143295c427175b8bf082
strbuf: introduce starts_with() and ends_with()

prefixcmp() and suffixcmp() share the common "cmp" suffix that
typically are used to name functions that can be used for ordering,
but they can't, because they are not antisymmetric:

        prefixcmp("foo", "foobar") < 0
        prefixcmp("foobar", "foo") == 0

We in fact do not use these functions for ordering.  Replace them
with functions that just check for equality.

Add starts_with() and end_with() that will be used to replace
prefixcmp() and suffixcmp(), respectively, as the first step.  These
are named after corresponding functions/methods in programming
languages, like Java, Python and Ruby.

In vcs-svn/fast_export.c, there was already an ends_with() function
that did the same thing. Let's use the new one instead while at it.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-compat-util.h
strbuf.c
vcs-svn/fast_export.c