git-submodule.sh: avoid "test <cond> -a/-o <cond>"
[gitweb.git] / strbuf.c
index 83caf4a9147e6788107fb5fd23e6d9e1d6f6267f..4d31567a1a6a67ae9697816d78da442f87ab5803 100644 (file)
--- 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
@@ -96,15 +78,8 @@ void strbuf_grow(struct strbuf *sb, size_t extra)
 
 void strbuf_trim(struct strbuf *sb)
 {
-       char *b = sb->buf;
-       while (sb->len > 0 && isspace((unsigned char)sb->buf[sb->len - 1]))
-               sb->len--;
-       while (sb->len > 0 && isspace(*b)) {
-               b++;
-               sb->len--;
-       }
-       memmove(sb->buf, b, sb->len);
-       sb->buf[sb->len] = '\0';
+       strbuf_rtrim(sb);
+       strbuf_ltrim(sb);
 }
 void strbuf_rtrim(struct strbuf *sb)
 {