]> nuage.metani.fr Git - 3GPP.git/blob - bin/strip-unaffected.awk
Add strip-unaffected to remove unaffected IEs
[3GPP.git] / bin / strip-unaffected.awk
1 #!/bin/awk -f
2
3 BEGIN {
4 # A record is an IE heading
5 RS = "-- =+\n-- IE: [A-Z][A-Za-z0-9-]+"
6
7 # A field is a line
8 FS = "\n"
9
10 ORS = ""
11
12 # Usage explanation
13 if (ARGC != "3") {
14 print "Usage: " ARGV[0] "module.asn module-modified.asn"
15 print "Creates cr-module.asn and cr-module-modified.asn only including IEs"
16 print "that are different between module.asn and module-modified.asb"
17 exit
18 }
19
20 file = "origin"
21 }
22
23 BEGINFILE {
24 i = 1
25 ie_header = ""
26 }
27
28 {
29 if (ie_header != "") {
30 split(ie_header, header_fields, "-- IE: ")
31 ie_name = header_fields[2]
32
33 module_ie[file][i] = ie_name
34 module_ie_def[file][i] = ie_header $0
35
36 i++
37 }
38
39 ie_header = RT
40
41 }
42
43 ENDFILE {
44 file = "modified"
45 }
46
47 END {
48 stripped_origin = "stripped_" ARGV[1]
49 stripped_modified = "stripped_" ARGV[2]
50
51 i_origin = 1
52 i_modified = 1
53
54 # Process IEs of the original .asn
55 while (module_ie["origin"][i_origin] != "") {
56 i_modified_search = i_modified
57
58 # Search possibly until the end in the modified .asn for the same IE name
59 while ((module_ie["modified"][i_modified_search] != "") &&
60 (module_ie["modified"][i_modified_search] != module_ie["origin"][i_origin])) { i_modified_search++ }
61
62 # If the IE of the original .asn was found in the modified .asn
63 if (module_ie["modified"][i_modified_search] == module_ie["origin"][i_origin]) {
64
65 # Any IE in the modified .asn that was skipped is new, write it to the stripped modified file
66 i = i_modified
67 while (i < i_modified_search) {
68 print module_ie_def["modified"][i] > stripped_modified
69 i++
70 }
71
72 # If they are different
73 if (module_ie_def["modified"][i_modified_search] != module_ie_def["origin"][i_origin]) {
74 print module_ie_def["origin"][i_origin] > stripped_origin
75 print module_ie_def["modified"][i_modified_search] > stripped_modified
76 }
77
78 # Continue where we are
79 i_modified = i_modified_search + 1
80
81 }
82
83 # The IE of the original .asn was entirely deleted
84 else {
85 print module_ie_def["origin"][i_origin] > stripped_origin
86 }
87
88 i_origin++
89 }
90
91 while (module_ie["modified"][i_modified] != "") {
92 print module_ie_def["modified"][i_modified] > stripped_modified
93 i_modified++
94 }
95
96 }
97
98
99