]> git.saurik.com Git - apple/xnu.git/blob - libsyscall/xcodescripts/filter_mig.awk
xnu-4903.221.2.tar.gz
[apple/xnu.git] / libsyscall / xcodescripts / filter_mig.awk
1 #!/usr/bin/awk -f
2
3 # Usage: foo <template> <file>
4 # Searches through file for instances of 'kern_return_t $FOO'
5 # where $FOO is an line in the template file
6 # and prepends the first line in the template file.
7
8 # Example template format:
9 # __WATCHOS_PROHIBITED
10 # act_get_state
11 # thread_get_state
12 #
13
14 # BEGIN { print ARGV[1]; print ARGV[2] }
15
16 # In the first file, build array of lines
17 NR==FNR {
18 if (NR==1)
19 prefix=$0
20 else
21 templates[$0];
22 next
23 }
24
25 # In the second file, match kern_return_t <template>
26 # at the beginning of the line
27 # print the prefix line if found
28
29 /^kern_return_t/ {
30 # print "match"
31 if ($2 in templates) {
32 print prefix
33 }
34 }
35
36 # Pass through everything in the second file
37 { print }