1:
2    eval 'exec perl -S $0 ${1+"$@"}'
3        if 0;
4#**************************************************************
5#
6#  Licensed to the Apache Software Foundation (ASF) under one
7#  or more contributor license agreements.  See the NOTICE file
8#  distributed with this work for additional information
9#  regarding copyright ownership.  The ASF licenses this file
10#  to you under the Apache License, Version 2.0 (the
11#  "License"); you may not use this file except in compliance
12#  with the License.  You may obtain a copy of the License at
13#
14#    http://www.apache.org/licenses/LICENSE-2.0
15#
16#  Unless required by applicable law or agreed to in writing,
17#  software distributed under the License is distributed on an
18#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19#  KIND, either express or implied.  See the License for the
20#  specific language governing permissions and limitations
21#  under the License.
22#
23#**************************************************************
24
25
26#
27# Create ordinary theme from HiContrast images.
28#
29
30use File::Copy;
31use File::Find;
32use File::Path;
33use File::Spec;
34
35( $src, $dst ) = @ARGV;
36
37if ( $src eq "" || $dst eq "" ) {
38    print STDERR "Usage: hicontrast-to-theme.pl src dest\n\n";
39    print STDERR "Create ordinary theme from HiContrast images.\n";
40    exit 1;
41}
42
43$dst = File::Spec->rel2abs( $dst );
44
45@hc_table = (
46    [ ".*_h.png",         "_h.png",    ".png" ],
47    [ ".*_sch.png",       "_sch.png",  ".png" ],
48    [ ".*_hc.png",        "_hc.png",   ".png" ],
49    [ "lch_.*.png",       "lch_",      "lc_" ],
50    [ "sch_.*.png",       "sch_",      "sc_" ],
51    [ "lch[0-9].*.png",   "lch",       "lc" ],
52    [ "sch[0-9].*.png",   "sch",       "sc" ],
53    [ "loh[0-9].*.png",   "loh",       "lo" ],
54    [ "lxh[0-9].*.png",   "lxh",       "lx" ],
55    [ "sxh[0-9].*.png",   "sxh",       "sx" ],
56    [ "avh[0-9].*.png",   "avh",       "av" ],
57    [ "avlh[0-9].*.png",  "avlh",      "avl" ],
58    [ "idh[0-9].*.png",   "idh",       "id" ],
59    [ "imh[0-9].*.png",   "imh",       "im" ],
60    [ "mih[0-9].*.png",   "mih",       "mi" ],
61    [ "tbh[0-9].*.png",   "tbh",       "tb" ],
62    [ "nah[0-9].*.png",   "nah",       "na" ],
63    [ "nch[0-9].*.png",   "nch",       "nc" ],
64    [ "nvh[0-9].*.png",   "nvh",       "nv" ],
65    [ "ouh[0-9].*.png",   "ouh",       "ou" ],
66    [ "ddh[0-9].*.png",   "ddh",       "dd" ],
67    [ "sfh[0-9].*.png",   "sfh",       "sf" ],
68    [ "srh[0-9].*.png",   "srh",       "sr" ],
69    [ "wrh[0-9].*.png",   "wrh",       "wr" ],
70    [ "alh[0-9].*.png",   "alh",       "al" ],
71    [ "ath[0-9].*.png",   "ath",       "at" ],
72    [ "bih[0-9].*.png",   "bih",       "bi" ],
73    [ "coh[0-9].*.png",   "coh",       "co" ],
74    [ "foh[0-9].*.png",   "foh",       "fo" ],
75    [ "fuh[0-9].*.png",   "fuh",       "fu" ],
76    [ "oph[0-9].*.png",   "oph",       "op" ],
77    [ "unh[0-9].*.png",   "unh",       "un" ],
78    [ "edh[0-9].*.png",   "edh",       "ed" ],
79    [ "cdh[0-9].*.png",   "cdh",       "cd" ],
80    [ "frh[0-9].*.png",   "frh",       "fr" ],
81    [ "fwh[0-9].*.png",   "fwh",       "fw" ],
82    [ "nuh[0-9].*.png",   "nuh",       "nu" ],
83    [ "prh[0-9].*.png",   "prh",       "pr" ],
84    [ "shh[0-9].*.png",   "shh",       "sh" ],
85    [ "trh[0-9].*.png",   "trh",       "tr" ],
86    [ "reh[0-9].*.png",   "reh",       "re" ],
87    [ "joh[0-9].*.png",   "joh",       "jo" ],
88    [ "fph[0-9].*.png",   "fph",       "fp" ],
89    [ "dah[0-9].*.png",   "dah",       "da" ]
90);
91
92my (@from_stat, @to_stat);
93
94sub copy_normalized {
95    $file = $_;
96    for $hc ( @hc_table ) {
97        ( $what, $from, $to ) = @$hc;
98        if ( $file =~ /$what/&&!($file=~/\.svn/) ) {
99            my $dir = File::Spec->catdir( $dst, $File::Find::dir );
100
101            if ( ! -d $dir ) {
102                mkpath( $dir );
103            }
104
105            ( my $copy = $file ) =~ s/$from/$to/;
106            $copy = File::Spec->catfile( $dir, $copy );
107
108	        @from_stat = stat($file);
109	        @to_stat = stat($copy);
110			if ( $from_stat[9] > $to_stat[9] ) {
111	            copy( $file, $copy ) || die $!;
112				utime( $from_stat[9], $from_stat[9], $copy );
113			}
114
115            last;
116        }
117    }
118}
119
120chdir( $src );
121find( \&copy_normalized, '.' );
122