githelper.git / githelper.pike

version» Context lines:

githelper.git/githelper.pike:339:    GitAttributes attrs;       string get_file(string filename, int|void allow_empty);    string get_old_file(string filename, int|void allow_empty);    int entry_is_new(string filename) { return 0; }       int find_expanded_ident(string data)    {    int p=0;    while ((p = search(data, DOLLAR"Id", p))>=0) { -  if (data[p..p+3] != unexpanded_id) +  if (data[p..p+3] != unexpanded_id) { +  int p2 = search(data, DOLLAR, p+3), p3 = search(data, "\n", p+3); +  if (p2 > p && (p3 < 0 || p2 < p3))    return 1; -  +  }    p += 4;    }    return 0;    }       int check_ident(string filename)    {    if (find_expanded_ident(get_file(filename, 2))) {    write("File %s contains an expanded ident.\n", filename);    if(this_program == PreCommitHook) {
githelper.git/githelper.pike:717:   /* Filters */      /* A sample filter, not really useful... */      class NiceIdentFilter   {    static string replace_id(string f, function(string:string) replace) {    int p=0;    while((p=search(f, DOLLAR"Id", p)) >= 0) {    int p2 = search(f, DOLLAR, p+3), p3 = search(f, "\n", p+3); -  if (p2 > p && p2 < p3) { +  if (p2 > p && (p3 < 0 || p2 < p3)) {    string r = replace(f[p..p2]);    if (r) {    // werror("Replacing %O with %O\n", f[p..p2], r);    f = f[..p-1]+r+f[p2+1..];    p += sizeof(r);    } else {    // werror("Not replacing %O\n", f[p..p2]);    p = p2+1;    }    } else p += 3;