diff options
-rw-r--r-- | .gitignore | 10 | ||||
-rwxr-xr-x | sortrefl | 51 |
2 files changed, 61 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5090361 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +checkpkgist/ +diffrpmtree +docker/ +ffi-examples/ +git2rss/ +mine.lst +mock/ +myrpms +repodata/ + diff --git a/sortrefl b/sortrefl new file mode 100755 index 0000000..f38efb5 --- /dev/null +++ b/sortrefl @@ -0,0 +1,51 @@ +#!/usr/bin/php +<?php +if ($_SERVER['argc'] < 2) { + die("usage %s filename\n"); +} +$in = fopen($name = $_SERVER['argv'][1], "r"); +if (!$in) { + die("Can't read input file $name\n"); +} + +$res = []; +$tab = []; +$class = $method = false; +fprintf(STDERR, "Reading $name:\n"); +while ($buf = fgets($in)) { + if (preg_match("/Class .* class ([^ ]*) /", $buf, $m)) { + $class = strtolower($m[1]); + $res[$class] = []; + $tab[$class] = $buf; + fprintf(STDERR, "+ $class\n"); + } else if (preg_match("/Method .* method ([^ ]*) /", $buf, $m)) { + $method = strtolower($m[1]); + $res[$class][$method] = ''; + fprintf(STDERR, "+ $method\n"); + } + + if ($class) { + if ($method) { + $res[$class][$method] .= $buf; + } + } + + if (strpos($buf, "}") == 8) { + $method = false; + } else if (strpos($buf, "}") == 4) { + $class = false; + } +} + +ksort($res); +foreach ($res as $class => $methods) { + echo $tab[$class]; + + ksort($methods); + foreach ($methods as $method => $def) { + echo $def; + } +} +fprintf(STDERR, "\nDone\n"); +fclose($in); +?> |