Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/strbuf.c b/strbuf.c
index ac5a7ab62d..8007be8fba 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -11,6 +11,28 @@ int starts_with(const char *str, const char *prefix)
return 0;
}
+int skip_to_optional_arg_default(const char *str, const char *prefix,
+ const char **arg, const char *def)
+{
+ const char *p;
+
+ if (!skip_prefix(str, prefix, &p))
+ return 0;
+
+ if (!*p) {
+ if (arg)
+ *arg = def;
+ return 1;
+ }
+
+ if (*p != '=')
+ return 0;
+
+ if (arg)
+ *arg = p + 1;
+ return 1;
+}
+
/*
* 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