mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-09-24 17:36:00 +00:00
53 lines
1.1 KiB
Sed
53 lines
1.1 KiB
Sed
|
# cat someFile.h | sed -f fdfixh.sed
|
||
|
|
||
|
# It contains the instructions that sed requires to manipulate
|
||
|
# the header files produced by fdesign into a form usable by LyX
|
||
|
|
||
|
# In summary it...
|
||
|
|
||
|
# s/\(extern \)\(.*\)/\1 "C" \2/
|
||
|
#
|
||
|
# Replaces lines such as "extern void func(args);"
|
||
|
# with "extern "C" void func(args);"
|
||
|
|
||
|
# /create_form_/d
|
||
|
#
|
||
|
# Deletes lines containing "/create_form_/d"
|
||
|
|
||
|
# Rewrites as
|
||
|
# typedef struct { struct someStruct {
|
||
|
# ... ...
|
||
|
# void *vdata; ...
|
||
|
# char *cdata; };
|
||
|
# long ldata;
|
||
|
# ...
|
||
|
# } someStruct;
|
||
|
#
|
||
|
# This is detailed more closely below
|
||
|
|
||
|
s/\(extern \)\(.*\)/\1 "C" \2/
|
||
|
/create_form_/d
|
||
|
|
||
|
/typedef struct {/,/} .*;/{
|
||
|
# delete lines containing ...
|
||
|
/typedef struct {/d
|
||
|
/vdata/d
|
||
|
/cdata/d
|
||
|
/ldata/d
|
||
|
|
||
|
# copy remaining lines into the hold space
|
||
|
H
|
||
|
|
||
|
# rewrite "} someStruct;" as "struct someStruct {" and print
|
||
|
s/} \(.*\);/struct \1 {/p
|
||
|
|
||
|
# delete line from pattern space
|
||
|
d
|
||
|
}
|
||
|
# swap the hold space back into the pattern space and...
|
||
|
/^$/x
|
||
|
{
|
||
|
# rewrite "} someStruct;" as "};"
|
||
|
s/} \(.*\);/};/
|
||
|
}
|