#!/bin/sh
: ; exec klone $0 "$@"
; The above line finds the klone executable in the $PATH
;;Skeleton of a typical klone script
(setq args (getopts "USAGE: %0 [options]
takes an IDRAW drawing (postscript) and outputs its strings on stdout"
("-l" () nl "add a newline between each paragraph")
("-c" () concat "concatenates lines of the same paragraph")
("-v" () verbose "verbose operation")
("-debug" () enter-debugger-on-error "enter klone debugger on error")
("-stackdump" () stackdump-on-error "verbose stack dump on error")
))
(if enter-debugger-on-error (kdb t))
(if stackdump-on-error (stack-dump-on-error t))
(defun filter-idraw-strings (in out &aux
(res (regcomp "^[(](.*)[)]$"))
(re-accents (regcomp "[\\][0-7][0-7][0-7]"))
line
(was-s t)
tt
)
(catch 'EOF (while t (setq line (read-line in))
(if (regexec res line) (progn
(setq line (regsub res 1))
(if (and (or nl concat) (not was-s)) (write-line "" out))
(if (and concat was-s) (write-string " " out))
(replace-string line re-accents
[
"\\347" "ç"
"\\371" "ù"
"\\364" "ô"
"\\356" "î"
"\\373" "û"
"\\353" "ë"
"\\357" "ï"
"\\374" "ü"
"\\351" "é"
"\\350" "è"
"\\352" "ê"
"\\340" "à"
"\\342" "â"
]
:all t :quote t
)
(write-string line out)
(if (not concat) (write-line "" out) (setq tt t))
(setq was-s t)
)
(setq was-s ())
)))
(if tt (write-line "" out))
)
(defun main (&aux
)
(filter-idraw-strings *standard-input* *standard-output*)
)
(main)
;;; EMACS MODES
;;; Local Variables: ***
;;; mode:lisp ***
;;; End: ***
syntax highlighted by Code2HTML, v. 0.9.1