~hww3/caudium

ref: 93d5a75fba08db71b832716377276978cdd7888d caudium/tools/autofooter.pike -rw-r--r-- 1.5 KiB
93d5a75fWilliam Welliver storage: method "None" was missing stop function. should fix error on shutdown 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env pike
// Generate inline auto-footer strings in Caudium files
#define THIS split[i][e+1]

#define ENDINGS "\n" \
"/*\n" \
" * If you visit a file that doesn't contain these lines at its end, please\n" \
" * cut and paste everything from here to that file.\n" \
" */\n" \
"\n" \
"/*\n" \
" * Local Variables:\n" \
" * c-basic-offset: 2\n" \
" * End:\n" \
" *\n" \
" * vim: softtabstop=2 tabstop=2 expandtab autoindent formatoptions=croqlt smartindent cindent shiftwidth=2\n" \
" */\n" \
"\n" 


#define SEP "\n/* START AUTOGENERATED ENDINGS FOOTER */\n\n"

int main(int argc, array(string) argv)
{
  
  foreach(argv[1..], string file) {
    string doc = SEP;
    string origdata;
/*
    if((file / ".")[-1] != "pike")
      continue;
*/
    string data = Stdio.read_file(file);
    origdata = data;
    if(!data) continue;
    array split;
    sscanf(data, "%s\n/* START AUTOGENERATED ENDINGS FOOTER", data);
      
    array err = catch {
      split = Parser.Pike->group(Parser.Pike->hide_whitespaces(Parser.Pike->tokenize(Parser.Pike->split(data))));
      if(!arrayp(split))
	continue;
      if(doc != SEP) {
	data += doc;
	if(data != origdata) {
	  if(!mv(file, file+"~")) {
	    werror("Failed to write backup-file "+file+"~ - aborting.\n");
	    exit(1);
	  }
          data += ENDINGS;
	  Stdio.write_file(file, data);
	  write("+++ "+ file+" updated\n");
	} else
	  write("    "+file+" unmodified\n");
      }
    };
    if(err) {
      werror("*** "+file+" failed.\n");
      werror(describe_backtrace(err));
    }
  }
}