| 1 |
#!/bin/awk -f |
| 2 |
# |
| 3 |
# fstrcmp - fuzzy string compare library |
| 4 |
# Copyright (C) 2009 Peter Miller |
| 5 |
# Written by Peter Miller <[email protected]> |
| 6 |
# |
| 7 |
# This program is free software; you can redistribute it and/or modify |
| 8 |
# it under the terms of the GNU General Public License as published by |
| 9 |
# the Free Software Foundation; either version 3 of the License, or (at |
| 10 |
# your option) any later version. |
| 11 |
# |
| 12 |
# This program is distributed in the hope that it will be useful, |
| 13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 |
# General Public License for more details. |
| 16 |
# |
| 17 |
# You should have received a copy of the GNU General Public License |
| 18 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
# |
| 20 |
function output_end() |
| 21 |
{ |
| 22 |
if (start == 0) |
| 23 |
return; |
| 24 |
if (middle != 0) |
| 25 |
printf(",") |
| 26 |
middle = 1 |
| 27 |
printf("%d", start); |
| 28 |
if (start != finish) |
| 29 |
printf("-%d", finish); |
| 30 |
start = 0; |
| 31 |
finish = 0; |
| 32 |
} |
| 33 |
|
| 34 |
function output(n) |
| 35 |
{ |
| 36 |
if (start == 0) |
| 37 |
{ |
| 38 |
start = n |
| 39 |
finish = n |
| 40 |
return |
| 41 |
} |
| 42 |
if (n == finish + 1) |
| 43 |
{ |
| 44 |
finish = n; |
| 45 |
return |
| 46 |
} |
| 47 |
output_end(); |
| 48 |
start = n; |
| 49 |
finish = n; |
| 50 |
} |
| 51 |
|
| 52 |
function output_even() |
| 53 |
{ |
| 54 |
if ((page[finish] % 2) != 0) |
| 55 |
{ |
| 56 |
output_end(); |
| 57 |
printf(",_"); |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
/Page:/ { |
| 62 |
page[$3] = $2 |
| 63 |
if ($3 > max) |
| 64 |
max = $3 |
| 65 |
} |
| 66 |
END { |
| 67 |
output(1); |
| 68 |
output(2); |
| 69 |
numtoc = 0 |
| 70 |
for (j = 3; j <= max; ++j) |
| 71 |
{ |
| 72 |
if (page[j] > 1000) |
| 73 |
{ |
| 74 |
output(j); |
| 75 |
numtoc++ |
| 76 |
} |
| 77 |
} |
| 78 |
output_even(); |
| 79 |
for (j = 3; j <= max; ++j) |
| 80 |
{ |
| 81 |
if (page[j] < 1000) |
| 82 |
output(j); |
| 83 |
} |
| 84 |
output_even(); |
| 85 |
output_end(); |
| 86 |
printf("\n"); |
| 87 |
} |