File: mkproto.awk

package info (click to toggle)
rsync 3.2.3-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 4,612 kB
  • sloc: ansic: 42,277; sh: 5,922; perl: 930; python: 825; asm: 665; makefile: 349; cpp: 289; awk: 191
file content (40 lines) | stat: -rw-r--r-- 901 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/awk -f

BEGIN {
    while ((getline i < "proto.h") > 0) old_protos = old_protos ? old_protos "\n" i : i
    close("proto.h")
    protos = "/* This file is automatically generated with \"make proto\". DO NOT EDIT */\n"
}

inheader {
    protos = protos "\n" ((inheader = /\)[ \t]*$/ ? 0 : 1) ? $0 : $0 ";")
    next
}

/^FN_(LOCAL|GLOBAL)_[^(]+\([^,()]+/ {
    local = /^FN_LOCAL/
    gsub(/^FN_(LOC|GLOB)AL_|,.*$/, "")
    sub(/^BOOL\(/, "BOOL ")
    sub(/^CHAR\(/, "char ")
    sub(/^INTEGER\(/, "int ")
    sub(/^STRING\(/, "char *")
    protos = protos "\n" $0 (local ? "(int module_id);" : "(void);")
    next
}

/^static|^extern|;/||!/^[A-Za-z][A-Za-z0-9_]* / { next }

/\(.*\)[ \t]*$/ {
    protos = protos "\n" $0 ";"
    next
}

/\(/ {
    inheader = 1
    protos = protos "\n" $0
}

END {
    if (old_protos != protos) print protos > "proto.h"
    system("touch proto.h-tstamp")
}