[BACK]Return to make_emacs_tags CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / pari-2.2 / src

File: [local] / OpenXM_contrib / pari-2.2 / src / Attic / make_emacs_tags (download)

Revision 1.2, Wed Sep 11 07:26:47 2002 UTC (21 years, 8 months ago) by noro
Branch: MAIN
CVS Tags: RELEASE_1_2_3, RELEASE_1_2_2_KNOPPIX_b, RELEASE_1_2_2_KNOPPIX, RELEASE_1_2_2
Changes since 1.1: +11 -1 lines

Upgraded pari-2.2 to pari-2.2.4.

#!/bin/sh

# Generate a tags file which contains PARI functions, and allows going
# to help-message for a PARI functions and to a PARI function of C function
# by repeated C-u M-.

# If you are reading this, you may enjoy imenu-go.el from
#    ftp://ftp.math.ohio-state.edu/pub/users/ilya/emacs/

# Skip language/init.c, gp/gp_init.c and language/helpmessages.c:

errors='language/errmsg.c'
messages='language/helpmsg.c'
gp_init='gp/gp_init.c'
init_c='language/init.c'

excluded=`perl -e 'print join "\n",
                      grep { $_ ne "'$init_c'"
			     and $_ ne "'$errors'"
			     and $_ ne "'$messages'"
			     and $_ ne "'$gp_init'" }
                           <*/*.[chs]>, <*/*/*.[chs]>'`

# Start with errmessages (otherwise enums will come first):
#  /* suppler2 */

errre='\/\*[ \t]*\([a-zA-Z_0-9]+\)[ \t]*\*\/'

etags -r "/$errre/\\1/"  $errors

# All files which do not require a special processing
etags -a $excluded

# Process declarations like

# {"polredord",1,(void*)ordred,6,"Gp"},

# => an entry for polredord, and an entry for ordred as well
# (so that one may find which PARI function is implemented by the C one)

re='[ \t]*{[ \t]*"\([a-zA-Z_0-9]+\)"[ \t]*,[ \t]*[0-9]+[ \t]*,[ \t]*([ \t]*void[ \t]*\*[ \t]*)[ \t]*\([a-zA-Z0-9+]+\)[ \t]*,'

etags -a -l c -o TAGS.tmp     -r "/$re/\\1/" -r "/$re/\\2/" $init_c

# Process helpmessages too:
#  "printtex(a): outputs a in TeX format",

helpre='[ \t]*"\([a-zA-Z_0-9]+\)[=(]'

etags -a -l c -o TAGS.tmp     -r "/$re/\\1/" -r "/$re/\\2/" \
    -r "/$helpre/\\1/"    $gp_init

etags -a -l c -o TAGS.tmp     -r "/$helpre/\\1/"  $messages

# This would produces a wrong entry size - though AFAIK, nobody uses it
# uniq TAGS.tm >> TAGS

perl -w014pe 'if (s/^(.*\n)\1+/$1/mg) {		# Remove duplicate lines
		  $chars = chomp;
		  s/^((\n.+,)\d+)/ $2 . (length($_) - length($1) - 1) /e;
		  $_ .= ("\f" x $chars);
	      }' TAGS.tmp > TAGS.tm2

# Since we generate *specific* definitions for the functions in the table,
# they will be prefered by Emacs over non-specific ones for the code, so we
# convert non-specific definitions into specific ones (with \x1):

perl -w014pe 'if (s/^( [^\n\x7F\x01]*\b	# 1:   TAG group
	               (\w+)		#   2: word
		       [^\w\x7F\x01\n]*	#      Most anything
		       \x7F		#      End of description
		     )
		     (\d+,\d+\n)	# 3:   TAGS Trail
		   /$1$2\x01$3/mgx) {	# Add specific marking
		  $chars = chomp;
		  s/^((\n.+,)\d+)/ $2 . (length($_) - length($1) - 1) /e;
		  $_ .= ("\f" x $chars);
	      }' TAGS > TAGS.tm1 && mv TAGS.tm1 TAGS

cat TAGS.tm2 >> TAGS
rm TAGS.tm*