#!/bin/sed -f # Hide functions with leading underscores. # Used for patching the pcc-libs tree. # Since we need to patch the line before the one that matches a pattern, # we must use the hold space. # Method: # hold/delete line one # if this line matches, swap for last line, modify pattern space, swap back # swap with last line, so we print it and save this line for next # at the end, print the prior line, then swap it for the last line 1{h;d} /^_.*(.*)$/{x;s/^\(.*\)$/__attribute__((__visibility__("hidden"))) \1/;x} 2,$x ${p;x}