From 59556548230e617b837343c2c07e357e688e2ca4 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 30 Nov 2013 21:55:40 +0100 Subject: replace {pre,suf}fixcmp() with {starts,ends}_with() Leaving only the function definitions and declarations so that any new topic in flight can still make use of the old functions, replace existing uses of the prefixcmp() and suffixcmp() with new API functions. The change can be recreated by mechanically applying this: $ git grep -l -e prefixcmp -e suffixcmp -- \*.c | grep -v strbuf\\.c | xargs perl -pi -e ' s|!prefixcmp\(|starts_with\(|g; s|prefixcmp\(|!starts_with\(|g; s|!suffixcmp\(|ends_with\(|g; s|suffixcmp\(|!ends_with\(|g; ' on the result of preparatory changes in this series. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- remote-testsvn.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'remote-testsvn.c') diff --git a/remote-testsvn.c b/remote-testsvn.c index d7cd5d272f..078f1ffa41 100644 --- a/remote-testsvn.c +++ b/remote-testsvn.c @@ -82,7 +82,7 @@ static int parse_rev_note(const char *msg, struct rev_note *res) len = end ? end - msg : strlen(msg); key = "Revision-number: "; - if (!prefixcmp(msg, key)) { + if (starts_with(msg, key)) { long i; char *end; value = msg + strlen(key); @@ -154,7 +154,7 @@ static void check_or_regenerate_marks(int latestrev) } else { strbuf_addf(&sb, ":%d ", latestrev); while (strbuf_getline(&line, marksfile, '\n') != EOF) { - if (!prefixcmp(line.buf, sb.buf)) { + if (starts_with(line.buf, sb.buf)) { found++; break; } @@ -264,7 +264,7 @@ static int do_command(struct strbuf *line) return 1; /* end of command stream, quit */ } if (batch_cmd) { - if (prefixcmp(batch_cmd->name, line->buf)) + if (!starts_with(batch_cmd->name, line->buf)) die("Active %s batch interrupted by %s", batch_cmd->name, line->buf); /* buffer batch lines */ string_list_append(&batchlines, line->buf); @@ -272,7 +272,7 @@ static int do_command(struct strbuf *line) } for (p = input_command_list; p->name; p++) { - if (!prefixcmp(line->buf, p->name) && (strlen(p->name) == line->len || + if (starts_with(line->buf, p->name) && (strlen(p->name) == line->len || line->buf[strlen(p->name)] == ' ')) { if (p->batchable) { batch_cmd = p; @@ -304,7 +304,7 @@ int main(int argc, char **argv) remote = remote_get(argv[1]); url_in = (argc == 3) ? argv[2] : remote->url[0]; - if (!prefixcmp(url_in, "file://")) { + if (starts_with(url_in, "file://")) { dump_from_file = 1; url = url_decode(url_in + sizeof("file://")-1); } else { -- cgit v1.2.1