summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4c7517c)
raw | patch | inline | side by side (parent: 4c7517c)
author | Michael Haggerty <mhagger@alum.mit.edu> | |
Fri, 12 Aug 2011 21:43:07 +0000 (23:43 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 14 Aug 2011 22:01:59 +0000 (15:01 -0700) |
parse_attr() only needs access to the attr_state to which it should
store its results, not to the whole match_attr structure. This change
also removes the need for it to know num_attr. Change its signature
accordingly and add a comment.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
store its results, not to the whole match_attr structure. This change
also removes the need for it to know num_attr. Change its signature
accordingly and add a comment.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
attr.c | patch | blob | history |
index cac550decd477525560423f6118c1aa2ca91e6d1..f23f62a6b13239e19284e207f2e8ec87431048dd 100644 (file)
--- a/attr.c
+++ b/attr.c
static const char blank[] = " \t\r\n";
+/*
+ * Parse a whitespace-delimited attribute state (i.e., "attr",
+ * "-attr", "!attr", or "attr=value") from the string starting at src.
+ * If e is not NULL, write the results to *e. Return a pointer to the
+ * remainder of the string (with leading whitespace removed), or NULL
+ * if there was an error.
+ */
static const char *parse_attr(const char *src, int lineno, const char *cp,
- int num_attr, struct match_attr *res)
+ struct attr_state *e)
{
const char *ep, *equals;
int len;
len = equals - cp;
else
len = ep - cp;
- if (!res) {
+ if (!e) {
if (*cp == '-' || *cp == '!') {
cp++;
len--;
return NULL;
}
} else {
- struct attr_state *e;
-
- e = &(res->state[num_attr]);
if (*cp == '-' || *cp == '!') {
e->setto = (*cp == '-') ? ATTR__FALSE : ATTR__UNSET;
cp++;
cp = name + namelen;
cp = cp + strspn(cp, blank);
while (*cp) {
- cp = parse_attr(src, lineno, cp, num_attr, res);
+ cp = parse_attr(src, lineno, cp,
+ pass ? &(res->state[num_attr]) : NULL);
if (!cp)
return NULL;
num_attr++;