1#!/usr/bin/sed -nEf 2 3# 4# Rules go 3 by 3: 5# 6# 1. try to rewrite `bitmap_t * __indexable foo` 7# into `bitmap_t *foo` removing all spaces. 8# 9# 2. try to rewrite `static inline bitmap_t * __indexable` 10# into `static inline bitmap_t *` collapsing redundant spaces. 11# 12# 3. just eliminate all other kinds of use of the keyword that missed (1) or (2). 13# 14s/\* *(__bidi_indexable|__indexable|__single|__unsafe_indexable) /*/g 15s/ (__bidi_indexable|__indexable|__single|__unsafe_indexable)( |$)/\2/g 16s/(__bidi_indexable|__indexable|__single|__unsafe_indexable)//g 17 18# 19# Those are approximate because matching parenthesis requires a C parser. 20# There's a bound-attributes-check.pl that will make sure we didn't leave any. 21# 22s/\* *(__counted_by|__sized_by|__ended_by)\([^()]*\)/*/g 23s/ (__counted_by|__sized_by|__ended_by)\([^()]*\)( |$)/\2/g 24s/(__counted_by|__sized_by|__ended_by)\([^()]*\)//g 25 26/^__ASSUME_PTR_ABI_SINGLE_BEGIN$/d 27/^__ASSUME_PTR_ABI_SINGLE_END$/d 28s/ __ASSUME_PTR_ABI_SINGLE_BEGIN//g 29s/ __ASSUME_PTR_ABI_SINGLE_END$//g 30s/__ASSUME_PTR_ABI_SINGLE_BEGIN //g 31s/__ASSUME_PTR_ABI_SINGLE_END //g 32 33# 34# Finally, print lines we didn't suppress 35# 36p 37