[alt.sources] [folklore] Re: Ugly source contest

avg@hq.demos.su (Vadim G. Antonov) (10/15/90)

Archive-name: ctags/14-Oct-90
Original-posting-by: avg@hq.demos.su (Vadim G. Antonov)
Original-subject: Re:  Ugly source contest
Reposted-by: emv@math.lsa.umich.edu (Edward Vielmetti)

[Reposted from alt.folklore.computers.
Comments on this service to emv@math.lsa.umich.edu (Edward Vielmetti).]

In article <ben.3004@epmooch.UUCP> ben@epmooch.UUCP (Rev. Ben A. Mesander) writes:
>>In article <1990Oct12.192001.12739@tsa.co.uk> domo@tsa.co.uk (Dominic Dunlop) writes:
>>Should be possible to create some pretty ugly
>>regexps given that amount of rope to play with.  Prizes will be awarded
>>if the sun cools significantly during processing...
>
>Here's one that's actually useful: it extracts C function declarations (all
>lowercase...
>^[a-z][a-z]*[\s\t]*.*([^;]*)[^;]*$

	Hm. Sometimes I use to hack with my C defines set simulating
	Algol-68 :-). Needless to say that ctags barfs at it. Thus I
	had to write my own ctags - hereafter THE ACTUAL CODE of it
	(a part of Makefile). Enjoy.

tags:   $(SRC) $(HDR)
	fgrep -v '&&&&&&&&&&&&&&&&&&&' $(SRC) $(HDR) | \
|       sed -n 's/^\([^:]*\):\([a-zA-Z_][a-zA-Z0-9_ ]*\) \([a-zA-Z]
|       [a-zA-Z0-9_]*\)\( *([a-zA-Z0-9_, ]*).*\)/\3`\1`?^\2 \3\4$$?
|       /p; s/^\([^:]*\):\([a-zA-Z_][a-zA-Z0-9_]*\)\( *([a-zA-Z0-9_
|       , ]*).*\)/\2`\1`?^\2\3$$?/p; s/^\([^:]*\):\(# *define  *\)\
|       ([a-zA-Z_][0-9_a-zA-Z0-9_]*\)\(.*\)/\3`\1`?^\2\3\4$$?/p' | \
	tr '`' '\011' | sort > tags

NOTE: all marked with | at the first column SHOULD BE PUT IN ONE LINE!
      (Sorry I'm not sure your mailers can handle LONG lines).

	Try to use it - it handles #define-s unline original ctags :-)

	/This example is got from the actual Makefile of the kernel of D3
	operating system/

	Vadim Antonov
	DEMOS, Moscow, USSR
	(It is a joke!)