aboutsummaryrefslogtreecommitdiffstats
path: root/parse-options.c
diff options
context:
space:
mode:
authorChristian Couder <chriscool@tuxfamily.org>2013-11-30 21:55:40 +0100
committerJunio C Hamano <gitster@pobox.com>2013-12-05 14:13:21 -0800
commit59556548230e617b837343c2c07e357e688e2ca4 (patch)
tree5e66894c3d666f0fdc39aaf79de554dfeb7d0e36 /parse-options.c
parent956623157f828b2b4fd91a9bc5e78ba8e42437d9 (diff)
downloadgit-59556548230e617b837343c2c07e357e688e2ca4.tar.gz
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 <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options.c')
-rw-r--r--parse-options.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/parse-options.c b/parse-options.c
index 62e9b1cc68..7b8d3faa17 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -273,13 +273,13 @@ is_abbreviated:
if (options->flags & PARSE_OPT_NONEG)
continue;
/* negated and abbreviated very much? */
- if (!prefixcmp("no-", arg)) {
+ if (starts_with("no-", arg)) {
flags |= OPT_UNSET;
goto is_abbreviated;
}
/* negated? */
- if (prefixcmp(arg, "no-")) {
- if (!prefixcmp(long_name, "no-")) {
+ if (!starts_with(arg, "no-")) {
+ if (starts_with(long_name, "no-")) {
long_name += 3;
opt_flags |= OPT_UNSET;
goto again;
@@ -289,7 +289,7 @@ is_abbreviated:
flags |= OPT_UNSET;
rest = skip_prefix(arg + 3, long_name);
/* abbreviated and negated? */
- if (!rest && !prefixcmp(long_name, arg + 3))
+ if (!rest && starts_with(long_name, arg + 3))
goto is_abbreviated;
if (!rest)
continue;
@@ -334,7 +334,7 @@ static void check_typos(const char *arg, const struct option *options)
if (strlen(arg) < 3)
return;
- if (!prefixcmp(arg, "no-")) {
+ if (starts_with(arg, "no-")) {
error ("did you mean `--%s` (with two dashes ?)", arg);
exit(129);
}
@@ -342,7 +342,7 @@ static void check_typos(const char *arg, const struct option *options)
for (; options->type != OPTION_END; options++) {
if (!options->long_name)
continue;
- if (!prefixcmp(options->long_name, arg)) {
+ if (starts_with(options->long_name, arg)) {
error ("did you mean `--%s` (with two dashes ?)", arg);
exit(129);
}