githelper.git / githelper.pike

version» Context lines:

githelper.git/githelper.pike:130:    if(!sizeof(line) || line[0] == '#')    return 0;    if(has_prefix(line, "[attr]")) {    if(!macro_ok)    fail("%s not allowed\n", name);    is_macro=1;    sscanf(line, "[attr]%*[ ]%s%*[ ]%s", name, line);    } 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)    {    MatchAttr a = parse_attr_line(line, macro_ok);    if(a) attrs += ({ a });    }       static void create(string data)    {    foreach(data/"\n", string line)    handle_attr_line(line, 1); -  +  attrs = reverse(attrs);    }       static int path_matches(string path, string pattern)    {    if(search(pattern, "/")<0)    return glob(pattern, (path/"/")[-1]);    if(has_prefix(pattern, "/"))    pattern = pattern[1..];    return glob(pattern, path);    }       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);    }    }    }       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)    {    mapping(string:string|int) all_attr = ([]);    fill(path, attrs, all_attr);    return all_attr;    }       array(string) findattr(string attrname)