Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Jul 2004 20:53:46 -0600 (MDT)
From:      Warren Block <wblock@wonkity.com>
To:        Ceri Davies <ceri@FreeBSD.org>
Cc:        doc@FreeBSD.org
Subject:   Re: Handbook Acronyms
Message-ID:  <20040713203222.R19556@wonkity.com>
In-Reply-To: <20040713235332.GD29928@submonkey.net>
References:  <20040712171533.R43767@wonkity.com> <20040713165232.GT29928@submonkey.net> <20040713235332.GD29928@submonkey.net>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
On Wed, 14 Jul 2004, Ceri Davies wrote:

[glossary]

> Great - it's at
> doc/en<mumble>/share/sgml/glossary/freebsd-glossary.sgml.

Okay, as a first step at defining all these terms, here's a little Perl 
snippet (requires 5.8, I think) that creates a list of acronyms used in 
the Handbook and removes those terms already present in the glossary.

Surprisingly, it turns out that the terms presently defined in the 
glossary are not used in the Handbook at all, and vice versa.

(I can't escape the feeling that this could be done in about two lines 
of Perl if I had a better handle on it. 8-)

-Warren Block * Rapid City, South Dakota USA
[-- Attachment #2 --]
#!/usr/bin/perl

# List acronyms used in the FreeBSD Handbook but not yet
# defined in the Glossary.
# WB, 20040713

use strict;
use warnings;

use File::Find;
use Switch;

my $dir = '/usr/doc/en_US.ISO8859-1/books/handbook/';
my $glossary = '/usr/doc/en_US.ISO8859-1/share/sgml/glossary/freebsd-glossary.sgml';
my $fileext = '.sgml';
my %acronyms;

# add terms to list
find(\&wanted, $dir);

# remove terms already defined in glossary
terms($glossary,'del');

my @sorted = sort keys %acronyms;

foreach (@sorted) {
    print "$_\n";
}

exit 0;

sub wanted {
    my($fname) = $_;
    if ((-f $fname) and ($fname =~ /$fileext/)) {
        terms($fname, 'add');
    }
}           

sub terms {
    my($fname, $op) = @_;
    open my $fh, $fname or die "** couldn't open '$fname'--$!";
    while (<$fh>) {
        if (/<acronym>(\w+)/) {
            switch ($op) {
                 case 'add'   { $acronyms{uc($1)} = 1    }
                 case 'del'   { delete $acronyms{uc($1)} }
            }
        }
    }
    close $fh or die "** couldn't close '$fname'--$!";
}
help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040713203222.R19556>