githelper.git/
githelper.pike
Branch:
Tag:
Non-build tags
All tags
No tags
2010-09-26
2010-09-26 17:24:49 by Marcus Comstedt <marcus@mc.pp.se>
19bf736e481b4a2b464a43377962dc83b00965fb (
23
lines) (+
12
/-
11
)
[
Show
|
Annotate
]
Branch:
master
Pre-reverse attribute arrays for simpler access.
137:
} else { sscanf(line, "%s%*[ ]%s", name, line); }
-
return MatchAttr(name, is_macro, map(line/" "-({""}), parse_attr));
+
return MatchAttr(name, is_macro,
reverse(
map(line/" "-({""}), parse_attr))
)
;
} static void handle_attr_line(string line, int macro_ok)
150:
{ foreach(data/"\n", string line) handle_attr_line(line, 1);
+
attrs = reverse(attrs);
} static int path_matches(string path, string pattern)
164:
static void macroexpand_one(string attrname, array(MatchAttr) attrs, mapping(string:string|int) all_attr) {
-
MatchAttr
a
= 0;
+
MatchAttr
ma
= 0;
if(all_attr[attrname] != ATTR_TRUE) return;
-
for
(
int i=sizeof(
attrs
)-1;
i>=0;
--i
)
-
if(
attrs[i]
->is_macro &&
attrs[i]
->name == attrname)
-
a
=
attrs[i]
;
-
if(
a
) fill_one(
a
, attrs, all_attr);
+
foreach
(attrs
,
MatchAttr
a
)
+
if(
a
->is_macro &&
a
->name == attrname)
+
ma
=
a
;
+
if(
ma
) fill_one(
ma
, attrs, all_attr);
} static void fill_one(MatchAttr attr, array(MatchAttr) attrs, mapping(string:string|int) all_attr) {
-
for
(
int i = sizeof(
attr->states
)-1;
i>=0; --i) {
-
AttrState s
= attr->states[i];
+
foreach
(attr->states
,
AttrState
s
) {
if(!all_attr[s->attr]) { all_attr[s->attr] = s->setto; macroexpand_one(s->attr, attrs, all_attr);
188:
static void fill(string path, array(MatchAttr) attrs, mapping(string:string|int) all_attr) {
-
for
(
int i=sizeof(
attrs
)-1;
i>=0;
--i
)
-
if(!
attrs[i]
->is_macro && path_matches(path,
attrs[i]
->name))
-
fill_one(
attrs[i]
, attrs, all_attr);
+
foreach
(attrs
,
MatchAttr
a
)
+
if(!
a
->is_macro && path_matches(path,
a
->name))
+
fill_one(
a
, attrs, all_attr);
} mapping(string:string|int) checkattr(string path)