]>
Commit | Line | Data |
---|---|---|
9dcd6f09 | 1 | # Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. |
776dc15d KC |
2 | # Contributed by Kelley Cook, June 2004. |
3 | # Original code from Neil Booth, May 2003. | |
4 | # | |
5 | # This program is free software; you can redistribute it and/or modify it | |
6 | # under the terms of the GNU General Public License as published by the | |
9dcd6f09 | 7 | # Free Software Foundation; either version 3, or (at your option) any |
776dc15d KC |
8 | # later version. |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License | |
9dcd6f09 NC |
16 | # along with this program; see the file COPYING3. If not see |
17 | # <http://www.gnu.org/licenses/>. | |
776dc15d KC |
18 | |
19 | # This Awk script takes a list of *.opt files and combines them into | |
20 | # a three-field sorted list suitable for input into opt[ch]-gen.awk. | |
21 | # | |
22 | # Usage: awk -f opt-gather.awk file1.opt [...] > outputfile | |
23 | ||
24 | function sort(ARRAY, ELEMENTS) | |
25 | { | |
26 | for (i = 2; i <= ELEMENTS; ++i) { | |
27 | for (j = i; ARRAY[j-1] > ARRAY[j]; --j) { | |
28 | temp = ARRAY[j] | |
29 | ARRAY[j] = ARRAY[j-1] | |
30 | ARRAY[j-1] = temp | |
31 | } | |
32 | } | |
33 | return | |
34 | } | |
35 | ||
36 | BEGIN { numrec = 0 } | |
37 | ||
38 | # Ignore comments and blank lines | |
39 | /^[ \t]*(;|$)/ { flag = 0; next } | |
40 | /^[^ \t]/ { if (flag == 0) { | |
41 | record[++numrec] = $0 | |
42 | flag = 1 } | |
43 | else { | |
44 | record[numrec] = record[numrec] SUBSEP $0 | |
45 | } | |
46 | } | |
47 | ||
48 | # Sort it and output it | |
49 | END { | |
50 | sort(record,numrec) | |
51 | ||
52 | for (i = 1; i <= numrec; i++) { | |
53 | print record[i] } | |
54 | } |