1999-10-19 02:55:01 +04:00
|
|
|
#!/usr/bonsaitools/bin/perl -w
|
1998-06-17 01:43:24 +04:00
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
1999-11-02 02:33:56 +03:00
|
|
|
# The contents of this file are subject to the Netscape Public
|
|
|
|
# License Version 1.1 (the "License"); you may not use this file
|
|
|
|
# except in compliance with the License. You may obtain a copy of
|
|
|
|
# the License at http://www.mozilla.org/NPL/
|
1998-06-17 01:43:24 +04:00
|
|
|
#
|
1999-11-02 02:33:56 +03:00
|
|
|
# Software distributed under the License is distributed on an "AS
|
|
|
|
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
# implied. See the License for the specific language governing
|
|
|
|
# rights and limitations under the License.
|
1998-06-17 01:43:24 +04:00
|
|
|
#
|
|
|
|
# The Original Code is the Bonsai CVS tool.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is Netscape Communications
|
1999-11-02 02:33:56 +03:00
|
|
|
# Corporation. Portions created by Netscape are
|
|
|
|
# Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
# Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s):
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
# SourceChecker.cgi -- tools for creating or modifying the dictionary
|
|
|
|
# used by cvsblame.cgi.
|
|
|
|
#
|
|
|
|
# Created: Scott Collins <scc@netscape.com>, 4 Feb 1998.
|
|
|
|
#
|
|
|
|
# Arguments (passes via GET or POST):
|
|
|
|
# ...
|
|
|
|
#
|
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
use strict;
|
|
|
|
|
1998-06-17 01:43:24 +04:00
|
|
|
use CGI;
|
|
|
|
use SourceChecker;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Global
|
|
|
|
#
|
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
my $query = new CGI;
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Subroutines
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
sub print_page_header()
|
|
|
|
{
|
|
|
|
print <<'END_OF_HEADER';
|
|
|
|
<H1>SourceChecker Dictionary Maintainance</H1>
|
|
|
|
END_OF_HEADER
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub print_page_trailer()
|
|
|
|
{
|
|
|
|
print <<'END_OF_TRAILER';
|
|
|
|
<HR>
|
|
|
|
<FONT SIZE=-1>
|
|
|
|
Last updated 5 Feb 1998.
|
|
|
|
<A HREF="SourceChecker.cgi">Dictionary maintainance and help</A>.</FONT>
|
|
|
|
Mail feedback to <A HREF="mailto:scc?subject=[SourceChecker.cgi]"><scc@netscape.com></A>.
|
|
|
|
END_OF_TRAILER
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
my $error_header = '<HR><H2>I couldn\'t process your request...</H2>';
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
sub print_error($)
|
|
|
|
{
|
1999-10-19 02:55:01 +04:00
|
|
|
my $message = shift;
|
1998-06-17 01:43:24 +04:00
|
|
|
print "$error_header<P><EM>Error</EM>: $message</P>";
|
|
|
|
$error_header = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub print_query_building_form()
|
|
|
|
{
|
|
|
|
print $query->start_multipart_form;
|
|
|
|
|
|
|
|
print '<HR><H2>Build a new request</H2>';
|
|
|
|
print '<P>...to modify or create a remote dictionary with words from one or more local files.</P>';
|
|
|
|
|
|
|
|
print '<H3>Files on the server</H3>';
|
|
|
|
print '<P>...i.e., the dictionary to be created or modified.</P>';
|
|
|
|
|
|
|
|
print $query->textfield( -name=>'dictionary',
|
|
|
|
-default=>'',
|
|
|
|
-override=>1,
|
|
|
|
-size=>30 );
|
|
|
|
print '-- the path to dictionary.';
|
|
|
|
|
|
|
|
print '<H3>Files on your local machine</H3>';
|
|
|
|
print '<P>...that will be uploaded to the server, so their contents can be added to the dictionary.</P>';
|
|
|
|
|
|
|
|
print '<BR>';
|
|
|
|
print $query->filefield( -name=>'ignore_english', -size=>30 );
|
|
|
|
print '-- contains english (i.e., transformable) words to ignore.';
|
|
|
|
|
|
|
|
print '<BR>';
|
|
|
|
print $query->filefield( -name=>'ignore_strings', -size=>30 );
|
|
|
|
print '-- contains identifiers (i.e., non-transformable) words to ignore.';
|
|
|
|
|
|
|
|
print '<BR>';
|
|
|
|
print $query->filefield( -name=>'flag_strings', -size=>30 );
|
|
|
|
print '-- contains identifiers words to be flagged.';
|
|
|
|
|
|
|
|
print '<BR>';
|
|
|
|
print $query->filefield( -name=>'ignore_names', -size=>30 );
|
|
|
|
print '-- contains user names to be ignored.';
|
|
|
|
|
|
|
|
print '<BR>';
|
|
|
|
print $query->submit;
|
|
|
|
|
|
|
|
print $query->endform;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub do_add_good_words($)
|
|
|
|
{
|
1999-10-19 02:55:01 +04:00
|
|
|
my $file = shift;
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
while ( <$file> )
|
|
|
|
{
|
|
|
|
next if /\#/;
|
|
|
|
add_good_words($_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub do_add_bad_words($)
|
|
|
|
{
|
1999-10-19 02:55:01 +04:00
|
|
|
my $file = shift;
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
while ( <$file> )
|
|
|
|
{
|
|
|
|
next if /\#/;
|
|
|
|
add_bad_words($_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub do_add_good_english($)
|
|
|
|
{
|
1999-10-19 02:55:01 +04:00
|
|
|
my $file = shift;
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
while ( <$file> )
|
|
|
|
{
|
|
|
|
next if /\#/;
|
|
|
|
add_good_english($_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub do_add_names($)
|
|
|
|
{
|
1999-10-19 02:55:01 +04:00
|
|
|
my $file = shift;
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
while ( <$file> )
|
|
|
|
{
|
|
|
|
next if /\#/;
|
|
|
|
add_names($_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub handle_query()
|
|
|
|
{
|
1999-10-19 02:55:01 +04:00
|
|
|
my $dictionary_path = $query->param('dictionary');
|
1998-06-17 01:43:24 +04:00
|
|
|
if ( ! $dictionary_path )
|
|
|
|
{
|
|
|
|
print_error('You didn\'t supply a path to the dictionary file.');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dbmopen %SourceChecker::token_dictionary, "$dictionary_path", 0666
|
|
|
|
|| print_error("The dictionary you named could not be opened.");
|
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
my $added_some_words = 0;
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
my ($file_of_good_english, $file_of_good_words,
|
|
|
|
$file_of_bad_words, $file_of_names);
|
1998-06-17 01:43:24 +04:00
|
|
|
if ( $file_of_good_english = $query->param('ignore_english') )
|
|
|
|
{
|
|
|
|
do_add_good_english($file_of_good_english);
|
|
|
|
$added_some_words = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $file_of_good_words = $query->param('ignore_strings') )
|
|
|
|
{
|
|
|
|
do_add_good_words($file_of_good_words);
|
|
|
|
$added_some_words = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $file_of_bad_words = $query->param('flag_strings') )
|
|
|
|
{
|
|
|
|
do_add_bad_words($file_of_bad_words);
|
|
|
|
$added_some_words = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $file_of_names = $query->param('ignore_names') )
|
|
|
|
{
|
|
|
|
do_add_names($file_of_names);
|
|
|
|
$added_some_words = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! $added_some_words )
|
|
|
|
{
|
|
|
|
print_error("You did not supply any words to add to the dictionary.");
|
|
|
|
}
|
|
|
|
|
|
|
|
dbmclose %SourceChecker::token_dictionary;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# The main script
|
|
|
|
#
|
|
|
|
|
|
|
|
print $query->header;
|
|
|
|
print $query->start_html(-title=>'SourceChecker Dictionary Maintainance',
|
|
|
|
-author=>'scc@netscape.com');
|
|
|
|
|
|
|
|
print_page_header();
|
|
|
|
|
|
|
|
if ( $query->param )
|
|
|
|
{
|
|
|
|
handle_query();
|
|
|
|
}
|
|
|
|
|
|
|
|
print_query_building_form();
|
|
|
|
print_page_trailer();
|
|
|
|
|
|
|
|
print $query->end_html;
|
|
|
|
|
|
|
|
__DATA__
|
|
|
|
|