File: manualindex

package info (click to toggle)
gap 4r7p5-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 29,272 kB
  • ctags: 7,129
  • sloc: ansic: 107,802; xml: 46,868; sh: 3,548; perl: 2,329; makefile: 740; python: 94; asm: 62; awk: 6
file content (43 lines) | stat: -rwxr-xr-x 966 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
# lowercase all lines without an @ symbol
awk '$0 !~ /@/ {$0=tolower($0)} {print}' $1.idx >$1.idl

# call makeindex to sort indexentries and produce an index
# ... this *needs* manual.mst to be in place, otherwise we'll end
# up with a LaTeX style index with \begin{index} .. \end{index}
makeindex -l $1.idl

# put hyphenation help into long commands
echo "Hyphenating long index entries"
echo '{a=index($0,"`");\
    if (a==0) {print $0;}\
    else {\
      b=index($0,"'"'"'");\
      if (b-a>40) {\
	anf=substr($0,1,a);\
	mid=substr($0,a+1,b-a-1);\
	end=substr($0,b);\
	b=length(mid);\
	i=1;\
	cap=1;\
	mid2=substr(mid,1,i-1);\
	while (i<=length(mid)) {\
	  c=substr(mid,i,1);\
	  if (c!=tolower(c)){\
	    if (cap==0) mid2 = mid2 "\\-";\
	    cap=1;\
	  }\
	  else cap=0;\
	  mid2=mid2 c;\
	  i=i+1;\
	}\
	print anf mid2 end;\
      }\
      else print $0;\
    }
  }' >mh.awk
cp $1.ind $1.idl
awk -f mh.awk $1.idl >$1.ind

# clean up
rm $1.idl mh.awk