Debian Codegraph @

test/sortglos.awk

raw
1 BEGIN {
2 pr="y";
3 npre=0;
4 po="n";
5 npos=0;
6 }
7
8 pr=="y" { npre++; pre[npre]=$0; }
9 $1=="@table" && $2=="@asis" { pr="n";nite++; next; }
10
11 po=="y" { npos++; pos[npos]=$0; }
12 $1=="@end" && $2=="table" {
13 po="y";
14 npos++;
15 pos[npos]=$0;
16 # last item...
17 vec[nite]=nlin;
18 }
19
20 { nite++; }
21
22 END {
23 for ( i=1; i<=npre; i++ ) { print pre[i]; }
24 if ( srt=="y" ) {
25 n=asorti(entr,ital);
26 ##print "n=",n;
27 for ( i=1; i<=n; i++ ) {
28 #printf("=========> %3.3d %s\n",i,ital[i]);
29 # ital[i] is the sorted key;
30 j=entr[ital[i]];
31 # j is the original item number
32 for ( k=1; k<=vec[j]; k++ ) {
33 print dat[j,k];
34 }
35 }
36 }
37 if ( srt=="n" ) {
38 for ( i=1; i<=nite; i++ ) {
39 printf("=========> %3.3d %2.2d %s\n",i,vec[i],titl[i]);
40 for ( j=1; j<=vec[i]; j++ ) {
41 print dat[i,j];
42 }
43 }
44 print "========================= END";
45 }
46 for ( i=1; i<=npos; i++ ) { print pos[i]; }
47 print "@c npre=" npre;
48 print "@c nite=" nite;
49 print "@c npos=" npos;
50 }
51