home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / hcshdemo.zip / csh-os2.zip / SAMPLES / SH_2_CSH / CASE.SED next >
Text File  |  1993-11-24  |  679b  |  34 lines

  1. #    Fixup case statements:
  2.  
  3. #        case word in                switch (word)
  4. #            a)                                case "a":
  5. #                :                                :
  6. #                ;;                                break
  7. #            b|c)            -->            case "b":
  8. #                :                            case "c":
  9. #                                                :
  10. #                break                            FixBreak  <-- Hand-Fixup required
  11. #            *)                                default:
  12. #                :                                :
  13. #        esac                            end
  14.  
  15. /^[     ]*case/,/^[    ]*esac/{
  16.     s/case[     ][     ]*\([^     ].*\)[     ][     ]*in/switch (\1)/
  17.     /^[^(]*)/{
  18.         s/\([     ]*\)\([^)]*\))/\1case "\2":
  19. \1   /
  20.     :case
  21.         /".*|.*"/{
  22.             s/\([     ]*\)\(case "[^|]*\)|\(.*":\)/\1\2":
  23. \1case "\3/
  24.             b case
  25.             }
  26.         }
  27.     s/case "\*":/default:/
  28.     s/break/FixBreak/
  29.     /;;/s/^\([     ]*\)\([^     ].*\);;/\1\2
  30. \1break/
  31.     /;;/s/;;/break/
  32.     s/esac/end/
  33.     }
  34.