Introduction
Introduction Statistics Contact Development Disclaimer Help
tproto.sh - ploot - simple plotting tools
git clone git://bitreich.org/ploot git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65…
Log
Files
Refs
Tags
README
---
tproto.sh (1328B)
---
1 #!/bin/sh
2 awk='
3 BEGIN {
4 tab = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\…
5 print "/**/"
6 }
7
8 END {
9 print ""
10 print "#endif"
11 }
12
13 # functions
14
15 args {
16 sub(/^[ \t]*/, " ")
17 args = args $0
18 }
19
20 /^[a-zA-Z0-9_]+\([][)(a-z_A-Z0-9*,. \t]*$/ {
21 if (match(type, "static") || match($0, ";$"))
22 next
23
24 symbol = $0
25 sub(/\(.*/, "", symbol)
26 sub(/[a-zA-Z0-9_]*\(/, "", $0)
27 if (symbol == "main")
28 next
29
30 args = $0
31 sub(/^[a-z]*\(/, "", args)
32 }
33
34 args && /\)$/ {
35 gsub(/[\n \t]+/, " ", args)
36
37 sub(/\)$/, "", args)
38
39 gsub(/[a-zA-Z0-9_]+\[[^]]*\]/, "[]", args)
40 gsub(/[*][a-zA-Z0-9_]+/, "*", args)
41 gsub(/[ ][a-zA-Z0-9_]+,/, ",", args)
42 gsub(/[ ][a-zA-Z0-9_]+$/, "", args)
43 gsub(/[ ][a-zA-Z0-9_]+\*/, "*", args)
44 gsub(/\.\.\.\$/, "...", args)
45 gsub(/void\)$/, "void", args)
46
47 printf("%s%s%s%s(%s);\n",
48 type, substr(tab, 1, 20 / 8 - (length(type) - 3) / 8),
49 symbol, substr(tab, 1, 30 / 8 - (length(symbol) - 1) / 8),
50 args)
51
52 args = ""
53 }
54
55 !args {
56 type = $0
57 }
58
59 # variables
60
61 /^[a-zA-Z][][ \t*a-z_A-Z0-9]*=.*[;{]$/ && $1 != "static" && $1 != "enum"…
62 sub(/ *=.*/, ";")
63 sub(/[ \t]*;$/, ";");
64 print
65 }
66 '
67
68 for file in src/*.c; do file=${file%.c}
69 grep -Fq '/**/' "$file.h" 2>/dev/null || continue
70 header=$(awk '$0 == "/**/" { exit(0) } 1' "$file.h"
71 awk "$awk" "$file.c")
72 printf '%s\n' "$header" >"$file.h"
73 done
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.