File: Common.pm

package info (click to toggle)
debbugs 2.4.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, sarge, squeeze, wheezy
  • size: 620 kB
  • ctags: 290
  • sloc: perl: 6,067; sh: 176; makefile: 63
file content (63 lines) | stat: -rw-r--r-- 1,173 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package Debbugs::Common; 

use strict;

BEGIN {
	use Exporter   ();
	use vars       qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);

	# set the version for version checking
	$VERSION     = 1.00;

	@ISA         = qw(Exporter);
	@EXPORT      = qw(&fail &NameToPathHash &sani &quit);
	%EXPORT_TAGS = (  );     # eg: TAG => [ qw!name1 name2! ],

	# your exported package globals go here,
	# as well as any optionally exported functions
	@EXPORT_OK   = qw();
}

use vars      @EXPORT_OK;
use Debbugs::Config qw(%Globals);
use FileHandle;
my @cleanups;
my $DEBUG = new FileHandle;

sub fail
{
	print "$_[0]\n";
	exit 1;
}
sub NameToPathHash
{
#   12345 -> 5/4/3/12345
#   12 -> s/2/1/12
    my $name = $_[0];
    my $tmp = $name;
    $name =~ /^.*?(.)(.)(.)$/ ;
    if(!defined($1)) {
	$name =~ /^(.*?)(.)(.)$/ ;
	$tmp = "$1$2$3"."s";
    }
    $tmp =~ /^.*?(.)(.)(.)$/ ;
    return "$3/$2/$1/$name";
}

sub DEBUG
{
    print $DEBUG $_;
}
sub quit
{
    DEBUG("quitting >$_[0]<\n");
    my $u;
    while ($u= $cleanups[$#cleanups]) { &$u; }
    die "*** $_[0]\n";
}
sub sani
{
    HTML::Entities::encode($a);
}
1;
END { }       # module clean-up code here (global destructor)