home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / fj / lang / awk / 28 next >
Encoding:
Text File  |  1992-11-16  |  3.5 KB  |  118 lines

  1. Path: sparky!uunet!ccut!wakasato!epsongw!icphimiko!icphimiko!green
  2. From: green@icphimiko.ic.epson.co.jp (CAD M.Tanaka)
  3. Newsgroups: fj.lang.awk
  4. Subject: One line editor
  5. Message-ID: <GREEN.92Nov16195521@iccbrandy.icphimiko.ic.epson.co.jp>
  6. Date: 16 Nov 92 10:55:20 GMT
  7. Sender: news@icphimiko.hino.ic.epson.co.jp
  8. Distribution: fj
  9. Organization: SEIKO EPSON Corp., Nagano, Japan.
  10. Lines: 106
  11.  
  12. $@$3$s$K$A$O!#EDCg!w%;(J$@%$%3!<%(%W%=%s$K$F$G$9!#(J
  13.  
  14. $@8OLZ$b;3$NFx$N5(@a$H$$$&$3$H$G!"Fx$N$?$a$@$1$N(J awk $@%9%/%j%W%H$r$R$H$D!#(J
  15. ole $@$H$$$&L>A0$J$s$G$9$,!"J8;zNs$rJT=8$7$FI8=`=PNO$KEG$-$^$9!#$?$H$($P(J
  16.  
  17.     %ole bakayaro-        $@$H%3%^%s%I$r$$$l(J$@$k$H(J
  18.     bakayaro-        $@$H%=!<%9$rI=<($9$k$N$G(J
  19.     k b            $@$HJ8;z$N2<$KCV49J8;z$rCV$/$H(J
  20.     kabayaro-        $@CV$-49$($FI=<((J$@$7$^$9!#(J
  21.                 $@2?$bF~$l$J$1$l$P!J#C!?#R$N$_!K(J
  22.     kabayaro-        $@$HI8=`=PNO$K=P$7$^$9!#(J
  23.  
  24.   $@A^F~!":o=|$J$s$+$O%3(J$@%a%s%H$r8+$F2<$5$$!#(J
  25.   $@$3$l$O$b$H$b$H(J csh $@$N%3%^%s%IMzNr$NJT=8MQ$K:n$C$?$b$N$G$9!#(Jole $@$r;H$C(J
  26. $@$?<!$N(J csh $@$N(J alias $@$OD>A0$N%3%^%s%I$rJT=8$7$^$9!#!J$?$$$,$$<:GT$7$?;~(J
  27. $@$K;H$C$?$N$G(J ohno $@$H$$$&L>A0$G$9!#!K(J
  28.  
  29. alias ohno 'ole "\!-1:q" >/tmp/ole$$;source -h /tmp/ole$$;source /tmp/ole$$;rm -f /tmp/ole$$'
  30.  
  31.   $@$=$l(J$@$+$i$3$l$OEPO?:Q$_$N(J alias $@$rJT=8$9$k$b$N$G$9!#!J!V(Jaliole $@%(%$%j(J
  32. $@%"%9L>!W$H$$$l$^$9!#!K(J
  33.  
  34. alias aliole 'ole "`alias \!*`" >/tmp/ole$$;alias \!* `cat /tmp/ole$$`;rm -f /tmp/ole$$'
  35.  
  36.   $@$H$^$"!"$3$s$J$b$s$G$9(J$@$1$I!"(Jtcsh,zsh,ksh,bash $@$H$+$N%7%'%k$d(J ile $@$H(J
  37. $@$+$N%3%^%s%I%(%G%#%?$,=P2s$C$F$$$k8=:_$8$c$"!"$"$s$^$jMx(J$@MQ2ACM$O$J$$$G(J
  38. $@$9$M!#(J:- P
  39.   $@:G6a!";w$?$h$&$J$N$r$U$?$D$P$+$jL\$K$7$^$7$F!"!V?M4V$N9M$($k$3$H$OF1(J
  40. $@$8$8(J$@$c!W$HL/$K46?4$7$F$7$^$$$^$7$?!#$3$3$K%]%9%H$9$k$N$O(JPDS$@$N%7%'%k(J rc 
  41. $@$K$D$$$F$?$b$N$r;29M$K$7$F=q$-D>$7(J$@$?$b$N$G$9!#!J$=$s$J;~4V$J$$$N$K!#!#!K(J
  42. $@$G$O!"$I$&$>>P$C$F$d$C$F2<$5$$!#(J:-)
  43.  
  44. --------- cut here ------------------------------------------------
  45. #!/bin/gawk -f
  46. # ole : The one line editor
  47. # v2.0 92/9/15 m.tanaka create
  48. #
  49. # usage : ole source_string
  50. #
  51. #     any character
  52. #          Replaces the character above.
  53. #
  54. #     space or tab( at begining of line )
  55. #          Skips over the above character(s). 
  56. #
  57. #     #    Deletes one character.
  58. #
  59. #     %    Replaces one character with a space.
  60. #
  61. #     ^    Inserts the rest of the  typed  line  just  before  the
  62. #          character.
  63. #
  64. #     $    Deletes the rest of the line from  that  character  on,
  65. #          and replaces it with the rest of the typed line.
  66. #
  67. #
  68.  
  69. BEGIN{
  70.     print ARGV[1] > "/dev/tty"
  71.     src = ARGV[1]
  72.     ARGV[1] = "-"
  73.  
  74.     chgpat =    "(\\^.*$|[^ #^%$]+|[#]+|[%]+|[$].*$)"
  75. }
  76. /^$/{
  77.     exit
  78. }
  79. {
  80.     gsub("\t","        ")
  81.     src = sprintf("%-" length($0) "s",src)
  82.     out = ""
  83.     p = 1
  84.     while( match(substr($0, p ), chgpat) ){
  85.     out = out substr(src, p , RSTART - 1) 
  86.     p += (RSTART - 1) 
  87.     key = substr($0, p, 1)
  88.     if(key == "%"){
  89.         for(i=1; i <= RLENGTH; i++) {out = out  " "}
  90.     }
  91.     else if(key == "^"){
  92.         out = out substr($0, p+1)  
  93.         break
  94.     }
  95.     else if(key == "$"){
  96.         p = -1
  97.         break
  98.     }
  99.     else if(key != "#"){
  100.         out = out  substr($0, p, RLENGTH)
  101.     }
  102.     p += RLENGTH 
  103.     }
  104.     src = out ((p > 0) ? substr(src,p) : "")
  105.     print src  > "/dev/tty"
  106. }
  107. END{
  108.     print src
  109.     exit
  110. }
  111. --------------- cut here -------------------------------
  112.  
  113. --
  114. --
  115.         $@EDCg(J $@L-(J        $@%;%$%3!<%(%W%=%s3t<02q<R(J DAG CADT $@$K$F(J
  116.       Tanaka Minoru      
  117.   green@iccbrandy.ic.epson.co.jp
  118.