summaryrefslogtreecommitdiff
path: root/tool/gperf.sed
blob: 6b3e1980be9b5c4a8dd230efa0c433070b31e9cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/ANSI-C code/{
  h
  s/.*/ANSI:offset:/
  x
}
/\/\*!ANSI{\*\//{
  G
  s/\/\*!ANSI{\*\/\(.*\)\/\*}!ANSI\*\/\(.*\)\nANSI:.*/\/\*\1\*\/\2/
}
s/(int)([a-z_]*)&((struct \([a-zA-Z_0-9][a-zA-Z_0-9]*\)_t *\*)0)->\1_str\([1-9][0-9]*\),/gperf_offsetof(\1, \2),/g
/^#line/{
  G
  x
  s/:offset:/:/
  x
  s/\(.*\)\(\n\).*:offset:.*/#define gperf_offsetof(s, n) (short)offsetof(struct s##_t, s##_str##n)\2\1/
  s/\n[^#].*//
}
/^[a-zA-Z_0-9]*hash/,/^}/{
  s/ hval = / hval = (unsigned int)/
  s/ return / return (unsigned int)/
}