Case.sed



#  Fixup case statements:

#     case word in            switch (word)
#        a)                      case "a":
#           :                       :
#           ;;                      break
#        b|c)        -->         case "b":
#           :                    case "c":
#                                   :
#           break                   FixBreak  <-- Hand-Fixup required
#        *)                      default:
#           :                       :
#     esac                    end

/^[   ]*case/,/^[ ]*esac/{
   s/case[  ][    ]*\([^   ].*\)[   ][    ]*in/switch (\1)/
   /^[^(]*)/{
      s/\([    ]*\)\([^)]*\))/\1case "\2":
\1   /
   :case
      /".*|.*"/{
         s/\([    ]*\)\(case "[^|]*\)|\(.*":\)/\1\2":
\1case "\3/
         b case
         }
      }
   s/case "\*":/default:/
   s/break/FixBreak/
   /;;/s/^\([  ]*\)\([^    ].*\);;/\1\2
\1break/
   /;;/s/;;/break/
   s/esac/end/
   }



Hamilton C shell | Free Updates | Free Demo Software | Win32 Training
Y2K | Customer Testimonials | On-line Hamilton C shell User Guide
Home | Email | Support | Company Profile | Distributors | Links



Copyright © 1997-2001 by Hamilton Laboratories. All rights reserved.
You are visitor number . This page was last modified August 14, 2001.