Tranform the assignments from ifs.
Here is the script used:
{
macros[1] = "NSK_VERIFY"
macros[2] = "NSK_JNI_VERIFY"
macros[3] = "NSK_JVMTI_VERIFY"
indentation = gensub(/([ ]*).*/, "\\1" , "g", $0)
pattern = ".*NULL)(.*)"
suffix = gensub(pattern, "\\1" , "g", $0)
comparator = gensub(/.* (..) NULL.*/, "\\1", "g", $0)
for (m in macros) {
macro = macros[m]
pattern = macro "((.* = .* .. NULL))"
if ($0 ~ pattern) {
pattern = "(.*" macro "\\().*"
prefix = gensub(pattern, "\\1", "g", $0)
pattern = ".*" macro "\\(\\((.*)\\) .. NULL)).*"
assignment = gensub(pattern, "\\1" , "g", $0)
dest = gensub(/(.*) =.*/, "\\1" , "g", assignment)
print indentation assignment ";"
print prefix dest " " comparator " NULL)" suffix
next
}
}
if ($0 ~ "((.* = .* .. NULL))") {
assignment = gensub(/.*\(\((.*)) .. NULL).*/, "\\1" , "g", $0)
prefix = gensub(/(.*if \().*/, "\\1", "g", $0)
dest = gensub(/(.*) =.*/, "\\1" , "g", assignment)
print indentation assignment ";"
print prefix dest " " comparator " NULL)" suffix
next
}
# No macro...
print $0
}
Here is the script used:
{
macros[1] = "NSK_VERIFY"
macros[2] = "NSK_JNI_VERIFY"
macros[3] = "NSK_JVMTI_VERIFY"
indentation = gensub(/([ ]*).*/, "\\1" , "g", $0)
pattern = ".*NULL)(.*)"
suffix = gensub(pattern, "\\1" , "g", $0)
comparator = gensub(/.* (..) NULL.*/, "\\1", "g", $0)
for (m in macros) {
macro = macros[m]
pattern = macro "((.* = .* .. NULL))"
if ($0 ~ pattern) {
pattern = "(.*" macro "\\().*"
prefix = gensub(pattern, "\\1", "g", $0)
pattern = ".*" macro "\\(\\((.*)\\) .. NULL)).*"
assignment = gensub(pattern, "\\1" , "g", $0)
dest = gensub(/(.*) =.*/, "\\1" , "g", assignment)
print indentation assignment ";"
print prefix dest " " comparator " NULL)" suffix
next
}
}
if ($0 ~ "((.* = .* .. NULL))") {
assignment = gensub(/.*\(\((.*)) .. NULL).*/, "\\1" , "g", $0)
prefix = gensub(/(.*if \().*/, "\\1", "g", $0)
dest = gensub(/(.*) =.*/, "\\1" , "g", assignment)
print indentation assignment ";"
print prefix dest " " comparator " NULL)" suffix
next
}
# No macro...
print $0
}