[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ltsp-developer
Subject:    [Ltsp-developer] [PATCH] removed long if-elsif
From:       "Emiliano 'AlberT' Gabrielli" <AlberT () SuperAlberT ! it>
Date:       2004-08-27 17:10:52
Message-ID: 200408271910.52596.AlberT () SuperAlberT ! it
[Download RAW message or body]

hi,
  just a code beautify.

- removed long chains of if-elsif and replaced with SWITCH-like blocks
- added vim comments at end of file
- renamed install_update() function in packages_install_update() in prevision
  of introduceing some other functions handling packages (namespaces)


-- 
<?php echo '       Emiliano `AlberT` Gabrielli       ',"\n",
           '  E-Mail: AlberT_AT_SuperAlberT_it  ',"\n",
           '  Web:    http://SuperAlberT.it  ',"\n",
'  IRC:    #php,#AES azzurra.com ',"\n",'ICQ: 158591185'; ?>

["ltspadmin_switch_not_if.patch" (text/x-diff)]

343a344,346
>       SWITCH:
>       {
>         local $_=$action;
345,357c348,349
<       if( $action eq "dn" ){
<         $cur_ent++;
<       }
<       elsif( $action eq "up" ){
<         $cur_ent--;
<       }
<       elsif( $action eq "install" ){
<         if( main::need_new_installer() ){
<           $self->header();
<           $prev_top = 0;
<         }
<         else{
<           $self->select_packages($curentry);
---
>         /^dn$/ &&
>         do {
359,384c351,410
<         }
<       }
<       elsif( $action eq "toggle" ){
<         $self->toggle_packages($curentry);
<       }
<       elsif( $action eq "uninstall" ){
<         $self->un_select_packages($curentry);
<         $cur_ent++;
<       }
<       elsif( $action eq "all" ){
<         if( main::need_new_installer() ){
<           $self->header();
<           $prev_top = 0;
<         }
<         else{
<           map { $self->select_packages($components{$_}) } keys %components;
<           $prev_top = 0;
<         }
<       }
<       elsif( $action eq "quit" ){
<         $done = 1;
<       }
<       elsif( $action eq "debug" ){
<         $debug = 1;
<       }
<       else{
---
>           last;
>         };
> 
>         /^up$/ &&
>         do {
>           $cur_ent--;
>           last;
>         };
> 
>         /^install$/ &&
>         do {
>           if( main::need_new_installer() ) {
>             $self->header();
>             $prev_top = 0;
>           }
>           else{
>             $self->select_packages($curentry);
>             $cur_ent++;
>           }
>           last;
>         };
>         
>         /^toggle$/ &&
>         do {
>           $self->toggle_packages($curentry);
>           last;
>         };
> 
>         /^uninstall$/ &&
>         do {
>           $self->un_select_packages($curentry);
>           $cur_ent++;
>           last;
>         };
> 
>         /^all$/ &&
>         do {
>           if( main::need_new_installer() ){
>             $self->header();
>             $prev_top = 0;
>           }
>           else{
>             map { $self->select_packages($components{$_}) } keys %components;
>             $prev_top = 0;
>           }
>           last;
>         };
> 
>         /^quit$/ &&
>         do {
>           $done = 1;
>           last;
>         };
> 
>         /^debug$/ &&
>         do {
>           $debug = 1;
>           last;
>         };
> 
393c419
<       }
---
>       } ## SWITCH
579,597c605,639
<       my $action = $self->getentry($idx)->{action};
<       if( $action eq "install" ){
<         ::install_update();
<         $scrn_changed = 1;
<       }
<       elsif( $action eq "config_installer" ){
<         ::configure_installer();
<         $scrn_changed = 1;
<       }
<       elsif( $action eq "config_ltsp" ){
<         ::configure_ltsp();
<         $scrn_changed = 1;
<       }
<       elsif( $action eq "quit" ){
<         $scrn_changed = -1;
<       }
<       elsif( $action eq "nop" ){
<         $scrn_changed = 1;
<       }
---
> 
>       SWITCH:
>       {
>         local $_ = $self->getentry($idx)->{action};
>       
>         /^packages_install$/ &&
>         do {
>           ::packages_install_update();
>           $scrn_changed = 1;
>           last;
>         };
>         /^config_installer$/ &&
>         do {
>           ::configure_installer();
>           $scrn_changed = 1;
>           last;
>         };
>         /^config_ltsp$/ &&
>         do {
>           ::configure_ltsp();
>           $scrn_changed = 1;
>           last;
>         };
>         /^quit$/ &&
>         do {
>           $scrn_changed = -1;
>           last;
>         };
>         /^nop$/ &&
>         do {
>           $scrn_changed = 1;
>           last;
>         };
> 	die "BUG: Unknown switch";
>       } ## SWITCH
855c897
<                  action => "install",
---
>                  action => "packages_install",
898c940
< sub install_update {
---
> sub packages_install_update {
1652a1695,1697
> ##
> # vim: set et,ts=2,ai,syntax on
> ##

-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
_____________________________________________________________________
Ltsp-developer mailing list.   To un-subscribe, or change prefs, goto:
      https://lists.sourceforge.net/lists/listinfo/ltsp-developer
For additional LTSP help,   try #ltsp channel on irc.freenode.net

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic