Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
Add strbuf_cmp.
author
Pierre Habouzit
<madcoder@debian.org>
Mon, 24 Sep 2007 09:25:03 +0000
(11:25 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 26 Sep 2007 09:27:05 +0000
(
02:27
-0700)
Signed-off-by: Junio C Hamano <gitster@pobox.com>
strbuf.c
patch
|
blob
|
history
strbuf.h
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
a8f3e22
)
diff --git
a/strbuf.c
b/strbuf.c
index dcb725dcdd2f8edb04502fed425bd3b7a7204ebf..d5e92ee17257ea3a3ff53580b0df011d4994240a 100644
(file)
--- a/
strbuf.c
+++ b/
strbuf.c
@@
-50,6
+50,18
@@
void strbuf_rtrim(struct strbuf *sb)
sb->buf[sb->len] = '\0';
}
sb->buf[sb->len] = '\0';
}
+int strbuf_cmp(struct strbuf *a, struct strbuf *b)
+{
+ int cmp;
+ if (a->len < b->len) {
+ cmp = memcmp(a->buf, b->buf, a->len);
+ return cmp ? cmp : -1;
+ } else {
+ cmp = memcmp(a->buf, b->buf, b->len);
+ return cmp ? cmp : a->len != b->len;
+ }
+}
+
void strbuf_splice(struct strbuf *sb, size_t pos, size_t len,
const void *data, size_t dlen)
{
void strbuf_splice(struct strbuf *sb, size_t pos, size_t len,
const void *data, size_t dlen)
{
diff --git
a/strbuf.h
b/strbuf.h
index 3b19de3048bf9d96feb11380e743db2034acad50..fd683893341723f29301b6ddb51955857b3ffee9 100644
(file)
--- a/
strbuf.h
+++ b/
strbuf.h
@@
-78,6
+78,7
@@
static inline void strbuf_setlen(struct strbuf *sb, size_t len) {
/*----- content related -----*/
extern void strbuf_rtrim(struct strbuf *);
/*----- content related -----*/
extern void strbuf_rtrim(struct strbuf *);
+extern int strbuf_cmp(struct strbuf *, struct strbuf *);
/*----- add data in your buffer -----*/
static inline void strbuf_addch(struct strbuf *sb, int c) {
/*----- add data in your buffer -----*/
static inline void strbuf_addch(struct strbuf *sb, int c) {