git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Couder <chriscool@tuxfamily.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
	Antoine Pelisse <apelisse@gmail.com>,
	Avery Pennarun <apenwarr@gmail.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Jonathan Nieder <jrnieder@gmail.com>, Max Horn <max@quendi.de>,
	Andreas Ericsson <ae@op5.se>
Subject: [PATCH 5/5] strbuf: remove prefixcmp() and suffixcmp()
Date: Sun, 01 Dec 2013 08:49:18 +0100	[thread overview]
Message-ID: <20131201074919.3042.68588.chriscool@tuxfamily.org> (raw)
In-Reply-To: <20131201074818.3042.57357.chriscool@tuxfamily.org>

As starts_with() and ends_with() have been used to
replace prefixcmp() and suffixcmp() respectively,
we can now remove them.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 git-compat-util.h |  2 --
 strbuf.c          | 18 ------------------
 2 files changed, 20 deletions(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index b73916b..c4c01e7 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -351,9 +351,7 @@ extern void set_error_routine(void (*routine)(const char *err, va_list params));
 extern void set_die_is_recursing_routine(int (*routine)(void));
 
 extern int starts_with(const char *str, const char *prefix);
-extern int prefixcmp(const char *str, const char *prefix);
 extern int ends_with(const char *str, const char *suffix);
-extern int suffixcmp(const char *str, const char *suffix);
 
 static inline const char *skip_prefix(const char *str, const char *prefix)
 {
diff --git a/strbuf.c b/strbuf.c
index 83caf4a..ee96dcf 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -10,15 +10,6 @@ int starts_with(const char *str, const char *prefix)
 			return 0;
 }
 
-int prefixcmp(const char *str, const char *prefix)
-{
-	for (; ; str++, prefix++)
-		if (!*prefix)
-			return 0;
-		else if (*str != *prefix)
-			return (unsigned char)*prefix - (unsigned char)*str;
-}
-
 int ends_with(const char *str, const char *suffix)
 {
 	int len = strlen(str), suflen = strlen(suffix);
@@ -28,15 +19,6 @@ int ends_with(const char *str, const char *suffix)
 		return !strcmp(str + len - suflen, suffix);
 }
 
-int suffixcmp(const char *str, const char *suffix)
-{
-	int len = strlen(str), suflen = strlen(suffix);
-	if (len < suflen)
-		return -1;
-	else
-		return strcmp(str + len - suflen, suffix);
-}
-
 /*
  * Used as the default ->buf value, so that people can always assume
  * buf is non NULL and ->buf is NUL terminated even for a freshly
-- 
1.8.4.1.561.g12affca

  parent reply	other threads:[~2013-12-01  7:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-01  7:49 [PATCH 0/5] use starts_with() and ends_with() Christian Couder
2013-12-01  7:49 ` [PATCH 1/5] environment: normalize use of prefixcmp() by removing " != 0" Christian Couder
2013-12-01  7:49 ` [PATCH 2/5] builtin/remote: remove postfixcmp() and use suffixcmp() instead Christian Couder
2013-12-01  7:49 ` [PATCH 3/5] strbuf: introduce starts_with() and ends_with() Christian Couder
2013-12-01  7:49 ` Christian Couder [this message]
2013-12-02 15:09 ` [PATCH 0/5] use " Jeff King
2013-12-02 18:32   ` Junio C Hamano
2013-12-02 19:29     ` Christian Couder
2013-12-02 19:32       ` Antoine Pelisse
2013-12-03  6:06         ` Christian Couder
     [not found] ` <20131201074919.3042.92026.chriscool@tuxfamily.org>
     [not found]   ` <CAP8UFD0jg_Vr7Zf+DiMX9RG6vmmQvmk2NvmL7j=MC-x3fLOOBA@mail.gmail.com>
2013-12-03 12:46     ` Fwd: [PATCH 4/5] Replace {pre,suf}fixcmp() with {starts,ends}_with() Jeff King
2013-12-03 20:24       ` Christian Couder
2013-12-04 19:45         ` Jeff King
2013-12-04 20:51         ` Junio C Hamano
2013-12-04 22:02           ` Junio C Hamano
2013-12-05  7:19             ` Christian Couder
2013-12-05 18:04               ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131201074919.3042.68588.chriscool@tuxfamily.org \
    --to=chriscool@tuxfamily.org \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=ae@op5.se \
    --cc=apelisse@gmail.com \
    --cc=apenwarr@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=max@quendi.de \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).