9base

revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log | Files | Refs | README | LICENSE

unansi (1221B)


      1 # The awk program cvt will convert the relatively sterotyped ansi c
      2 # in this troff distribution into older-style c, by munging function
      3 # declarations.
      4 
      5 # You will also have to edit fns.h, by
      6 #	sed 's/(.*)/()/g' fns.h >foo; mv foo fns.h
      7 # check this before doing the move!
      8 
      9 # you will also have to make some editing changes in
     10 # tdef.h in the Contab structure: s/(void)/()/
     11 # you may have to fix up some function declarations
     12 # in n4.c, the ones with (*f)(Tchar).
     13 
     14 # you will surely also have header files to deal with.
     15 
     16 # the most obvious cases are dealt with by the following
     17 # commands.  make sure you do this stuff on a copy!
     18 
     19 # function prototypes in n8.c probably belong in fns.h. readpats(void) must
     20 # be readpats() before cvt runs.
     21 
     22 sed \
     23 	-e 's/(void)/()/' \
     24 	-e 's/(Tchar[^)]*);/();/' \
     25 	-e 's/(char[^)]*);/();/' \
     26 	-e 's/(int[^)]*);/();/' \
     27 n8.c >foo
     28 mv foo n8.c
     29 
     30 for i in *.c
     31 do
     32 	cvt $i >foo
     33 	mv foo $i
     34 done
     35 
     36 sed 's/(.*)/()/g' fns.h >foo
     37 mv foo fns.h
     38 
     39 sed -e 's/(void)/()/g' -e '/stdlib/d' tdef.h >foo
     40 mv foo tdef.h
     41 
     42 # Compliers may not approve of void *setbrk() in fns.h and n3.c.
     43 
     44 sed 's/^void\*[ 	]setbrk/char*	setbrk/' fns.h >foo
     45 mv foo fns.h
     46 
     47 sed 's/^void \*setbrk/char *setbrk/' n3.c >foo
     48 mv foo n3.c
     49