aboutsummaryrefslogtreecommitdiff
path: root/manual/xtract-typefun.awk
blob: d39ceef188c1d001d054a7c83c6fa42d3fab4a02 (plain)
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
#! /usr/local/bin/gawk -f
BEGIN {
  last_node="";
}

/^@node/ {
  name = $0;
  sub(/^@node +/, "", name);
  sub(/[@,].*$/, "", name);
  last_node = name;
}

/^@deftype(fn|vr)/ {
# The string we want is $4, except that if there were brace blocks
# before that point then it gets shifted to the right, since awk
# doesn't know from brace blocks.
  id = 4; check = 2; squig = 0;
  while(check < id)
  {
    if($check ~ /{/) squig++;
    if($check ~ /}/) squig--;
    if(squig) id++;
    check++;
  }

  gsub(/[(){}*]/, "", $id);
  printf ("* %s: (libc)%s.\n", $id, last_node);
}

/^@deftypefun/ {
# Likewise, except it's $3 theoretically.
  id = 3; check = 2; squig = 0;
  while(check < id)
  {
    if($check ~ /{/) squig++;
    if($check ~ /}/) squig--;
    if(squig) id++;
    check++;
  }

  gsub(/[(){}*]/, "", $id);
  printf ("* %s: (libc)%s.\n", $id, last_node);
}