Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Enable "use strict" on perl programmes.
It is a sin without it.
  • Loading branch information
ThomasAdam committed Sep 5, 2010
1 parent 58ef297 commit d177e7c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 41 deletions.
9 changes: 5 additions & 4 deletions bin/fvwm-themes-com.in
Expand Up @@ -24,6 +24,7 @@
# pod2man -c "Fvwm Utility" fvwm-themes-com | nroff -man | less -e
#-----------------------------------------------------------------------------

use strict;
use Getopt::Long;

my $version = '@VERSION@';
Expand Down Expand Up @@ -58,10 +59,10 @@ GetOptions(
) || wrongUsage();

my $bufFile = ".tmp-com-buf-$name";
$bufFile = ".tmp-com-buf-$optBufferName" if ($optBufferName ne "");
$bufFile = ".tmp-com-buf-$optBufferName" if (defined $optBufferName and $optBufferName ne "");

if ($getBuf) {
$l = 0; $line-- if ($line > 0);
my $l = 0; $line-- if ($line > 0);
open(IN,"$bufFile") || die "cannot open $bufFile";
while(<IN>) {
if ($line == $l || !$line) { print $_; }
Expand All @@ -72,7 +73,7 @@ if ($getBuf) {

if ($clearBuf) { unlink($bufFile); }

if ($message ne "") {
if (defined $message and $message ne "") {

my $outFifo = ".tmp-com-out-$name";
my $inFifo = ".tmp-com-in-$name";
Expand Down Expand Up @@ -154,7 +155,7 @@ if ($message ne "") {

while(!$done) {
if (-p $inFifo) {
$answer[0]="";
my @answer;

eval {
local $SIG{ALRM} = sub { die "Timeout" };
Expand Down
68 changes: 35 additions & 33 deletions bin/fvwm-themes-menuapp.in
Expand Up @@ -24,8 +24,7 @@
# pod2man -c "Fvwm Utility" fvwm-themes-menuapp | nroff -man | less -e
#-----------------------------------------------------------------------------

# this may work but ...
#use strict;
use strict;
use Getopt::Long;

my $prefix = $ENV{'prefix'} || '@prefix@';
Expand Down Expand Up @@ -63,6 +62,10 @@ my $comPid = 0;
my $menuFiles = "";
my $site = 0;

# TA: FIXME - this is package global because of BEGIN{} but using that is
# ultimately the wrong solution here anyway.
our $menuGroupByName = {};

GetOptions(
"help" => \&showHelp,
"version" => \&showVersion,
Expand Down Expand Up @@ -765,7 +768,7 @@ sub analyzePipeRead {
#----------------------------------------------------------------------------
#
BEGIN {
$menuGroupByName = {
$menuGroupByName = {
"System" => "System",
"Shells" => "Shells",
"ScreenSaver" => "ScreenSaver",
Expand Down Expand Up @@ -853,13 +856,11 @@ sub checkPopupInstrMenu {
}

sub checkMenuInstrMenu {
my $test = 0;
my $change = 0;
my $key;

foreach $key (keys(%strMenu)) {
$test = 0;
for ($i = 0; $i <= $menuInfo{"$key"}{itemsnbr}; $i++) {
foreach my $key (keys(%strMenu)) {
my $test = 0;
for (my $i = 0; $i <= $menuInfo{"$key"}{itemsnbr}; $i++) {
if ($strMenu{"$key"}[$i]{active} == 1) {
$test = 1;
}
Expand All @@ -876,10 +877,10 @@ sub checkTitleAndNopInstrMenu {
my $hasActiveAfter = 0;
my $ok = 1;
my $hasActiveBefore = 0;
my $key;
my $j = 0;

foreach $key (keys(%strMenu)) {
for ($i = 0; $i <= $menuInfo{"$key"}{itemsnbr}; $i++) {
foreach my $key (keys(%strMenu)) {
for (my $i = 0; $i <= $menuInfo{"$key"}{itemsnbr}; $i++) {
$hasActiveBefore = 1 if ($strMenu{"$key"}[$i]{active});
if ($strMenu{"$key"}[$i]{type} =~ /^(Nop|Title|empty)$/) {
$ok = 1; $j = $i + 1; $hasActiveAfter = 0;
Expand Down Expand Up @@ -983,7 +984,7 @@ sub addItemstrMenu {
my ($menu,$type,$name,$lefticon,$upicon,$trueaction,$useraction,$workingdir,
$checkaction,$windowtitle,$file,$linenbr) = @_;

$index = $menuInfo{$menu}{itemsnbr};
my $index = $menuInfo{$menu}{itemsnbr};
$strMenu{$menu}[$index]{type} = $type;
$strMenu{$menu}[$index]{name} = $name;
$strMenu{$menu}[$index]{lefticon} = $lefticon;
Expand Down Expand Up @@ -1111,7 +1112,7 @@ sub addOrEditItem {
$newItem{name} = "";
}
elsif ($newItem{type} eq "Title") {
$newItem{trueaction} = Title;
$newItem{trueaction} = "Title";
}
else {
$newItem{trueaction} = $newItem{useraction};
Expand All @@ -1134,7 +1135,7 @@ sub addOrEditItem {
if ($main eq "A") {
insertItem($menu,$i,$line,\%newItem);
} else {
foreach $key (keys(%newItem)) {
foreach my $key (keys(%newItem)) {
$strMenu{$menu}[$i]{$key} = $newItem{$key}
}
${$strMenu{$menu}[$i]{line}} = $line;
Expand Down Expand Up @@ -1337,10 +1338,10 @@ sub addToselMenu {

if ($index == $item) {
$lastSel++;
foreach $key (keys(%{$strMenu{$menu}[$i]})) {
foreach my $key (keys(%{$strMenu{$menu}[$i]})) {
next if ($key eq "file" || $key eq "linenbr");
if ($key eq "line") {
$selMenu[$lastSel]{line} = ${$strMenu{$menu}[$i]{line}};
$selMenu[$lastSel]{$key} = ${$strMenu{$menu}[$i]{$key}};
} else {
$selMenu[$lastSel]{$key} = $strMenu{$menu}[$i]{$key};
}
Expand Down Expand Up @@ -1385,12 +1386,15 @@ sub freeselMenu {
sub insertOneselItem {
my ($menu,$item,$selItem) = @_;
$selItem--;

my $i = -1;
my %menuInfo;

return 0 if ($selItem < 0);

if (!defined $menuInfo{$menu}{itemsnbr}) {
# new menu!
$menuInfo{$menu}{itemsnbr} = 0;
$menuInfo{$menu}{itemsnbr} = 0;
$menuInfo{$menu}{side} = "";
$menuInfo{$menu}{submenus} = "";
$menuInfo{$menu}{group} = getGroupByMenuName($menu);
Expand All @@ -1403,7 +1407,7 @@ sub insertOneselItem {
}

# build the new line
$line = $selMenu[$selItem]{line};
my $line = $selMenu[$selItem]{line};
chomp($line);
print STDERR "1:".$line . "\n";
if ($line =~ /^AddToMenu\s+/i) {
Expand Down Expand Up @@ -1461,7 +1465,7 @@ sub menusList() {
$return .= $menu;
}

return $return . "\n";
return "$return\n";

}
#----------------------------------------------------------------------------
Expand All @@ -1470,14 +1474,13 @@ sub menusList() {
sub rootMenusList() {
my ($index) = @_;
my $j = 1;
my $i = 0;
my $isRoot = 1;
my $return = "";

foreach $menu (keys(%strMenu)) {
foreach my $menu (keys(%strMenu)) {
$isRoot = 1;
foreach $key (keys(%strMenu)) {
for ($i = 0; $i <= $menuInfo{"$key"}{itemsnbr}; $i++) {
foreach my $key (keys(%strMenu)) {
for (my $i = 0; $i <= $menuInfo{"$key"}{itemsnbr}; $i++) {
$isRoot = 0 if (eqi($menu,$strMenu{$key}[$i]{useraction}) &&
($strMenu{"$key"}[$i]{type} eq "Menu" ||
$strMenu{"$key"}[$i]{type} eq "Popup"));
Expand All @@ -1490,7 +1493,7 @@ sub rootMenusList() {
$return .= $menu;
}
}
return $return . "\n";
return "$return\n";
}

#----------------------------------------------------------------------------
Expand Down Expand Up @@ -1560,10 +1563,9 @@ sub itemsList {

sub outPutfilesLines {
my $return = "";
my $i;

foreach $key (keys(%filesLines)) {
for ($i=0; $i <= $lastLine{$key}; $i++) {
foreach my $key (keys(%filesLines)) {
for (my $i=0; $i <= $lastLine{$key}; $i++) {
$return .= $filesLines{"$key"}[$i]{line};
}
}
Expand Down Expand Up @@ -1619,9 +1621,9 @@ sub writeFiles {
-d $persThemeDir || mkdir($persThemeDir, 0775) ||
die "cannot create directory $persThemeDir\n";
}
foreach $key (keys(%filesLines)) {
open(OUT,">$key") || die "cannot write on $key";
for ($i=0; $i <= $lastLine{$key}; $i++) {
foreach my $key (keys(%filesLines)) {
open(OUT,">$key") || die "cannot write on $key: $!";
for (my $i=0; $i <= $lastLine{$key}; $i++) {
print OUT $filesLines{"$key"}[$i]{line};
}
close(OUT);
Expand All @@ -1637,8 +1639,8 @@ sub writeFiles {

sub debugfilesLines {

foreach $key (keys(%filesLines)) {
for ($i=0; $i <= $lastLine{$key}; $i++) {
foreach my $key (keys(%filesLines)) {
for (my $i=0; $i <= $lastLine{$key}; $i++) {
print $filesLines{"$key"}[$i]{line};
}
}
Expand All @@ -1657,7 +1659,7 @@ sub removeItemInlist {
undef ($$reflist[$last]);
return 1;
}
for ($i=$item; $i < $last; $i++) {
for (my $i=$item; $i < $last; $i++) {
$$reflist[$i] = $$reflist[$i+1];
}
undef ($$reflist[$last]);
Expand Down
8 changes: 4 additions & 4 deletions bin/fvwm-themes-xrdb.in
@@ -1,9 +1,9 @@
#!@PERL@ -w

my $font = "-*-lucidabright-medium-r-*-*-14-*-*-*-*-*-*-*";
my %fore = ();
my %back = ();
use strict;

my $font = "-*-lucidabright-medium-r-*-*-14-*-*-*-*-*-*-*";
my (%back, %fore );
my @colorsetNames = qw(
default inactivewindow activewindow inactivemenuitem
activemenuitem greyedmenuitem defaultmodule swallowedwindow
Expand Down Expand Up @@ -35,7 +35,7 @@ foreach (@lines) {
}
}

$xresources = qq{
my $xresources = qq{
*Menu*background: $back{form}
rxvt*background: $back{term}
rxvt*foreground: $fore{term}
Expand Down

0 comments on commit d177e7c

Please sign in to comment.