#!/usr/bin/env ruby # slf # -- simple line formater # NISHI Takao # # Time-stamp: <2002/05/29 12:05:54 zophos> # require 'jcode' require 'kconv' $KCODE='euc' DEFAULT_FILL=76 DEFAULT_HANG_CHAR=['\,','.',',','.','、','。', ')','}',']',')','」','』',10.chr,13.chr] DEFAULT_EXPEL_CHAR=['(','{','[','(','「','『'] DEFAULT_HANG_DEPTH=2 def usage print <=maxlen) tmp=dst.split(//) unless(expel_chars.index(tmp[-1]).nil?) src.unshift(c) c=tmp.pop dst=tmp.join('') end if((hang_chars.index(c).nil?)||(hd>maxhangdepth)) puts dst dst='' hd=0 else hd+=1 end end dst+=c.to_s c=src.shift end unless(dst.empty?) puts dst end } rescue ensure file.close end