-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsort_iriclib_funcs.php
70 lines (63 loc) · 1.67 KB
/
sort_iriclib_funcs.php
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
64
65
66
67
68
69
70
<?php
$fp = fopen("iriclib.c", "r");
$funcs = array();
while (! feof($fp)){
$line = fgets($fp);
if (preg_match("/^(static |) *([a-zA-Z]+) +([a-zA-Z0-9_]+)\\((.*)\\)/", $line, $matches)){
$funcname = $matches[3];
$funclines = array();
$funclines[] = rtrim($line);
$nestdepth = 0;
$nestdepth += substr_count($line, "{");
$nestdepth -= substr_count($line, "}");
} else {
$trimmedline = trim($line);
if ($trimmedline == "" && $nestdepth == 0){continue;}
if (substr($trimmedline, 0, 2) == "//" && $nestdepth == 0){continue;}
$funclines[] = rtrim($line);
$nestdepth += substr_count($line, "{");
$nestdepth -= substr_count($line, "}");
if ($nestdepth == 0){
$funcs[$funcname] = $funclines;
}
}
}
// print_r($funcs);
// exit;
fclose($fp);
// output local functions.
$outputfuncs = array();
foreach ($funcs as $funcname => $funclines){
if (FALSE !== strpos($funcname, "local_")){
foreach ($funclines as $l){
echo $l, "\n";
}
echo "\n";
$outputfuncs[] = $funcname;
}
}
$fp =fopen("iriclib.h", "r");
while (! feof($fp)){
$line = fgets($fp);
// echo $line;
if (preg_match("/^ *([a-zA-Z]+) +([a-zA-Z0-9_]+)\\((.*)\\)/", $line, $matches)){
$funcname = $matches[2];
if (! isset($funcs[$funcname])){
echo "Warning: No implementation for ", $funcname, "\n";
} else {
$funclines = $funcs[$funcname];
foreach ($funclines as $l){
echo $l, "\n";
}
echo "\n";
$outputfuncs[] = $funcname;
}
}
}
fclose($fp);
foreach ($funcs as $funcname => $funclines){
if (array_search($funcname, $outputfuncs) === FALSE){
echo "WARNING Not output function: ", $funcname, "\n";
}
}
?>