From: David Lecompte <3gpp@metani.eu> Date: Sun, 2 Aug 2026 15:48:33 +0000 (+0200) Subject: Add strip-unaffected to remove unaffected IEs X-Git-Url: https://nuage.metani.fr/gitweb/3GPP.git/commitdiff_plain/95338e97eb03b237c33f89c503fb38046803c2fc?ds=sidebyside;hp=60f412d7df17508c78c77f948163ae22f21c35b3 Add strip-unaffected to remove unaffected IEs --- diff --git a/bin/strip-unaffected.awk b/bin/strip-unaffected.awk new file mode 100755 index 0000000..cdb4224 --- /dev/null +++ b/bin/strip-unaffected.awk @@ -0,0 +1,99 @@ +#!/bin/awk -f + +BEGIN { + # A record is an IE heading + RS = "-- =+\n-- IE: [A-Z][A-Za-z0-9-]+" + + # A field is a line + FS = "\n" + + ORS = "" + + # Usage explanation + if (ARGC != "3") { + print "Usage: " ARGV[0] "module.asn module-modified.asn" + print "Creates cr-module.asn and cr-module-modified.asn only including IEs" + print "that are different between module.asn and module-modified.asb" + exit + } + + file = "origin" +} + +BEGINFILE { + i = 1 + ie_header = "" +} + +{ + if (ie_header != "") { + split(ie_header, header_fields, "-- IE: ") + ie_name = header_fields[2] + + module_ie[file][i] = ie_name + module_ie_def[file][i] = ie_header $0 + + i++ + } + + ie_header = RT + +} + +ENDFILE { + file = "modified" +} + +END { + stripped_origin = "stripped_" ARGV[1] + stripped_modified = "stripped_" ARGV[2] + + i_origin = 1 + i_modified = 1 + + # Process IEs of the original .asn + while (module_ie["origin"][i_origin] != "") { + i_modified_search = i_modified + + # Search possibly until the end in the modified .asn for the same IE name + while ((module_ie["modified"][i_modified_search] != "") && + (module_ie["modified"][i_modified_search] != module_ie["origin"][i_origin])) { i_modified_search++ } + + # If the IE of the original .asn was found in the modified .asn + if (module_ie["modified"][i_modified_search] == module_ie["origin"][i_origin]) { + + # Any IE in the modified .asn that was skipped is new, write it to the stripped modified file + i = i_modified + while (i < i_modified_search) { + print module_ie_def["modified"][i] > stripped_modified + i++ + } + + # If they are different + if (module_ie_def["modified"][i_modified_search] != module_ie_def["origin"][i_origin]) { + print module_ie_def["origin"][i_origin] > stripped_origin + print module_ie_def["modified"][i_modified_search] > stripped_modified + } + + # Continue where we are + i_modified = i_modified_search + 1 + + } + + # The IE of the original .asn was entirely deleted + else { + print module_ie_def["origin"][i_origin] > stripped_origin + } + + i_origin++ + } + + while (module_ie["modified"][i_modified] != "") { + print module_ie_def["modified"][i_modified] > stripped_modified + i_modified++ + } + +} + + +